@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
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,21 +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) {
|
|
962
|
-
if (dailyUsd < 1e-3) continue;
|
|
952
|
+
const assetSymbol = resolvePoolSymbol(pool);
|
|
963
953
|
rewards.push({
|
|
964
954
|
protocol: "navi",
|
|
965
|
-
|
|
966
|
-
|
|
955
|
+
asset: assetSymbol,
|
|
956
|
+
coinType: rewardType,
|
|
957
|
+
symbol: REWARD_SYMBOLS[rewardType] ?? rewardType.split("::").pop() ?? "UNKNOWN",
|
|
967
958
|
amount: 0,
|
|
968
|
-
estimatedValueUsd:
|
|
959
|
+
estimatedValueUsd: 0
|
|
969
960
|
});
|
|
970
961
|
}
|
|
971
962
|
return rewards;
|
|
@@ -1026,6 +1017,7 @@ async function addClaimRewardsToTx(tx, client, address) {
|
|
|
1026
1017
|
tx.transferObjects([coin], address);
|
|
1027
1018
|
claimed.push({
|
|
1028
1019
|
protocol: "navi",
|
|
1020
|
+
asset: assets.join(", "),
|
|
1029
1021
|
coinType: rewardType,
|
|
1030
1022
|
symbol: REWARD_SYMBOLS[rewardType] ?? "UNKNOWN",
|
|
1031
1023
|
amount: 0,
|
|
@@ -2025,46 +2017,24 @@ var SuilendAdapter = class {
|
|
|
2025
2017
|
this.fetchObligation(caps[0].obligationId)
|
|
2026
2018
|
]);
|
|
2027
2019
|
const rewards = [];
|
|
2028
|
-
const rewardEstimates = /* @__PURE__ */ new Map();
|
|
2029
2020
|
for (const dep of obligation.deposits) {
|
|
2030
2021
|
const reserve = reserves[dep.reserveIdx];
|
|
2031
2022
|
if (!reserve) continue;
|
|
2032
|
-
const ratio = cTokenRatio(reserve);
|
|
2033
|
-
const amount = dep.ctokenAmount * ratio / 10 ** reserve.mintDecimals;
|
|
2034
|
-
const price = reserve.price;
|
|
2035
|
-
const depositUsd = amount * price;
|
|
2036
2023
|
for (const rw of reserve.depositPoolRewards) {
|
|
2037
2024
|
if (!this.isClaimableReward(rw.coinType)) continue;
|
|
2038
|
-
const rewardReserve = reserves.find((r) => {
|
|
2039
|
-
try {
|
|
2040
|
-
return utils.normalizeStructTag(r.coinType) === utils.normalizeStructTag(rw.coinType);
|
|
2041
|
-
} catch {
|
|
2042
|
-
return false;
|
|
2043
|
-
}
|
|
2044
|
-
});
|
|
2045
|
-
const rewardPrice = rewardReserve?.price ?? 0;
|
|
2046
|
-
const rewardDecimals = rewardReserve?.mintDecimals ?? 9;
|
|
2047
2025
|
const durationMs = rw.endTimeMs - rw.startTimeMs;
|
|
2048
2026
|
if (durationMs <= 0) continue;
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
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
|
+
});
|
|
2055
2036
|
}
|
|
2056
2037
|
}
|
|
2057
|
-
for (const [coinType, dailyUsd] of rewardEstimates) {
|
|
2058
|
-
if (dailyUsd < 1e-3) continue;
|
|
2059
|
-
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2060
|
-
rewards.push({
|
|
2061
|
-
protocol: "suilend",
|
|
2062
|
-
coinType,
|
|
2063
|
-
symbol,
|
|
2064
|
-
amount: 0,
|
|
2065
|
-
estimatedValueUsd: dailyUsd
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
2038
|
return rewards;
|
|
2069
2039
|
}
|
|
2070
2040
|
async addClaimRewardsToTx(tx, address) {
|
|
@@ -2107,6 +2077,7 @@ var SuilendAdapter = class {
|
|
|
2107
2077
|
const symbol = coinType.includes("spring_sui") ? "SPRING_SUI" : coinType.includes("deep::") ? "DEEP" : coinType.split("::").pop() ?? "UNKNOWN";
|
|
2108
2078
|
claimed.push({
|
|
2109
2079
|
protocol: "suilend",
|
|
2080
|
+
asset: "",
|
|
2110
2081
|
coinType,
|
|
2111
2082
|
symbol,
|
|
2112
2083
|
amount: 0,
|