@t2000/sdk 1.23.0 → 1.24.0
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 +45 -48
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +45 -48
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +208 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -4
- package/dist/index.d.ts +191 -4
- package/dist/index.js +206 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/index.cjs
CHANGED
|
@@ -4023,35 +4023,6 @@ async function vt(e, n) {
|
|
|
4023
4023
|
);
|
|
4024
4024
|
return await De(e, t, n);
|
|
4025
4025
|
}
|
|
4026
|
-
function wt(e) {
|
|
4027
|
-
const n = /* @__PURE__ */ new Map();
|
|
4028
|
-
e.forEach((r) => {
|
|
4029
|
-
const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
|
|
4030
|
-
n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
|
|
4031
|
-
assetId: t,
|
|
4032
|
-
rewardType: a,
|
|
4033
|
-
coinType: r.rewardCoinType,
|
|
4034
|
-
total: Number(r.userClaimableReward),
|
|
4035
|
-
market: r.market
|
|
4036
|
-
});
|
|
4037
|
-
});
|
|
4038
|
-
const o = /* @__PURE__ */ new Map();
|
|
4039
|
-
for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
|
|
4040
|
-
const c = `${r}-${t}-${i}`;
|
|
4041
|
-
o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
|
|
4042
|
-
const u = o.get(c);
|
|
4043
|
-
u.rewards.set(a, (u.rewards.get(a) || 0) + s);
|
|
4044
|
-
}
|
|
4045
|
-
return Array.from(o.values()).map((r) => ({
|
|
4046
|
-
assetId: r.assetId,
|
|
4047
|
-
rewardType: r.rewardType,
|
|
4048
|
-
market: r.market,
|
|
4049
|
-
rewards: Array.from(r.rewards.entries()).map(([t, a]) => ({
|
|
4050
|
-
coinType: t,
|
|
4051
|
-
available: a.toFixed(6)
|
|
4052
|
-
}))
|
|
4053
|
-
}));
|
|
4054
|
-
}
|
|
4055
4026
|
async function Ct(e, n, o) {
|
|
4056
4027
|
const r = await R({
|
|
4057
4028
|
...o,
|
|
@@ -4227,6 +4198,47 @@ async function Ct(e, n, o) {
|
|
|
4227
4198
|
return a;
|
|
4228
4199
|
}
|
|
4229
4200
|
|
|
4201
|
+
// src/token-registry.ts
|
|
4202
|
+
var COIN_REGISTRY = {
|
|
4203
|
+
// ── Tier 1 — Financial layer ──────────────────────────────────────────
|
|
4204
|
+
USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
|
|
4205
|
+
// ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
|
|
4206
|
+
SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
|
|
4207
|
+
wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
|
|
4208
|
+
ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
|
|
4209
|
+
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
|
|
4210
|
+
DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
|
|
4211
|
+
WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
|
|
4212
|
+
NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
|
|
4213
|
+
IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
|
|
4214
|
+
CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
|
|
4215
|
+
NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
|
|
4216
|
+
vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
|
|
4217
|
+
haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
|
|
4218
|
+
afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
|
|
4219
|
+
LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
|
|
4220
|
+
MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
|
|
4221
|
+
// ── Legacy — no tier, kept for display accuracy on existing positions ──
|
|
4222
|
+
USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
|
|
4223
|
+
USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
|
|
4224
|
+
USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
|
|
4225
|
+
};
|
|
4226
|
+
var BY_TYPE = /* @__PURE__ */ new Map();
|
|
4227
|
+
for (const meta of Object.values(COIN_REGISTRY)) {
|
|
4228
|
+
BY_TYPE.set(meta.type, meta);
|
|
4229
|
+
}
|
|
4230
|
+
function getCoinMeta(coinType) {
|
|
4231
|
+
return BY_TYPE.get(coinType);
|
|
4232
|
+
}
|
|
4233
|
+
(() => {
|
|
4234
|
+
const map2 = {};
|
|
4235
|
+
for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
|
|
4236
|
+
map2[name] = meta.type;
|
|
4237
|
+
map2[name.toUpperCase()] = meta.type;
|
|
4238
|
+
}
|
|
4239
|
+
return map2;
|
|
4240
|
+
})();
|
|
4241
|
+
|
|
4230
4242
|
// src/protocols/navi.ts
|
|
4231
4243
|
var MIN_HEALTH_FACTOR = 1.5;
|
|
4232
4244
|
function sdkOptions(client) {
|
|
@@ -4602,24 +4614,8 @@ async function getPendingRewards(client, address) {
|
|
|
4602
4614
|
);
|
|
4603
4615
|
}
|
|
4604
4616
|
if (!rewards || rewards.length === 0) return [];
|
|
4605
|
-
const
|
|
4606
|
-
|
|
4607
|
-
for (const s of summary) {
|
|
4608
|
-
for (const rw of s.rewards) {
|
|
4609
|
-
const available = Number(rw.available);
|
|
4610
|
-
if (available <= 0) continue;
|
|
4611
|
-
const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
|
|
4612
|
-
result.push({
|
|
4613
|
-
protocol: "navi",
|
|
4614
|
-
asset: String(s.assetId),
|
|
4615
|
-
coinType: rw.coinType,
|
|
4616
|
-
symbol,
|
|
4617
|
-
amount: available,
|
|
4618
|
-
estimatedValueUsd: 0
|
|
4619
|
-
});
|
|
4620
|
-
}
|
|
4621
|
-
}
|
|
4622
|
-
return result;
|
|
4617
|
+
const claimable = rewards.filter((r) => Number(r.userClaimableReward) > 0);
|
|
4618
|
+
return aggregateClaimableRewards(claimable);
|
|
4623
4619
|
}
|
|
4624
4620
|
async function addClaimRewardsToTx(tx, client, address) {
|
|
4625
4621
|
let rewards;
|
|
@@ -4663,7 +4659,8 @@ function aggregateClaimableRewards(claimable) {
|
|
|
4663
4659
|
for (const c of claimable) {
|
|
4664
4660
|
const coinType = c.rewardCoinType;
|
|
4665
4661
|
if (!coinType) continue;
|
|
4666
|
-
const
|
|
4662
|
+
const meta = getCoinMeta(coinType);
|
|
4663
|
+
const symbol = meta?.symbol ?? coinType.split("::").pop() ?? "REWARD";
|
|
4667
4664
|
const amount = Number(c.userClaimableReward);
|
|
4668
4665
|
if (!Number.isFinite(amount) || amount <= 0) continue;
|
|
4669
4666
|
const existing = aggregated.get(coinType);
|