@t2000/sdk 0.16.6 → 0.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.cjs +10 -8
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +10 -8
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -1486,12 +1486,13 @@ var SuilendAdapter = class {
|
|
|
1486
1486
|
if (!reserve) throw new T2000Error("ASSET_NOT_SUPPORTED", `${assetInfo.displayName} reserve not found on Suilend`);
|
|
1487
1487
|
const caps = await this.fetchObligationCaps(address);
|
|
1488
1488
|
if (caps.length === 0) throw new T2000Error("NO_COLLATERAL", "No Suilend position found");
|
|
1489
|
-
const
|
|
1490
|
-
const
|
|
1489
|
+
const obligation = await this.fetchObligation(caps[0].obligationId);
|
|
1490
|
+
const dep = obligation.deposits.find((d) => d.reserveIdx === reserve.arrayIndex);
|
|
1491
|
+
const ratio = cTokenRatio(reserve);
|
|
1492
|
+
const deposited = dep ? dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals : 0;
|
|
1491
1493
|
const effectiveAmount = Math.min(amount, deposited);
|
|
1492
1494
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on Suilend`);
|
|
1493
|
-
const
|
|
1494
|
-
const ctokenAmount = Math.ceil(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
|
|
1495
|
+
const ctokenAmount = dep && effectiveAmount >= deposited * 0.999 ? dep.ctokenAmount : Math.floor(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
|
|
1495
1496
|
const tx = new Transaction();
|
|
1496
1497
|
tx.setSender(address);
|
|
1497
1498
|
const [ctokens] = tx.moveCall({
|
|
@@ -1532,12 +1533,13 @@ var SuilendAdapter = class {
|
|
|
1532
1533
|
if (!reserve) throw new T2000Error("ASSET_NOT_SUPPORTED", `${assetInfo.displayName} reserve not found on Suilend`);
|
|
1533
1534
|
const caps = await this.fetchObligationCaps(address);
|
|
1534
1535
|
if (caps.length === 0) throw new T2000Error("NO_COLLATERAL", "No Suilend position found");
|
|
1535
|
-
const
|
|
1536
|
-
const
|
|
1536
|
+
const obligation = await this.fetchObligation(caps[0].obligationId);
|
|
1537
|
+
const dep = obligation.deposits.find((d) => d.reserveIdx === reserve.arrayIndex);
|
|
1538
|
+
const ratio = cTokenRatio(reserve);
|
|
1539
|
+
const deposited = dep ? dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals : 0;
|
|
1537
1540
|
const effectiveAmount = Math.min(amount, deposited);
|
|
1538
1541
|
if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on Suilend`);
|
|
1539
|
-
const
|
|
1540
|
-
const ctokenAmount = Math.ceil(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
|
|
1542
|
+
const ctokenAmount = dep && effectiveAmount >= deposited * 0.999 ? dep.ctokenAmount : Math.floor(effectiveAmount * 10 ** reserve.mintDecimals / ratio);
|
|
1541
1543
|
const [ctokens] = tx.moveCall({
|
|
1542
1544
|
target: `${pkg}::lending_market::withdraw_ctokens`,
|
|
1543
1545
|
typeArguments: [LENDING_MARKET_TYPE, assetInfo.type],
|