From 723d82a1cc1ed8ab18295f463f11235ef9b3ab12 Mon Sep 17 00:00:00 2001 From: 0xodia <0xodia@solend.fi> Date: Mon, 6 Jan 2025 11:49:20 -0500 Subject: [PATCH] fix dust deposits --- solend-sdk/package.json | 2 +- solend-sdk/src/core/actions.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/solend-sdk/package.json b/solend-sdk/package.json index a50f465b..3b74f8cc 100644 --- a/solend-sdk/package.json +++ b/solend-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@solendprotocol/solend-sdk", - "version": "0.13.33", + "version": "0.13.35", "private": true, "main": "src/index.ts", "module": "src/index.ts", diff --git a/solend-sdk/src/core/actions.ts b/solend-sdk/src/core/actions.ts index 9647e39f..d60ba836 100644 --- a/solend-sdk/src/core/actions.ts +++ b/solend-sdk/src/core/actions.ts @@ -1403,6 +1403,16 @@ export class SolendActionCore { this.borrowReserves, this.programId ); + + this.depositReserves = this.depositReserves.filter((reserve) => { + const deposit = this.obligationAccountInfo?.deposits.find((d) => d.depositReserve.toBase58() === reserve.toBase58()); + return deposit?.depositedAmount.gt(new BN(0)); + }); + this.borrowReserves = this.borrowReserves.filter((reserve) => { + const borrow = this.obligationAccountInfo?.borrows.find((b) => b.borrowReserve.toBase58() === reserve.toBase58()); + return borrow?.borrowedAmountWads.gt(new BN(0)); + }); + if (this.debug) console.log("adding refresh obligation ix to setup txn"); this.setupIxs.push(refreshObligationIx); }