Skip to content

Commit 227122e

Browse files
Copilot0xdeval
andcommitted
Improve comment clarity in calculateGasReserve method
Co-authored-by: 0xdeval <26190360+0xdeval@users.noreply.github.com>
1 parent 7baef99 commit 227122e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/sdk/src/protocols/base/BaseProtocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,17 @@ export abstract class BaseProtocol {
226226
/**
227227
* Calculate gas reserve amount based on balance and token decimals
228228
* Uses a more sophisticated calculation that considers token decimal places:
229-
* - For tokens with low decimals (≤6): uses a fixed minimum amount configured via
229+
* - For tokens with 6 or fewer decimals: uses a fixed minimum amount configured via
230230
* GAS_RESERVE_MINIMUM (e.g., currently 0.01 tokens), with at least 1 unit reserved
231-
* - For tokens with higher decimals (>6): uses the maximum of GAS_RESERVE_PERCENTAGE%
231+
* - For tokens with more than 6 decimals: uses the maximum of GAS_RESERVE_PERCENTAGE%
232232
* of the balance and a fixed minimum (GAS_RESERVE_MINIMUM), ensuring a balance-independent
233233
* minimum for withdraw validation
234234
* @param balance Current token balance
235235
* @param tokenDecimals Number of decimals for the token
236236
* @returns Gas reserve amount in token units
237237
*/
238238
protected calculateGasReserve(balance: bigint, tokenDecimals: number): bigint {
239-
// For tokens with low decimals (e.g., 6-decimal tokens like USDC), use a fixed minimum
239+
// For tokens with 6 or fewer decimals (e.g., USDC with 6 decimals), use a fixed minimum
240240
// This ensures sufficient gas coverage for high-value or low-decimal tokens
241241
if (tokenDecimals <= 6) {
242242
// Reserve GAS_RESERVE_MINIMUM tokens (e.g., 0.01) or 1 unit if that's larger
@@ -245,7 +245,7 @@ export abstract class BaseProtocol {
245245
return fixedReserve > oneUnit ? fixedReserve : oneUnit;
246246
}
247247

248-
// For tokens with higher decimals, use the maximum of percentage-based and fixed minimum
248+
// For tokens with more than 6 decimals, use the maximum of percentage-based and fixed minimum
249249
// This ensures withdraw validation has a meaningful balance-independent minimum
250250
const percentageReserve = (balance * BigInt(GAS_RESERVE_PERCENTAGE)) / 100n;
251251
const fixedMinimum = parseUnits(GAS_RESERVE_MINIMUM, tokenDecimals);

0 commit comments

Comments
 (0)