@t2000/cli 0.24.3 → 0.24.5

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.
@@ -64091,9 +64091,34 @@ var SUPPORTED_ASSETS = {
64091
64091
  decimals: 9,
64092
64092
  symbol: "SUI",
64093
64093
  displayName: "SUI"
64094
+ },
64095
+ WAL: {
64096
+ type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL",
64097
+ decimals: 9,
64098
+ symbol: "WAL",
64099
+ displayName: "WAL"
64100
+ },
64101
+ ETH: {
64102
+ type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH",
64103
+ decimals: 8,
64104
+ symbol: "ETH",
64105
+ displayName: "suiETH"
64106
+ },
64107
+ NAVX: {
64108
+ type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX",
64109
+ decimals: 9,
64110
+ symbol: "NAVX",
64111
+ displayName: "NAVX"
64112
+ },
64113
+ GOLD: {
64114
+ type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM",
64115
+ decimals: 6,
64116
+ symbol: "GOLD",
64117
+ displayName: "XAUM"
64094
64118
  }
64095
64119
  };
64096
- var STABLE_ASSETS = ["USDC"];
64120
+ var STABLE_ASSETS = ["USDC", "USDT", "USDe", "USDsui"];
64121
+ var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
64097
64122
  var T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
64098
64123
  var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
64099
64124
  var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
@@ -64557,7 +64582,6 @@ async function reportFee(agentAddress, operation, feeAmount, feeRate, txDigest)
64557
64582
  }
64558
64583
  init_errors();
64559
64584
  var MIN_HEALTH_FACTOR = 1.5;
64560
- var NAVI_SUPPORTED_ASSETS = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
64561
64585
  function sdkOptions(client) {
64562
64586
  return { env: "prod", client, cacheTime: 0, disableCache: true };
64563
64587
  }
@@ -64601,7 +64625,11 @@ var NAVI_SYMBOL_MAP = {
64601
64625
  USDC: "USDC",
64602
64626
  USDT: "USDT",
64603
64627
  USDe: "USDe",
64604
- USDsui: "USDsui"
64628
+ USDsui: "USDsui",
64629
+ WAL: "WAL",
64630
+ NAVX: "NAVX",
64631
+ ETH: "ETH",
64632
+ GOLD: "GOLD"
64605
64633
  };
64606
64634
  function resolveNaviSymbol(sdkSymbol, coinType) {
64607
64635
  for (const [key, info] of Object.entries(SUPPORTED_ASSETS)) {
@@ -64676,7 +64704,7 @@ async function getRates(client) {
64676
64704
  try {
64677
64705
  const pools = await R2(sdkOptions(client));
64678
64706
  const result = {};
64679
- for (const asset of NAVI_SUPPORTED_ASSETS) {
64707
+ for (const asset of ALL_NAVI_ASSETS) {
64680
64708
  const targetType = SUPPORTED_ASSETS[asset].type;
64681
64709
  const pool = pools.find((p) => {
64682
64710
  const poolSuffix = (p.suiCoinType || p.coinType || "").split("::").slice(1).join("::").toLowerCase();
@@ -65126,7 +65154,7 @@ var NaviAdapter = class {
65126
65154
  name = "NAVI Protocol";
65127
65155
  version = "1.0.0";
65128
65156
  capabilities = ["save", "withdraw", "borrow", "repay"];
65129
- supportedAssets = [...STABLE_ASSETS, "SUI", "ETH", "GOLD"];
65157
+ supportedAssets = [...ALL_NAVI_ASSETS];
65130
65158
  supportsSameAssetBorrow = true;
65131
65159
  client;
65132
65160
  async init(client) {
@@ -66145,20 +66173,34 @@ var T2000 = class _T2000 extends import_index.default {
66145
66173
  const asset = params.asset ?? "USDC";
66146
66174
  const assetInfo = SUPPORTED_ASSETS[asset];
66147
66175
  if (!assetInfo) throw new T2000Error("ASSET_NOT_SUPPORTED", `Unsupported asset: ${asset}`);
66148
- const bal = await queryBalance(this.client, this._address);
66176
+ const isStable = STABLE_ASSETS.includes(asset);
66149
66177
  let amount;
66150
66178
  if (params.amount === "all") {
66151
- amount = (bal.available ?? 0) - 1;
66179
+ if (isStable) {
66180
+ const bal = await queryBalance(this.client, this._address);
66181
+ amount = (bal.available ?? 0) - 1;
66182
+ } else if (asset === "SUI") {
66183
+ const suiBal = await this.client.getBalance({ owner: this._address, coinType: assetInfo.type });
66184
+ const suiAmount = Number(suiBal.totalBalance) / 10 ** assetInfo.decimals;
66185
+ amount = suiAmount - 0.15;
66186
+ } else {
66187
+ const coins = await this._fetchCoins(assetInfo.type);
66188
+ const totalRaw = coins.reduce((sum2, c) => sum2 + BigInt(c.balance), 0n);
66189
+ amount = Number(totalRaw) / 10 ** assetInfo.decimals;
66190
+ }
66152
66191
  if (amount <= 0) {
66153
- throw new T2000Error("INSUFFICIENT_BALANCE", "Balance too low to save after $1 gas reserve", {
66154
- reason: "gas_reserve_required",
66155
- available: bal.available ?? 0
66192
+ throw new T2000Error("INSUFFICIENT_BALANCE", `No ${asset} available to save`, {
66193
+ reason: "insufficient_balance",
66194
+ asset
66156
66195
  });
66157
66196
  }
66158
66197
  } else {
66159
66198
  amount = params.amount;
66160
- if (amount > (bal.available ?? 0)) {
66161
- throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient balance. Available: $${(bal.available ?? 0).toFixed(2)}, requested: $${amount.toFixed(2)}`);
66199
+ if (isStable) {
66200
+ const bal = await queryBalance(this.client, this._address);
66201
+ if (amount > (bal.available ?? 0)) {
66202
+ throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient balance. Available: $${(bal.available ?? 0).toFixed(2)}, requested: $${amount.toFixed(2)}`);
66203
+ }
66162
66204
  }
66163
66205
  }
66164
66206
  const fee = calculateFee("save", amount);
@@ -66281,11 +66323,12 @@ var T2000 = class _T2000 extends import_index.default {
66281
66323
  finalAmount = built.effectiveAmount;
66282
66324
  return built.tx;
66283
66325
  });
66284
- this.emitBalanceChange("USDC", finalAmount, "withdraw", gasResult.digest);
66326
+ this.emitBalanceChange(target.asset, finalAmount, "withdraw", gasResult.digest);
66285
66327
  return {
66286
66328
  success: true,
66287
66329
  tx: gasResult.digest,
66288
66330
  amount: finalAmount,
66331
+ asset: target.asset,
66289
66332
  gasCost: gasResult.gasCostSui,
66290
66333
  gasMethod: gasResult.gasMethod
66291
66334
  };
@@ -66907,6 +66950,7 @@ export {
66907
66950
  CLOCK_ID,
66908
66951
  SUPPORTED_ASSETS,
66909
66952
  STABLE_ASSETS,
66953
+ ALL_NAVI_ASSETS,
66910
66954
  DEFAULT_NETWORK,
66911
66955
  CETUS_USDC_SUI_POOL,
66912
66956
  GAS_RESERVE_MIN,
@@ -67000,4 +67044,4 @@ axios/dist/node/axios.cjs:
67000
67044
  @scure/bip39/index.js:
67001
67045
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
67002
67046
  */
67003
- //# sourceMappingURL=chunk-NVVRO5EM.js.map
67047
+ //# sourceMappingURL=chunk-H2UWSH2A.js.map