@t2000/sdk 3.1.1 → 3.3.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/README.md +5 -8
- package/dist/adapters/index.cjs +3 -3
- 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 +3 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +101 -318
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -135
- package/dist/index.d.ts +34 -135
- package/dist/index.js +102 -315
- package/dist/index.js.map +1 -1
- package/dist/{types-DOnXJXL2.d.cts → types-C1DH4kPA.d.cts} +5 -3
- package/dist/{types-CfBlFLmU.d.ts → types-DjeENMuV.d.ts} +5 -3
- package/dist/{types-Bk7NncQ_.d.cts → types-HJGbXJ37.d.cts} +1 -16
- package/dist/{types-Bk7NncQ_.d.ts → types-HJGbXJ37.d.ts} +1 -16
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -651,155 +651,6 @@ var require_lodash = __commonJS({
|
|
|
651
651
|
}
|
|
652
652
|
});
|
|
653
653
|
|
|
654
|
-
// src/protocols/volo.ts
|
|
655
|
-
var volo_exports = {};
|
|
656
|
-
__export(volo_exports, {
|
|
657
|
-
MIN_STAKE_MIST: () => MIN_STAKE_MIST,
|
|
658
|
-
SUI_SYSTEM_STATE: () => SUI_SYSTEM_STATE,
|
|
659
|
-
VOLO_METADATA: () => exports.VOLO_METADATA,
|
|
660
|
-
VOLO_PKG: () => exports.VOLO_PKG,
|
|
661
|
-
VOLO_POOL: () => exports.VOLO_POOL,
|
|
662
|
-
VSUI_TYPE: () => exports.VSUI_TYPE,
|
|
663
|
-
addStakeVSuiToTx: () => addStakeVSuiToTx,
|
|
664
|
-
addUnstakeVSuiToTx: () => addUnstakeVSuiToTx,
|
|
665
|
-
buildStakeVSuiTx: () => buildStakeVSuiTx,
|
|
666
|
-
buildUnstakeVSuiTx: () => buildUnstakeVSuiTx,
|
|
667
|
-
getVoloStats: () => getVoloStats
|
|
668
|
-
});
|
|
669
|
-
async function getVoloStats() {
|
|
670
|
-
const res = await fetch(VOLO_STATS_URL, {
|
|
671
|
-
signal: AbortSignal.timeout(8e3)
|
|
672
|
-
});
|
|
673
|
-
if (!res.ok) {
|
|
674
|
-
throw new Error(`VOLO stats API error: HTTP ${res.status}`);
|
|
675
|
-
}
|
|
676
|
-
const data = await res.json();
|
|
677
|
-
const d = data.data ?? data;
|
|
678
|
-
return {
|
|
679
|
-
apy: d.apy ?? 0,
|
|
680
|
-
exchangeRate: d.exchange_rate ?? d.exchangeRate ?? 1,
|
|
681
|
-
tvl: d.tvl ?? 0
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
async function buildStakeVSuiTx(_client, address, amountMist) {
|
|
685
|
-
if (amountMist < MIN_STAKE_MIST) {
|
|
686
|
-
throw new Error(`Minimum stake is 1 SUI (${MIN_STAKE_MIST} MIST). Got: ${amountMist}`);
|
|
687
|
-
}
|
|
688
|
-
const tx = new transactions.Transaction();
|
|
689
|
-
tx.setSender(address);
|
|
690
|
-
const [suiCoin] = tx.splitCoins(tx.gas, [amountMist]);
|
|
691
|
-
const [vSuiCoin] = tx.moveCall({
|
|
692
|
-
target: `${exports.VOLO_PKG}::stake_pool::stake`,
|
|
693
|
-
arguments: [
|
|
694
|
-
tx.object(exports.VOLO_POOL),
|
|
695
|
-
tx.object(exports.VOLO_METADATA),
|
|
696
|
-
tx.object(SUI_SYSTEM_STATE),
|
|
697
|
-
suiCoin
|
|
698
|
-
]
|
|
699
|
-
});
|
|
700
|
-
tx.transferObjects([vSuiCoin], address);
|
|
701
|
-
return tx;
|
|
702
|
-
}
|
|
703
|
-
async function buildUnstakeVSuiTx(client, address, amountMist) {
|
|
704
|
-
const balResp = await client.getBalance({ owner: address, coinType: exports.VSUI_TYPE });
|
|
705
|
-
const totalBalance = BigInt(balResp.totalBalance);
|
|
706
|
-
if (totalBalance === 0n) {
|
|
707
|
-
throw new Error("No vSUI found in wallet.");
|
|
708
|
-
}
|
|
709
|
-
const tx = new transactions.Transaction();
|
|
710
|
-
tx.setSender(address);
|
|
711
|
-
const requested = amountMist === "all" ? totalBalance : amountMist;
|
|
712
|
-
if (requested > totalBalance) {
|
|
713
|
-
throw new Error(`Insufficient vSUI: need ${requested} MIST, have ${totalBalance}`);
|
|
714
|
-
}
|
|
715
|
-
const vSuiCoin = transactions.coinWithBalance({ type: exports.VSUI_TYPE, balance: requested })(tx);
|
|
716
|
-
const [suiCoin] = tx.moveCall({
|
|
717
|
-
target: `${exports.VOLO_PKG}::stake_pool::unstake`,
|
|
718
|
-
arguments: [
|
|
719
|
-
tx.object(exports.VOLO_POOL),
|
|
720
|
-
tx.object(exports.VOLO_METADATA),
|
|
721
|
-
tx.object(SUI_SYSTEM_STATE),
|
|
722
|
-
vSuiCoin
|
|
723
|
-
]
|
|
724
|
-
});
|
|
725
|
-
tx.transferObjects([suiCoin], address);
|
|
726
|
-
return tx;
|
|
727
|
-
}
|
|
728
|
-
async function addStakeVSuiToTx(tx, client, address, input) {
|
|
729
|
-
if (input.amountMist < MIN_STAKE_MIST) {
|
|
730
|
-
throw new Error(`Minimum stake is 1 SUI (${MIN_STAKE_MIST} MIST). Got: ${input.amountMist}`);
|
|
731
|
-
}
|
|
732
|
-
let suiCoin;
|
|
733
|
-
if (input.inputCoin) {
|
|
734
|
-
suiCoin = input.inputCoin;
|
|
735
|
-
} else {
|
|
736
|
-
const balResp = await client.getBalance({ owner: address, coinType: exports.SUI_TYPE });
|
|
737
|
-
const totalBalance = BigInt(balResp.totalBalance);
|
|
738
|
-
if (totalBalance < input.amountMist) {
|
|
739
|
-
throw new Error(`Insufficient SUI: need ${input.amountMist} MIST, have ${totalBalance}`);
|
|
740
|
-
}
|
|
741
|
-
suiCoin = transactions.coinWithBalance({
|
|
742
|
-
type: exports.SUI_TYPE,
|
|
743
|
-
balance: input.amountMist,
|
|
744
|
-
useGasCoin: false
|
|
745
|
-
})(tx);
|
|
746
|
-
}
|
|
747
|
-
const [vSuiCoin] = tx.moveCall({
|
|
748
|
-
target: `${exports.VOLO_PKG}::stake_pool::stake`,
|
|
749
|
-
arguments: [
|
|
750
|
-
tx.object(exports.VOLO_POOL),
|
|
751
|
-
tx.object(exports.VOLO_METADATA),
|
|
752
|
-
tx.object(SUI_SYSTEM_STATE),
|
|
753
|
-
suiCoin
|
|
754
|
-
]
|
|
755
|
-
});
|
|
756
|
-
return { coin: vSuiCoin, effectiveAmountMist: input.amountMist };
|
|
757
|
-
}
|
|
758
|
-
async function addUnstakeVSuiToTx(tx, client, address, input) {
|
|
759
|
-
let vSuiCoin;
|
|
760
|
-
if (input.inputCoin) {
|
|
761
|
-
if (input.amountMist === "all") {
|
|
762
|
-
vSuiCoin = input.inputCoin;
|
|
763
|
-
} else {
|
|
764
|
-
[vSuiCoin] = tx.splitCoins(input.inputCoin, [input.amountMist]);
|
|
765
|
-
}
|
|
766
|
-
} else {
|
|
767
|
-
const balResp = await client.getBalance({ owner: address, coinType: exports.VSUI_TYPE });
|
|
768
|
-
const totalBalance = BigInt(balResp.totalBalance);
|
|
769
|
-
if (totalBalance === 0n) {
|
|
770
|
-
throw new Error("No vSUI found in wallet.");
|
|
771
|
-
}
|
|
772
|
-
const requested = input.amountMist === "all" ? totalBalance : input.amountMist;
|
|
773
|
-
if (requested > totalBalance) {
|
|
774
|
-
throw new Error(`Insufficient vSUI: need ${requested} MIST, have ${totalBalance}`);
|
|
775
|
-
}
|
|
776
|
-
vSuiCoin = transactions.coinWithBalance({ type: exports.VSUI_TYPE, balance: requested })(tx);
|
|
777
|
-
}
|
|
778
|
-
const [suiCoin] = tx.moveCall({
|
|
779
|
-
target: `${exports.VOLO_PKG}::stake_pool::unstake`,
|
|
780
|
-
arguments: [
|
|
781
|
-
tx.object(exports.VOLO_POOL),
|
|
782
|
-
tx.object(exports.VOLO_METADATA),
|
|
783
|
-
tx.object(SUI_SYSTEM_STATE),
|
|
784
|
-
vSuiCoin
|
|
785
|
-
]
|
|
786
|
-
});
|
|
787
|
-
return { coin: suiCoin, effectiveAmountMist: input.amountMist };
|
|
788
|
-
}
|
|
789
|
-
exports.VOLO_PKG = void 0; exports.VOLO_POOL = void 0; exports.VOLO_METADATA = void 0; exports.VSUI_TYPE = void 0; var SUI_SYSTEM_STATE, MIN_STAKE_MIST, VOLO_STATS_URL;
|
|
790
|
-
var init_volo = __esm({
|
|
791
|
-
"src/protocols/volo.ts"() {
|
|
792
|
-
init_token_registry();
|
|
793
|
-
exports.VOLO_PKG = "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20";
|
|
794
|
-
exports.VOLO_POOL = "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5";
|
|
795
|
-
exports.VOLO_METADATA = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
796
|
-
exports.VSUI_TYPE = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT";
|
|
797
|
-
SUI_SYSTEM_STATE = "0x05";
|
|
798
|
-
MIN_STAKE_MIST = 1000000000n;
|
|
799
|
-
VOLO_STATS_URL = "https://open-api.naviprotocol.io/api/volo/stats";
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
|
|
803
654
|
// src/wallet/coinSelection.ts
|
|
804
655
|
var coinSelection_exports = {};
|
|
805
656
|
__export(coinSelection_exports, {
|
|
@@ -1145,6 +996,65 @@ var init_cetus_swap = __esm({
|
|
|
1145
996
|
}
|
|
1146
997
|
});
|
|
1147
998
|
|
|
999
|
+
// src/swap-quote.ts
|
|
1000
|
+
var swap_quote_exports = {};
|
|
1001
|
+
__export(swap_quote_exports, {
|
|
1002
|
+
getSwapQuote: () => getSwapQuote
|
|
1003
|
+
});
|
|
1004
|
+
async function getSwapQuote(params) {
|
|
1005
|
+
const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
1006
|
+
const fromType = resolveTokenType2(params.from);
|
|
1007
|
+
const toType = resolveTokenType2(params.to);
|
|
1008
|
+
if (!fromType) {
|
|
1009
|
+
throw new exports.T2000Error(
|
|
1010
|
+
"ASSET_NOT_SUPPORTED",
|
|
1011
|
+
`Unknown token: ${params.from}. Provide the symbol (USDC, SUI, ...) or full coin type.`
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
if (!toType) {
|
|
1015
|
+
throw new exports.T2000Error(
|
|
1016
|
+
"ASSET_NOT_SUPPORTED",
|
|
1017
|
+
`Unknown token: ${params.to}. Provide the symbol (USDC, SUI, ...) or full coin type.`
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
const byAmountIn = params.byAmountIn ?? true;
|
|
1021
|
+
const fromDecimals = getDecimalsForCoinType(fromType);
|
|
1022
|
+
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
1023
|
+
const route = await findSwapRoute2({
|
|
1024
|
+
walletAddress: params.walletAddress,
|
|
1025
|
+
from: fromType,
|
|
1026
|
+
to: toType,
|
|
1027
|
+
amount: rawAmount,
|
|
1028
|
+
byAmountIn,
|
|
1029
|
+
providers: params.providers
|
|
1030
|
+
});
|
|
1031
|
+
if (!route) throw new exports.T2000Error("SWAP_FAILED", `No swap route found for ${params.from} -> ${params.to}.`);
|
|
1032
|
+
if (route.insufficientLiquidity) {
|
|
1033
|
+
throw new exports.T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
|
|
1034
|
+
}
|
|
1035
|
+
const toDecimals = getDecimalsForCoinType(toType);
|
|
1036
|
+
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
1037
|
+
const toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
1038
|
+
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
1039
|
+
const { serializeCetusRoute: serializeCetusRoute2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
1040
|
+
const serializedRoute = serializeCetusRoute2(route, { fromCoinType: fromType, toCoinType: toType });
|
|
1041
|
+
return {
|
|
1042
|
+
fromToken: params.from,
|
|
1043
|
+
toToken: params.to,
|
|
1044
|
+
fromAmount,
|
|
1045
|
+
toAmount,
|
|
1046
|
+
priceImpact: route.priceImpact,
|
|
1047
|
+
route: routeDesc,
|
|
1048
|
+
serializedRoute
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
var init_swap_quote = __esm({
|
|
1052
|
+
"src/swap-quote.ts"() {
|
|
1053
|
+
init_errors();
|
|
1054
|
+
init_token_registry();
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1148
1058
|
// src/constants.ts
|
|
1149
1059
|
init_errors();
|
|
1150
1060
|
var MIST_PER_SUI = 1000000000n;
|
|
@@ -1210,7 +1120,8 @@ var SUPPORTED_ASSETS = {
|
|
|
1210
1120
|
displayName: "XAUM"
|
|
1211
1121
|
}
|
|
1212
1122
|
};
|
|
1213
|
-
var STABLE_ASSETS = ["USDC"];
|
|
1123
|
+
var STABLE_ASSETS = ["USDC", "USDsui"];
|
|
1124
|
+
var SAVEABLE_ASSETS = ["USDC", "USDsui"];
|
|
1214
1125
|
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
1215
1126
|
var OPERATION_ASSETS = {
|
|
1216
1127
|
save: ["USDC", "USDsui"],
|
|
@@ -6015,7 +5926,7 @@ var ProtocolRegistry = class {
|
|
|
6015
5926
|
}
|
|
6016
5927
|
async bestSaveRateAcrossAssets() {
|
|
6017
5928
|
const candidates = [];
|
|
6018
|
-
for (const asset of
|
|
5929
|
+
for (const asset of SAVEABLE_ASSETS) {
|
|
6019
5930
|
for (const adapter of this.lending.values()) {
|
|
6020
5931
|
if (!adapter.supportedAssets.includes(asset)) continue;
|
|
6021
5932
|
if (!adapter.capabilities.includes("save")) continue;
|
|
@@ -6035,7 +5946,7 @@ var ProtocolRegistry = class {
|
|
|
6035
5946
|
async allRatesAcrossAssets() {
|
|
6036
5947
|
const results = [];
|
|
6037
5948
|
const seen = /* @__PURE__ */ new Set();
|
|
6038
|
-
for (const asset of
|
|
5949
|
+
for (const asset of SAVEABLE_ASSETS) {
|
|
6039
5950
|
if (seen.has(asset)) continue;
|
|
6040
5951
|
seen.add(asset);
|
|
6041
5952
|
for (const adapter of this.lending.values()) {
|
|
@@ -6645,51 +6556,14 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
6645
6556
|
receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
6646
6557
|
};
|
|
6647
6558
|
}
|
|
6648
|
-
//
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
});
|
|
6657
|
-
const vSuiReceived = params.amount / stats.exchangeRate;
|
|
6658
|
-
return {
|
|
6659
|
-
success: true,
|
|
6660
|
-
tx: gasResult.digest,
|
|
6661
|
-
amountSui: params.amount,
|
|
6662
|
-
vSuiReceived,
|
|
6663
|
-
apy: stats.apy,
|
|
6664
|
-
gasCost: gasResult.gasCostSui
|
|
6665
|
-
};
|
|
6666
|
-
}
|
|
6667
|
-
async unstakeVSui(params) {
|
|
6668
|
-
this.enforcer.assertNotLocked();
|
|
6669
|
-
const { buildUnstakeVSuiTx: buildUnstakeVSuiTx2, getVoloStats: getVoloStats2, VSUI_TYPE: VSUI_TYPE2 } = await Promise.resolve().then(() => (init_volo(), volo_exports));
|
|
6670
|
-
let amountMist;
|
|
6671
|
-
let vSuiAmount;
|
|
6672
|
-
if (params.amount === "all") {
|
|
6673
|
-
amountMist = "all";
|
|
6674
|
-
const bal = await this.client.getBalance({ owner: this._address, coinType: VSUI_TYPE2 });
|
|
6675
|
-
vSuiAmount = Number(bal.totalBalance) / 1e9;
|
|
6676
|
-
} else {
|
|
6677
|
-
amountMist = BigInt(Math.floor(params.amount * 1e9));
|
|
6678
|
-
vSuiAmount = params.amount;
|
|
6679
|
-
}
|
|
6680
|
-
const stats = await getVoloStats2();
|
|
6681
|
-
const gasResult = await executeTx(this.client, this._signer, async () => {
|
|
6682
|
-
return buildUnstakeVSuiTx2(this.client, this._address, amountMist);
|
|
6683
|
-
});
|
|
6684
|
-
const suiReceived = vSuiAmount * stats.exchangeRate;
|
|
6685
|
-
return {
|
|
6686
|
-
success: true,
|
|
6687
|
-
tx: gasResult.digest,
|
|
6688
|
-
vSuiAmount,
|
|
6689
|
-
suiReceived,
|
|
6690
|
-
gasCost: gasResult.gasCostSui
|
|
6691
|
-
};
|
|
6692
|
-
}
|
|
6559
|
+
// [S.323 / 2026-05-25] VOLO vSUI staking surfaces removed (full cut).
|
|
6560
|
+
// Engine cut Volo in S.277; SDK + CLI + MCP followed in S.323 because the
|
|
6561
|
+
// product surface (five products: Passport / Intelligence / Finance / Pay
|
|
6562
|
+
// / Store) doesn't include a staking primitive. vSUI still appears in the
|
|
6563
|
+
// codebase as a passive token (NAVI reward rewards, Cetus swap routing),
|
|
6564
|
+
// but there is no longer any way to MINT or REDEEM vSUI through t2000.
|
|
6565
|
+
// History: see spec/archive/v07e/AUDIT_V07E_EARNS_ITS_KEEP_2026-05-23.md
|
|
6566
|
+
// and the S.323 build-tracker entry.
|
|
6693
6567
|
// -- Swap --
|
|
6694
6568
|
async swap(params) {
|
|
6695
6569
|
this.enforcer.assertNotLocked();
|
|
@@ -6797,36 +6671,24 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
6797
6671
|
gasCost: gasResult.gasCostSui
|
|
6798
6672
|
};
|
|
6799
6673
|
}
|
|
6674
|
+
/**
|
|
6675
|
+
* [SPEC_AGENTIC_STACK P1 / SDK F2 — 2026-05-25]
|
|
6676
|
+
* Thin wrapper around the standalone `getSwapQuote()`. Pre-Phase 1 this method
|
|
6677
|
+
* was ~50 LoC duplicating `swap-quote.ts` — missing `serializedRoute` (SPEC 20.2
|
|
6678
|
+
* fast-path) and the `providers` allow-list (Bug A fix / Pyth-dependent
|
|
6679
|
+
* provider filter for sponsored callers). Routing both API surfaces through
|
|
6680
|
+
* one implementation ensures fixes land for both.
|
|
6681
|
+
*/
|
|
6800
6682
|
async swapQuote(params) {
|
|
6801
|
-
const {
|
|
6802
|
-
|
|
6803
|
-
const toType = resolveTokenType2(params.to);
|
|
6804
|
-
if (!fromType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.from}. Provide the full coin type.`);
|
|
6805
|
-
if (!toType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.to}. Provide the full coin type.`);
|
|
6806
|
-
const byAmountIn = params.byAmountIn ?? true;
|
|
6807
|
-
const fromDecimals = getDecimalsForCoinType(fromType);
|
|
6808
|
-
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
6809
|
-
const route = await findSwapRoute2({
|
|
6683
|
+
const { getSwapQuote: getSwapQuote2 } = await Promise.resolve().then(() => (init_swap_quote(), swap_quote_exports));
|
|
6684
|
+
return getSwapQuote2({
|
|
6810
6685
|
walletAddress: this._address,
|
|
6811
|
-
from:
|
|
6812
|
-
to:
|
|
6813
|
-
amount:
|
|
6814
|
-
byAmountIn
|
|
6686
|
+
from: params.from,
|
|
6687
|
+
to: params.to,
|
|
6688
|
+
amount: params.amount,
|
|
6689
|
+
byAmountIn: params.byAmountIn,
|
|
6690
|
+
providers: params.providers
|
|
6815
6691
|
});
|
|
6816
|
-
if (!route) throw new exports.T2000Error("SWAP_NO_ROUTE", `No swap route found for ${params.from} -> ${params.to}.`);
|
|
6817
|
-
if (route.insufficientLiquidity) throw new exports.T2000Error("SWAP_NO_ROUTE", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
|
|
6818
|
-
const toDecimals = getDecimalsForCoinType(toType);
|
|
6819
|
-
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
6820
|
-
const toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
6821
|
-
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
6822
|
-
return {
|
|
6823
|
-
fromToken: params.from,
|
|
6824
|
-
toToken: params.to,
|
|
6825
|
-
fromAmount,
|
|
6826
|
-
toAmount,
|
|
6827
|
-
priceImpact: route.priceImpact,
|
|
6828
|
-
route: routeDesc
|
|
6829
|
-
};
|
|
6830
6692
|
}
|
|
6831
6693
|
// -- Wallet --
|
|
6832
6694
|
address() {
|
|
@@ -6957,6 +6819,16 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
6957
6819
|
].join("\n")
|
|
6958
6820
|
};
|
|
6959
6821
|
}
|
|
6822
|
+
/**
|
|
6823
|
+
* [SPEC_AGENTIC_STACK P1 / SDK F2 (CLI rename support) — 2026-05-25]
|
|
6824
|
+
* Preferred alias of `deposit()`. The CLI surface is `t2000 fund` post-Phase 1
|
|
6825
|
+
* (more intuitive than "deposit" which sounds like a NAVI lending action).
|
|
6826
|
+
* `deposit()` stays as the canonical method name for back-compat; it is NOT
|
|
6827
|
+
* deprecated. This wrapper exists so SDK consumers can mirror CLI naming.
|
|
6828
|
+
*/
|
|
6829
|
+
async fund() {
|
|
6830
|
+
return this.deposit();
|
|
6831
|
+
}
|
|
6960
6832
|
receive(params) {
|
|
6961
6833
|
const amount = params?.amount ?? null;
|
|
6962
6834
|
const currency = params?.currency ?? "USDC";
|
|
@@ -7671,7 +7543,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
7671
7543
|
this.emit("yield", {
|
|
7672
7544
|
earned: result.dailyEarning,
|
|
7673
7545
|
total: result.totalYieldEarned,
|
|
7674
|
-
apy: result.currentApy
|
|
7546
|
+
apy: result.currentApy,
|
|
7675
7547
|
timestamp: Date.now()
|
|
7676
7548
|
});
|
|
7677
7549
|
}
|
|
@@ -7918,7 +7790,6 @@ async function buildHarvestRewardsTx(client, address, options = {}) {
|
|
|
7918
7790
|
|
|
7919
7791
|
// src/composeTx.ts
|
|
7920
7792
|
init_cetus_swap();
|
|
7921
|
-
init_volo();
|
|
7922
7793
|
init_coinSelection();
|
|
7923
7794
|
init_token_registry();
|
|
7924
7795
|
init_errors();
|
|
@@ -8142,41 +8013,8 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
8142
8013
|
expectedUsdcDeposited: plan.expectedUsdcDeposited
|
|
8143
8014
|
}
|
|
8144
8015
|
};
|
|
8145
|
-
},
|
|
8146
|
-
volo_stake: async (tx, input, ctx) => {
|
|
8147
|
-
if (input.amountSui <= 0) {
|
|
8148
|
-
throw new exports.T2000Error("INVALID_AMOUNT", "Stake amount must be greater than zero");
|
|
8149
|
-
}
|
|
8150
|
-
const amountMist = BigInt(Math.floor(input.amountSui * 1e9));
|
|
8151
|
-
const result = await addStakeVSuiToTx(tx, ctx.client, ctx.sender, {
|
|
8152
|
-
amountMist,
|
|
8153
|
-
inputCoin: ctx.chainedCoin
|
|
8154
|
-
});
|
|
8155
|
-
if (!ctx.isOutputConsumed) {
|
|
8156
|
-
tx.transferObjects([result.coin], ctx.sender);
|
|
8157
|
-
}
|
|
8158
|
-
return {
|
|
8159
|
-
preview: { toolName: "volo_stake", effectiveAmountMist: result.effectiveAmountMist },
|
|
8160
|
-
outputCoin: result.coin
|
|
8161
|
-
};
|
|
8162
|
-
},
|
|
8163
|
-
volo_unstake: async (tx, input, ctx) => {
|
|
8164
|
-
const amountMist = input.amountVSui === "all" ? "all" : BigInt(Math.floor(input.amountVSui * 1e9));
|
|
8165
|
-
if (amountMist !== "all" && amountMist <= 0n) {
|
|
8166
|
-
throw new exports.T2000Error("INVALID_AMOUNT", "Unstake amount must be greater than zero");
|
|
8167
|
-
}
|
|
8168
|
-
const result = await addUnstakeVSuiToTx(tx, ctx.client, ctx.sender, {
|
|
8169
|
-
amountMist,
|
|
8170
|
-
inputCoin: ctx.chainedCoin
|
|
8171
|
-
});
|
|
8172
|
-
if (!ctx.isOutputConsumed) {
|
|
8173
|
-
tx.transferObjects([result.coin], ctx.sender);
|
|
8174
|
-
}
|
|
8175
|
-
return {
|
|
8176
|
-
preview: { toolName: "volo_unstake", effectiveAmountMist: result.effectiveAmountMist },
|
|
8177
|
-
outputCoin: result.coin
|
|
8178
|
-
};
|
|
8179
8016
|
}
|
|
8017
|
+
// [S.323 / 2026-05-25] volo_stake / volo_unstake appenders removed.
|
|
8180
8018
|
};
|
|
8181
8019
|
function deriveAllowedAddressesFromPtb(tx) {
|
|
8182
8020
|
const addresses = /* @__PURE__ */ new Set();
|
|
@@ -8237,7 +8075,7 @@ async function composeTx(opts) {
|
|
|
8237
8075
|
if (producer.toolName === "save_deposit" || producer.toolName === "repay_debt" || producer.toolName === "send_transfer" || producer.toolName === "claim_rewards") {
|
|
8238
8076
|
throw new exports.T2000Error(
|
|
8239
8077
|
"CHAIN_MODE_INVALID",
|
|
8240
|
-
`Step ${i} (${step.toolName}) references step ${idx} (${producer.toolName}) as producer, but '${producer.toolName}' is a terminal consumer that does not produce a chainable coin handle. Allowed producers: withdraw, borrow, swap_execute
|
|
8078
|
+
`Step ${i} (${step.toolName}) references step ${idx} (${producer.toolName}) as producer, but '${producer.toolName}' is a terminal consumer that does not produce a chainable coin handle. Allowed producers: withdraw, borrow, swap_execute.`
|
|
8241
8079
|
);
|
|
8242
8080
|
}
|
|
8243
8081
|
consumedSteps.add(idx);
|
|
@@ -8453,61 +8291,10 @@ function parseMoveAbort(errorStr) {
|
|
|
8453
8291
|
return { reason: errorStr };
|
|
8454
8292
|
}
|
|
8455
8293
|
|
|
8456
|
-
// src/swap-quote.ts
|
|
8457
|
-
init_errors();
|
|
8458
|
-
init_token_registry();
|
|
8459
|
-
async function getSwapQuote(params) {
|
|
8460
|
-
const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
8461
|
-
const fromType = resolveTokenType2(params.from);
|
|
8462
|
-
const toType = resolveTokenType2(params.to);
|
|
8463
|
-
if (!fromType) {
|
|
8464
|
-
throw new exports.T2000Error(
|
|
8465
|
-
"ASSET_NOT_SUPPORTED",
|
|
8466
|
-
`Unknown token: ${params.from}. Provide the symbol (USDC, SUI, ...) or full coin type.`
|
|
8467
|
-
);
|
|
8468
|
-
}
|
|
8469
|
-
if (!toType) {
|
|
8470
|
-
throw new exports.T2000Error(
|
|
8471
|
-
"ASSET_NOT_SUPPORTED",
|
|
8472
|
-
`Unknown token: ${params.to}. Provide the symbol (USDC, SUI, ...) or full coin type.`
|
|
8473
|
-
);
|
|
8474
|
-
}
|
|
8475
|
-
const byAmountIn = params.byAmountIn ?? true;
|
|
8476
|
-
const fromDecimals = getDecimalsForCoinType(fromType);
|
|
8477
|
-
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
8478
|
-
const route = await findSwapRoute2({
|
|
8479
|
-
walletAddress: params.walletAddress,
|
|
8480
|
-
from: fromType,
|
|
8481
|
-
to: toType,
|
|
8482
|
-
amount: rawAmount,
|
|
8483
|
-
byAmountIn,
|
|
8484
|
-
providers: params.providers
|
|
8485
|
-
});
|
|
8486
|
-
if (!route) throw new exports.T2000Error("SWAP_FAILED", `No swap route found for ${params.from} -> ${params.to}.`);
|
|
8487
|
-
if (route.insufficientLiquidity) {
|
|
8488
|
-
throw new exports.T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
|
|
8489
|
-
}
|
|
8490
|
-
const toDecimals = getDecimalsForCoinType(toType);
|
|
8491
|
-
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
8492
|
-
const toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
8493
|
-
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
8494
|
-
const { serializeCetusRoute: serializeCetusRoute2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
8495
|
-
const serializedRoute = serializeCetusRoute2(route, { fromCoinType: fromType, toCoinType: toType });
|
|
8496
|
-
return {
|
|
8497
|
-
fromToken: params.from,
|
|
8498
|
-
toToken: params.to,
|
|
8499
|
-
fromAmount,
|
|
8500
|
-
toAmount,
|
|
8501
|
-
priceImpact: route.priceImpact,
|
|
8502
|
-
route: routeDesc,
|
|
8503
|
-
serializedRoute
|
|
8504
|
-
};
|
|
8505
|
-
}
|
|
8506
|
-
|
|
8507
8294
|
// src/index.ts
|
|
8295
|
+
init_swap_quote();
|
|
8508
8296
|
init_cetus_swap();
|
|
8509
8297
|
init_token_registry();
|
|
8510
|
-
init_volo();
|
|
8511
8298
|
var AUDRIC_PARENT_NAME = "audric.sui";
|
|
8512
8299
|
var AUDRIC_PARENT_NFT_ID = "0x070456e283ec988b6302bdd6cc5172bbdcb709998cf116586fb98d19b0870198";
|
|
8513
8300
|
var LABEL_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
@@ -8597,6 +8384,7 @@ exports.NaviAdapter = NaviAdapter;
|
|
|
8597
8384
|
exports.OPERATION_ASSETS = OPERATION_ASSETS;
|
|
8598
8385
|
exports.OUTBOUND_OPS = OUTBOUND_OPS;
|
|
8599
8386
|
exports.ProtocolRegistry = ProtocolRegistry;
|
|
8387
|
+
exports.SAVEABLE_ASSETS = SAVEABLE_ASSETS;
|
|
8600
8388
|
exports.SAVE_FEE_BPS = SAVE_FEE_BPS;
|
|
8601
8389
|
exports.SPONSORED_PYTH_DEPENDENT_PROVIDERS = SPONSORED_PYTH_DEPENDENT_PROVIDERS;
|
|
8602
8390
|
exports.STABLE_ASSETS = STABLE_ASSETS;
|
|
@@ -8617,9 +8405,7 @@ exports.ZkLoginSigner = ZkLoginSigner;
|
|
|
8617
8405
|
exports.addClaimRewardsToTx = addClaimRewardsToTx;
|
|
8618
8406
|
exports.addFeeTransfer = addFeeTransfer;
|
|
8619
8407
|
exports.addSendToTx = addSendToTx;
|
|
8620
|
-
exports.addStakeVSuiToTx = addStakeVSuiToTx;
|
|
8621
8408
|
exports.addSwapToTx = addSwapToTx;
|
|
8622
|
-
exports.addUnstakeVSuiToTx = addUnstakeVSuiToTx;
|
|
8623
8409
|
exports.aggregateClaimableRewards = aggregateClaimableRewards;
|
|
8624
8410
|
exports.allDescriptors = allDescriptors;
|
|
8625
8411
|
exports.assertAllowedAsset = assertAllowedAsset;
|
|
@@ -8628,9 +8414,7 @@ exports.buildClaimRewardsTx = buildClaimRewardsTx;
|
|
|
8628
8414
|
exports.buildHarvestRewardsTx = buildHarvestRewardsTx;
|
|
8629
8415
|
exports.buildRevokeLeafTx = buildRevokeLeafTx;
|
|
8630
8416
|
exports.buildSendTx = buildSendTx;
|
|
8631
|
-
exports.buildStakeVSuiTx = buildStakeVSuiTx;
|
|
8632
8417
|
exports.buildSwapTx = buildSwapTx;
|
|
8633
|
-
exports.buildUnstakeVSuiTx = buildUnstakeVSuiTx;
|
|
8634
8418
|
exports.calculateFee = calculateFee;
|
|
8635
8419
|
exports.classifyAction = classifyAction;
|
|
8636
8420
|
exports.classifyLabel = classifyLabel;
|
|
@@ -8663,7 +8447,6 @@ exports.getRates = getRates;
|
|
|
8663
8447
|
exports.getSponsoredSwapProviders = getSponsoredSwapProviders;
|
|
8664
8448
|
exports.getSwapQuote = getSwapQuote;
|
|
8665
8449
|
exports.getTier = getTier;
|
|
8666
|
-
exports.getVoloStats = getVoloStats;
|
|
8667
8450
|
exports.isAllowedAsset = isAllowedAsset;
|
|
8668
8451
|
exports.isCetusRouteFresh = isCetusRouteFresh;
|
|
8669
8452
|
exports.isInRegistry = isInRegistry;
|