@t2000/sdk 0.8.3 → 0.8.4
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 +22 -3
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +22 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -577,6 +577,20 @@ function addOracleUpdate(tx, config, pool) {
|
|
|
577
577
|
]
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
|
+
function addOracleUpdatesForPositions(tx, config, pools, states, primaryPool) {
|
|
581
|
+
const updated = /* @__PURE__ */ new Set();
|
|
582
|
+
addOracleUpdate(tx, config, primaryPool);
|
|
583
|
+
updated.add(primaryPool.id);
|
|
584
|
+
for (const state of states) {
|
|
585
|
+
if (updated.has(state.assetId)) continue;
|
|
586
|
+
const pool = pools.find((p) => p.id === state.assetId);
|
|
587
|
+
if (!pool) continue;
|
|
588
|
+
const feed = config.oracle.feeds?.find((f2) => f2.assetId === pool.id);
|
|
589
|
+
if (!feed) continue;
|
|
590
|
+
addOracleUpdate(tx, config, pool);
|
|
591
|
+
updated.add(pool.id);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
580
594
|
function rateToApy(rawRate) {
|
|
581
595
|
if (!rawRate || rawRate === "0") return 0;
|
|
582
596
|
return Number(BigInt(rawRate)) / 10 ** RATE_DECIMALS * 100;
|
|
@@ -689,7 +703,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
689
703
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
690
704
|
const tx = new transactions.Transaction();
|
|
691
705
|
tx.setSender(address);
|
|
692
|
-
|
|
706
|
+
addOracleUpdatesForPositions(tx, config, pools, states, pool);
|
|
693
707
|
const [balance] = tx.moveCall({
|
|
694
708
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
695
709
|
arguments: [
|
|
@@ -720,10 +734,15 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
720
734
|
const asset = options.asset ?? "USDC";
|
|
721
735
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
722
736
|
const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
|
|
723
|
-
const [config, pool] = await Promise.all([
|
|
737
|
+
const [config, pool, pools, states] = await Promise.all([
|
|
738
|
+
getConfig(),
|
|
739
|
+
getPool(asset),
|
|
740
|
+
getPools(),
|
|
741
|
+
getUserState(client, address)
|
|
742
|
+
]);
|
|
724
743
|
const tx = new transactions.Transaction();
|
|
725
744
|
tx.setSender(address);
|
|
726
|
-
|
|
745
|
+
addOracleUpdatesForPositions(tx, config, pools, states, pool);
|
|
727
746
|
const [balance] = tx.moveCall({
|
|
728
747
|
target: `${config.package}::incentive_v3::borrow_v2`,
|
|
729
748
|
arguments: [
|