@sodax/sdk 0.0.1-rc.30 → 0.0.1-rc.31

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.mjs CHANGED
@@ -6700,8 +6700,8 @@ var spokeChainConfig = {
6700
6700
  [SUI_MAINNET_CHAIN_ID]: {
6701
6701
  addresses: {
6702
6702
  connection: "0xf3b1e696a66d02cb776dc15aae73c68bc8f03adcb6ba0ec7f6332d9d90a6a3d2::connectionv3::0x3ee76d13909ac58ae13baab4c9be5a5142818d9a387aed641825e5d4356969bf",
6703
- assetManagerId: "0x71535403c625ebf004135f52c8691cb0b740f801f19beb43791cb2cecc6f37ae::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6704
- assetManager: "0x897f911a4b7691870a1a2513af7e85fdee8de275615c77068fd8b90b8e78c678::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6703
+ assetManagerConfigId: "0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6704
+ originalAssetManager: "0xa17a409164d1676db71b411ab50813ba2c7dd547d2df538c699049566f1ff922::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6705
6705
  xTokenManager: "",
6706
6706
  rateLimit: "",
6707
6707
  testToken: ""
@@ -8374,684 +8374,850 @@ var StellarSpokeProvider = class {
8374
8374
  return toHex(Buffer.from(stellaraddress, "hex"));
8375
8375
  }
8376
8376
  };
8377
- var SuiSpokeProvider = class _SuiSpokeProvider {
8378
- walletProvider;
8379
- chainConfig;
8380
- publicClient;
8381
- constructor(config, wallet_provider) {
8382
- this.chainConfig = config;
8383
- this.walletProvider = wallet_provider;
8384
- this.publicClient = new SuiClient({ url: getFullnodeUrl("mainnet") });
8385
- }
8386
- async getBalance(token) {
8387
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
8388
- const tx = new Transaction();
8389
- const result = await this.walletProvider.viewContract(
8390
- tx,
8391
- assetmanager.packageId,
8392
- assetmanager.moduleId,
8393
- "get_token_balance",
8394
- [tx.object(assetmanager.stateId)],
8395
- [token]
8396
- );
8397
- if (!Array.isArray(result?.returnValues) || !Array.isArray(result.returnValues[0]) || result.returnValues[0][0] === void 0) {
8398
- throw new Error("Failed to get Balance");
8399
- }
8400
- const val = result.returnValues[0][0];
8401
- const str_u64 = bcs.U64.parse(Uint8Array.from(val));
8402
- return BigInt(str_u64);
8377
+ var Erc20Service = class {
8378
+ constructor() {
8403
8379
  }
8404
- async transfer(token, amount, to, data, raw) {
8405
- const isNative2 = token.toLowerCase() === this.chainConfig.nativeToken.toLowerCase();
8406
- const tx = new Transaction();
8407
- const walletAddress = await this.walletProvider.getWalletAddressBytes();
8408
- const coin = isNative2 ? await this.getNativeCoin(tx, amount) : await this.getCoin(tx, token, amount, walletAddress);
8409
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
8410
- const assetManager = this.splitAddress(this.chainConfig.addresses.assetManager);
8411
- tx.moveCall({
8412
- target: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8413
- typeArguments: [token],
8414
- arguments: [
8415
- tx.object(assetManager.stateId),
8416
- tx.object(connection.stateId),
8417
- // Connection state object
8418
- coin,
8419
- tx.pure(bcs.vector(bcs.u8()).serialize(to)),
8420
- tx.pure(bcs.vector(bcs.u8()).serialize(data))
8421
- ]
8422
- });
8423
- if (raw) {
8424
- tx.setSender(walletAddress);
8425
- const transactionRaw = await tx.build({
8426
- client: this.publicClient,
8427
- onlyTransactionKind: true
8380
+ /**
8381
+ * Check if spender has enough ERC20 allowance for given amount
8382
+ * @param token - ERC20 token address
8383
+ * @param amount - Amount to check allowance for
8384
+ * @param owner - User wallet address
8385
+ * @param spender - Spender address
8386
+ * @param spokeProvider - EVM Spoke provider
8387
+ * @return - True if spender is allowed to spend amount on behalf of owner
8388
+ */
8389
+ static async isAllowanceValid(token, amount, owner, spender, spokeProvider) {
8390
+ try {
8391
+ if (token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
8392
+ return {
8393
+ ok: true,
8394
+ value: true
8395
+ };
8396
+ }
8397
+ const allowedAmount = await spokeProvider.publicClient.readContract({
8398
+ address: token,
8399
+ abi: erc20Abi$1,
8400
+ functionName: "allowance",
8401
+ args: [owner, spender]
8428
8402
  });
8429
- const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
8430
8403
  return {
8431
- from: walletAddress,
8432
- to: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8433
- value: amount,
8434
- data: transactionRawBase64String
8404
+ ok: true,
8405
+ value: allowedAmount >= amount
8435
8406
  };
8436
- }
8437
- return this.walletProvider.signAndExecuteTxn(tx);
8438
- }
8439
- async getNativeCoin(tx, amount) {
8440
- const coin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])[0];
8441
- if (coin === void 0) {
8442
- return Promise.reject(Error("[SuiIntentService.getNativeCoin] coin undefined"));
8443
- }
8444
- return coin;
8445
- }
8446
- async getCoin(tx, coin, amount, address) {
8447
- const coins = await this.walletProvider.getCoins(address, coin);
8448
- const objects = [];
8449
- let totalAmount = BigInt(0);
8450
- for (const coin2 of coins.data) {
8451
- totalAmount += BigInt(coin2.balance);
8452
- objects.push(coin2.coinObjectId);
8453
- if (totalAmount >= amount) {
8454
- break;
8455
- }
8456
- }
8457
- const firstObject = objects[0];
8458
- if (!firstObject) {
8459
- throw new Error(`[SuiIntentService.getCoin] Coin=${coin} not found for address=${address} and amount=${amount}`);
8460
- }
8461
- if (objects.length > 1) {
8462
- tx.mergeCoins(firstObject, objects.slice(1));
8463
- }
8464
- if (totalAmount === amount) {
8465
- return tx.object(firstObject);
8466
- }
8467
- return tx.splitCoins(firstObject, [amount]);
8468
- }
8469
- splitAddress(address) {
8470
- const parts = address.split("::");
8471
- if (parts.length === 3) {
8472
- if (parts[0] && parts[1] && parts[2]) {
8473
- return { packageId: parts[0], moduleId: parts[1], stateId: parts[2] };
8474
- }
8475
- throw new Error("Invalid package address");
8476
- }
8477
- throw new Error("Invalid package address");
8478
- }
8479
- async sendMessage(dst_chain_id, dst_address, data, raw) {
8480
- const txb = new Transaction();
8481
- const connection = this.splitAddress(this.chainConfig.addresses.connection);
8482
- txb.moveCall({
8483
- target: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
8484
- arguments: [
8485
- txb.object(connection.stateId),
8486
- txb.pure.u256(dst_chain_id),
8487
- txb.pure(bcs.vector(bcs.u8()).serialize(dst_address)),
8488
- txb.pure(bcs.vector(bcs.u8()).serialize(data))
8489
- ]
8490
- });
8491
- const walletAddress = await this.walletProvider.getWalletAddress();
8492
- if (raw) {
8493
- txb.setSender(walletAddress);
8494
- const transactionRaw = await txb.build({
8495
- client: this.publicClient,
8496
- onlyTransactionKind: true
8497
- });
8498
- const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
8407
+ } catch (e) {
8499
8408
  return {
8500
- from: walletAddress,
8501
- to: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
8502
- value: 0n,
8503
- data: transactionRawBase64String
8409
+ ok: false,
8410
+ error: e
8504
8411
  };
8505
8412
  }
8506
- return this.walletProvider.signAndExecuteTxn(txb);
8507
8413
  }
8508
- async configureAssetManagerHub(hubNetworkId, hubAssetManager) {
8509
- const tx = new Transaction();
8510
- const assetmanager = this.splitAddress(this.chainConfig.addresses.assetManager);
8511
- tx.moveCall({
8512
- target: `${assetmanager.packageId}::${assetmanager.moduleId}::set_hub_details`,
8513
- arguments: [tx.object(assetmanager.stateId), tx.pure.u64(hubNetworkId), tx.pure.vector("u8", hubAssetManager)]
8514
- });
8515
- const result = await this.walletProvider.signAndExecuteTxn(tx);
8516
- return result;
8414
+ /**
8415
+ * Approve ERC20 amount spending
8416
+ * @param token - ERC20 token address
8417
+ * @param amount - Amount to approve
8418
+ * @param spender - Spender address
8419
+ * @param provider - EVM Provider
8420
+ */
8421
+ static async approve(token, amount, spender, spokeProvider, raw) {
8422
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
8423
+ const rawTx = {
8424
+ from: walletAddress,
8425
+ to: token,
8426
+ value: 0n,
8427
+ data: encodeFunctionData({
8428
+ abi: erc20Abi$1,
8429
+ functionName: "approve",
8430
+ args: [spender, amount]
8431
+ })
8432
+ };
8433
+ if (raw) {
8434
+ return rawTx;
8435
+ }
8436
+ return spokeProvider.walletProvider.sendTransaction(rawTx);
8517
8437
  }
8518
- async getWalletAddress() {
8519
- return this.walletProvider.getWalletAddress();
8438
+ /**
8439
+ * Encodes a transfer transaction for a token.
8440
+ * @param token - The address of the token.
8441
+ * @param to - The address to transfer the token to.
8442
+ * @param amount - The amount of the token to transfer.
8443
+ * @returns The encoded contract call.
8444
+ */
8445
+ static encodeTransfer(token, to, amount) {
8446
+ return {
8447
+ address: token,
8448
+ value: 0n,
8449
+ data: encodeFunctionData({
8450
+ abi: erc20Abi$1,
8451
+ functionName: "transfer",
8452
+ args: [to, amount]
8453
+ })
8454
+ };
8520
8455
  }
8521
- async getWalletAddressBytes() {
8522
- const address = await this.getWalletAddress();
8523
- return _SuiSpokeProvider.getAddressBCSBytes(address);
8456
+ /**
8457
+ * Encodes a transferFrom transaction for a token.
8458
+ * @param token - The address of the token.
8459
+ * @param from - The address to transfer the token from.
8460
+ * @param to - The address to transfer the token to.
8461
+ * @param amount - The amount of the token to transfer.
8462
+ * @returns The encoded contract call.
8463
+ */
8464
+ static encodeTransferFrom(token, from, to, amount) {
8465
+ return {
8466
+ address: token,
8467
+ value: 0n,
8468
+ data: encodeFunctionData({
8469
+ abi: erc20Abi$1,
8470
+ functionName: "transferFrom",
8471
+ args: [from, to, amount]
8472
+ })
8473
+ };
8524
8474
  }
8525
- static getAddressBCSBytes(suiaddress) {
8526
- return toHex(bcs.Address.serialize(suiaddress).toBytes());
8475
+ /**
8476
+ * Encodes an approval transaction for a token.
8477
+ * @param token - The address of the token.
8478
+ * @param to - The address to approve the token to.
8479
+ * @param amount - The amount of the token to approve.
8480
+ * @returns The encoded contract call.
8481
+ */
8482
+ static encodeApprove(token, to, amount) {
8483
+ return {
8484
+ address: token,
8485
+ value: 0n,
8486
+ data: encodeFunctionData({
8487
+ abi: erc20Abi$1,
8488
+ functionName: "approve",
8489
+ args: [to, amount]
8490
+ })
8491
+ };
8527
8492
  }
8528
8493
  };
8529
-
8530
- // src/entities/solana/SolanaSpokeProvider.ts
8531
- var SolanaSpokeProvider = class {
8532
- walletProvider;
8533
- chainConfig;
8534
- constructor(walletProvider, chainConfig) {
8535
- this.walletProvider = walletProvider;
8536
- this.chainConfig = chainConfig;
8494
+ var EvmVaultTokenService = class {
8495
+ constructor() {
8537
8496
  }
8538
- };
8539
- var solanaSpokeChainConfig = spokeChainConfig[SOLANA_MAINNET_CHAIN_ID];
8540
- function getSolanaAddressBytes(address) {
8541
- return `0x${Buffer.from(address.toBytes()).toString("hex")}`;
8542
- }
8543
- function isNative(address) {
8544
- if (address.equals(new PublicKey(solanaSpokeChainConfig.nativeToken))) {
8545
- return true;
8497
+ /**
8498
+ * Fetches token information for a specific token in the vault.
8499
+ * @param vault - The address of the vault.
8500
+ * @param token - The address of the token.
8501
+ * @param publicClient - PublicClient<HttpTransport>
8502
+ * @returns Token information as a TokenInfo object.
8503
+ */
8504
+ static async getTokenInfo(vault, token, publicClient) {
8505
+ const [decimals, depositFee, withdrawalFee, maxDeposit, isSupported] = await publicClient.readContract({
8506
+ address: vault,
8507
+ abi: vaultTokenAbi,
8508
+ functionName: "tokenInfo",
8509
+ args: [token]
8510
+ });
8511
+ return { decimals, depositFee, withdrawalFee, maxDeposit, isSupported };
8546
8512
  }
8547
- return false;
8548
- }
8549
- function convertTransactionInstructionToRaw(instruction) {
8550
- return {
8551
- keys: instruction.keys.map((key) => ({
8552
- pubkey: key.pubkey.toBase58(),
8553
- isSigner: key.isSigner,
8554
- isWritable: key.isWritable
8555
- })),
8556
- programId: instruction.programId.toBase58(),
8557
- data: instruction.data
8558
- };
8559
- }
8560
-
8561
- // src/entities/icon/HanaWalletConnector.ts
8562
- function requestAddress() {
8563
- return new Promise((resolve) => {
8564
- const eventHandler = (event) => {
8565
- const customEvent = event;
8566
- const response = customEvent.detail;
8567
- if (isResponseAddressType(response)) {
8568
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8569
- resolve({
8570
- ok: true,
8571
- value: response.payload
8572
- });
8573
- }
8574
- };
8575
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8576
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8577
- window.dispatchEvent(
8578
- new CustomEvent("ICONEX_RELAY_REQUEST", {
8579
- detail: {
8580
- type: "REQUEST_ADDRESS"
8581
- }
8582
- })
8583
- );
8584
- });
8585
- }
8586
- function requestSigning(from, hash) {
8587
- return new Promise((resolve, reject) => {
8588
- const signRequest = new CustomEvent("ICONEX_RELAY_REQUEST", {
8589
- detail: {
8590
- type: "REQUEST_SIGNING",
8591
- payload: {
8592
- from,
8593
- hash
8594
- }
8595
- }
8513
+ /**
8514
+ * Retrieves the reserves of the vault.
8515
+ * @param vault - The address of the vault.
8516
+ * @param publicClient - PublicClient<HttpTransport>
8517
+ * @returns An object containing tokens and their balances.
8518
+ */
8519
+ static async getVaultReserves(vault, publicClient) {
8520
+ const [tokens, balances] = await publicClient.readContract({
8521
+ address: vault,
8522
+ abi: vaultTokenAbi,
8523
+ functionName: "getVaultReserves",
8524
+ args: []
8596
8525
  });
8597
- const eventHandler = (event) => {
8598
- const customEvent = event;
8599
- const response = customEvent.detail;
8600
- if (isResponseSigningType(response)) {
8601
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8602
- resolve({
8603
- ok: true,
8604
- value: response.payload
8605
- });
8606
- } else if (response.type === "CANCEL_SIGNING") {
8607
- reject(new Error("CANCEL_SIGNING"));
8608
- }
8609
- };
8610
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8611
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8612
- window.dispatchEvent(signRequest);
8613
- });
8614
- }
8615
- function requestJsonRpc(rawTransaction, id = 99999) {
8616
- return new Promise((resolve, reject) => {
8617
- const eventHandler = (event) => {
8618
- const customEvent = event;
8619
- const { type, payload } = customEvent.detail;
8620
- if (type === "RESPONSE_JSON-RPC") {
8621
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8622
- if (isJsonRpcPayloadResponse(payload)) {
8623
- resolve({
8624
- ok: true,
8625
- value: payload
8626
- });
8627
- } else {
8628
- reject(new Error("Invalid payload response type (expected JsonRpcPayloadResponse)"));
8629
- }
8630
- } else if (type === "CANCEL_JSON-RPC") {
8631
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8632
- reject(new Error("CANCEL_JSON-RPC"));
8633
- }
8526
+ return {
8527
+ tokens,
8528
+ balances
8634
8529
  };
8635
- window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8636
- window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
8637
- window.dispatchEvent(
8638
- new CustomEvent("ICONEX_RELAY_REQUEST", {
8639
- detail: {
8640
- type: "REQUEST_JSON-RPC",
8641
- payload: {
8642
- jsonrpc: "2.0",
8643
- method: "icx_sendTransaction",
8644
- params: rawTransaction,
8645
- id
8646
- }
8647
- }
8530
+ }
8531
+ /**
8532
+ * Retrieves all token information for the vault.
8533
+ * @param vault - The address of the vault.
8534
+ * @param publicClient - PublicClient<HttpTransport>
8535
+ * @returns A promise that resolves to an object containing tokens, their infos, and reserves.
8536
+ */
8537
+ async getAllTokenInfo(vault, publicClient) {
8538
+ const [tokens, infos, reserves] = await publicClient.readContract({
8539
+ address: vault,
8540
+ abi: vaultTokenAbi,
8541
+ functionName: "getAllTokenInfo",
8542
+ args: []
8543
+ });
8544
+ return {
8545
+ tokens,
8546
+ infos,
8547
+ reserves
8548
+ };
8549
+ }
8550
+ /**
8551
+ * Deposits a specified amount of a token into the vault.
8552
+ * @param vault - The address of the vault.
8553
+ * @param token - The address of the token to deposit.
8554
+ * @param amount - The amount of the token to deposit.
8555
+ * @param walletProvider - IEvmWalletProvider
8556
+ * @returns Transaction hash
8557
+ */
8558
+ static async deposit(vault, token, amount, walletProvider) {
8559
+ const from = await walletProvider.getWalletAddress();
8560
+ return walletProvider.sendTransaction({
8561
+ from,
8562
+ to: vault,
8563
+ value: 0n,
8564
+ data: encodeFunctionData({
8565
+ abi: vaultTokenAbi,
8566
+ functionName: "deposit",
8567
+ args: [token, amount]
8648
8568
  })
8649
- );
8650
- });
8651
- }
8652
- var Erc20Service = class {
8653
- constructor() {
8569
+ });
8654
8570
  }
8655
8571
  /**
8656
- * Check if spender has enough ERC20 allowance for given amount
8657
- * @param token - ERC20 token address
8658
- * @param amount - Amount to check allowance for
8659
- * @param owner - User wallet address
8660
- * @param spender - Spender address
8661
- * @param spokeProvider - EVM Spoke provider
8662
- * @return - True if spender is allowed to spend amount on behalf of owner
8572
+ * Withdraws a specified amount of a token from the vault.
8573
+ * @param vault - The address of the vault.
8574
+ * @param token - The address of the token to withdraw.
8575
+ * @param amount - The amount of the token to withdraw.
8576
+ * @param provider - EvmWalletProvider
8577
+ * @returns Transaction hash
8663
8578
  */
8664
- static async isAllowanceValid(token, amount, owner, spender, spokeProvider) {
8665
- try {
8666
- if (token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
8667
- return {
8668
- ok: true,
8669
- value: true
8670
- };
8671
- }
8672
- const allowedAmount = await spokeProvider.publicClient.readContract({
8673
- address: token,
8674
- abi: erc20Abi$1,
8675
- functionName: "allowance",
8676
- args: [owner, spender]
8677
- });
8678
- return {
8679
- ok: true,
8680
- value: allowedAmount >= amount
8681
- };
8682
- } catch (e) {
8683
- return {
8684
- ok: false,
8685
- error: e
8686
- };
8687
- }
8579
+ static async withdraw(vault, token, amount, provider) {
8580
+ const from = await provider.getWalletAddress();
8581
+ return provider.sendTransaction({
8582
+ from,
8583
+ to: vault,
8584
+ value: 0n,
8585
+ data: encodeFunctionData({
8586
+ abi: vaultTokenAbi,
8587
+ functionName: "withdraw",
8588
+ args: [token, amount]
8589
+ })
8590
+ });
8688
8591
  }
8689
8592
  /**
8690
- * Approve ERC20 amount spending
8691
- * @param token - ERC20 token address
8692
- * @param amount - Amount to approve
8693
- * @param spender - Spender address
8694
- * @param provider - EVM Provider
8593
+ * Encodes the deposit transaction data for the vault.
8594
+ * @param vault - The address of the vault.
8595
+ * @param token - The address of the token to deposit.
8596
+ * @param amount - The amount of the token to deposit.
8597
+ * @returns The encoded contract call data.
8695
8598
  */
8696
- static async approve(token, amount, spender, spokeProvider, raw) {
8697
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
8698
- const rawTx = {
8699
- from: walletAddress,
8700
- to: token,
8599
+ static encodeDeposit(vault, token, amount) {
8600
+ return {
8601
+ address: vault,
8701
8602
  value: 0n,
8702
8603
  data: encodeFunctionData({
8703
- abi: erc20Abi$1,
8704
- functionName: "approve",
8705
- args: [spender, amount]
8604
+ abi: vaultTokenAbi,
8605
+ functionName: "deposit",
8606
+ args: [token, amount]
8706
8607
  })
8707
8608
  };
8708
- if (raw) {
8709
- return rawTx;
8710
- }
8711
- return spokeProvider.walletProvider.sendTransaction(rawTx);
8712
8609
  }
8713
8610
  /**
8714
- * Encodes a transfer transaction for a token.
8715
- * @param token - The address of the token.
8716
- * @param to - The address to transfer the token to.
8717
- * @param amount - The amount of the token to transfer.
8718
- * @returns The encoded contract call.
8611
+ * Encodes the withdraw transaction data for the vault.
8612
+ * @param vault - The address of the vault.
8613
+ * @param token - The address of the token to withdraw.
8614
+ * @param amount - The amount of the token to withdraw.
8615
+ * @returns The encoded contract call data.
8719
8616
  */
8720
- static encodeTransfer(token, to, amount) {
8617
+ static encodeWithdraw(vault, token, amount) {
8721
8618
  return {
8722
- address: token,
8619
+ address: vault,
8723
8620
  value: 0n,
8724
8621
  data: encodeFunctionData({
8725
- abi: erc20Abi$1,
8726
- functionName: "transfer",
8727
- args: [to, amount]
8622
+ abi: vaultTokenAbi,
8623
+ functionName: "withdraw",
8624
+ args: [token, amount]
8728
8625
  })
8729
8626
  };
8730
8627
  }
8731
8628
  /**
8732
- * Encodes a transferFrom transaction for a token.
8629
+ * Translates token amounts from their native decimals to 18 decimals
8630
+ * @param decimals - The number of decimals of the token
8631
+ * @param amount - The amount to translate
8632
+ * @returns The translated amount
8633
+ */
8634
+ static translateIncomingDecimals(decimals, amount) {
8635
+ if (decimals <= 18) {
8636
+ return amount * BigInt(10 ** (18 - decimals));
8637
+ }
8638
+ return amount / BigInt(10 ** (decimals - 18));
8639
+ }
8640
+ /**
8641
+ * Translates token amounts from 18 decimals back to their native decimals
8642
+ * @param decimals - The number of decimals of the token
8643
+ * @param amount - The amount to translate
8644
+ * @returns The translated amount
8645
+ */
8646
+ static translateOutgoingDecimals(decimals, amount) {
8647
+ if (decimals <= 18) {
8648
+ return amount / BigInt(10 ** (18 - decimals));
8649
+ }
8650
+ return amount * BigInt(10 ** (decimals - 18));
8651
+ }
8652
+ };
8653
+
8654
+ // src/services/hub/EvmAssetManagerService.ts
8655
+ var EvmAssetManagerService = class _EvmAssetManagerService {
8656
+ constructor() {
8657
+ }
8658
+ /**
8659
+ * Get asset information for a given asset address
8660
+ * @param asset - The address of the asset contract
8661
+ * @param assetManager - The address of the asset manager contract
8662
+ * @param client - The Viem public client
8663
+ * @returns Object containing chainID and spoke address for the asset
8664
+ */
8665
+ static async getAssetInfo(asset, assetManager, client) {
8666
+ const [chainId, spokeAddress] = await client.readContract({
8667
+ address: assetManager,
8668
+ abi: assetManagerAbi,
8669
+ functionName: "assetInfo",
8670
+ args: [asset]
8671
+ });
8672
+ return {
8673
+ chainId,
8674
+ spokeAddress
8675
+ };
8676
+ }
8677
+ /**
8678
+ * Encodes a transfer transaction for an asset.
8733
8679
  * @param token - The address of the token.
8734
- * @param from - The address to transfer the token from.
8735
8680
  * @param to - The address to transfer the token to.
8736
8681
  * @param amount - The amount of the token to transfer.
8682
+ * @param assetManager
8737
8683
  * @returns The encoded contract call.
8738
8684
  */
8739
- static encodeTransferFrom(token, from, to, amount) {
8685
+ static encodeTransfer(token, to, amount, assetManager) {
8740
8686
  return {
8741
- address: token,
8687
+ address: assetManager,
8742
8688
  value: 0n,
8743
8689
  data: encodeFunctionData({
8744
- abi: erc20Abi$1,
8745
- functionName: "transferFrom",
8746
- args: [from, to, amount]
8690
+ abi: assetManagerAbi,
8691
+ functionName: "transfer",
8692
+ args: [token, to, amount, "0x"]
8747
8693
  })
8748
8694
  };
8749
8695
  }
8750
8696
  /**
8751
- * Encodes an approval transaction for a token.
8752
- * @param token - The address of the token.
8753
- * @param to - The address to approve the token to.
8754
- * @param amount - The amount of the token to approve.
8755
- * @returns The encoded contract call.
8697
+ * Constructs the data for depositing tokens to the spoke chain.
8698
+ * @param {EvmDepositToDataParams} params - The address of the token to deposit.
8699
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
8700
+ * @returns {Hex} Encoded contract calls for the deposit transaction.
8701
+ * @throws Will throw an error if the asset or vault address is not found.
8702
+ */
8703
+ static depositToData(params, spokeChainId) {
8704
+ const calls = [];
8705
+ const assetConfig = getHubAssetInfo(spokeChainId, params.token);
8706
+ if (!assetConfig) {
8707
+ throw new Error("[depositToData] Hub asset not found");
8708
+ }
8709
+ const assetAddress = assetConfig.asset;
8710
+ const vaultAddress = assetConfig.vault;
8711
+ calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, params.amount));
8712
+ calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, params.amount));
8713
+ const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, params.amount);
8714
+ calls.push(Erc20Service.encodeTransfer(vaultAddress, params.to, translatedAmount));
8715
+ return encodeContractCalls(calls);
8716
+ }
8717
+ /**
8718
+ * Withdraw tokens from the spoke chain.
8719
+ * @param {EvmWithdrawAssetDataParams} params - Parameters for the withdrawal.
8720
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
8721
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
8722
+ * @returns {Hex} Encoded contract calls for the withdrawal transaction.
8723
+ * @throws Will throw an error if the asset address is not found.
8724
+ */
8725
+ static withdrawAssetData(params, hubProvider, spokeChainId) {
8726
+ const calls = [];
8727
+ const assetConfig = getHubAssetInfo(spokeChainId, params.token);
8728
+ if (!assetConfig) {
8729
+ throw new Error("[withdrawAssetData] Hub asset not found");
8730
+ }
8731
+ const assetAddress = assetConfig.asset;
8732
+ calls.push(
8733
+ _EvmAssetManagerService.encodeTransfer(
8734
+ assetAddress,
8735
+ params.to,
8736
+ params.amount,
8737
+ hubProvider.chainConfig.addresses.assetManager
8738
+ )
8739
+ );
8740
+ return encodeContractCalls(calls);
8741
+ }
8742
+ /**
8743
+ * Get asset address for a given chain ID and spoke address
8744
+ * @param chainId Chain ID where the asset exists
8745
+ * @param spokeAddress Address of the asset on the spoke chain
8746
+ * @param assetManager Address of the asset manager contract
8747
+ * @param client The Viem public client
8748
+ * @returns The asset's address on the hub chain
8756
8749
  */
8757
- static encodeApprove(token, to, amount) {
8758
- return {
8759
- address: token,
8760
- value: 0n,
8761
- data: encodeFunctionData({
8762
- abi: erc20Abi$1,
8763
- functionName: "approve",
8764
- args: [to, amount]
8765
- })
8766
- };
8750
+ async getAssetAddress(chainId, spokeAddress, assetManager, client) {
8751
+ return client.readContract({
8752
+ address: assetManager,
8753
+ abi: assetManagerAbi,
8754
+ functionName: "assets",
8755
+ args: [chainId, spokeAddress]
8756
+ });
8767
8757
  }
8768
8758
  };
8769
- var EvmVaultTokenService = class {
8759
+
8760
+ // src/services/hub/EvmWalletAbstraction.ts
8761
+ var EvmWalletAbstraction = class {
8770
8762
  constructor() {
8771
8763
  }
8772
8764
  /**
8773
- * Fetches token information for a specific token in the vault.
8774
- * @param vault - The address of the vault.
8775
- * @param token - The address of the token.
8776
- * @param publicClient - PublicClient<HttpTransport>
8777
- * @returns Token information as a TokenInfo object.
8765
+ * Get the hub wallet address for a given spoke chain and address.
8766
+ * @param chainId - The spoke chain ID.
8767
+ * @param address - The address on the spoke chain.
8768
+ * @param hubProvider - The hub provider.
8769
+ * @returns The hub wallet address.
8778
8770
  */
8779
- static async getTokenInfo(vault, token, publicClient) {
8780
- const [decimals, depositFee, withdrawalFee, maxDeposit, isSupported] = await publicClient.readContract({
8781
- address: vault,
8782
- abi: vaultTokenAbi,
8783
- functionName: "tokenInfo",
8784
- args: [token]
8771
+ static async getUserHubWalletAddress(chainId, address, hubProvider) {
8772
+ return hubProvider.publicClient.readContract({
8773
+ address: hubProvider.chainConfig.addresses.hubWallet,
8774
+ abi: walletFactoryAbi,
8775
+ functionName: "getDeployedAddress",
8776
+ args: [BigInt(getIntentRelayChainId(chainId)), address]
8785
8777
  });
8786
- return { decimals, depositFee, withdrawalFee, maxDeposit, isSupported };
8787
8778
  }
8788
- /**
8789
- * Retrieves the reserves of the vault.
8790
- * @param vault - The address of the vault.
8791
- * @param publicClient - PublicClient<HttpTransport>
8792
- * @returns An object containing tokens and their balances.
8793
- */
8794
- static async getVaultReserves(vault, publicClient) {
8795
- const [tokens, balances] = await publicClient.readContract({
8796
- address: vault,
8797
- abi: vaultTokenAbi,
8798
- functionName: "getVaultReserves",
8799
- args: []
8800
- });
8801
- return {
8802
- tokens,
8803
- balances
8804
- };
8779
+ };
8780
+ var SuiSpokeService = class _SuiSpokeService {
8781
+ constructor() {
8805
8782
  }
8806
8783
  /**
8807
- * Retrieves all token information for the vault.
8808
- * @param vault - The address of the vault.
8809
- * @param publicClient - PublicClient<HttpTransport>
8810
- * @returns A promise that resolves to an object containing tokens, their infos, and reserves.
8784
+ * Estimate the gas for a transaction.
8785
+ * @param {SuiRawTransaction} rawTx - The raw transaction to estimate the gas for.
8786
+ * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
8787
+ * @returns {Promise<bigint>} The estimated computation cost.
8811
8788
  */
8812
- async getAllTokenInfo(vault, publicClient) {
8813
- const [tokens, infos, reserves] = await publicClient.readContract({
8814
- address: vault,
8815
- abi: vaultTokenAbi,
8816
- functionName: "getAllTokenInfo",
8817
- args: []
8789
+ static async estimateGas(rawTx, spokeProvider) {
8790
+ const txb = Transaction.fromKind(rawTx.data);
8791
+ const result = await spokeProvider.publicClient.devInspectTransactionBlock({
8792
+ sender: rawTx.from,
8793
+ transactionBlock: txb
8818
8794
  });
8819
- return {
8820
- tokens,
8821
- infos,
8822
- reserves
8823
- };
8795
+ return result.effects.gasUsed;
8824
8796
  }
8825
8797
  /**
8826
- * Deposits a specified amount of a token into the vault.
8827
- * @param vault - The address of the vault.
8828
- * @param token - The address of the token to deposit.
8829
- * @param amount - The amount of the token to deposit.
8830
- * @param walletProvider - IEvmWalletProvider
8831
- * @returns Transaction hash
8798
+ * Deposit tokens to the spoke chain.
8799
+ * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
8800
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
8801
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
8802
+ * @param {boolean} raw - The return type raw or just transaction hash
8803
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
8832
8804
  */
8833
- static async deposit(vault, token, amount, walletProvider) {
8834
- const from = await walletProvider.getWalletAddress();
8835
- return walletProvider.sendTransaction({
8836
- from,
8837
- to: vault,
8838
- value: 0n,
8839
- data: encodeFunctionData({
8840
- abi: vaultTokenAbi,
8841
- functionName: "deposit",
8842
- args: [token, amount]
8843
- })
8844
- });
8805
+ static async deposit(params, spokeProvider, hubProvider, raw) {
8806
+ const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
8807
+ spokeProvider.chainConfig.chain.id,
8808
+ params.from,
8809
+ hubProvider
8810
+ );
8811
+ return _SuiSpokeService.transfer(
8812
+ {
8813
+ token: params.token,
8814
+ recipient: userWallet,
8815
+ amount: params.amount,
8816
+ data: params.data
8817
+ },
8818
+ spokeProvider,
8819
+ raw
8820
+ );
8845
8821
  }
8846
8822
  /**
8847
- * Withdraws a specified amount of a token from the vault.
8848
- * @param vault - The address of the vault.
8849
- * @param token - The address of the token to withdraw.
8850
- * @param amount - The amount of the token to withdraw.
8851
- * @param provider - EvmWalletProvider
8852
- * @returns Transaction hash
8823
+ * Get the balance of the token in the spoke chain.
8824
+ * @param {Address} token - The address of the token to get the balance of.
8825
+ * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
8826
+ * @returns {Promise<bigint>} The balance of the token.
8853
8827
  */
8854
- static async withdraw(vault, token, amount, provider) {
8855
- const from = await provider.getWalletAddress();
8856
- return provider.sendTransaction({
8857
- from,
8858
- to: vault,
8859
- value: 0n,
8860
- data: encodeFunctionData({
8861
- abi: vaultTokenAbi,
8862
- functionName: "withdraw",
8863
- args: [token, amount]
8864
- })
8865
- });
8828
+ static async getDeposit(token, spokeProvider) {
8829
+ return spokeProvider.getBalance(token);
8866
8830
  }
8867
8831
  /**
8868
- * Encodes the deposit transaction data for the vault.
8869
- * @param vault - The address of the vault.
8870
- * @param token - The address of the token to deposit.
8871
- * @param amount - The amount of the token to deposit.
8872
- * @returns The encoded contract call data.
8832
+ * Generate simulation parameters for deposit from SuiSpokeDepositParams.
8833
+ * @param {SuiSpokeDepositParams} params - The deposit parameters.
8834
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
8835
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
8836
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
8873
8837
  */
8874
- static encodeDeposit(vault, token, amount) {
8838
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
8839
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
8840
+ spokeProvider.chainConfig.chain.id,
8841
+ params.from,
8842
+ hubProvider
8843
+ );
8844
+ const encoder = new TextEncoder();
8875
8845
  return {
8876
- address: vault,
8877
- value: 0n,
8878
- data: encodeFunctionData({
8879
- abi: vaultTokenAbi,
8880
- functionName: "deposit",
8881
- args: [token, amount]
8882
- })
8846
+ spokeChainID: spokeProvider.chainConfig.chain.id,
8847
+ token: toHex(encoder.encode(params.token)),
8848
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
8849
+ to,
8850
+ amount: params.amount,
8851
+ data: params.data,
8852
+ srcAddress: toHex(encoder.encode(spokeProvider.chainConfig.addresses.originalAssetManager))
8883
8853
  };
8884
8854
  }
8885
8855
  /**
8886
- * Encodes the withdraw transaction data for the vault.
8887
- * @param vault - The address of the vault.
8888
- * @param token - The address of the token to withdraw.
8889
- * @param amount - The amount of the token to withdraw.
8890
- * @returns The encoded contract call data.
8856
+ * Calls a contract on the spoke chain using the user's wallet.
8857
+ * @param {HubAddress} from - The address of the user on the spoke chain.
8858
+ * @param {Hex} payload - The payload to send to the contract.
8859
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
8860
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
8861
+ * @param {boolean} raw - The return type raw or just transaction hash
8862
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
8891
8863
  */
8892
- static encodeWithdraw(vault, token, amount) {
8893
- return {
8894
- address: vault,
8895
- value: 0n,
8896
- data: encodeFunctionData({
8897
- abi: vaultTokenAbi,
8898
- functionName: "withdraw",
8899
- args: [token, amount]
8900
- })
8901
- };
8864
+ static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
8865
+ const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
8866
+ return _SuiSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
8902
8867
  }
8903
8868
  /**
8904
- * Translates token amounts from their native decimals to 18 decimals
8905
- * @param decimals - The number of decimals of the token
8906
- * @param amount - The amount to translate
8907
- * @returns The translated amount
8869
+ * Fetch the asset manager config from the spoke chain.
8870
+ * @param {SuiSpokeProvider} suiSpokeProvider - The spoke provider.
8871
+ * @returns {Promise<string>} The asset manager config.
8872
+ */
8873
+ static async fetchAssetManagerAddress(suiSpokeProvider) {
8874
+ const latestPackageId = await _SuiSpokeService.fetchLatestAssetManagerPackageId(suiSpokeProvider);
8875
+ return `${latestPackageId}::asset_manager::${suiSpokeProvider.chainConfig.addresses.assetManagerConfigId}`;
8876
+ }
8877
+ /**
8878
+ * Fetch the latest asset manager package id from the spoke chain.
8879
+ * @param {SuiSpokeProvider} suiSpokeProvider - The spoke provider.
8880
+ * @returns {Promise<string>} The latest asset manager package id.
8881
+ */
8882
+ static async fetchLatestAssetManagerPackageId(suiSpokeProvider) {
8883
+ const configData = await suiSpokeProvider.publicClient.getObject({
8884
+ id: suiSpokeProvider.chainConfig.addresses.assetManagerConfigId,
8885
+ options: {
8886
+ showContent: true
8887
+ }
8888
+ });
8889
+ if (configData.error) {
8890
+ throw new Error(`Failed to fetch asset manager id. Details: ${JSON.stringify(configData.error)}`);
8891
+ }
8892
+ if (!configData.data) {
8893
+ throw new Error("Asset manager id not found (no data)");
8894
+ }
8895
+ if (configData.data.content?.dataType !== "moveObject") {
8896
+ throw new Error("Asset manager id not found (not a move object)");
8897
+ }
8898
+ if (!("latest_package_id" in configData.data.content.fields)) {
8899
+ throw new Error("Asset manager id not found (no latest package id)");
8900
+ }
8901
+ const latestPackageId = configData.data.content.fields["latest_package_id"];
8902
+ if (typeof latestPackageId !== "string") {
8903
+ throw new Error("Asset manager id invalid (latest package id is not a string)");
8904
+ }
8905
+ if (!latestPackageId) {
8906
+ throw new Error("Asset manager id not found (no latest package id)");
8907
+ }
8908
+ return latestPackageId.toString();
8909
+ }
8910
+ /**
8911
+ * Transfers tokens to the hub chain.
8912
+ * @param {SuiTransferToHubParams} params - The parameters for the transfer, including:
8913
+ * - {string} token: The address of the token to transfer (use address(0) for native token).
8914
+ * - {Uint8Array} recipient: The recipient address on the hub chain.
8915
+ * - {string} amount: The amount to transfer.
8916
+ * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
8917
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
8918
+ * @param {boolean} raw - The return type raw or just transaction hash
8919
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
8908
8920
  */
8909
- static translateIncomingDecimals(decimals, amount) {
8910
- if (decimals <= 18) {
8911
- return amount * BigInt(10 ** (18 - decimals));
8912
- }
8913
- return amount / BigInt(10 ** (decimals - 18));
8921
+ static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
8922
+ return spokeProvider.transfer(token, amount, fromHex(recipient, "bytes"), fromHex(data, "bytes"), raw);
8914
8923
  }
8915
8924
  /**
8916
- * Translates token amounts from 18 decimals back to their native decimals
8917
- * @param decimals - The number of decimals of the token
8918
- * @param amount - The amount to translate
8919
- * @returns The translated amount
8925
+ * Sends a message to the hub chain.
8926
+ * @param {bigint} dstChainId - The chain ID of the hub chain.
8927
+ * @param {HubAddress} dstAddress - The address on the hub chain.
8928
+ * @param {Hex} payload - The payload to send.
8929
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
8930
+ * @param {boolean} raw - The return type raw or just transaction hash
8931
+ * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
8920
8932
  */
8921
- static translateOutgoingDecimals(decimals, amount) {
8922
- if (decimals <= 18) {
8923
- return amount / BigInt(10 ** (18 - decimals));
8924
- }
8925
- return amount * BigInt(10 ** (decimals - 18));
8933
+ static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
8934
+ return spokeProvider.sendMessage(dstChainId, fromHex(dstAddress, "bytes"), fromHex(payload, "bytes"), raw);
8926
8935
  }
8927
8936
  };
8928
8937
 
8929
- // src/services/hub/EvmAssetManagerService.ts
8930
- var EvmAssetManagerService = class _EvmAssetManagerService {
8931
- constructor() {
8938
+ // src/entities/sui/SuiSpokeProvider.ts
8939
+ var SuiSpokeProvider = class _SuiSpokeProvider {
8940
+ walletProvider;
8941
+ chainConfig;
8942
+ publicClient;
8943
+ assetManagerAddress;
8944
+ constructor(config, wallet_provider) {
8945
+ this.chainConfig = config;
8946
+ this.walletProvider = wallet_provider;
8947
+ this.publicClient = new SuiClient({ url: getFullnodeUrl("mainnet") });
8932
8948
  }
8933
- /**
8934
- * Get asset information for a given asset address
8935
- * @param asset - The address of the asset contract
8936
- * @param assetManager - The address of the asset manager contract
8937
- * @param client - The Viem public client
8938
- * @returns Object containing chainID and spoke address for the asset
8939
- */
8940
- static async getAssetInfo(asset, assetManager, client) {
8941
- const [chainId, spokeAddress] = await client.readContract({
8942
- address: assetManager,
8943
- abi: assetManagerAbi,
8944
- functionName: "assetInfo",
8945
- args: [asset]
8949
+ async getBalance(token) {
8950
+ const assetmanager = this.splitAddress(await this.getAssetManagerAddress());
8951
+ const tx = new Transaction();
8952
+ const result = await this.walletProvider.viewContract(
8953
+ tx,
8954
+ assetmanager.packageId,
8955
+ assetmanager.moduleId,
8956
+ "get_token_balance",
8957
+ [tx.object(assetmanager.stateId)],
8958
+ [token]
8959
+ );
8960
+ if (!Array.isArray(result?.returnValues) || !Array.isArray(result.returnValues[0]) || result.returnValues[0][0] === void 0) {
8961
+ throw new Error("Failed to get Balance");
8962
+ }
8963
+ const val = result.returnValues[0][0];
8964
+ const str_u64 = bcs.U64.parse(Uint8Array.from(val));
8965
+ return BigInt(str_u64);
8966
+ }
8967
+ async transfer(token, amount, to, data, raw) {
8968
+ const isNative2 = token.toLowerCase() === this.chainConfig.nativeToken.toLowerCase();
8969
+ const tx = new Transaction();
8970
+ const walletAddress = await this.walletProvider.getWalletAddressBytes();
8971
+ const coin = isNative2 ? await this.getNativeCoin(tx, amount) : await this.getCoin(tx, token, amount, walletAddress);
8972
+ const connection = this.splitAddress(this.chainConfig.addresses.connection);
8973
+ const assetManager = this.splitAddress(await this.getAssetManagerAddress());
8974
+ tx.moveCall({
8975
+ target: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8976
+ typeArguments: [token],
8977
+ arguments: [
8978
+ tx.object(assetManager.stateId),
8979
+ tx.object(connection.stateId),
8980
+ // Connection state object
8981
+ coin,
8982
+ tx.pure(bcs.vector(bcs.u8()).serialize(to)),
8983
+ tx.pure(bcs.vector(bcs.u8()).serialize(data))
8984
+ ]
8946
8985
  });
8947
- return {
8948
- chainId,
8949
- spokeAddress
8950
- };
8986
+ if (raw) {
8987
+ tx.setSender(walletAddress);
8988
+ const transactionRaw = await tx.build({
8989
+ client: this.publicClient,
8990
+ onlyTransactionKind: true
8991
+ });
8992
+ const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
8993
+ return {
8994
+ from: walletAddress,
8995
+ to: `${assetManager.packageId}::${assetManager.moduleId}::transfer`,
8996
+ value: amount,
8997
+ data: transactionRawBase64String
8998
+ };
8999
+ }
9000
+ return this.walletProvider.signAndExecuteTxn(tx);
8951
9001
  }
8952
- /**
8953
- * Encodes a transfer transaction for an asset.
8954
- * @param token - The address of the token.
8955
- * @param to - The address to transfer the token to.
8956
- * @param amount - The amount of the token to transfer.
8957
- * @param assetManager
8958
- * @returns The encoded contract call.
8959
- */
8960
- static encodeTransfer(token, to, amount, assetManager) {
8961
- return {
8962
- address: assetManager,
8963
- value: 0n,
8964
- data: encodeFunctionData({
8965
- abi: assetManagerAbi,
8966
- functionName: "transfer",
8967
- args: [token, to, amount, "0x"]
8968
- })
8969
- };
9002
+ async getNativeCoin(tx, amount) {
9003
+ const coin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])[0];
9004
+ if (coin === void 0) {
9005
+ return Promise.reject(Error("[SuiIntentService.getNativeCoin] coin undefined"));
9006
+ }
9007
+ return coin;
8970
9008
  }
8971
- /**
8972
- * Constructs the data for depositing tokens to the spoke chain.
8973
- * @param {EvmDepositToDataParams} params - The address of the token to deposit.
8974
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
8975
- * @returns {Hex} Encoded contract calls for the deposit transaction.
8976
- * @throws Will throw an error if the asset or vault address is not found.
8977
- */
8978
- static depositToData(params, spokeChainId) {
8979
- const calls = [];
8980
- const assetConfig = getHubAssetInfo(spokeChainId, params.token);
8981
- if (!assetConfig) {
8982
- throw new Error("[depositToData] Hub asset not found");
9009
+ async getCoin(tx, coin, amount, address) {
9010
+ const coins = await this.walletProvider.getCoins(address, coin);
9011
+ const objects = [];
9012
+ let totalAmount = BigInt(0);
9013
+ for (const coin2 of coins.data) {
9014
+ totalAmount += BigInt(coin2.balance);
9015
+ objects.push(coin2.coinObjectId);
9016
+ if (totalAmount >= amount) {
9017
+ break;
9018
+ }
8983
9019
  }
8984
- const assetAddress = assetConfig.asset;
8985
- const vaultAddress = assetConfig.vault;
8986
- calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, params.amount));
8987
- calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, params.amount));
8988
- const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, params.amount);
8989
- calls.push(Erc20Service.encodeTransfer(vaultAddress, params.to, translatedAmount));
8990
- return encodeContractCalls(calls);
9020
+ const firstObject = objects[0];
9021
+ if (!firstObject) {
9022
+ throw new Error(`[SuiIntentService.getCoin] Coin=${coin} not found for address=${address} and amount=${amount}`);
9023
+ }
9024
+ if (objects.length > 1) {
9025
+ tx.mergeCoins(firstObject, objects.slice(1));
9026
+ }
9027
+ if (totalAmount === amount) {
9028
+ return tx.object(firstObject);
9029
+ }
9030
+ return tx.splitCoins(firstObject, [amount]);
8991
9031
  }
8992
- /**
8993
- * Withdraw tokens from the spoke chain.
8994
- * @param {EvmWithdrawAssetDataParams} params - Parameters for the withdrawal.
8995
- * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
8996
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
8997
- * @returns {Hex} Encoded contract calls for the withdrawal transaction.
8998
- * @throws Will throw an error if the asset address is not found.
8999
- */
9000
- static withdrawAssetData(params, hubProvider, spokeChainId) {
9001
- const calls = [];
9002
- const assetConfig = getHubAssetInfo(spokeChainId, params.token);
9003
- if (!assetConfig) {
9004
- throw new Error("[withdrawAssetData] Hub asset not found");
9032
+ splitAddress(address) {
9033
+ const parts = address.split("::");
9034
+ if (parts.length === 3) {
9035
+ if (parts[0] && parts[1] && parts[2]) {
9036
+ return { packageId: parts[0], moduleId: parts[1], stateId: parts[2] };
9037
+ }
9038
+ throw new Error("Invalid package address");
9005
9039
  }
9006
- const assetAddress = assetConfig.asset;
9007
- calls.push(
9008
- _EvmAssetManagerService.encodeTransfer(
9009
- assetAddress,
9010
- params.to,
9011
- params.amount,
9012
- hubProvider.chainConfig.addresses.assetManager
9013
- )
9014
- );
9015
- return encodeContractCalls(calls);
9040
+ throw new Error("Invalid package address");
9016
9041
  }
9017
- /**
9018
- * Get asset address for a given chain ID and spoke address
9019
- * @param chainId Chain ID where the asset exists
9020
- * @param spokeAddress Address of the asset on the spoke chain
9021
- * @param assetManager Address of the asset manager contract
9022
- * @param client The Viem public client
9023
- * @returns The asset's address on the hub chain
9024
- */
9025
- async getAssetAddress(chainId, spokeAddress, assetManager, client) {
9026
- return client.readContract({
9027
- address: assetManager,
9028
- abi: assetManagerAbi,
9029
- functionName: "assets",
9030
- args: [chainId, spokeAddress]
9042
+ async sendMessage(dst_chain_id, dst_address, data, raw) {
9043
+ const txb = new Transaction();
9044
+ const connection = this.splitAddress(this.chainConfig.addresses.connection);
9045
+ txb.moveCall({
9046
+ target: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
9047
+ arguments: [
9048
+ txb.object(connection.stateId),
9049
+ txb.pure.u256(dst_chain_id),
9050
+ txb.pure(bcs.vector(bcs.u8()).serialize(dst_address)),
9051
+ txb.pure(bcs.vector(bcs.u8()).serialize(data))
9052
+ ]
9053
+ });
9054
+ const walletAddress = await this.walletProvider.getWalletAddress();
9055
+ if (raw) {
9056
+ txb.setSender(walletAddress);
9057
+ const transactionRaw = await txb.build({
9058
+ client: this.publicClient,
9059
+ onlyTransactionKind: true
9060
+ });
9061
+ const transactionRawBase64String = Buffer.from(transactionRaw).toString("base64");
9062
+ return {
9063
+ from: walletAddress,
9064
+ to: `${connection.packageId}::${connection.moduleId}::send_message_ua`,
9065
+ value: 0n,
9066
+ data: transactionRawBase64String
9067
+ };
9068
+ }
9069
+ return this.walletProvider.signAndExecuteTxn(txb);
9070
+ }
9071
+ async configureAssetManagerHub(hubNetworkId, hubAssetManager) {
9072
+ const tx = new Transaction();
9073
+ const assetmanager = this.splitAddress(await this.getAssetManagerAddress());
9074
+ tx.moveCall({
9075
+ target: `${assetmanager.packageId}::${assetmanager.moduleId}::set_hub_details`,
9076
+ arguments: [tx.object(assetmanager.stateId), tx.pure.u64(hubNetworkId), tx.pure.vector("u8", hubAssetManager)]
9031
9077
  });
9078
+ const result = await this.walletProvider.signAndExecuteTxn(tx);
9079
+ return result;
9080
+ }
9081
+ async getWalletAddress() {
9082
+ return this.walletProvider.getWalletAddress();
9083
+ }
9084
+ async getWalletAddressBytes() {
9085
+ const address = await this.getWalletAddress();
9086
+ return _SuiSpokeProvider.getAddressBCSBytes(address);
9087
+ }
9088
+ static getAddressBCSBytes(suiaddress) {
9089
+ return toHex(bcs.Address.serialize(suiaddress).toBytes());
9090
+ }
9091
+ async getAssetManagerAddress() {
9092
+ if (!this.assetManagerAddress) {
9093
+ this.assetManagerAddress = await SuiSpokeService.fetchAssetManagerAddress(this);
9094
+ }
9095
+ return this.assetManagerAddress.toString();
9032
9096
  }
9033
9097
  };
9034
9098
 
9035
- // src/services/hub/EvmWalletAbstraction.ts
9036
- var EvmWalletAbstraction = class {
9037
- constructor() {
9038
- }
9039
- /**
9040
- * Get the hub wallet address for a given spoke chain and address.
9041
- * @param chainId - The spoke chain ID.
9042
- * @param address - The address on the spoke chain.
9043
- * @param hubProvider - The hub provider.
9044
- * @returns The hub wallet address.
9045
- */
9046
- static async getUserHubWalletAddress(chainId, address, hubProvider) {
9047
- return hubProvider.publicClient.readContract({
9048
- address: hubProvider.chainConfig.addresses.hubWallet,
9049
- abi: walletFactoryAbi,
9050
- functionName: "getDeployedAddress",
9051
- args: [BigInt(getIntentRelayChainId(chainId)), address]
9052
- });
9099
+ // src/entities/solana/SolanaSpokeProvider.ts
9100
+ var SolanaSpokeProvider = class {
9101
+ walletProvider;
9102
+ chainConfig;
9103
+ constructor(walletProvider, chainConfig) {
9104
+ this.walletProvider = walletProvider;
9105
+ this.chainConfig = chainConfig;
9053
9106
  }
9054
9107
  };
9108
+ var solanaSpokeChainConfig = spokeChainConfig[SOLANA_MAINNET_CHAIN_ID];
9109
+ function getSolanaAddressBytes(address) {
9110
+ return `0x${Buffer.from(address.toBytes()).toString("hex")}`;
9111
+ }
9112
+ function isNative(address) {
9113
+ if (address.equals(new PublicKey(solanaSpokeChainConfig.nativeToken))) {
9114
+ return true;
9115
+ }
9116
+ return false;
9117
+ }
9118
+ function convertTransactionInstructionToRaw(instruction) {
9119
+ return {
9120
+ keys: instruction.keys.map((key) => ({
9121
+ pubkey: key.pubkey.toBase58(),
9122
+ isSigner: key.isSigner,
9123
+ isWritable: key.isWritable
9124
+ })),
9125
+ programId: instruction.programId.toBase58(),
9126
+ data: instruction.data
9127
+ };
9128
+ }
9129
+
9130
+ // src/entities/icon/HanaWalletConnector.ts
9131
+ function requestAddress() {
9132
+ return new Promise((resolve) => {
9133
+ const eventHandler = (event) => {
9134
+ const customEvent = event;
9135
+ const response = customEvent.detail;
9136
+ if (isResponseAddressType(response)) {
9137
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9138
+ resolve({
9139
+ ok: true,
9140
+ value: response.payload
9141
+ });
9142
+ }
9143
+ };
9144
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9145
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9146
+ window.dispatchEvent(
9147
+ new CustomEvent("ICONEX_RELAY_REQUEST", {
9148
+ detail: {
9149
+ type: "REQUEST_ADDRESS"
9150
+ }
9151
+ })
9152
+ );
9153
+ });
9154
+ }
9155
+ function requestSigning(from, hash) {
9156
+ return new Promise((resolve, reject) => {
9157
+ const signRequest = new CustomEvent("ICONEX_RELAY_REQUEST", {
9158
+ detail: {
9159
+ type: "REQUEST_SIGNING",
9160
+ payload: {
9161
+ from,
9162
+ hash
9163
+ }
9164
+ }
9165
+ });
9166
+ const eventHandler = (event) => {
9167
+ const customEvent = event;
9168
+ const response = customEvent.detail;
9169
+ if (isResponseSigningType(response)) {
9170
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9171
+ resolve({
9172
+ ok: true,
9173
+ value: response.payload
9174
+ });
9175
+ } else if (response.type === "CANCEL_SIGNING") {
9176
+ reject(new Error("CANCEL_SIGNING"));
9177
+ }
9178
+ };
9179
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9180
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9181
+ window.dispatchEvent(signRequest);
9182
+ });
9183
+ }
9184
+ function requestJsonRpc(rawTransaction, id = 99999) {
9185
+ return new Promise((resolve, reject) => {
9186
+ const eventHandler = (event) => {
9187
+ const customEvent = event;
9188
+ const { type, payload } = customEvent.detail;
9189
+ if (type === "RESPONSE_JSON-RPC") {
9190
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9191
+ if (isJsonRpcPayloadResponse(payload)) {
9192
+ resolve({
9193
+ ok: true,
9194
+ value: payload
9195
+ });
9196
+ } else {
9197
+ reject(new Error("Invalid payload response type (expected JsonRpcPayloadResponse)"));
9198
+ }
9199
+ } else if (type === "CANCEL_JSON-RPC") {
9200
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9201
+ reject(new Error("CANCEL_JSON-RPC"));
9202
+ }
9203
+ };
9204
+ window.removeEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9205
+ window.addEventListener("ICONEX_RELAY_RESPONSE", eventHandler, false);
9206
+ window.dispatchEvent(
9207
+ new CustomEvent("ICONEX_RELAY_REQUEST", {
9208
+ detail: {
9209
+ type: "REQUEST_JSON-RPC",
9210
+ payload: {
9211
+ jsonrpc: "2.0",
9212
+ method: "icx_sendTransaction",
9213
+ params: rawTransaction,
9214
+ id
9215
+ }
9216
+ }
9217
+ })
9218
+ );
9219
+ });
9220
+ }
9055
9221
  var EvmSpokeService = class _EvmSpokeService {
9056
9222
  constructor() {
9057
9223
  }
@@ -9913,121 +10079,6 @@ var StellarSpokeService = class _StellarSpokeService {
9913
10079
  );
9914
10080
  }
9915
10081
  };
9916
- var SuiSpokeService = class _SuiSpokeService {
9917
- constructor() {
9918
- }
9919
- /**
9920
- * Estimate the gas for a transaction.
9921
- * @param {SuiRawTransaction} rawTx - The raw transaction to estimate the gas for.
9922
- * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9923
- * @returns {Promise<bigint>} The estimated computation cost.
9924
- */
9925
- static async estimateGas(rawTx, spokeProvider) {
9926
- const txb = Transaction.fromKind(rawTx.data);
9927
- const result = await spokeProvider.publicClient.devInspectTransactionBlock({
9928
- sender: rawTx.from,
9929
- transactionBlock: txb
9930
- });
9931
- return result.effects.gasUsed;
9932
- }
9933
- /**
9934
- * Deposit tokens to the spoke chain.
9935
- * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9936
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9937
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9938
- * @param {boolean} raw - The return type raw or just transaction hash
9939
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9940
- */
9941
- static async deposit(params, spokeProvider, hubProvider, raw) {
9942
- const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9943
- spokeProvider.chainConfig.chain.id,
9944
- params.from,
9945
- hubProvider
9946
- );
9947
- return _SuiSpokeService.transfer(
9948
- {
9949
- token: params.token,
9950
- recipient: userWallet,
9951
- amount: params.amount,
9952
- data: params.data
9953
- },
9954
- spokeProvider,
9955
- raw
9956
- );
9957
- }
9958
- /**
9959
- * Get the balance of the token in the spoke chain.
9960
- * @param {Address} token - The address of the token to get the balance of.
9961
- * @param {SuiSpokeProvider} spokeProvider - The spoke provider.
9962
- * @returns {Promise<bigint>} The balance of the token.
9963
- */
9964
- static async getDeposit(token, spokeProvider) {
9965
- return spokeProvider.getBalance(token);
9966
- }
9967
- /**
9968
- * Generate simulation parameters for deposit from SuiSpokeDepositParams.
9969
- * @param {SuiSpokeDepositParams} params - The deposit parameters.
9970
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9971
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9972
- * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9973
- */
9974
- static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9975
- const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9976
- spokeProvider.chainConfig.chain.id,
9977
- params.from,
9978
- hubProvider
9979
- );
9980
- const encoder = new TextEncoder();
9981
- return {
9982
- spokeChainID: spokeProvider.chainConfig.chain.id,
9983
- token: toHex(encoder.encode(params.token)),
9984
- from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9985
- to,
9986
- amount: params.amount,
9987
- data: params.data,
9988
- srcAddress: toHex(encoder.encode(spokeProvider.chainConfig.addresses.assetManagerId))
9989
- };
9990
- }
9991
- /**
9992
- * Calls a contract on the spoke chain using the user's wallet.
9993
- * @param {HubAddress} from - The address of the user on the spoke chain.
9994
- * @param {Hex} payload - The payload to send to the contract.
9995
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9996
- * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9997
- * @param {boolean} raw - The return type raw or just transaction hash
9998
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
9999
- */
10000
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
10001
- const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
10002
- return _SuiSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
10003
- }
10004
- /**
10005
- * Transfers tokens to the hub chain.
10006
- * @param {SuiTransferToHubParams} params - The parameters for the transfer, including:
10007
- * - {string} token: The address of the token to transfer (use address(0) for native token).
10008
- * - {Uint8Array} recipient: The recipient address on the hub chain.
10009
- * - {string} amount: The amount to transfer.
10010
- * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
10011
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10012
- * @param {boolean} raw - The return type raw or just transaction hash
10013
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
10014
- */
10015
- static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
10016
- return spokeProvider.transfer(token, amount, fromHex(recipient, "bytes"), fromHex(data, "bytes"), raw);
10017
- }
10018
- /**
10019
- * Sends a message to the hub chain.
10020
- * @param {bigint} dstChainId - The chain ID of the hub chain.
10021
- * @param {HubAddress} dstAddress - The address on the hub chain.
10022
- * @param {Hex} payload - The payload to send.
10023
- * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10024
- * @param {boolean} raw - The return type raw or just transaction hash
10025
- * @returns {PromiseSuiTxReturnType<R>} A promise that resolves to the transaction hash or raw transaction base64 string.
10026
- */
10027
- static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
10028
- return spokeProvider.sendMessage(dstChainId, fromHex(dstAddress, "bytes"), fromHex(payload, "bytes"), raw);
10029
- }
10030
- };
10031
10082
  var SonicSpokeService = class _SonicSpokeService {
10032
10083
  constructor() {
10033
10084
  }
@@ -16628,6 +16679,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
16628
16679
  return SolverIntentErrorCode2;
16629
16680
  })(SolverIntentErrorCode || {});
16630
16681
 
16631
- export { BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, ChainIdToIntentRelayChainId, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SupportedMigrationTokens, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isBalnMigrateParams, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isNewbnUSDChainId, isNewbnUSDToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isUnifiedBnUSDMigrateParams, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, originalAssetTohubAssetMap, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
16682
+ export { BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, ChainIdToIntentRelayChainId, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SuiSpokeService, SupportedMigrationTokens, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isBalnMigrateParams, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isNewbnUSDChainId, isNewbnUSDToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isUnifiedBnUSDMigrateParams, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, originalAssetTohubAssetMap, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
16632
16683
  //# sourceMappingURL=index.mjs.map
16633
16684
  //# sourceMappingURL=index.mjs.map