Skip to content

Commit

Permalink
fix: withdraw dust issue
Browse files Browse the repository at this point in the history
  • Loading branch information
naturexie committed Feb 10, 2025
1 parent ce96ac4 commit 68fa41f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions store/actions/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export async function withdraw({
// console.log('0000000000000-accountId', accountId)
// console.log('0000000000000-account', account)
if (!accountId) return;

const asset = assets[tokenId];
const { decimals } = asset.metadata;
const { logicContract, oracleContract } = await getBurrow();
const isNEAR = tokenId === nearTokenId;
const { isLpToken } = asset;
const suppliedBalance = new Decimal(accountPortfolio?.supplied[tokenId]?.balance || 0);
const hasBorrow = accountPortfolio?.borrows?.length > 0;
const maxAmount = computeWithdrawMaxAmount(tokenId, assets, accountPortfolio!);

const expandedAmount = isMax
Expand Down Expand Up @@ -137,7 +137,8 @@ export async function withdraw({
{
DecreaseCollateral: {
token_id: tokenId,
amount: decreaseCollateralAmount.toFixed(0),
amount:
!hasBorrow && isMax ? undefined : decreaseCollateralAmount.toFixed(0),
},
},
withdrawAction,
Expand All @@ -151,7 +152,8 @@ export async function withdraw({
{
DecreaseCollateral: {
token_id: tokenId,
amount: decreaseCollateralAmount.toFixed(0),
amount:
!hasBorrow && isMax ? undefined : decreaseCollateralAmount.toFixed(0),
},
},
withdrawAction,
Expand Down

0 comments on commit 68fa41f

Please sign in to comment.