@t2000/sdk 0.17.15 → 0.17.17
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 +18 -47
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +18 -47
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-xQEri-Eu.d.cts → index-Dl9CthNB.d.cts} +2 -0
- package/dist/{index-xQEri-Eu.d.ts → index-Dl9CthNB.d.ts} +2 -0
- package/dist/index.cjs +18 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -352,6 +352,7 @@ interface AutoInvestRunResult {
|
|
|
352
352
|
}
|
|
353
353
|
interface PendingReward$1 {
|
|
354
354
|
protocol: string;
|
|
355
|
+
asset: string;
|
|
355
356
|
coinType: string;
|
|
356
357
|
symbol: string;
|
|
357
358
|
amount: number;
|
|
@@ -506,6 +507,7 @@ interface LendingAdapter {
|
|
|
506
507
|
}
|
|
507
508
|
interface PendingReward {
|
|
508
509
|
protocol: string;
|
|
510
|
+
asset: string;
|
|
509
511
|
coinType: string;
|
|
510
512
|
symbol: string;
|
|
511
513
|
amount: number;
|
|
@@ -352,6 +352,7 @@ interface AutoInvestRunResult {
|
|
|
352
352
|
}
|
|
353
353
|
interface PendingReward$1 {
|
|
354
354
|
protocol: string;
|
|
355
|
+
asset: string;
|
|
355
356
|
coinType: string;
|
|
356
357
|
symbol: string;
|
|
357
358
|
amount: number;
|
|
@@ -506,6 +507,7 @@ interface LendingAdapter {
|
|
|
506
507
|
}
|
|
507
508
|
interface PendingReward {
|
|
508
509
|
protocol: string;
|
|
510
|
+
asset: string;
|
|
509
511
|
coinType: string;
|
|
510
512
|
symbol: string;
|
|
511
513
|
amount: number;
|
package/dist/index.cjs
CHANGED
|
@@ -1246,15 +1246,13 @@ function stripPrefix(coinType) {
|
|
|
1246
1246
|
return coinType.replace(/^0x0*/, "");
|
|
1247
1247
|
}
|
|
1248
1248
|
async function getPendingRewards(client, address) {
|
|
1249
|
-
const [pools, states
|
|
1249
|
+
const [pools, states] = await Promise.all([
|
|
1250
1250
|
getPools(),
|
|
1251
|
-
getUserState(client, address)
|
|
1252
|
-
getIncentiveRules(client)
|
|
1251
|
+
getUserState(client, address)
|
|
1253
1252
|
]);
|
|
1254
1253
|
const rewards = [];
|
|
1255
1254
|
const deposited = states.filter((s) => s.supplyBalance > 0n);
|
|
1256
1255
|
if (deposited.length === 0) return rewards;
|
|
1257
|
-
const rewardTotals = /* @__PURE__ */ new Map();
|
|
1258
1256
|
for (const state of deposited) {
|
|
1259
1257
|
const pool = pools.find((p) => p.id === state.assetId);
|
|
1260
1258
|
if (!pool) continue;
|
|
@@ -1263,21 +1261,14 @@ async function getPendingRewards(client, address) {
|
|
|
1263
1261
|
const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
|
|
1264
1262
|
if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
|
|
1265
1263
|
const rewardType = rewardCoins[0];
|
|
1266
|
-
const
|
|
1267
|
-
const price = pool.token?.price ?? 0;
|
|
1268
|
-
const depositUsd = supplyBal * price;
|
|
1269
|
-
const annualRewardUsd = depositUsd * (boostedApr / 100);
|
|
1270
|
-
const estimatedUsd = annualRewardUsd / 365;
|
|
1271
|
-
rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
|
|
1272
|
-
}
|
|
1273
|
-
for (const [coinType, dailyUsd] of rewardTotals) {
|
|
1274
|
-
if (dailyUsd < 1e-3) continue;
|
|
1264
|
+
const assetSymbol = resolvePoolSymbol(pool);
|
|
1275
1265
|
rewards.push({
|
|
1276
1266
|
protocol: "navi",
|
|
1277
|
-
|
|
1278
|
-
|
|
1267
|
+
asset: assetSymbol,
|
|
1268
|
+
coinType: rewardType,
|
|
1269
|
+
symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
|
|
1279
1270
|
amount: 0,
|
|
1280
|
-
estimatedValueUsd:
|
|
1271
|
+
estimatedValueUsd: 0
|
|
1281
1272
|
});
|
|
1282
1273
|
}
|
|
1283
1274
|
return rewards;
|
|
@@ -1338,6 +1329,7 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
1338
1329
|
tx.transferObjects([coin], address);
|
|
1339
1330
|
claimed.push({
|
|
1340
1331
|
protocol: "navi",
|
|
1332
|
+
asset: assets.join(", "),
|
|
1341
1333
|
coinType: rewardType,
|
|
1342
1334
|
symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
|
|
1343
1335
|
amount: 0,
|
|
@@ -2698,46 +2690,24 @@ var SuilendAdapter = class {
|
|
|
2698
2690
|
this.fetchObligation(caps[0].obligationId)
|
|
2699
2691
|
]);
|
|
2700
2692
|
const rewards = [];
|
|
2701
|
-
const rewardEstimates = /* @__PURE__ */ new Map();
|
|
2702
2693
|
for (const dep of obligation.deposits) {
|
|
2703
2694
|
const reserve = reserves[dep.reserveIdx];
|
|
2704
2695
|
if (!reserve) continue;
|
|
2705
|
-
const ratio = cTokenRatio(reserve);
|
|
2706
|
-
const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
|
|
2707
|
-
const price = reserve.price;
|
|
2708
|
-
const depositUsd = amount * price;
|
|
2709
2696
|
for (const rw of reserve.depositPoolRewards) {
|
|
2710
2697
|
if (!this.isClaimableReward(rw.coinType)) continue;
|
|
2711
|
-
const rewardReserve = reserves.find((r) => {
|
|
2712
|
-
try {
|
|
2713
|
-
return utils.normalizeStructTag(r.coinType) === utils.normalizeStructTag(rw.coinType);
|
|
2714
|
-
} catch {
|
|
2715
|
-
return false;
|
|
2716
|
-
}
|
|
2717
|
-
});
|
|
2718
|
-
const rewardPrice = rewardReserve?.price ?? 0;
|
|
2719
|
-
const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
|
|
2720
2698
|
const durationMs = rw.endTimeMs - rw.startTimeMs;
|
|
2721
2699
|
if (durationMs <= 0) continue;
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2700
|
+
const assetSymbol = this.resolveSymbol(reserve.coinType);
|
|
2701
|
+
rewards.push({
|
|
2702
|
+
protocol: "suilend",
|
|
2703
|
+
asset: assetSymbol,
|
|
2704
|
+
coinType: rw.coinType,
|
|
2705
|
+
symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
|
|
2706
|
+
amount: 0,
|
|
2707
|
+
estimatedValueUsd: 0
|
|
2708
|
+
});
|
|
2728
2709
|
}
|
|
2729
2710
|
}
|
|
2730
|
-
for (const [coinType, dailyUsd] of rewardEstimates) {
|
|
2731
|
-
if (dailyUsd < 1e-3) continue;
|
|
2732
|
-
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2733
|
-
rewards.push({
|
|
2734
|
-
protocol: "suilend",
|
|
2735
|
-
coinType,
|
|
2736
|
-
symbol,
|
|
2737
|
-
amount: 0,
|
|
2738
|
-
estimatedValueUsd: dailyUsd
|
|
2739
|
-
});
|
|
2740
|
-
}
|
|
2741
2711
|
return rewards;
|
|
2742
2712
|
}
|
|
2743
2713
|
async addClaimRewardsToTx(tx, address) {
|
|
@@ -2780,6 +2750,7 @@ var SuilendAdapter = class {
|
|
|
2780
2750
|
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2781
2751
|
claimed.push({
|
|
2782
2752
|
protocol: "suilend",
|
|
2753
|
+
asset: "",
|
|
2783
2754
|
coinType,
|
|
2784
2755
|
symbol,
|
|
2785
2756
|
amount: 0,
|