@t2000/sdk 4.4.0 → 5.1.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 +3 -3
- package/dist/browser.cjs +333 -161
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +333 -150
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +802 -6702
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -541
- package/dist/index.d.ts +29 -541
- package/dist/index.js +805 -6677
- package/dist/index.js.map +1 -1
- package/dist/types-C01EGu76.d.cts +1222 -0
- package/dist/types-C01EGu76.d.ts +1222 -0
- package/package.json +3 -16
- package/dist/adapters/descriptors.cjs +0 -48
- package/dist/adapters/descriptors.cjs.map +0 -1
- package/dist/adapters/descriptors.d.cts +0 -3
- package/dist/adapters/descriptors.d.ts +0 -3
- package/dist/adapters/descriptors.js +0 -45
- package/dist/adapters/descriptors.js.map +0 -1
- package/dist/adapters/index.cjs +0 -4815
- package/dist/adapters/index.cjs.map +0 -1
- package/dist/adapters/index.d.cts +0 -91
- package/dist/adapters/index.d.ts +0 -91
- package/dist/adapters/index.js +0 -4810
- package/dist/adapters/index.js.map +0 -1
- package/dist/descriptors-DqIb4AnV.d.cts +0 -134
- package/dist/descriptors-DqIb4AnV.d.ts +0 -134
- package/dist/types-CFV4VcJJ.d.cts +0 -667
- package/dist/types-Ch0zVUpC.d.cts +0 -727
- package/dist/types-Ch0zVUpC.d.ts +0 -727
- package/dist/types-DqRLGfOC.d.ts +0 -667
package/dist/browser.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, b as MaxWithdrawResult, O as OVERLAY_FEE_RATE, c as OverlayFeeConfig, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, j as SwapRouteResult, T as TransactionLeg, k as TransactionRecord, W as WithdrawResult, l as buildSwapTx, m as findSwapRoute } from './types-Ch0zVUpC.cjs';
|
|
1
|
+
export { B as BalanceResponse, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, D as DEFAULT_NETWORK, e as DEFAULT_SAFEGUARD_CONFIG, f as DepositInfo, E as ETH_TYPE, g as ExtractedTransfer, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, O as OVERLAY_FEE_RATE, k as OverlayFeeConfig, P as PayOptions, l as PayResult, S as STABLE_ASSETS, m as SUI_DECIMALS, n as SUI_TYPE, o as SUPPORTED_ASSETS, p as SafeguardConfig, q as SafeguardError, r as SafeguardErrorDetails, s as SafeguardRule, t as SendResult, u as SimulationResult, v as StableAsset, w as SuiHolding, x as SuiRpcTxBlock, y as SupportedAsset, z as SwapRouteResult, T as T2000Error, A as T2000ErrorCode, F as T2000ErrorData, H as T2000_OVERLAY_FEE_WALLET, J as TOKEN_MAP, Q as TransactionLeg, R as TransactionRecord, U as TransactionSigner, V as TxDirection, W as TxMetadata, X as USDC_DECIMALS, Y as USDC_TYPE, Z as USDE_TYPE, _ as USDSUI_TYPE, $ as USDT_TYPE, a0 as WAL_TYPE, a1 as WBTC_TYPE, a2 as ZkLoginProof, a3 as ZkLoginSigner, a4 as buildSwapTx, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, ai as getDecimals, aj as getDecimalsForCoinType, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, an as parseSuiRpcTx, ao as payWithMpp, ap as rawToStable, aq as rawToUsdc, ar as refineLendingLabel, as as resolveSymbol, at as resolveTokenType, au as stableToRaw, av as suiToMist, aw as truncateAddress, ax as usdcToRaw, ay as validateAddress } from './types-C01EGu76.cjs';
|
|
3
2
|
import '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import '@mysten/sui/jsonRpc';
|
|
5
|
-
import '@mysten/sui/transactions';
|
|
6
3
|
import '@mysten/sui/grpc';
|
|
4
|
+
import '@mysten/sui/client';
|
|
5
|
+
import '@mysten/sui/transactions';
|
|
7
6
|
import '@cetusprotocol/aggregator-sdk';
|
|
7
|
+
import '@mysten/sui/jsonRpc';
|
|
8
8
|
|
|
9
9
|
/** Cross-platform (Node + browser) base64 helpers. */
|
|
10
10
|
declare function toBase64(bytes: Uint8Array): string;
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { A as AssetRates, B as BalanceResponse, a as BorrowResult, C as ClaimRewardsResult, D as DepositInfo, E as EarningsResult, F as FundStatusResult, G as GasReserve, H as HealthFactorResult, M as MaxBorrowResult, b as MaxWithdrawResult, O as OVERLAY_FEE_RATE, c as OverlayFeeConfig, P as PayOptions, d as PayResult, e as PendingReward, f as PositionEntry, g as PositionsResult, R as RatesResult, h as RepayResult, S as SaveResult, i as SendResult, j as SwapRouteResult, T as TransactionLeg, k as TransactionRecord, W as WithdrawResult, l as buildSwapTx, m as findSwapRoute } from './types-Ch0zVUpC.js';
|
|
1
|
+
export { B as BalanceResponse, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, D as DEFAULT_NETWORK, e as DEFAULT_SAFEGUARD_CONFIG, f as DepositInfo, E as ETH_TYPE, g as ExtractedTransfer, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, O as OVERLAY_FEE_RATE, k as OverlayFeeConfig, P as PayOptions, l as PayResult, S as STABLE_ASSETS, m as SUI_DECIMALS, n as SUI_TYPE, o as SUPPORTED_ASSETS, p as SafeguardConfig, q as SafeguardError, r as SafeguardErrorDetails, s as SafeguardRule, t as SendResult, u as SimulationResult, v as StableAsset, w as SuiHolding, x as SuiRpcTxBlock, y as SupportedAsset, z as SwapRouteResult, T as T2000Error, A as T2000ErrorCode, F as T2000ErrorData, H as T2000_OVERLAY_FEE_WALLET, J as TOKEN_MAP, Q as TransactionLeg, R as TransactionRecord, U as TransactionSigner, V as TxDirection, W as TxMetadata, X as USDC_DECIMALS, Y as USDC_TYPE, Z as USDE_TYPE, _ as USDSUI_TYPE, $ as USDT_TYPE, a0 as WAL_TYPE, a1 as WBTC_TYPE, a2 as ZkLoginProof, a3 as ZkLoginSigner, a4 as buildSwapTx, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, ai as getDecimals, aj as getDecimalsForCoinType, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, an as parseSuiRpcTx, ao as payWithMpp, ap as rawToStable, aq as rawToUsdc, ar as refineLendingLabel, as as resolveSymbol, at as resolveTokenType, au as stableToRaw, av as suiToMist, aw as truncateAddress, ax as usdcToRaw, ay as validateAddress } from './types-C01EGu76.js';
|
|
3
2
|
import '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import '@mysten/sui/jsonRpc';
|
|
5
|
-
import '@mysten/sui/transactions';
|
|
6
3
|
import '@mysten/sui/grpc';
|
|
4
|
+
import '@mysten/sui/client';
|
|
5
|
+
import '@mysten/sui/transactions';
|
|
7
6
|
import '@cetusprotocol/aggregator-sdk';
|
|
7
|
+
import '@mysten/sui/jsonRpc';
|
|
8
8
|
|
|
9
9
|
/** Cross-platform (Node + browser) base64 helpers. */
|
|
10
10
|
declare function toBase64(bytes: Uint8Array): string;
|
package/dist/browser.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import '@mysten/sui/
|
|
1
|
+
import { coinWithBalance } from '@mysten/sui/transactions';
|
|
2
|
+
import { fromBase64, normalizeSuiAddress, isValidSuiAddress } from '@mysten/sui/utils';
|
|
2
3
|
import '@mysten/sui/grpc';
|
|
3
|
-
import
|
|
4
|
+
import '@mysten/sui/graphql';
|
|
4
5
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
5
6
|
import 'bn.js';
|
|
6
7
|
|
|
@@ -104,20 +105,33 @@ var init_errors = __esm({
|
|
|
104
105
|
});
|
|
105
106
|
|
|
106
107
|
// src/token-registry.ts
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
var token_registry_exports = {};
|
|
109
|
+
__export(token_registry_exports, {
|
|
110
|
+
COIN_REGISTRY: () => COIN_REGISTRY,
|
|
111
|
+
ETH_TYPE: () => ETH_TYPE,
|
|
112
|
+
IKA_TYPE: () => IKA_TYPE,
|
|
113
|
+
LOFI_TYPE: () => LOFI_TYPE,
|
|
114
|
+
MANIFEST_TYPE: () => MANIFEST_TYPE,
|
|
115
|
+
NAVX_TYPE: () => NAVX_TYPE,
|
|
116
|
+
SUI_TYPE: () => SUI_TYPE,
|
|
117
|
+
TOKEN_MAP: () => TOKEN_MAP,
|
|
118
|
+
USDC_TYPE: () => USDC_TYPE,
|
|
119
|
+
USDE_TYPE: () => USDE_TYPE,
|
|
120
|
+
USDSUI_TYPE: () => USDSUI_TYPE,
|
|
121
|
+
USDT_TYPE: () => USDT_TYPE,
|
|
122
|
+
WAL_TYPE: () => WAL_TYPE,
|
|
123
|
+
WBTC_TYPE: () => WBTC_TYPE,
|
|
124
|
+
getCoinMeta: () => getCoinMeta,
|
|
125
|
+
getDecimalsForCoinType: () => getDecimalsForCoinType,
|
|
126
|
+
isInRegistry: () => isInRegistry,
|
|
127
|
+
resolveSymbol: () => resolveSymbol,
|
|
128
|
+
resolveTokenType: () => resolveTokenType
|
|
129
|
+
});
|
|
130
|
+
function getCoinMeta(coinType) {
|
|
131
|
+
return BY_TYPE.get(coinType);
|
|
118
132
|
}
|
|
119
|
-
function
|
|
120
|
-
return BY_TYPE.
|
|
133
|
+
function isInRegistry(coinType) {
|
|
134
|
+
return BY_TYPE.has(coinType);
|
|
121
135
|
}
|
|
122
136
|
function getDecimalsForCoinType(coinType) {
|
|
123
137
|
const direct = BY_TYPE.get(coinType);
|
|
@@ -151,25 +165,25 @@ var COIN_REGISTRY, BY_TYPE, TOKEN_MAP, SUI_TYPE, USDC_TYPE, USDT_TYPE, USDSUI_TY
|
|
|
151
165
|
var init_token_registry = __esm({
|
|
152
166
|
"src/token-registry.ts"() {
|
|
153
167
|
COIN_REGISTRY = {
|
|
154
|
-
// ──
|
|
155
|
-
USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC"
|
|
156
|
-
// ──
|
|
157
|
-
SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI"
|
|
158
|
-
wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC"
|
|
159
|
-
ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH"
|
|
160
|
-
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD"
|
|
161
|
-
DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP"
|
|
162
|
-
WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL"
|
|
163
|
-
NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS"
|
|
164
|
-
IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA"
|
|
165
|
-
CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS"
|
|
166
|
-
NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX"
|
|
167
|
-
vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI"
|
|
168
|
-
haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI"
|
|
169
|
-
afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI"
|
|
170
|
-
LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI"
|
|
171
|
-
MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST"
|
|
172
|
-
// ──
|
|
168
|
+
// ── Settlement stable ─────────────────────────────────────────────────
|
|
169
|
+
USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC" },
|
|
170
|
+
// ── Common swap assets (symbol ergonomics — any coin type still swaps) ─
|
|
171
|
+
SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI" },
|
|
172
|
+
wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC" },
|
|
173
|
+
ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH" },
|
|
174
|
+
GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD" },
|
|
175
|
+
DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP" },
|
|
176
|
+
WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL" },
|
|
177
|
+
NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS" },
|
|
178
|
+
IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA" },
|
|
179
|
+
CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS" },
|
|
180
|
+
NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX" },
|
|
181
|
+
vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI" },
|
|
182
|
+
haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI" },
|
|
183
|
+
afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI" },
|
|
184
|
+
LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI" },
|
|
185
|
+
MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST" },
|
|
186
|
+
// ── Other stables (display / classification) ──────────────────────────
|
|
173
187
|
USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
|
|
174
188
|
USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
|
|
175
189
|
USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
|
|
@@ -201,6 +215,136 @@ var init_token_registry = __esm({
|
|
|
201
215
|
}
|
|
202
216
|
});
|
|
203
217
|
|
|
218
|
+
// src/wallet/coinSelection.ts
|
|
219
|
+
var coinSelection_exports = {};
|
|
220
|
+
__export(coinSelection_exports, {
|
|
221
|
+
fetchAllCoins: () => fetchAllCoins,
|
|
222
|
+
selectAndSplitCoin: () => selectAndSplitCoin,
|
|
223
|
+
selectSuiCoin: () => selectSuiCoin
|
|
224
|
+
});
|
|
225
|
+
async function fetchAllCoins(client, owner, coinType) {
|
|
226
|
+
const [balance, ids] = await Promise.all([
|
|
227
|
+
client.core.getBalance({ owner, coinType }),
|
|
228
|
+
(async () => {
|
|
229
|
+
const out = [];
|
|
230
|
+
let cursor;
|
|
231
|
+
let hasNext = true;
|
|
232
|
+
while (hasNext) {
|
|
233
|
+
const page = await client.core.listCoins({ owner, coinType, cursor: cursor ?? void 0 });
|
|
234
|
+
for (const c of page.objects) out.push(c.objectId);
|
|
235
|
+
cursor = page.cursor;
|
|
236
|
+
hasNext = page.hasNextPage;
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
})()
|
|
240
|
+
]);
|
|
241
|
+
return { ids, totalBalance: BigInt(balance.balance.balance) };
|
|
242
|
+
}
|
|
243
|
+
async function selectAndSplitCoin(tx, client, owner, coinType, amount, options = {}) {
|
|
244
|
+
if (options.sponsoredContext) {
|
|
245
|
+
return selectCoinObjectsOnly(
|
|
246
|
+
tx,
|
|
247
|
+
client,
|
|
248
|
+
owner,
|
|
249
|
+
coinType,
|
|
250
|
+
amount,
|
|
251
|
+
options.allowSwapAll ?? true,
|
|
252
|
+
options.mergeCache
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
const balanceResp = await client.core.getBalance({ owner, coinType });
|
|
256
|
+
const totalBalance = BigInt(balanceResp.balance.balance);
|
|
257
|
+
if (totalBalance === 0n) {
|
|
258
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `No balance found for ${coinType}`);
|
|
259
|
+
}
|
|
260
|
+
const allowSwapAll = options.allowSwapAll ?? true;
|
|
261
|
+
if (amount !== "all" && amount > totalBalance && !allowSwapAll) {
|
|
262
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient balance for ${coinType}`, {
|
|
263
|
+
available: totalBalance.toString(),
|
|
264
|
+
required: amount.toString()
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const requested = amount === "all" ? totalBalance : amount;
|
|
268
|
+
const swapAll = amount === "all" || requested >= totalBalance;
|
|
269
|
+
const effectiveAmount = swapAll ? totalBalance : requested;
|
|
270
|
+
const coin = coinWithBalance({ type: coinType, balance: effectiveAmount })(tx);
|
|
271
|
+
return { coin, effectiveAmount, swapAll };
|
|
272
|
+
}
|
|
273
|
+
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll, mergeCache) {
|
|
274
|
+
const cached = mergeCache?.get(coinType);
|
|
275
|
+
if (cached) {
|
|
276
|
+
const requested2 = amount === "all" ? cached.remaining : amount;
|
|
277
|
+
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
278
|
+
throw new T2000Error(
|
|
279
|
+
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
280
|
+
`Not enough ${coinType} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
281
|
+
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
const swapAll2 = amount === "all" || requested2 >= cached.remaining;
|
|
285
|
+
const effectiveAmount2 = swapAll2 ? cached.remaining : requested2;
|
|
286
|
+
const coin2 = swapAll2 ? cached.primary : tx.splitCoins(cached.primary, [effectiveAmount2])[0];
|
|
287
|
+
cached.remaining -= effectiveAmount2;
|
|
288
|
+
return { coin: coin2, effectiveAmount: effectiveAmount2, swapAll: swapAll2 };
|
|
289
|
+
}
|
|
290
|
+
const objects = [];
|
|
291
|
+
let coinObjectTotal = 0n;
|
|
292
|
+
let cursor;
|
|
293
|
+
let hasNext = true;
|
|
294
|
+
while (hasNext) {
|
|
295
|
+
const page = await client.core.listCoins({ owner, coinType, cursor: cursor ?? void 0 });
|
|
296
|
+
for (const c of page.objects) {
|
|
297
|
+
objects.push({ objectId: c.objectId, balance: BigInt(c.balance) });
|
|
298
|
+
coinObjectTotal += BigInt(c.balance);
|
|
299
|
+
}
|
|
300
|
+
cursor = page.cursor;
|
|
301
|
+
hasNext = page.hasNextPage;
|
|
302
|
+
}
|
|
303
|
+
const unsponsorable = () => new T2000Error(
|
|
304
|
+
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
305
|
+
`These funds are in your address balance, which sponsored transactions can't access yet. (Funds received via gasless transfers land there.) This will work once the gas sponsor adds address-balance support.`,
|
|
306
|
+
{ coinObjectTotal: coinObjectTotal.toString(), coinType }
|
|
307
|
+
);
|
|
308
|
+
if (coinObjectTotal === 0n) {
|
|
309
|
+
throw unsponsorable();
|
|
310
|
+
}
|
|
311
|
+
const requested = amount === "all" ? coinObjectTotal : amount;
|
|
312
|
+
if (requested > coinObjectTotal) {
|
|
313
|
+
if (allowSwapAll && amount === "all") ; else {
|
|
314
|
+
throw unsponsorable();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const swapAll = amount === "all" || requested >= coinObjectTotal;
|
|
318
|
+
const effectiveAmount = swapAll ? coinObjectTotal : requested;
|
|
319
|
+
const [first, ...rest] = objects;
|
|
320
|
+
const primary = tx.object(first.objectId);
|
|
321
|
+
if (rest.length > 0) {
|
|
322
|
+
tx.mergeCoins(
|
|
323
|
+
primary,
|
|
324
|
+
rest.map((o) => tx.object(o.objectId))
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
const coin = swapAll ? primary : tx.splitCoins(primary, [effectiveAmount])[0];
|
|
328
|
+
mergeCache?.set(coinType, {
|
|
329
|
+
primary,
|
|
330
|
+
remaining: coinObjectTotal - effectiveAmount
|
|
331
|
+
});
|
|
332
|
+
return { coin, effectiveAmount, swapAll };
|
|
333
|
+
}
|
|
334
|
+
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
|
|
335
|
+
if (sponsoredContext) {
|
|
336
|
+
const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
|
|
337
|
+
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false, mergeCache);
|
|
338
|
+
}
|
|
339
|
+
const [coin] = tx.splitCoins(tx.gas, [amountMist]);
|
|
340
|
+
return { coin, effectiveAmount: amountMist, swapAll: false };
|
|
341
|
+
}
|
|
342
|
+
var init_coinSelection = __esm({
|
|
343
|
+
"src/wallet/coinSelection.ts"() {
|
|
344
|
+
init_errors();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
204
348
|
// src/wallet/keypairSigner.ts
|
|
205
349
|
var KeypairSigner = class {
|
|
206
350
|
constructor(keypair) {
|
|
@@ -260,12 +404,8 @@ var ZkLoginSigner = class {
|
|
|
260
404
|
}
|
|
261
405
|
};
|
|
262
406
|
|
|
263
|
-
// src/
|
|
264
|
-
|
|
265
|
-
const raw = challenge?.request?.amount;
|
|
266
|
-
const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
|
|
267
|
-
return Number.isFinite(n) ? n : void 0;
|
|
268
|
-
}
|
|
407
|
+
// src/wallet/pay.ts
|
|
408
|
+
init_errors();
|
|
269
409
|
|
|
270
410
|
// src/wallet/executeTx.ts
|
|
271
411
|
async function executeTx(client, signer, buildTx, options = {}) {
|
|
@@ -273,63 +413,142 @@ async function executeTx(client, signer, buildTx, options = {}) {
|
|
|
273
413
|
tx.setSender(signer.getAddress());
|
|
274
414
|
const txBytes = await tx.build({ client: options.buildClient ?? client });
|
|
275
415
|
const { signature } = await signer.signTransaction(txBytes);
|
|
276
|
-
const result = await client.
|
|
277
|
-
|
|
278
|
-
signature,
|
|
279
|
-
|
|
416
|
+
const result = await client.core.executeTransaction({
|
|
417
|
+
transaction: txBytes,
|
|
418
|
+
signatures: [signature],
|
|
419
|
+
include: { effects: true }
|
|
280
420
|
});
|
|
281
|
-
|
|
282
|
-
|
|
421
|
+
const txn = result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
|
|
422
|
+
await client.core.waitForTransaction({ digest: txn.digest });
|
|
423
|
+
const effects = txn.effects ?? void 0;
|
|
424
|
+
const gasUsed = effects?.gasUsed;
|
|
283
425
|
let gasCostSui = 0;
|
|
284
426
|
if (gasUsed) {
|
|
285
427
|
const total = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
286
428
|
gasCostSui = Number(total) / 1e9;
|
|
287
429
|
}
|
|
288
|
-
return { digest:
|
|
430
|
+
return { digest: txn.digest, gasCostSui, effects };
|
|
289
431
|
}
|
|
290
432
|
|
|
291
433
|
// src/wallet/pay.ts
|
|
292
434
|
async function payWithMpp(args) {
|
|
293
435
|
const { signer, client, options } = args;
|
|
294
|
-
const { Mppx } = await import('mppx/client');
|
|
295
|
-
const { sui, USDC } = await import('@suimpp/mpp/client');
|
|
296
|
-
const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
|
|
297
|
-
const signerAddress = signer.getAddress();
|
|
298
|
-
let paymentDigest;
|
|
299
|
-
let gasCostSui = 0;
|
|
300
|
-
let chargedAmount;
|
|
301
|
-
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
302
|
-
const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
303
|
-
const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
|
|
304
|
-
const mppx = Mppx.create({
|
|
305
|
-
polyfill: false,
|
|
306
|
-
onChallenge: async (challenge) => {
|
|
307
|
-
const parsed = parseChallengeAmount(challenge);
|
|
308
|
-
if (parsed !== void 0) chargedAmount = parsed;
|
|
309
|
-
return void 0;
|
|
310
|
-
},
|
|
311
|
-
methods: [sui({
|
|
312
|
-
client,
|
|
313
|
-
currency: USDC,
|
|
314
|
-
signer: {
|
|
315
|
-
toSuiAddress: () => signerAddress,
|
|
316
|
-
signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
|
|
317
|
-
},
|
|
318
|
-
execute: async (tx) => {
|
|
319
|
-
const result = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
|
|
320
|
-
paymentDigest = result.digest;
|
|
321
|
-
gasCostSui = result.gasCostSui;
|
|
322
|
-
return { digest: result.digest };
|
|
323
|
-
}
|
|
324
|
-
})]
|
|
325
|
-
});
|
|
326
436
|
const method = (options.method ?? "GET").toUpperCase();
|
|
327
437
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
328
|
-
const
|
|
438
|
+
const reqInit = {
|
|
329
439
|
method,
|
|
330
440
|
headers: options.headers,
|
|
331
441
|
body: canHaveBody ? options.body : void 0
|
|
442
|
+
};
|
|
443
|
+
const probe = await fetch(options.url, reqInit);
|
|
444
|
+
if (probe.status !== 402) {
|
|
445
|
+
return finalize(probe, { paid: false });
|
|
446
|
+
}
|
|
447
|
+
const requirements = await pickSuiExactRequirements(probe, client.network);
|
|
448
|
+
if (!requirements) {
|
|
449
|
+
throw new T2000Error(
|
|
450
|
+
"FACILITATOR_REJECTION",
|
|
451
|
+
`Endpoint returned 402 without an x402 'exact' / sui:${client.network} payment requirement. This SDK only speaks the x402 dialect.`
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
return payViaX402({ signer, client, options, reqInit, requirements });
|
|
455
|
+
}
|
|
456
|
+
async function pickSuiExactRequirements(response, network) {
|
|
457
|
+
try {
|
|
458
|
+
const body = await response.clone().json();
|
|
459
|
+
const want = `sui:${network === "testnet" ? "testnet" : "mainnet"}`;
|
|
460
|
+
return body.accepts?.find((a) => a.scheme === "exact" && a.network === want);
|
|
461
|
+
} catch {
|
|
462
|
+
return void 0;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async function payViaX402(args) {
|
|
466
|
+
const { signer, client, options, reqInit, requirements } = args;
|
|
467
|
+
const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import('@suimpp/mpp/x402');
|
|
468
|
+
const amountRaw = BigInt(requirements.maxAmountRequired);
|
|
469
|
+
const migrationGasSui = await ensureAddressBalanceCovers({
|
|
470
|
+
signer,
|
|
471
|
+
client,
|
|
472
|
+
asset: requirements.asset,
|
|
473
|
+
amountRaw
|
|
332
474
|
});
|
|
475
|
+
const signerAdapter = {
|
|
476
|
+
toSuiAddress: () => signer.getAddress(),
|
|
477
|
+
signTransaction: (bytes) => signer.signTransaction(bytes)
|
|
478
|
+
};
|
|
479
|
+
const { header } = await buildX402SignedPayment({ requirements, signer: signerAdapter });
|
|
480
|
+
const res = await fetch(options.url, {
|
|
481
|
+
...reqInit,
|
|
482
|
+
headers: { ...options.headers ?? {}, [X402_PAYMENT_HEADER]: header }
|
|
483
|
+
});
|
|
484
|
+
const settleHeader = res.headers.get(X402_PAYMENT_RESPONSE_HEADER);
|
|
485
|
+
const paid = !!settleHeader;
|
|
486
|
+
let digest;
|
|
487
|
+
if (settleHeader) {
|
|
488
|
+
try {
|
|
489
|
+
digest = JSON.parse(new TextDecoder().decode(fromBase64(settleHeader))).transaction;
|
|
490
|
+
} catch {
|
|
491
|
+
digest = void 0;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const result = await finalize(res, { paid });
|
|
495
|
+
if (!paid) return { ...result, dialect: "x402" };
|
|
496
|
+
return {
|
|
497
|
+
...result,
|
|
498
|
+
dialect: "x402",
|
|
499
|
+
cost: atomicToHuman(amountRaw, await assetDecimals(requirements.asset)),
|
|
500
|
+
gasCostSui: migrationGasSui,
|
|
501
|
+
receipt: digest ? { reference: digest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : result.receipt
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
async function ensureAddressBalanceCovers(args) {
|
|
505
|
+
const { signer, client, asset, amountRaw } = args;
|
|
506
|
+
const owner = signer.getAddress();
|
|
507
|
+
const balanceResp = await client.core.getBalance({ owner, coinType: asset });
|
|
508
|
+
const total = BigInt(balanceResp.balance.balance);
|
|
509
|
+
if (total < amountRaw) {
|
|
510
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${asset} to pay`, {
|
|
511
|
+
available: total.toString(),
|
|
512
|
+
required: amountRaw.toString()
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
let coinSum = 0n;
|
|
516
|
+
let cursor;
|
|
517
|
+
let hasNext = true;
|
|
518
|
+
while (hasNext) {
|
|
519
|
+
const page = await client.core.listCoins({ owner, coinType: asset, cursor: cursor ?? void 0 });
|
|
520
|
+
for (const c of page.objects) coinSum += BigInt(c.balance);
|
|
521
|
+
cursor = page.cursor;
|
|
522
|
+
hasNext = page.hasNextPage;
|
|
523
|
+
}
|
|
524
|
+
const addressBalance = total - coinSum;
|
|
525
|
+
if (addressBalance >= amountRaw) return 0;
|
|
526
|
+
const shortfall = amountRaw - addressBalance;
|
|
527
|
+
const { Transaction: Transaction2 } = await import('@mysten/sui/transactions');
|
|
528
|
+
const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
|
|
529
|
+
const grpcClient = await makeGrpcBuildClient(client);
|
|
530
|
+
const migration = await executeTx(
|
|
531
|
+
client,
|
|
532
|
+
signer,
|
|
533
|
+
async () => {
|
|
534
|
+
const tx = new Transaction2();
|
|
535
|
+
const { coin } = await selectAndSplitCoin2(tx, client, owner, asset, shortfall, {
|
|
536
|
+
sponsoredContext: true,
|
|
537
|
+
// coin-objects-only — never the address balance
|
|
538
|
+
allowSwapAll: false
|
|
539
|
+
});
|
|
540
|
+
tx.moveCall({
|
|
541
|
+
target: "0x2::coin::send_funds",
|
|
542
|
+
typeArguments: [asset],
|
|
543
|
+
arguments: [coin, tx.pure.address(owner)]
|
|
544
|
+
});
|
|
545
|
+
return tx;
|
|
546
|
+
},
|
|
547
|
+
{ buildClient: grpcClient }
|
|
548
|
+
);
|
|
549
|
+
return migration.gasCostSui;
|
|
550
|
+
}
|
|
551
|
+
async function finalize(response, opts) {
|
|
333
552
|
const contentType = response.headers.get("content-type") ?? "";
|
|
334
553
|
let body;
|
|
335
554
|
try {
|
|
@@ -337,15 +556,25 @@ async function payWithMpp(args) {
|
|
|
337
556
|
} catch {
|
|
338
557
|
body = null;
|
|
339
558
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
559
|
+
return { status: response.status, body, paid: opts.paid };
|
|
560
|
+
}
|
|
561
|
+
async function makeGrpcBuildClient(client) {
|
|
562
|
+
const { SuiGrpcClient: SuiGrpcClient2 } = await import('@mysten/sui/grpc');
|
|
563
|
+
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
564
|
+
const baseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
565
|
+
return new SuiGrpcClient2({ baseUrl, network });
|
|
566
|
+
}
|
|
567
|
+
function atomicToHuman(raw, decimals) {
|
|
568
|
+
return Number(raw) / 10 ** decimals;
|
|
569
|
+
}
|
|
570
|
+
async function assetDecimals(coinType) {
|
|
571
|
+
try {
|
|
572
|
+
const { getDecimalsForCoinType: getDecimalsForCoinType2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
|
|
573
|
+
const d = getDecimalsForCoinType2(coinType);
|
|
574
|
+
return typeof d === "number" ? d : 6;
|
|
575
|
+
} catch {
|
|
576
|
+
return 6;
|
|
577
|
+
}
|
|
349
578
|
}
|
|
350
579
|
|
|
351
580
|
// src/browser.ts
|
|
@@ -356,9 +585,6 @@ init_errors();
|
|
|
356
585
|
var MIST_PER_SUI = 1000000000n;
|
|
357
586
|
var SUI_DECIMALS = 9;
|
|
358
587
|
var USDC_DECIMALS = 6;
|
|
359
|
-
var BPS_DENOMINATOR = 10000n;
|
|
360
|
-
var SAVE_FEE_BPS = 10n;
|
|
361
|
-
var BORROW_FEE_BPS = 5n;
|
|
362
588
|
var CLOCK_ID = "0x6";
|
|
363
589
|
var SUPPORTED_ASSETS = {
|
|
364
590
|
USDC: {
|
|
@@ -417,7 +643,6 @@ var SUPPORTED_ASSETS = {
|
|
|
417
643
|
}
|
|
418
644
|
};
|
|
419
645
|
var STABLE_ASSETS = ["USDC", "USDsui"];
|
|
420
|
-
var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
|
|
421
646
|
({
|
|
422
647
|
USDC: SUPPORTED_ASSETS.USDC.type,
|
|
423
648
|
USDsui: SUPPORTED_ASSETS.USDsui.type
|
|
@@ -581,8 +806,13 @@ function extractAllUserLegs(changes, sender) {
|
|
|
581
806
|
}
|
|
582
807
|
return legs;
|
|
583
808
|
}
|
|
584
|
-
|
|
585
|
-
|
|
809
|
+
function buildRecord(args) {
|
|
810
|
+
const { digest, moveCallTargets, commandTypes, balanceChanges, timestampMs, gasCost, address } = args;
|
|
811
|
+
const legs = extractAllUserLegs(balanceChanges, address);
|
|
812
|
+
const { amount, asset, recipient, direction } = extractTransferDetails(balanceChanges, address);
|
|
813
|
+
const { action, label } = classifyTransaction(moveCallTargets, commandTypes, balanceChanges, address);
|
|
814
|
+
return { digest, action, label, legs, amount, asset, recipient, direction, timestamp: timestampMs, gasCost };
|
|
815
|
+
}
|
|
586
816
|
function parseSuiRpcTx(tx, address) {
|
|
587
817
|
return parseTxRecord(tx, address);
|
|
588
818
|
}
|
|
@@ -603,27 +833,15 @@ function parseTxRecord(tx, address) {
|
|
|
603
833
|
const gasUsed = tx.effects?.gasUsed;
|
|
604
834
|
const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
|
|
605
835
|
const { moveCallTargets, commandTypes } = extractCommands(tx.transaction);
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const { amount, asset, recipient, direction } = extractTransferDetails(balanceChanges, address);
|
|
609
|
-
const { action, label } = classifyTransaction(
|
|
836
|
+
return buildRecord({
|
|
837
|
+
digest: tx.digest,
|
|
610
838
|
moveCallTargets,
|
|
611
839
|
commandTypes,
|
|
612
|
-
balanceChanges,
|
|
840
|
+
balanceChanges: tx.balanceChanges ?? [],
|
|
841
|
+
timestampMs: Number(tx.timestampMs ?? 0),
|
|
842
|
+
gasCost,
|
|
613
843
|
address
|
|
614
|
-
);
|
|
615
|
-
return {
|
|
616
|
-
digest: tx.digest,
|
|
617
|
-
action,
|
|
618
|
-
label,
|
|
619
|
-
legs,
|
|
620
|
-
amount,
|
|
621
|
-
asset,
|
|
622
|
-
recipient,
|
|
623
|
-
direction,
|
|
624
|
-
timestamp: Number(tx.timestampMs ?? 0),
|
|
625
|
-
gasCost
|
|
626
|
-
};
|
|
844
|
+
});
|
|
627
845
|
}
|
|
628
846
|
function extractCommands(txBlock) {
|
|
629
847
|
const result = { moveCallTargets: [], commandTypes: [] };
|
|
@@ -698,44 +916,13 @@ function toBase64(bytes) {
|
|
|
698
916
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
699
917
|
return btoa(binary);
|
|
700
918
|
}
|
|
701
|
-
function
|
|
919
|
+
function fromBase642(b64) {
|
|
702
920
|
const binary = atob(b64);
|
|
703
921
|
const bytes = new Uint8Array(binary.length);
|
|
704
922
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
705
923
|
return bytes;
|
|
706
924
|
}
|
|
707
925
|
|
|
708
|
-
// src/protocols/protocolFee.ts
|
|
709
|
-
var FEE_RATES = {
|
|
710
|
-
save: SAVE_FEE_BPS,
|
|
711
|
-
borrow: BORROW_FEE_BPS,
|
|
712
|
-
// Swap uses Cetus's overlay-fee mechanism (taken from output by the aggregator
|
|
713
|
-
// and transferred to `overlayFee.receiver`). We list the rate here for display
|
|
714
|
-
// / quote calculations only — `addFeeTransfer` is NOT called for swaps.
|
|
715
|
-
swap: 10n
|
|
716
|
-
// 0.1%
|
|
717
|
-
};
|
|
718
|
-
function calculateFee(operation, amount) {
|
|
719
|
-
const bps = FEE_RATES[operation];
|
|
720
|
-
const feeAmount = amount * Number(bps) / Number(BPS_DENOMINATOR);
|
|
721
|
-
const rawAmount = stableToRaw(feeAmount, USDC_DECIMALS);
|
|
722
|
-
return {
|
|
723
|
-
amount: feeAmount,
|
|
724
|
-
asset: "USDC",
|
|
725
|
-
rate: Number(bps) / Number(BPS_DENOMINATOR),
|
|
726
|
-
rawAmount
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
function addFeeTransfer(tx, paymentCoin, feeBps, receiver, amount, decimals = USDC_DECIMALS) {
|
|
730
|
-
if (feeBps <= 0n) return;
|
|
731
|
-
if (amount <= 0) return;
|
|
732
|
-
const feeAmount = amount * Number(feeBps) / Number(BPS_DENOMINATOR);
|
|
733
|
-
const rawFee = stableToRaw(feeAmount, decimals);
|
|
734
|
-
if (rawFee <= 0n) return;
|
|
735
|
-
const [feeCoin] = tx.splitCoins(paymentCoin, [tx.pure.u64(rawFee)]);
|
|
736
|
-
tx.transferObjects([feeCoin], tx.pure.address(receiver));
|
|
737
|
-
}
|
|
738
|
-
|
|
739
926
|
// src/protocols/cetus-swap.ts
|
|
740
927
|
init_token_registry();
|
|
741
928
|
init_token_registry();
|
|
@@ -838,10 +1025,6 @@ function buildMessage(rule, details) {
|
|
|
838
1025
|
}
|
|
839
1026
|
|
|
840
1027
|
// src/safeguards/types.ts
|
|
841
|
-
var OUTBOUND_OPS = /* @__PURE__ */ new Set([
|
|
842
|
-
"send",
|
|
843
|
-
"pay"
|
|
844
|
-
]);
|
|
845
1028
|
var DEFAULT_SAFEGUARD_CONFIG = {
|
|
846
1029
|
locked: false,
|
|
847
1030
|
maxPerTx: 0,
|
|
@@ -853,6 +1036,6 @@ var DEFAULT_SAFEGUARD_CONFIG = {
|
|
|
853
1036
|
// src/browser.ts
|
|
854
1037
|
init_token_registry();
|
|
855
1038
|
|
|
856
|
-
export {
|
|
1039
|
+
export { CLOCK_ID, COIN_REGISTRY, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OVERLAY_FEE_RATE, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, buildSwapTx, classifyAction, classifyLabel, classifyTransaction, executeTx, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase642 as fromBase64, getDecimals, getDecimalsForCoinType, mapMoveAbortCode, mapWalletError, mistToSui, parseSuiRpcTx, payWithMpp, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
|
|
857
1040
|
//# sourceMappingURL=browser.js.map
|
|
858
1041
|
//# sourceMappingURL=browser.js.map
|