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