@@ -1037,13 +1037,13 @@ access(all) contract FlowALPModels {
10371037 /// (used when deposits are made)
10381038 access (EImplementation ) fun consumeDepositCapacity (_ amount : UFix64 , pid : UInt64 )
10391039
1040- /// Returns the per-deposit limit based on user deposit limit cap and available deposit capacity.
1040+ /// Returns the per-deposit limit based on user deposit limit and available deposit capacity.
10411041 /// Rationale: cap per-deposit size to a fraction of the total depositCapacityCap
10421042 /// so a single large deposit cannot monopolize capacity.
10431043 /// Excess is queued and drained in chunks (see asyncUpdatePosition),
10441044 /// enabling fair throughput across many deposits in a block. The 5%
10451045 /// fraction is conservative and can be tuned by protocol parameters.
1046- access (EImplementation ) view fun depositLimit (): UFix64
1046+ access (EImplementation ) view fun depositLimit (pid : UInt64 ): UFix64
10471047
10481048 /// Updates interest indices and regenerates deposit capacity for elapsed time
10491049 access (EImplementation ) fun updateForTimeChange ()
@@ -1376,13 +1376,15 @@ access(all) contract FlowALPModels {
13761376 )
13771377 }
13781378
1379- /// Returns the per-deposit limit based on user deposit limit cap and available deposit capacity.
1380- access (EImplementation ) view fun depositLimit (): UFix64 {
1381- let cap = self .getUserDepositLimitCap ()
1382- if self .depositCapacity < cap {
1383- return self .depositCapacity
1379+ /// Returns the maximum amount that can be deposited to the given position without being queued.
1380+ access (EImplementation ) view fun depositLimit (pid : UInt64 ): UFix64 {
1381+ let userCap = self .getUserDepositLimitCap ()
1382+ let userUsed = self .getDepositUsageForPosition (pid )
1383+ var available = userCap - userUsed
1384+ if self .depositCapacity < available {
1385+ available = self .depositCapacity
13841386 }
1385- return cap
1387+ return available
13861388 }
13871389
13881390 /// Updates interest indices and regenerates deposit capacity for elapsed time.
0 commit comments