@t2000/sdk 0.8.3 → 0.8.5
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 +38 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.js
CHANGED
|
@@ -365,6 +365,20 @@ function addOracleUpdate(tx, config, pool) {
|
|
|
365
365
|
]
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
|
+
function addOracleUpdatesForPositions(tx, config, pools, states, primaryPool) {
|
|
369
|
+
const updated = /* @__PURE__ */ new Set();
|
|
370
|
+
addOracleUpdate(tx, config, primaryPool);
|
|
371
|
+
updated.add(primaryPool.id);
|
|
372
|
+
for (const state of states) {
|
|
373
|
+
if (updated.has(state.assetId)) continue;
|
|
374
|
+
const pool = pools.find((p) => p.id === state.assetId);
|
|
375
|
+
if (!pool) continue;
|
|
376
|
+
const feed = config.oracle.feeds?.find((f2) => f2.assetId === pool.id);
|
|
377
|
+
if (!feed) continue;
|
|
378
|
+
addOracleUpdate(tx, config, pool);
|
|
379
|
+
updated.add(pool.id);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
368
382
|
function rateToApy(rawRate) {
|
|
369
383
|
if (!rawRate || rawRate === "0") return 0;
|
|
370
384
|
return Number(BigInt(rawRate)) / 10 ** RATE_DECIMALS * 100;
|
|
@@ -477,7 +491,7 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
|
|
|
477
491
|
const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
|
|
478
492
|
const tx = new Transaction();
|
|
479
493
|
tx.setSender(address);
|
|
480
|
-
|
|
494
|
+
addOracleUpdatesForPositions(tx, config, pools, states, pool);
|
|
481
495
|
const [balance] = tx.moveCall({
|
|
482
496
|
target: `${config.package}::incentive_v3::withdraw_v2`,
|
|
483
497
|
arguments: [
|
|
@@ -508,10 +522,15 @@ async function buildBorrowTx(client, address, amount, options = {}) {
|
|
|
508
522
|
const asset = options.asset ?? "USDC";
|
|
509
523
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
510
524
|
const rawAmount = Number(stableToRaw(amount, assetInfo.decimals));
|
|
511
|
-
const [config, pool] = await Promise.all([
|
|
525
|
+
const [config, pool, pools, states] = await Promise.all([
|
|
526
|
+
getConfig(),
|
|
527
|
+
getPool(asset),
|
|
528
|
+
getPools(),
|
|
529
|
+
getUserState(client, address)
|
|
530
|
+
]);
|
|
512
531
|
const tx = new Transaction();
|
|
513
532
|
tx.setSender(address);
|
|
514
|
-
|
|
533
|
+
addOracleUpdatesForPositions(tx, config, pools, states, pool);
|
|
515
534
|
const [balance] = tx.moveCall({
|
|
516
535
|
target: `${config.package}::incentive_v3::borrow_v2`,
|
|
517
536
|
arguments: [
|