@t2000/sdk 0.17.16 → 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 -45
- 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 -45
- 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 -45
- 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 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.cjs
CHANGED
|
@@ -934,15 +934,13 @@ function stripPrefix(coinType) {
|
|
|
934
934
|
return coinType.replace(/^0x0*/, "");
|
|
935
935
|
}
|
|
936
936
|
async function getPendingRewards(client, address) {
|
|
937
|
-
const [pools, states
|
|
937
|
+
const [pools, states] = await Promise.all([
|
|
938
938
|
getPools(),
|
|
939
|
-
getUserState(client, address)
|
|
940
|
-
getIncentiveRules(client)
|
|
939
|
+
getUserState(client, address)
|
|
941
940
|
]);
|
|
942
941
|
const rewards = [];
|
|
943
942
|
const deposited = states.filter((s) => s.supplyBalance > 0n);
|
|
944
943
|
if (deposited.length === 0) return rewards;
|
|
945
|
-
const rewardTotals = /* @__PURE__ */ new Map();
|
|
946
944
|
for (const state of deposited) {
|
|
947
945
|
const pool = pools.find((p) => p.id === state.assetId);
|
|
948
946
|
if (!pool) continue;
|
|
@@ -951,20 +949,14 @@ async function getPendingRewards(client, address) {
|
|
|
951
949
|
const rewardCoins = pool.supplyIncentiveApyInfo?.rewardCoin;
|
|
952
950
|
if (!Array.isArray(rewardCoins) || rewardCoins.length === 0) continue;
|
|
953
951
|
const rewardType = rewardCoins[0];
|
|
954
|
-
const
|
|
955
|
-
const price = pool.token?.price ?? 0;
|
|
956
|
-
const depositUsd = supplyBal * price;
|
|
957
|
-
const annualRewardUsd = depositUsd * (boostedApr / 100);
|
|
958
|
-
const estimatedUsd = annualRewardUsd / 365;
|
|
959
|
-
rewardTotals.set(rewardType, (rewardTotals.get(rewardType) ?? 0) + estimatedUsd);
|
|
960
|
-
}
|
|
961
|
-
for (const [coinType, dailyUsd] of rewardTotals) {
|
|
952
|
+
const assetSymbol = resolvePoolSymbol(pool);
|
|
962
953
|
rewards.push({
|
|
963
954
|
protocol: "navi",
|
|
964
|
-
|
|
965
|
-
|
|
955
|
+
asset: assetSymbol,
|
|
956
|
+
coinType: rewardType,
|
|
957
|
+
symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
|
|
966
958
|
amount: 0,
|
|
967
|
-
estimatedValueUsd:
|
|
959
|
+
estimatedValueUsd: 0
|
|
968
960
|
});
|
|
969
961
|
}
|
|
970
962
|
return rewards;
|
|
@@ -1025,6 +1017,7 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
1025
1017
|
tx.transferObjects([coin], address);
|
|
1026
1018
|
claimed.push({
|
|
1027
1019
|
protocol: "navi",
|
|
1020
|
+
asset: assets.join(", "),
|
|
1028
1021
|
coinType: rewardType,
|
|
1029
1022
|
symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
|
|
1030
1023
|
amount: 0,
|
|
@@ -2024,45 +2017,24 @@ var SuilendAdapter = class {
|
|
|
2024
2017
|
this.fetchObligation(caps[0].obligationId)
|
|
2025
2018
|
]);
|
|
2026
2019
|
const rewards = [];
|
|
2027
|
-
const rewardEstimates = /* @__PURE__ */ new Map();
|
|
2028
2020
|
for (const dep of obligation.deposits) {
|
|
2029
2021
|
const reserve = reserves[dep.reserveIdx];
|
|
2030
2022
|
if (!reserve) continue;
|
|
2031
|
-
const ratio = cTokenRatio(reserve);
|
|
2032
|
-
const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
|
|
2033
|
-
const price = reserve.price;
|
|
2034
|
-
const depositUsd = amount * price;
|
|
2035
2023
|
for (const rw of reserve.depositPoolRewards) {
|
|
2036
2024
|
if (!this.isClaimableReward(rw.coinType)) continue;
|
|
2037
|
-
const rewardReserve = reserves.find((r) => {
|
|
2038
|
-
try {
|
|
2039
|
-
return utils.normalizeStructTag(r.coinType) === utils.normalizeStructTag(rw.coinType);
|
|
2040
|
-
} catch {
|
|
2041
|
-
return false;
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
const rewardPrice = rewardReserve?.price ?? 0;
|
|
2045
|
-
const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
|
|
2046
2025
|
const durationMs = rw.endTimeMs - rw.startTimeMs;
|
|
2047
2026
|
if (durationMs <= 0) continue;
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2027
|
+
const assetSymbol = this.resolveSymbol(reserve.coinType);
|
|
2028
|
+
rewards.push({
|
|
2029
|
+
protocol: "suilend",
|
|
2030
|
+
asset: assetSymbol,
|
|
2031
|
+
coinType: rw.coinType,
|
|
2032
|
+
symbol: rw.coinType.includes("spring_sui") ? "sSUI" : rw.coinType.includes("deep::") ? "DEEP" : rw.coinType.split("::").pop() ?? "UNKNOWN",
|
|
2033
|
+
amount: 0,
|
|
2034
|
+
estimatedValueUsd: 0
|
|
2035
|
+
});
|
|
2054
2036
|
}
|
|
2055
2037
|
}
|
|
2056
|
-
for (const [coinType, dailyUsd] of rewardEstimates) {
|
|
2057
|
-
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2058
|
-
rewards.push({
|
|
2059
|
-
protocol: "suilend",
|
|
2060
|
-
coinType,
|
|
2061
|
-
symbol,
|
|
2062
|
-
amount: 0,
|
|
2063
|
-
estimatedValueUsd: dailyUsd
|
|
2064
|
-
});
|
|
2065
|
-
}
|
|
2066
2038
|
return rewards;
|
|
2067
2039
|
}
|
|
2068
2040
|
async addClaimRewardsToTx(tx, address) {
|
|
@@ -2105,6 +2077,7 @@ var SuilendAdapter = class {
|
|
|
2105
2077
|
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2106
2078
|
claimed.push({
|
|
2107
2079
|
protocol: "suilend",
|
|
2080
|
+
asset: "",
|
|
2108
2081
|
coinType,
|
|
2109
2082
|
symbol,
|
|
2110
2083
|
amount: 0,
|