@t2000/sdk 0.8.1 → 0.8.3
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 +19 -9
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +19 -9
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -538,6 +538,13 @@ function matchesCoinType(poolType, targetType) {
|
|
|
538
538
|
const targetSuffix = targetType.split("::").slice(1).join("::").toLowerCase();
|
|
539
539
|
return poolSuffix === targetSuffix;
|
|
540
540
|
}
|
|
541
|
+
function resolvePoolSymbol(pool) {
|
|
542
|
+
const coinType = pool.suiCoinType || pool.coinType || "";
|
|
543
|
+
for (const [key, info] of Object.entries(SUPPORTED_ASSETS)) {
|
|
544
|
+
if (matchesCoinType(coinType, info.type)) return key;
|
|
545
|
+
}
|
|
546
|
+
return pool.token?.symbol ?? "UNKNOWN";
|
|
547
|
+
}
|
|
541
548
|
async function getPool(asset = "USDC") {
|
|
542
549
|
const pools = await getPools();
|
|
543
550
|
const targetType = SUPPORTED_ASSETS[asset].type;
|
|
@@ -874,7 +881,7 @@ async function getPositions(client, addressOrKeypair) {
|
|
|
874
881
|
for (const state of states) {
|
|
875
882
|
const pool = pools.find((p) => p.id === state.assetId);
|
|
876
883
|
if (!pool) continue;
|
|
877
|
-
const symbol = pool
|
|
884
|
+
const symbol = resolvePoolSymbol(pool);
|
|
878
885
|
const supplyBal = compoundBalance(state.supplyBalance, pool.currentSupplyIndex);
|
|
879
886
|
const borrowBal = compoundBalance(state.borrowBalance, pool.currentBorrowIndex);
|
|
880
887
|
if (supplyBal > 1e-4) {
|
|
@@ -1325,10 +1332,10 @@ var NaviAdapter = class {
|
|
|
1325
1332
|
}
|
|
1326
1333
|
async getRates(asset) {
|
|
1327
1334
|
const rates = await getRates(this.client);
|
|
1328
|
-
const
|
|
1329
|
-
const r = rates[
|
|
1335
|
+
const normalized = normalizeAsset(asset);
|
|
1336
|
+
const r = rates[normalized];
|
|
1330
1337
|
if (!r) throw new T2000Error("ASSET_NOT_SUPPORTED", `NAVI does not support ${asset}`);
|
|
1331
|
-
return { asset, saveApy: r.saveApy, borrowApy: r.borrowApy };
|
|
1338
|
+
return { asset: normalized, saveApy: r.saveApy, borrowApy: r.borrowApy };
|
|
1332
1339
|
}
|
|
1333
1340
|
async getPositions(address) {
|
|
1334
1341
|
const result = await getPositions(this.client, address);
|
|
@@ -1341,22 +1348,22 @@ var NaviAdapter = class {
|
|
|
1341
1348
|
return getHealthFactor(this.client, address);
|
|
1342
1349
|
}
|
|
1343
1350
|
async buildSaveTx(address, amount, asset, options) {
|
|
1344
|
-
const stableAsset = asset
|
|
1351
|
+
const stableAsset = normalizeAsset(asset);
|
|
1345
1352
|
const tx = await buildSaveTx(this.client, address, amount, { ...options, asset: stableAsset });
|
|
1346
1353
|
return { tx };
|
|
1347
1354
|
}
|
|
1348
1355
|
async buildWithdrawTx(address, amount, asset) {
|
|
1349
|
-
const stableAsset = asset
|
|
1356
|
+
const stableAsset = normalizeAsset(asset);
|
|
1350
1357
|
const result = await buildWithdrawTx(this.client, address, amount, { asset: stableAsset });
|
|
1351
1358
|
return { tx: result.tx, effectiveAmount: result.effectiveAmount };
|
|
1352
1359
|
}
|
|
1353
1360
|
async buildBorrowTx(address, amount, asset, options) {
|
|
1354
|
-
const stableAsset = asset
|
|
1361
|
+
const stableAsset = normalizeAsset(asset);
|
|
1355
1362
|
const tx = await buildBorrowTx(this.client, address, amount, { ...options, asset: stableAsset });
|
|
1356
1363
|
return { tx };
|
|
1357
1364
|
}
|
|
1358
1365
|
async buildRepayTx(address, amount, asset) {
|
|
1359
|
-
const stableAsset = asset
|
|
1366
|
+
const stableAsset = normalizeAsset(asset);
|
|
1360
1367
|
const tx = await buildRepayTx(this.client, address, amount, { asset: stableAsset });
|
|
1361
1368
|
return { tx };
|
|
1362
1369
|
}
|