Skip to content

Commit eee4be4

Browse files
committed
Fix getting sell glp fee bps
1 parent d107d11 commit eee4be4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/legacy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,11 @@ export function getSellGlpToAmount(
357357

358358
// in the Vault contract, the token.usdgAmount is reduced before the fee basis points
359359
// is calculated
360+
const diff = fromToken.usdgAmount !== undefined ? fromToken.usdgAmount - usdgAmount : undefined;
361+
const noNegativeDiff = diff !== undefined ? (diff > 0n ? diff : 0n) : undefined;
360362
const feeBasisPoints = getFeeBasisPoints(
361363
fromToken,
362-
fromToken?.usdgAmount !== undefined ? fromToken.usdgAmount - usdgAmount : undefined,
364+
noNegativeDiff,
363365
usdgAmount,
364366
MINT_BURN_FEE_BASIS_POINTS,
365367
TAX_BASIS_POINTS,

0 commit comments

Comments
 (0)