@t2000/sdk 0.20.0 → 0.20.2
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/index.cjs +66 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H
|
|
|
6
6
|
import { T as T2000Options, P as PayOptions, a as PayResult, S as StakeVSuiResult, U as UnstakeVSuiResult, b as SwapResult, c as SwapQuoteResult, d as SendResult, B as BalanceResponse, e as TransactionRecord, D as DepositInfo, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as PendingReward, C as ClaimRewardsResult, j as PositionsResult, k as RatesResult, E as EarningsResult, F as FundStatusResult, G as GasMethod } from './index-MP_J_nSO.cjs';
|
|
7
7
|
export { A as AssetRates, l as GasReserve, N as NaviAdapter, m as PositionEntry, n as ProtocolRegistry } from './index-MP_J_nSO.cjs';
|
|
8
8
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
9
|
+
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Abstract signing interface that decouples the SDK from any specific
|
|
@@ -388,6 +389,82 @@ declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
|
388
389
|
|
|
389
390
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
390
391
|
|
|
392
|
+
declare function getSwapQuote(params: {
|
|
393
|
+
walletAddress: string;
|
|
394
|
+
from: string;
|
|
395
|
+
to: string;
|
|
396
|
+
amount: number;
|
|
397
|
+
byAmountIn?: boolean;
|
|
398
|
+
}): Promise<SwapQuoteResult>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Cetus Aggregator V3 SDK wrapper — the ONLY file that imports @cetusprotocol/aggregator-sdk.
|
|
402
|
+
* Documented CLAUDE.md exception: multi-DEX routing cannot be feasibly replaced by thin tx builders.
|
|
403
|
+
*/
|
|
404
|
+
|
|
405
|
+
interface SwapRouteResult {
|
|
406
|
+
routerData: RouterDataV3;
|
|
407
|
+
amountIn: string;
|
|
408
|
+
amountOut: string;
|
|
409
|
+
byAmountIn: boolean;
|
|
410
|
+
priceImpact: number;
|
|
411
|
+
insufficientLiquidity: boolean;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Find the optimal swap route via Cetus Aggregator REST API.
|
|
415
|
+
*/
|
|
416
|
+
declare function findSwapRoute(params: {
|
|
417
|
+
walletAddress: string;
|
|
418
|
+
from: string;
|
|
419
|
+
to: string;
|
|
420
|
+
amount: bigint;
|
|
421
|
+
byAmountIn: boolean;
|
|
422
|
+
}): Promise<SwapRouteResult | null>;
|
|
423
|
+
/**
|
|
424
|
+
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
425
|
+
* obtained by splitting/merging wallet coins.
|
|
426
|
+
*/
|
|
427
|
+
declare function buildSwapTx(params: {
|
|
428
|
+
walletAddress: string;
|
|
429
|
+
route: SwapRouteResult;
|
|
430
|
+
tx: Transaction;
|
|
431
|
+
inputCoin: TransactionObjectArgument;
|
|
432
|
+
slippage: number;
|
|
433
|
+
}): Promise<TransactionObjectArgument>;
|
|
434
|
+
declare const TOKEN_MAP: Record<string, string>;
|
|
435
|
+
/**
|
|
436
|
+
* Resolve a user-friendly token name ("SUI", "USDC") to its full coin type string.
|
|
437
|
+
* Returns the input unchanged if already a full coin type (contains "::").
|
|
438
|
+
*/
|
|
439
|
+
declare function resolveTokenType(nameOrType: string): string | null;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* VOLO vSUI liquid staking — thin transaction builders.
|
|
443
|
+
* No SDK dependency. Two Move calls, immutable contract addresses.
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
declare const VOLO_PKG = "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20";
|
|
447
|
+
declare const VOLO_POOL = "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5";
|
|
448
|
+
declare const VOLO_METADATA = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
449
|
+
declare const VSUI_TYPE = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT";
|
|
450
|
+
interface VoloStats {
|
|
451
|
+
apy: number;
|
|
452
|
+
exchangeRate: number;
|
|
453
|
+
tvl: number;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Fetch VOLO vSUI staking stats (APY, exchange rate, TVL).
|
|
457
|
+
*/
|
|
458
|
+
declare function getVoloStats(): Promise<VoloStats>;
|
|
459
|
+
/**
|
|
460
|
+
* Build a PTB to stake SUI for vSUI.
|
|
461
|
+
*/
|
|
462
|
+
declare function buildStakeVSuiTx(_client: SuiJsonRpcClient, address: string, amountMist: bigint): Promise<Transaction>;
|
|
463
|
+
/**
|
|
464
|
+
* Build a PTB to unstake vSUI back to SUI.
|
|
465
|
+
*/
|
|
466
|
+
declare function buildUnstakeVSuiTx(client: SuiJsonRpcClient, address: string, amountMist: bigint | 'all'): Promise<Transaction>;
|
|
467
|
+
|
|
391
468
|
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
392
469
|
interface SafeguardErrorDetails {
|
|
393
470
|
attempted?: number;
|
|
@@ -458,4 +535,4 @@ interface GasStatusResponse {
|
|
|
458
535
|
}
|
|
459
536
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
460
537
|
|
|
461
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CETUS_USDC_SUI_POOL, CLOCK_ID, ClaimRewardsResult, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, KeypairSigner, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PayOptions, PayResult, PendingReward, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, type SimulationResult, type StableAsset, StakeVSuiResult, type SupportedAsset, SwapQuoteResult, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TransactionSigner, type TxMetadata, USDC_DECIMALS, UnstakeVSuiResult, WithdrawResult, type ZkLoginProof, ZkLoginSigner, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
538
|
+
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CETUS_USDC_SUI_POOL, CLOCK_ID, ClaimRewardsResult, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, KeypairSigner, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PayOptions, PayResult, PendingReward, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, type SimulationResult, type StableAsset, StakeVSuiResult, type SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TOKEN_MAP, TransactionRecord, type TransactionSigner, type TxMetadata, USDC_DECIMALS, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, type ZkLoginProof, ZkLoginSigner, addCollectFeeToTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, findSwapRoute, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, resolveTokenType, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H
|
|
|
6
6
|
import { T as T2000Options, P as PayOptions, a as PayResult, S as StakeVSuiResult, U as UnstakeVSuiResult, b as SwapResult, c as SwapQuoteResult, d as SendResult, B as BalanceResponse, e as TransactionRecord, D as DepositInfo, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as PendingReward, C as ClaimRewardsResult, j as PositionsResult, k as RatesResult, E as EarningsResult, F as FundStatusResult, G as GasMethod } from './index-D1DxZ1DK.js';
|
|
7
7
|
export { A as AssetRates, l as GasReserve, N as NaviAdapter, m as PositionEntry, n as ProtocolRegistry } from './index-D1DxZ1DK.js';
|
|
8
8
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
9
|
+
import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Abstract signing interface that decouples the SDK from any specific
|
|
@@ -388,6 +389,82 @@ declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
|
388
389
|
|
|
389
390
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
390
391
|
|
|
392
|
+
declare function getSwapQuote(params: {
|
|
393
|
+
walletAddress: string;
|
|
394
|
+
from: string;
|
|
395
|
+
to: string;
|
|
396
|
+
amount: number;
|
|
397
|
+
byAmountIn?: boolean;
|
|
398
|
+
}): Promise<SwapQuoteResult>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Cetus Aggregator V3 SDK wrapper — the ONLY file that imports @cetusprotocol/aggregator-sdk.
|
|
402
|
+
* Documented CLAUDE.md exception: multi-DEX routing cannot be feasibly replaced by thin tx builders.
|
|
403
|
+
*/
|
|
404
|
+
|
|
405
|
+
interface SwapRouteResult {
|
|
406
|
+
routerData: RouterDataV3;
|
|
407
|
+
amountIn: string;
|
|
408
|
+
amountOut: string;
|
|
409
|
+
byAmountIn: boolean;
|
|
410
|
+
priceImpact: number;
|
|
411
|
+
insufficientLiquidity: boolean;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Find the optimal swap route via Cetus Aggregator REST API.
|
|
415
|
+
*/
|
|
416
|
+
declare function findSwapRoute(params: {
|
|
417
|
+
walletAddress: string;
|
|
418
|
+
from: string;
|
|
419
|
+
to: string;
|
|
420
|
+
amount: bigint;
|
|
421
|
+
byAmountIn: boolean;
|
|
422
|
+
}): Promise<SwapRouteResult | null>;
|
|
423
|
+
/**
|
|
424
|
+
* Build a swap PTB from a route result. The caller must provide an input coin
|
|
425
|
+
* obtained by splitting/merging wallet coins.
|
|
426
|
+
*/
|
|
427
|
+
declare function buildSwapTx(params: {
|
|
428
|
+
walletAddress: string;
|
|
429
|
+
route: SwapRouteResult;
|
|
430
|
+
tx: Transaction;
|
|
431
|
+
inputCoin: TransactionObjectArgument;
|
|
432
|
+
slippage: number;
|
|
433
|
+
}): Promise<TransactionObjectArgument>;
|
|
434
|
+
declare const TOKEN_MAP: Record<string, string>;
|
|
435
|
+
/**
|
|
436
|
+
* Resolve a user-friendly token name ("SUI", "USDC") to its full coin type string.
|
|
437
|
+
* Returns the input unchanged if already a full coin type (contains "::").
|
|
438
|
+
*/
|
|
439
|
+
declare function resolveTokenType(nameOrType: string): string | null;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* VOLO vSUI liquid staking — thin transaction builders.
|
|
443
|
+
* No SDK dependency. Two Move calls, immutable contract addresses.
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
declare const VOLO_PKG = "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20";
|
|
447
|
+
declare const VOLO_POOL = "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5";
|
|
448
|
+
declare const VOLO_METADATA = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
|
|
449
|
+
declare const VSUI_TYPE = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT";
|
|
450
|
+
interface VoloStats {
|
|
451
|
+
apy: number;
|
|
452
|
+
exchangeRate: number;
|
|
453
|
+
tvl: number;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Fetch VOLO vSUI staking stats (APY, exchange rate, TVL).
|
|
457
|
+
*/
|
|
458
|
+
declare function getVoloStats(): Promise<VoloStats>;
|
|
459
|
+
/**
|
|
460
|
+
* Build a PTB to stake SUI for vSUI.
|
|
461
|
+
*/
|
|
462
|
+
declare function buildStakeVSuiTx(_client: SuiJsonRpcClient, address: string, amountMist: bigint): Promise<Transaction>;
|
|
463
|
+
/**
|
|
464
|
+
* Build a PTB to unstake vSUI back to SUI.
|
|
465
|
+
*/
|
|
466
|
+
declare function buildUnstakeVSuiTx(client: SuiJsonRpcClient, address: string, amountMist: bigint | 'all'): Promise<Transaction>;
|
|
467
|
+
|
|
391
468
|
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
392
469
|
interface SafeguardErrorDetails {
|
|
393
470
|
attempted?: number;
|
|
@@ -458,4 +535,4 @@ interface GasStatusResponse {
|
|
|
458
535
|
}
|
|
459
536
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
460
537
|
|
|
461
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CETUS_USDC_SUI_POOL, CLOCK_ID, ClaimRewardsResult, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, KeypairSigner, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PayOptions, PayResult, PendingReward, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, type SimulationResult, type StableAsset, StakeVSuiResult, type SupportedAsset, SwapQuoteResult, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TransactionSigner, type TxMetadata, USDC_DECIMALS, UnstakeVSuiResult, WithdrawResult, type ZkLoginProof, ZkLoginSigner, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
538
|
+
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CETUS_USDC_SUI_POOL, CLOCK_ID, ClaimRewardsResult, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, KeypairSigner, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PayOptions, PayResult, PendingReward, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, type SimulationResult, type StableAsset, StakeVSuiResult, type SupportedAsset, SwapQuoteResult, SwapResult, type SwapRouteResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TOKEN_MAP, TransactionRecord, type TransactionSigner, type TxMetadata, USDC_DECIMALS, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStats, WithdrawResult, type ZkLoginProof, ZkLoginSigner, addCollectFeeToTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, findSwapRoute, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, resolveTokenType, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -3167,6 +3167,45 @@ function parseMoveAbort(errorStr) {
|
|
|
3167
3167
|
return { reason: errorStr };
|
|
3168
3168
|
}
|
|
3169
3169
|
|
|
3170
|
-
|
|
3170
|
+
// src/swap-quote.ts
|
|
3171
|
+
async function getSwapQuote(params) {
|
|
3172
|
+
const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2, TOKEN_MAP: TOKEN_MAP2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
3173
|
+
const fromType = resolveTokenType2(params.from);
|
|
3174
|
+
const toType = resolveTokenType2(params.to);
|
|
3175
|
+
if (!fromType) throw new Error(`Unknown token: ${params.from}. Provide the full coin type.`);
|
|
3176
|
+
if (!toType) throw new Error(`Unknown token: ${params.to}. Provide the full coin type.`);
|
|
3177
|
+
const byAmountIn = params.byAmountIn ?? true;
|
|
3178
|
+
const fromEntry = Object.values(TOKEN_MAP2).includes(fromType) ? Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === fromType) : null;
|
|
3179
|
+
const fromDecimals = fromEntry ? fromEntry[1].decimals : fromType === "0x2::sui::SUI" ? 9 : 6;
|
|
3180
|
+
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
3181
|
+
const route = await findSwapRoute2({
|
|
3182
|
+
walletAddress: params.walletAddress,
|
|
3183
|
+
from: fromType,
|
|
3184
|
+
to: toType,
|
|
3185
|
+
amount: rawAmount,
|
|
3186
|
+
byAmountIn
|
|
3187
|
+
});
|
|
3188
|
+
if (!route) throw new Error(`No swap route found for ${params.from} -> ${params.to}.`);
|
|
3189
|
+
if (route.insufficientLiquidity) throw new Error(`Insufficient liquidity for ${params.from} -> ${params.to}.`);
|
|
3190
|
+
const toEntry = Object.entries(SUPPORTED_ASSETS).find(([, v]) => v.type === toType);
|
|
3191
|
+
const toDecimals = toEntry ? toEntry[1].decimals : toType === "0x2::sui::SUI" ? 9 : 6;
|
|
3192
|
+
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
3193
|
+
const toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
3194
|
+
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
3195
|
+
return {
|
|
3196
|
+
fromToken: params.from,
|
|
3197
|
+
toToken: params.to,
|
|
3198
|
+
fromAmount,
|
|
3199
|
+
toAmount,
|
|
3200
|
+
priceImpact: route.priceImpact,
|
|
3201
|
+
route: routeDesc
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
// src/index.ts
|
|
3206
|
+
init_cetus_swap();
|
|
3207
|
+
init_volo();
|
|
3208
|
+
|
|
3209
|
+
export { BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, GAS_RESERVE_MIN, KeypairSigner, MIST_PER_SUI, NaviAdapter, OUTBOUND_OPS, ProtocolRegistry, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, TOKEN_MAP, USDC_DECIMALS, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, ZkLoginSigner, addCollectFeeToTx, allDescriptors, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, findSwapRoute, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, rawToStable, rawToUsdc, resolveTokenType, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
3171
3210
|
//# sourceMappingURL=index.js.map
|
|
3172
3211
|
//# sourceMappingURL=index.js.map
|