@sodax/sdk 0.0.1-rc.10 → 0.0.1-rc.12
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 +10 -10
- package/dist/index.cjs +2109 -477
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +845 -106
- package/dist/index.d.ts +845 -106
- package/dist/index.mjs +2089 -477
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { ICON_MAINNET_CHAIN_ID, SUI_MAINNET_CHAIN_ID, STELLAR_MAINNET_CHAIN_ID,
|
|
|
4
4
|
export * from '@sodax/types';
|
|
5
5
|
import { coins } from '@cosmjs/stargate';
|
|
6
6
|
import * as IconSdkRaw from 'icon-sdk-js';
|
|
7
|
-
import {
|
|
7
|
+
import { SorobanRpc, Horizon, Contract, TransactionBuilder, BASE_FEE, nativeToScVal, TimeoutInfinite, rpc, scValToBigInt, Operation, Address, Account } from '@stellar/stellar-sdk';
|
|
8
8
|
import { bcs } from '@mysten/sui/bcs';
|
|
9
9
|
import { Transaction } from '@mysten/sui/transactions';
|
|
10
10
|
import { PublicKey, SystemProgram, ComputeBudgetProgram, Connection } from '@solana/web3.js';
|
|
@@ -5076,6 +5076,8 @@ var DEFAULT_RETRY_DELAY_MS = 2e3;
|
|
|
5076
5076
|
var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
|
|
5077
5077
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
5078
5078
|
var FEE_PERCENTAGE_SCALE = 10000n;
|
|
5079
|
+
var STELLAR_PRIORITY_FEE = "10000";
|
|
5080
|
+
var STELLAR_DEFAULT_TX_TIMEOUT_SECONDS = 100;
|
|
5079
5081
|
var VAULT_TOKEN_DECIMALS = 18;
|
|
5080
5082
|
var INTENT_RELAY_CHAIN_IDS = {
|
|
5081
5083
|
AVAX: 6n,
|
|
@@ -5160,7 +5162,9 @@ var hubChainConfig = {
|
|
|
5160
5162
|
addresses: {
|
|
5161
5163
|
assetManager: "0x60c5681bD1DB4e50735c4cA3386005A4BA4937C0",
|
|
5162
5164
|
hubWallet: "0xA0ed3047D358648F2C0583B415CffCA571FDB544",
|
|
5163
|
-
xTokenManager: "0x5bD2843de9D6b0e6A05d0FB742072274EA3C6CA3"
|
|
5165
|
+
xTokenManager: "0x5bD2843de9D6b0e6A05d0FB742072274EA3C6CA3",
|
|
5166
|
+
icxMigration: "0x8Af7cae2c8377BEDD8820A5ad096AaFA29D839cc",
|
|
5167
|
+
sodaToken: "0x8515352CB9832D1d379D52366D1E995ADd358420"
|
|
5164
5168
|
},
|
|
5165
5169
|
nativeToken: "0x0000000000000000000000000000000000000000",
|
|
5166
5170
|
supportedTokens: []
|
|
@@ -5210,6 +5214,12 @@ var spokeChainConfig = {
|
|
|
5210
5214
|
name: "Wrapped Sonic",
|
|
5211
5215
|
decimals: 18,
|
|
5212
5216
|
address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
|
|
5217
|
+
},
|
|
5218
|
+
SODA: {
|
|
5219
|
+
symbol: "SODA",
|
|
5220
|
+
name: "SODAX",
|
|
5221
|
+
decimals: 18,
|
|
5222
|
+
address: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963"
|
|
5213
5223
|
}
|
|
5214
5224
|
}
|
|
5215
5225
|
},
|
|
@@ -5245,8 +5255,8 @@ var spokeChainConfig = {
|
|
|
5245
5255
|
}
|
|
5246
5256
|
},
|
|
5247
5257
|
gasPrice: "500000",
|
|
5248
|
-
rpcUrl: "https://
|
|
5249
|
-
wsUrl: "https://
|
|
5258
|
+
rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/i3q5fE3cYSFBE4Lcg1kS5",
|
|
5259
|
+
wsUrl: "https://solana-mainnet.g.alchemy.com/v2/i3q5fE3cYSFBE4Lcg1kS5",
|
|
5250
5260
|
walletAddress: ""
|
|
5251
5261
|
},
|
|
5252
5262
|
[AVALANCHE_MAINNET_CHAIN_ID]: {
|
|
@@ -5340,12 +5350,6 @@ var spokeChainConfig = {
|
|
|
5340
5350
|
decimals: 18,
|
|
5341
5351
|
address: "0xA256dd181C3f6E5eC68C6869f5D50a712d47212e"
|
|
5342
5352
|
},
|
|
5343
|
-
WETH: {
|
|
5344
|
-
symbol: "WETH",
|
|
5345
|
-
name: "Wrapped Ether",
|
|
5346
|
-
decimals: 18,
|
|
5347
|
-
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
5348
|
-
},
|
|
5349
5353
|
wstETH: {
|
|
5350
5354
|
symbol: "wstETH",
|
|
5351
5355
|
name: "Wrapped stETH",
|
|
@@ -5637,9 +5641,10 @@ var spokeChainConfig = {
|
|
|
5637
5641
|
},
|
|
5638
5642
|
nativeToken: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
|
|
5639
5643
|
bnUSD: "CD6YBFFWMU2UJHX2NGRJ7RN76IJVTCC7MRA46DUBXNB7E6W7H7JRJ2CX",
|
|
5640
|
-
|
|
5644
|
+
horizonRpcUrl: "https://horizon.stellar.org",
|
|
5645
|
+
sorobanRpcUrl: "https://rpc.ankr.com/stellar_soroban",
|
|
5641
5646
|
chain: {
|
|
5642
|
-
name: "
|
|
5647
|
+
name: "Stellar",
|
|
5643
5648
|
id: STELLAR_MAINNET_CHAIN_ID,
|
|
5644
5649
|
type: "STELLAR"
|
|
5645
5650
|
}
|
|
@@ -5670,6 +5675,42 @@ var spokeChainConfig = {
|
|
|
5670
5675
|
name: "USD Coin",
|
|
5671
5676
|
decimals: 6,
|
|
5672
5677
|
address: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
|
|
5678
|
+
},
|
|
5679
|
+
afSUI: {
|
|
5680
|
+
symbol: "afSUI",
|
|
5681
|
+
name: "Aftermath Staked Sui",
|
|
5682
|
+
decimals: 9,
|
|
5683
|
+
address: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
|
|
5684
|
+
},
|
|
5685
|
+
mSUI: {
|
|
5686
|
+
symbol: "mSUI",
|
|
5687
|
+
name: "Mirai Staked SUI",
|
|
5688
|
+
decimals: 9,
|
|
5689
|
+
address: "0x922d15d7f55c13fd790f6e54397470ec592caa2b508df292a2e8553f3d3b274f::msui::MSUI"
|
|
5690
|
+
},
|
|
5691
|
+
haSUI: {
|
|
5692
|
+
symbol: "haSUI",
|
|
5693
|
+
name: "haSUI",
|
|
5694
|
+
decimals: 9,
|
|
5695
|
+
address: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
5696
|
+
},
|
|
5697
|
+
vSUI: {
|
|
5698
|
+
symbol: "vSUI",
|
|
5699
|
+
name: "Volo Staked SUI",
|
|
5700
|
+
decimals: 9,
|
|
5701
|
+
address: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
5702
|
+
},
|
|
5703
|
+
yapSUI: {
|
|
5704
|
+
symbol: "yapSUI",
|
|
5705
|
+
name: "Yap Staked SUI",
|
|
5706
|
+
decimals: 9,
|
|
5707
|
+
address: "0x83f1bb8c91ecd1fd313344058b0eed94d63c54e41d8d1ae5bff1353443517d65::yap_sui::YAP_SUI"
|
|
5708
|
+
},
|
|
5709
|
+
trevinSUI: {
|
|
5710
|
+
symbol: "trevinSUI",
|
|
5711
|
+
name: "Trevin Staked SUI",
|
|
5712
|
+
decimals: 9,
|
|
5713
|
+
address: "0x502867b177303bf1bf226245fcdd3403c177e78d175a55a56c0602c7ff51c7fa::trevin_sui::TREVIN_SUI"
|
|
5673
5714
|
}
|
|
5674
5715
|
},
|
|
5675
5716
|
nativeToken: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
@@ -5685,7 +5726,8 @@ var spokeChainConfig = {
|
|
|
5685
5726
|
addresses: {
|
|
5686
5727
|
assetManager: "cx1be33c283c7dc7617181d1b21a6a2309e71b1ee7",
|
|
5687
5728
|
connection: "cxe5cdf3b0f26967b0efc72d470d57bbf534268f94",
|
|
5688
|
-
rateLimit: "cxbbdcea9e6757023a046067ba8daa3c4c50304358"
|
|
5729
|
+
rateLimit: "cxbbdcea9e6757023a046067ba8daa3c4c50304358",
|
|
5730
|
+
wICX: "cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
|
|
5689
5731
|
},
|
|
5690
5732
|
chain: {
|
|
5691
5733
|
id: ICON_MAINNET_CHAIN_ID,
|
|
@@ -5717,6 +5759,201 @@ var spokeChainConfig = {
|
|
|
5717
5759
|
nid: "0x1"
|
|
5718
5760
|
}
|
|
5719
5761
|
};
|
|
5762
|
+
var HubVaultSymbols = [
|
|
5763
|
+
"sodaAVAX",
|
|
5764
|
+
"sodaBNB",
|
|
5765
|
+
"sodaETH",
|
|
5766
|
+
"sodaBTC",
|
|
5767
|
+
"sodaSUI",
|
|
5768
|
+
"sodaINJ",
|
|
5769
|
+
"sodaXLM",
|
|
5770
|
+
"sodaSOL",
|
|
5771
|
+
"sodaSODA",
|
|
5772
|
+
"sodaUSDT",
|
|
5773
|
+
"sodaUSDC",
|
|
5774
|
+
"bnUSD",
|
|
5775
|
+
"sodaPOL",
|
|
5776
|
+
"sodaNIBI",
|
|
5777
|
+
"sodaS",
|
|
5778
|
+
"IbnUSD"
|
|
5779
|
+
];
|
|
5780
|
+
var hubVaults = {
|
|
5781
|
+
IbnUSD: {
|
|
5782
|
+
address: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51",
|
|
5783
|
+
reserves: [
|
|
5784
|
+
// hub asset addresses contained in the vault
|
|
5785
|
+
"0x654DdDf32a9a2aC53f5FB54bf1e93F66791f8047",
|
|
5786
|
+
"0xddf6AD38F9C9451C1F4cDf369040F6869e37393e",
|
|
5787
|
+
"0x1559B52d2e165da1505a542EA37C543c9137f52a"
|
|
5788
|
+
]
|
|
5789
|
+
},
|
|
5790
|
+
sodaS: {
|
|
5791
|
+
address: "0x62ecc3eeb80a162c57624b3ff80313fe69f5203e",
|
|
5792
|
+
reserves: [
|
|
5793
|
+
// hub asset addresses contained in the vault
|
|
5794
|
+
"0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38"
|
|
5795
|
+
]
|
|
5796
|
+
},
|
|
5797
|
+
sodaNIBI: {
|
|
5798
|
+
address: "0xc6c85287a8b173a509c2f198bb719a8a5a2d0c68",
|
|
5799
|
+
reserves: [
|
|
5800
|
+
// hub asset addresses contained in the vault
|
|
5801
|
+
"0xe0064414c2c1a636a9424c7a17d86fbf7fd3f190"
|
|
5802
|
+
]
|
|
5803
|
+
},
|
|
5804
|
+
sodaPOL: {
|
|
5805
|
+
address: "0x208ed38f4783328aa9ebfec360d32e7520a9b779",
|
|
5806
|
+
reserves: [
|
|
5807
|
+
// hub asset addresses contained in the vault
|
|
5808
|
+
"0x9ee17486571917837210824b0d4cadfe3b324d12"
|
|
5809
|
+
]
|
|
5810
|
+
},
|
|
5811
|
+
bnUSD: {
|
|
5812
|
+
address: "0xe801ca34e19abcbfea12025378d19c4fbe250131",
|
|
5813
|
+
reserves: [
|
|
5814
|
+
// hub asset addresses contained in the vault
|
|
5815
|
+
"0xabbb91c0617090f0028bdc27597cd0d038f3a833",
|
|
5816
|
+
"0xbdf1f453fcb61424011bbddcb96cfdb30f3fe876",
|
|
5817
|
+
"0x94dc79ce9c515ba4ae4d195da8e6ab86c69bfc38",
|
|
5818
|
+
"0x5ce6c1c51ff762cf3acd21396257046f694168b6",
|
|
5819
|
+
"0xdf5639d91359866f266b56d60d98ede9feedd100",
|
|
5820
|
+
"0x238384ae2b4f0ec189ecb5031859ba306b2679c5",
|
|
5821
|
+
"0x419ca9054e44e94ceab52846ecdc3997439bbca6",
|
|
5822
|
+
"0x18f85f9e80ff9496eebd5979a051af16ce751567",
|
|
5823
|
+
"0x289cda1043b4ce26bdca3c12e534f56b24308a5b",
|
|
5824
|
+
"0x23225ab8e63fca4070296678cb46566d57e1bbe3",
|
|
5825
|
+
"0x14c65b1cdc0b821569081b1f77342da0d0cbf439",
|
|
5826
|
+
"0xdf23097b9aeb917bf8fb70e99b6c528fffa35364",
|
|
5827
|
+
"0x11b93c162aabffd026539bb3b9f9ec22c8b7ef8a",
|
|
5828
|
+
"0x69425ffb14704124a58d6f69d510f74a59d9a5bc",
|
|
5829
|
+
"0x9d4b663eb075d2a1c7b8eaefb9eccc0510388b51"
|
|
5830
|
+
]
|
|
5831
|
+
},
|
|
5832
|
+
sodaSODA: {
|
|
5833
|
+
// SODA SODA vault
|
|
5834
|
+
address: "0x21685e341de7844135329914be6bd8d16982d834",
|
|
5835
|
+
reserves: [
|
|
5836
|
+
// hub asset addresses contained in the vault
|
|
5837
|
+
"0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
|
|
5838
|
+
// SODA SODA hub asset
|
|
5839
|
+
]
|
|
5840
|
+
},
|
|
5841
|
+
sodaAVAX: {
|
|
5842
|
+
// SODA AVAX vault
|
|
5843
|
+
address: "0x14238d267557e9d799016ad635b53cd15935d290",
|
|
5844
|
+
reserves: [
|
|
5845
|
+
// hub asset addresses contained in the vault
|
|
5846
|
+
"0xc9e4f0b6195f389d9d2b639f2878b7674eb9d8cd"
|
|
5847
|
+
// AvalancheAVAX hub asset
|
|
5848
|
+
]
|
|
5849
|
+
},
|
|
5850
|
+
sodaBNB: {
|
|
5851
|
+
// SODA BNB vault
|
|
5852
|
+
address: "0x40cd41b35db9e5109ae7e54b44de8625db320e6b",
|
|
5853
|
+
reserves: [
|
|
5854
|
+
// hub asset addresses contained in the vault
|
|
5855
|
+
"0x13b70564b1ec12876b20fab5d1bb630311312f4f"
|
|
5856
|
+
// BSC BNB hub asset
|
|
5857
|
+
]
|
|
5858
|
+
},
|
|
5859
|
+
sodaETH: {
|
|
5860
|
+
// SODA ETH vault
|
|
5861
|
+
address: "0x4effb5813271699683c25c734f4dabc45b363709",
|
|
5862
|
+
reserves: [
|
|
5863
|
+
// hub asset addresses contained in the vault
|
|
5864
|
+
"0x70178089842be7f8e4726b33f0d1569db8021faa",
|
|
5865
|
+
// BASE ETH hub asset
|
|
5866
|
+
"0xad332860dd3b6f0e63f4f66e9457900917ac78cd",
|
|
5867
|
+
// Optimism ETH hub asset
|
|
5868
|
+
"0xdcd9578b51ef55239b6e68629d822a8d97c95b86",
|
|
5869
|
+
// Arbitrum ETH hub asset
|
|
5870
|
+
"0x57fc2ac5701e463ae261adbd6c99fbeb48ce5293",
|
|
5871
|
+
// BSC ETH hub asset
|
|
5872
|
+
"0x50c42deacd8fc9773493ed674b675be577f2634b"
|
|
5873
|
+
// Sonic WETH hub asset
|
|
5874
|
+
]
|
|
5875
|
+
},
|
|
5876
|
+
sodaBTC: {
|
|
5877
|
+
// SODA BTC vault
|
|
5878
|
+
address: "0x7a1a5555842ad2d0ed274d09b5c4406a95799d5d",
|
|
5879
|
+
reserves: [
|
|
5880
|
+
// hub asset addresses contained in the vault
|
|
5881
|
+
"0x2803a23a3ba6b09e57d1c71dec0d9efdbb00a27f",
|
|
5882
|
+
// BASE cbBTC hub asset,
|
|
5883
|
+
"0xfb0acb1b2720b620935f50a6dd3f7fea52b2fcbe",
|
|
5884
|
+
// Arbitrum wBTC hub asset
|
|
5885
|
+
"0x96fc8540736f1598b7e235e6de8814062b3b5d3b",
|
|
5886
|
+
// Arbitrum tBTC hub asset,
|
|
5887
|
+
"0xd8a24c71fea5bb81c66c01e532de7d9b11e13905"
|
|
5888
|
+
// BSC BTCB hub asset
|
|
5889
|
+
]
|
|
5890
|
+
},
|
|
5891
|
+
sodaSUI: {
|
|
5892
|
+
// SODA SUI vault
|
|
5893
|
+
address: "0xdc5b4b00f98347e95b9f94911213dab4c687e1e3",
|
|
5894
|
+
reserves: [
|
|
5895
|
+
// hub asset addresses contained in the vault
|
|
5896
|
+
"0x4676b2a551b25c04e235553c1c81019337384673"
|
|
5897
|
+
// SUI SUI hub asset
|
|
5898
|
+
]
|
|
5899
|
+
},
|
|
5900
|
+
sodaINJ: {
|
|
5901
|
+
// SODA INJ vault
|
|
5902
|
+
address: "0x1f22279c89b213944b7ea41dacb0a868ddcdfd13",
|
|
5903
|
+
reserves: [
|
|
5904
|
+
// hub asset addresses contained in the vault
|
|
5905
|
+
"0xd375590b4955f6ea5623f799153f9b787a3bd319"
|
|
5906
|
+
// Injective INJ hub asset
|
|
5907
|
+
]
|
|
5908
|
+
},
|
|
5909
|
+
sodaXLM: {
|
|
5910
|
+
// SODA XLM vault
|
|
5911
|
+
address: "0x6bc8c37cba91f76e68c9e6d689a9c21e4d32079b",
|
|
5912
|
+
reserves: [
|
|
5913
|
+
// hub asset addresses contained in the vault
|
|
5914
|
+
"0x8ac68af223907fb1b893086601a3d99e00f2fa9d"
|
|
5915
|
+
// Stellar XLM hub asset
|
|
5916
|
+
]
|
|
5917
|
+
},
|
|
5918
|
+
sodaSOL: {
|
|
5919
|
+
// SODA SOL vault
|
|
5920
|
+
address: "0xdea692287e2ce8cb08fa52917be0f16b1dacdc87",
|
|
5921
|
+
reserves: [
|
|
5922
|
+
// hub asset addresses contained in the vault
|
|
5923
|
+
"0x0c09e69a4528945de6d16c7e469dea6996fdf636"
|
|
5924
|
+
// Solana SOL hub asset
|
|
5925
|
+
]
|
|
5926
|
+
},
|
|
5927
|
+
sodaUSDT: {
|
|
5928
|
+
// SODA USDT vault
|
|
5929
|
+
address: "0xbdf1f453fcb61424011bbddcb96cfdb30f3fe876",
|
|
5930
|
+
reserves: [
|
|
5931
|
+
// hub asset addresses contained in the vault
|
|
5932
|
+
"0x41fd5c169e014e2a657b9de3553f7a7b735fe47a",
|
|
5933
|
+
"0xc168067d95109003805ac865ae556e8476dc69bc",
|
|
5934
|
+
"0x3c0a80c6a1110fc80309382b3989ec626c135ee9",
|
|
5935
|
+
"0x6047828dc181963ba44974801ff68e538da5eaf9"
|
|
5936
|
+
// Sonic USDT
|
|
5937
|
+
]
|
|
5938
|
+
},
|
|
5939
|
+
sodaUSDC: {
|
|
5940
|
+
address: "0xabbb91c0617090f0028bdc27597cd0d038f3a833",
|
|
5941
|
+
reserves: [
|
|
5942
|
+
"0x41abf4b1559ff709ef8150079bcb26db1fffd117",
|
|
5943
|
+
"0x72e852545b024ddcbc5b70c1bcbdaa025164259c",
|
|
5944
|
+
"0xb7c213cbd24967de9838fa014668fddb338f724b",
|
|
5945
|
+
"0xdb7bda65c3a1c51d64dc4444e418684677334109",
|
|
5946
|
+
"0xa36893ba308b332fdebfa95916d1df3a2e3cf8b3",
|
|
5947
|
+
"0x29219dd400f2bf60e5a23d13be72b486d4038894",
|
|
5948
|
+
"0x5635369c8a29a081d26c2e9e28012fca548ba0cb",
|
|
5949
|
+
"0x3d73437dd81b3f9ec82752beb1752f03a8531710",
|
|
5950
|
+
"0x4bc1211faa06fb50ff61a70331f56167ae511057",
|
|
5951
|
+
"0x348007b53f25a9a857ab8ea81ec9e3ccbcf440f2",
|
|
5952
|
+
"0xc3f020057510ffe10ceb882e1b48238b43d78a5e",
|
|
5953
|
+
"0x9d58508ad10d34048a11640735ca5075bba07b35"
|
|
5954
|
+
]
|
|
5955
|
+
}
|
|
5956
|
+
};
|
|
5720
5957
|
var hubAssets = {
|
|
5721
5958
|
[SONIC_MAINNET_CHAIN_ID]: {
|
|
5722
5959
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].nativeToken]: {
|
|
@@ -5724,35 +5961,42 @@ var hubAssets = {
|
|
|
5724
5961
|
decimal: 18,
|
|
5725
5962
|
symbol: "S",
|
|
5726
5963
|
name: "Sonic",
|
|
5727
|
-
vault:
|
|
5964
|
+
vault: hubVaults.sodaS.address
|
|
5728
5965
|
},
|
|
5729
5966
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic.address]: {
|
|
5730
5967
|
asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
5731
5968
|
decimal: 18,
|
|
5732
5969
|
symbol: "wSonic",
|
|
5733
5970
|
name: "Sonic",
|
|
5734
|
-
vault:
|
|
5971
|
+
vault: hubVaults.sodaS.address
|
|
5735
5972
|
},
|
|
5736
5973
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address]: {
|
|
5737
5974
|
asset: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b",
|
|
5738
5975
|
decimal: 18,
|
|
5739
5976
|
symbol: "WETH",
|
|
5740
5977
|
name: "Wrapped Ethereum",
|
|
5741
|
-
vault:
|
|
5978
|
+
vault: hubVaults.sodaETH.address
|
|
5742
5979
|
},
|
|
5743
5980
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5744
5981
|
asset: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
5745
5982
|
decimal: 6,
|
|
5746
5983
|
symbol: "USDC ",
|
|
5747
5984
|
name: "USD Coin",
|
|
5748
|
-
vault:
|
|
5985
|
+
vault: hubVaults.sodaUSDC.address
|
|
5749
5986
|
},
|
|
5750
5987
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5751
5988
|
asset: "0x6047828dc181963ba44974801ff68e538da5eaf9",
|
|
5752
5989
|
decimal: 6,
|
|
5753
5990
|
symbol: "USDT",
|
|
5754
5991
|
name: "Tether USD",
|
|
5755
|
-
vault:
|
|
5992
|
+
vault: hubVaults.sodaUSDT.address
|
|
5993
|
+
},
|
|
5994
|
+
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address]: {
|
|
5995
|
+
asset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
|
|
5996
|
+
decimal: 18,
|
|
5997
|
+
symbol: "SODA",
|
|
5998
|
+
name: "SODA",
|
|
5999
|
+
vault: hubVaults.sodaSODA.address
|
|
5756
6000
|
}
|
|
5757
6001
|
},
|
|
5758
6002
|
[AVALANCHE_MAINNET_CHAIN_ID]: {
|
|
@@ -5761,28 +6005,28 @@ var hubAssets = {
|
|
|
5761
6005
|
decimal: 18,
|
|
5762
6006
|
symbol: "AVAX",
|
|
5763
6007
|
name: "AVAX",
|
|
5764
|
-
vault:
|
|
6008
|
+
vault: hubVaults.sodaAVAX.address
|
|
5765
6009
|
},
|
|
5766
6010
|
[spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5767
6011
|
asset: "0x41Fd5c169e014e2A657B9de3553f7a7b735Fe47A",
|
|
5768
6012
|
decimal: 6,
|
|
5769
6013
|
symbol: "USDT",
|
|
5770
6014
|
name: "Tether USD",
|
|
5771
|
-
vault:
|
|
6015
|
+
vault: hubVaults.sodaUSDT.address
|
|
5772
6016
|
},
|
|
5773
6017
|
[spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5774
6018
|
asset: "0x41abF4B1559FF709Ef8150079BcB26DB1Fffd117",
|
|
5775
6019
|
decimal: 6,
|
|
5776
6020
|
symbol: "USDC",
|
|
5777
6021
|
name: "USD Coin",
|
|
5778
|
-
vault:
|
|
6022
|
+
vault: hubVaults.sodaUSDC.address
|
|
5779
6023
|
},
|
|
5780
6024
|
[spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5781
6025
|
asset: "0x289cDa1043b4Ce26BDCa3c12E534f56b24308A5B",
|
|
5782
6026
|
decimal: 18,
|
|
5783
6027
|
symbol: "bnUSD",
|
|
5784
6028
|
name: "bnUSD",
|
|
5785
|
-
vault:
|
|
6029
|
+
vault: hubVaults.bnUSD.address
|
|
5786
6030
|
}
|
|
5787
6031
|
},
|
|
5788
6032
|
[ARBITRUM_MAINNET_CHAIN_ID]: {
|
|
@@ -5791,56 +6035,58 @@ var hubAssets = {
|
|
|
5791
6035
|
decimal: 18,
|
|
5792
6036
|
symbol: "ETH",
|
|
5793
6037
|
name: "Ethereum",
|
|
5794
|
-
vault:
|
|
6038
|
+
vault: hubVaults.sodaETH.address
|
|
5795
6039
|
},
|
|
5796
6040
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC.address]: {
|
|
5797
6041
|
asset: "0xfB0ACB1b2720B620935F50a6dd3F7FEA52b2FCBe",
|
|
5798
6042
|
decimal: 8,
|
|
5799
6043
|
symbol: "WBTC",
|
|
5800
6044
|
name: "Wrapped Bitcoin",
|
|
5801
|
-
vault:
|
|
6045
|
+
vault: hubVaults.sodaBTC.address
|
|
5802
6046
|
},
|
|
5803
6047
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5804
6048
|
asset: "0x08D5cf039De35627fD5C0f48B8AF4a1647a462E8",
|
|
5805
6049
|
decimal: 18,
|
|
5806
6050
|
symbol: "weETH",
|
|
5807
6051
|
name: "Wrapped eETH",
|
|
5808
|
-
vault: "
|
|
6052
|
+
vault: "0x"
|
|
6053
|
+
// no vault yet
|
|
5809
6054
|
},
|
|
5810
6055
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5811
6056
|
asset: "0x2D5A7837D68b0c2CC4b14C2af2a1F0Ef420DDDc5",
|
|
5812
6057
|
decimal: 18,
|
|
5813
6058
|
symbol: "wstETH",
|
|
5814
6059
|
name: "Wrapped Staked Ethereum",
|
|
5815
|
-
vault: "
|
|
6060
|
+
vault: "0x"
|
|
6061
|
+
// no vault yet
|
|
5816
6062
|
},
|
|
5817
6063
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.tBTC.address]: {
|
|
5818
6064
|
asset: "0x96Fc8540736f1598b7E235e6dE8814062b3b5d3B",
|
|
5819
6065
|
decimal: 18,
|
|
5820
6066
|
symbol: "tBTC",
|
|
5821
6067
|
name: "Arbitrum tBTC",
|
|
5822
|
-
vault:
|
|
6068
|
+
vault: hubVaults.sodaBTC.address
|
|
5823
6069
|
},
|
|
5824
6070
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5825
6071
|
asset: "0x3C0a80C6a1110fC80309382b3989eC626c135eE9",
|
|
5826
6072
|
decimal: 6,
|
|
5827
6073
|
symbol: "USDT",
|
|
5828
6074
|
name: "Tether USD",
|
|
5829
|
-
vault:
|
|
6075
|
+
vault: hubVaults.sodaUSDT.address
|
|
5830
6076
|
},
|
|
5831
6077
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5832
6078
|
asset: "0xdB7BdA65c3a1C51D64dC4444e418684677334109",
|
|
5833
6079
|
decimal: 6,
|
|
5834
6080
|
symbol: "USDC",
|
|
5835
6081
|
name: "USD Coin",
|
|
5836
|
-
vault:
|
|
6082
|
+
vault: hubVaults.sodaUSDC.address
|
|
5837
6083
|
},
|
|
5838
6084
|
[spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5839
6085
|
asset: "0x419cA9054E44E94ceAb52846eCdC3997439BBcA6",
|
|
5840
6086
|
decimal: 18,
|
|
5841
6087
|
symbol: "bnUSD",
|
|
5842
6088
|
name: "bnUSD",
|
|
5843
|
-
vault:
|
|
6089
|
+
vault: hubVaults.bnUSD.address
|
|
5844
6090
|
}
|
|
5845
6091
|
},
|
|
5846
6092
|
[BASE_MAINNET_CHAIN_ID]: {
|
|
@@ -5849,42 +6095,44 @@ var hubAssets = {
|
|
|
5849
6095
|
decimal: 18,
|
|
5850
6096
|
symbol: "ETH",
|
|
5851
6097
|
name: "Ethereum",
|
|
5852
|
-
vault:
|
|
6098
|
+
vault: hubVaults.sodaETH.address
|
|
5853
6099
|
},
|
|
5854
6100
|
[spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.cbBTC.address]: {
|
|
5855
6101
|
asset: "0x2803a23a3BA6b09e57D1c71deC0D9eFdBB00A27F",
|
|
5856
6102
|
decimal: 8,
|
|
5857
6103
|
symbol: "cbBTC",
|
|
5858
6104
|
name: "Coinbase Wrapped BTC",
|
|
5859
|
-
vault:
|
|
6105
|
+
vault: hubVaults.sodaBTC.address
|
|
5860
6106
|
},
|
|
5861
6107
|
[spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5862
6108
|
asset: "0x72E852545B024ddCbc5b70C1bCBDAA025164259C",
|
|
5863
6109
|
decimal: 6,
|
|
5864
6110
|
symbol: "USDC",
|
|
5865
6111
|
name: "USD Coin",
|
|
5866
|
-
vault:
|
|
6112
|
+
vault: hubVaults.sodaUSDC.address
|
|
5867
6113
|
},
|
|
5868
6114
|
[spokeChainConfig[BASE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5869
6115
|
asset: "0xDF5639D91359866f266b56D60d98edE9fEEDd100",
|
|
5870
6116
|
decimal: 18,
|
|
5871
6117
|
symbol: "bnUSD",
|
|
5872
6118
|
name: "bnUSD",
|
|
5873
|
-
vault:
|
|
6119
|
+
vault: hubVaults.bnUSD.address
|
|
5874
6120
|
},
|
|
5875
6121
|
[spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5876
6122
|
asset: "0x55e0ad45eb97493b3045eee417fb6726cb85dfd4",
|
|
5877
6123
|
decimal: 18,
|
|
5878
6124
|
symbol: "weETH",
|
|
5879
6125
|
name: "Wrapped eETH",
|
|
5880
|
-
vault: "
|
|
6126
|
+
vault: "0x"
|
|
6127
|
+
// no vault yet
|
|
5881
6128
|
},
|
|
5882
6129
|
[spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5883
6130
|
asset: "0x494aaeaefdf5964d4ed400174e8c5b98c00957aa",
|
|
5884
6131
|
decimal: 18,
|
|
5885
6132
|
symbol: "wstETH",
|
|
5886
6133
|
name: "Wrapped Staked Ethereum",
|
|
5887
|
-
vault: "
|
|
6134
|
+
vault: "0x"
|
|
6135
|
+
// no vault yet
|
|
5888
6136
|
}
|
|
5889
6137
|
},
|
|
5890
6138
|
[OPTIMISM_MAINNET_CHAIN_ID]: {
|
|
@@ -5893,42 +6141,44 @@ var hubAssets = {
|
|
|
5893
6141
|
decimal: 18,
|
|
5894
6142
|
symbol: "ETH",
|
|
5895
6143
|
name: "Ethereum",
|
|
5896
|
-
vault:
|
|
6144
|
+
vault: hubVaults.sodaETH.address
|
|
5897
6145
|
},
|
|
5898
6146
|
[spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5899
6147
|
asset: "0x238384AE2b4F0EC189ecB5031859bA306B2679c5",
|
|
5900
6148
|
decimal: 18,
|
|
5901
6149
|
symbol: "bnUSD",
|
|
5902
6150
|
name: "bnUSD",
|
|
5903
|
-
vault:
|
|
6151
|
+
vault: hubVaults.bnUSD.address
|
|
5904
6152
|
},
|
|
5905
6153
|
[spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5906
6154
|
asset: "0xb7C213CbD24967dE9838fa014668FDDB338f724B",
|
|
5907
6155
|
decimal: 6,
|
|
5908
6156
|
symbol: "USDC",
|
|
5909
6157
|
name: "USD Coin",
|
|
5910
|
-
vault:
|
|
6158
|
+
vault: hubVaults.sodaUSDC.address
|
|
5911
6159
|
},
|
|
5912
6160
|
[spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5913
6161
|
asset: "0x61e26f611090CdC6bc79A7Bf156b0fD10f1fC212",
|
|
5914
6162
|
decimal: 18,
|
|
5915
6163
|
symbol: "wstETH",
|
|
5916
6164
|
name: "Wrapped Staked Ethereum",
|
|
5917
|
-
vault: "
|
|
6165
|
+
vault: "0x"
|
|
6166
|
+
// no vault yet
|
|
5918
6167
|
},
|
|
5919
6168
|
[spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5920
6169
|
asset: "0xE121c0Dc2B33c00ff31ee3D902D248cc3f19Ea50",
|
|
5921
6170
|
decimal: 18,
|
|
5922
6171
|
symbol: "weETH",
|
|
5923
6172
|
name: "Wrapped eETH",
|
|
5924
|
-
vault: "
|
|
6173
|
+
vault: "0x"
|
|
6174
|
+
// no vault yet
|
|
5925
6175
|
},
|
|
5926
6176
|
[spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5927
6177
|
asset: "0xc168067d95109003805aC865ae556e8476DC69bc",
|
|
5928
6178
|
decimal: 6,
|
|
5929
6179
|
symbol: "USDT",
|
|
5930
6180
|
name: "Tether USD",
|
|
5931
|
-
vault:
|
|
6181
|
+
vault: hubVaults.sodaUSDT.address
|
|
5932
6182
|
}
|
|
5933
6183
|
},
|
|
5934
6184
|
[NIBIRU_MAINNET_CHAIN_ID]: {
|
|
@@ -5937,14 +6187,14 @@ var hubAssets = {
|
|
|
5937
6187
|
decimal: 18,
|
|
5938
6188
|
symbol: "NIBI",
|
|
5939
6189
|
name: "Nibiru",
|
|
5940
|
-
vault:
|
|
6190
|
+
vault: hubVaults.sodaNIBI.address
|
|
5941
6191
|
},
|
|
5942
6192
|
[spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5943
6193
|
asset: "0x11b93C162aABFfD026539bb3B9F9eC22c8b7ef8a",
|
|
5944
6194
|
decimal: 18,
|
|
5945
6195
|
symbol: "bnUSD",
|
|
5946
6196
|
name: "bnUSD",
|
|
5947
|
-
vault:
|
|
6197
|
+
vault: hubVaults.bnUSD.address
|
|
5948
6198
|
}
|
|
5949
6199
|
},
|
|
5950
6200
|
[BSC_MAINNET_CHAIN_ID]: {
|
|
@@ -5953,35 +6203,35 @@ var hubAssets = {
|
|
|
5953
6203
|
decimal: 18,
|
|
5954
6204
|
symbol: "BNB",
|
|
5955
6205
|
name: "BNB",
|
|
5956
|
-
vault:
|
|
6206
|
+
vault: hubVaults.sodaBNB.address
|
|
5957
6207
|
},
|
|
5958
6208
|
[spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.ETHB.address]: {
|
|
5959
6209
|
asset: "0x57fC2aC5701e463ae261AdBd6C99FBeB48Ce5293",
|
|
5960
6210
|
decimal: 18,
|
|
5961
6211
|
symbol: "ETHB",
|
|
5962
6212
|
name: "Wrapped Ethereum",
|
|
5963
|
-
vault:
|
|
6213
|
+
vault: hubVaults.sodaETH.address
|
|
5964
6214
|
},
|
|
5965
6215
|
[spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.BTCB.address]: {
|
|
5966
6216
|
asset: "0xD8A24c71FEa5bB81c66C01e532dE7d9B11e13905",
|
|
5967
6217
|
decimal: 18,
|
|
5968
6218
|
symbol: "BTCB",
|
|
5969
6219
|
name: "Wrapped Bitcoin",
|
|
5970
|
-
vault:
|
|
6220
|
+
vault: hubVaults.sodaBTC.address
|
|
5971
6221
|
},
|
|
5972
6222
|
[spokeChainConfig[BSC_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5973
6223
|
asset: "0x5Ce6C1c51ff762cF3acD21396257046f694168b6",
|
|
5974
6224
|
decimal: 18,
|
|
5975
6225
|
symbol: "bnUSD",
|
|
5976
6226
|
name: "bnUSD",
|
|
5977
|
-
vault:
|
|
6227
|
+
vault: hubVaults.bnUSD.address
|
|
5978
6228
|
},
|
|
5979
6229
|
[spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5980
6230
|
asset: "0x9d58508ad10d34048a11640735ca5075bba07b35",
|
|
5981
6231
|
decimal: 18,
|
|
5982
6232
|
symbol: "USDC",
|
|
5983
6233
|
name: "USD Coin",
|
|
5984
|
-
vault:
|
|
6234
|
+
vault: hubVaults.sodaUSDC.address
|
|
5985
6235
|
}
|
|
5986
6236
|
},
|
|
5987
6237
|
[POLYGON_MAINNET_CHAIN_ID]: {
|
|
@@ -5990,21 +6240,21 @@ var hubAssets = {
|
|
|
5990
6240
|
decimal: 18,
|
|
5991
6241
|
symbol: "MATIC",
|
|
5992
6242
|
name: "Polygon",
|
|
5993
|
-
vault:
|
|
6243
|
+
vault: hubVaults.sodaPOL.address
|
|
5994
6244
|
},
|
|
5995
6245
|
[spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5996
6246
|
asset: "0x18f85f9E80ff9496EeBD5979a051AF16Ce751567",
|
|
5997
6247
|
decimal: 18,
|
|
5998
6248
|
symbol: "bnUSD",
|
|
5999
6249
|
name: "bnUSD",
|
|
6000
|
-
vault:
|
|
6250
|
+
vault: hubVaults.bnUSD.address
|
|
6001
6251
|
},
|
|
6002
6252
|
[spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6003
6253
|
asset: "0xa36893ba308b332FDEbfa95916D1dF3a2e3CF8B3",
|
|
6004
6254
|
decimal: 6,
|
|
6005
6255
|
symbol: "USDC",
|
|
6006
6256
|
name: "USD Coin",
|
|
6007
|
-
vault:
|
|
6257
|
+
vault: hubVaults.sodaUSDC.address
|
|
6008
6258
|
}
|
|
6009
6259
|
},
|
|
6010
6260
|
[INJECTIVE_MAINNET_CHAIN_ID]: {
|
|
@@ -6013,21 +6263,21 @@ var hubAssets = {
|
|
|
6013
6263
|
decimal: 18,
|
|
6014
6264
|
symbol: "INJ",
|
|
6015
6265
|
name: "Injective",
|
|
6016
|
-
vault:
|
|
6266
|
+
vault: hubVaults.sodaINJ.address
|
|
6017
6267
|
},
|
|
6018
6268
|
[spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6019
6269
|
asset: "0x69425FFb14704124A58d6F69d510f74A59D9a5bC",
|
|
6020
6270
|
decimal: 18,
|
|
6021
6271
|
symbol: "bnUSD",
|
|
6022
6272
|
name: "bnUSD",
|
|
6023
|
-
vault:
|
|
6273
|
+
vault: hubVaults.bnUSD.address
|
|
6024
6274
|
},
|
|
6025
6275
|
[spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6026
6276
|
asset: "0x4bc1211faa06fb50ff61a70331f56167ae511057",
|
|
6027
6277
|
decimal: 6,
|
|
6028
6278
|
symbol: "USDC",
|
|
6029
6279
|
name: "USD Coin",
|
|
6030
|
-
vault:
|
|
6280
|
+
vault: hubVaults.sodaUSDC.address
|
|
6031
6281
|
}
|
|
6032
6282
|
},
|
|
6033
6283
|
[STELLAR_MAINNET_CHAIN_ID]: {
|
|
@@ -6036,21 +6286,21 @@ var hubAssets = {
|
|
|
6036
6286
|
decimal: 7,
|
|
6037
6287
|
symbol: "XLM",
|
|
6038
6288
|
name: "Stellar Lumens",
|
|
6039
|
-
vault:
|
|
6289
|
+
vault: hubVaults.sodaXLM.address
|
|
6040
6290
|
},
|
|
6041
6291
|
[spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6042
6292
|
asset: "0x23225Ab8E63FCa4070296678cb46566d57E1BBe3",
|
|
6043
6293
|
decimal: 7,
|
|
6044
6294
|
symbol: "bnUSD",
|
|
6045
6295
|
name: "bnUSD",
|
|
6046
|
-
vault:
|
|
6296
|
+
vault: hubVaults.bnUSD.address
|
|
6047
6297
|
},
|
|
6048
6298
|
[spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6049
6299
|
asset: "0x348007B53F25A9A857aB8eA81ec9E3CCBCf440f2",
|
|
6050
6300
|
decimal: 7,
|
|
6051
6301
|
symbol: "USDC",
|
|
6052
6302
|
name: "USD Coin",
|
|
6053
|
-
vault:
|
|
6303
|
+
vault: hubVaults.sodaUSDC.address
|
|
6054
6304
|
}
|
|
6055
6305
|
},
|
|
6056
6306
|
[SUI_MAINNET_CHAIN_ID]: {
|
|
@@ -6059,44 +6309,92 @@ var hubAssets = {
|
|
|
6059
6309
|
decimal: 9,
|
|
6060
6310
|
symbol: "SUI",
|
|
6061
6311
|
name: "Sui",
|
|
6062
|
-
vault:
|
|
6312
|
+
vault: hubVaults.sodaSUI.address
|
|
6063
6313
|
},
|
|
6064
6314
|
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6065
6315
|
asset: "0xDf23097B9AEb917Bf8fb70e99b6c528fffA35364",
|
|
6066
6316
|
decimal: 9,
|
|
6067
6317
|
symbol: "bnUSD",
|
|
6068
6318
|
name: "bnUSD",
|
|
6069
|
-
vault:
|
|
6319
|
+
vault: hubVaults.bnUSD.address
|
|
6070
6320
|
},
|
|
6071
6321
|
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6072
6322
|
asset: "0x5635369c8a29A081d26C2e9e28012FCa548BA0Cb",
|
|
6073
6323
|
decimal: 6,
|
|
6074
6324
|
symbol: "USDC",
|
|
6075
6325
|
name: "USD Coin",
|
|
6076
|
-
vault:
|
|
6326
|
+
vault: hubVaults.sodaUSDC.address
|
|
6327
|
+
},
|
|
6328
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.afSUI.address]: {
|
|
6329
|
+
asset: "0x039666bd0cbc96a66c40e8541af465beaa81aa7e",
|
|
6330
|
+
decimal: 9,
|
|
6331
|
+
symbol: "afSUI",
|
|
6332
|
+
name: "afSUI",
|
|
6333
|
+
vault: "0x"
|
|
6334
|
+
// no vault yet
|
|
6335
|
+
},
|
|
6336
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.mSUI.address]: {
|
|
6337
|
+
asset: "0xb202c674c9a79b5681e981ba0daa782b3ceeebbe",
|
|
6338
|
+
decimal: 9,
|
|
6339
|
+
symbol: "mSUI",
|
|
6340
|
+
name: "mSUI",
|
|
6341
|
+
vault: "0x"
|
|
6342
|
+
// no vault yet
|
|
6343
|
+
},
|
|
6344
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.haSUI.address]: {
|
|
6345
|
+
asset: "0x67a26d11fce15e8b33ac97230d36cae1c52c35e7",
|
|
6346
|
+
decimal: 9,
|
|
6347
|
+
symbol: "haSUI",
|
|
6348
|
+
name: "haSUI",
|
|
6349
|
+
vault: "0x"
|
|
6350
|
+
// no vault yet
|
|
6351
|
+
},
|
|
6352
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.vSUI.address]: {
|
|
6353
|
+
asset: "0x025715bcda08db06c795cd5bf944e2081468d99a",
|
|
6354
|
+
decimal: 9,
|
|
6355
|
+
symbol: "vSUI",
|
|
6356
|
+
name: "vSUI",
|
|
6357
|
+
vault: "0x"
|
|
6358
|
+
// no vault yet
|
|
6359
|
+
},
|
|
6360
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.yapSUI.address]: {
|
|
6361
|
+
asset: "0xac509404f3a3ca3f7766baf65be45a52b1cfccd7",
|
|
6362
|
+
decimal: 9,
|
|
6363
|
+
symbol: "yapSUI",
|
|
6364
|
+
name: "yapSUI",
|
|
6365
|
+
vault: "0x"
|
|
6366
|
+
// no vault yet
|
|
6367
|
+
},
|
|
6368
|
+
[spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.trevinSUI.address]: {
|
|
6369
|
+
asset: "0x514569c788b096595672e0f68ec72387a22ac67b",
|
|
6370
|
+
decimal: 9,
|
|
6371
|
+
symbol: "trevinSUI",
|
|
6372
|
+
name: "trevinSUI",
|
|
6373
|
+
vault: "0x"
|
|
6374
|
+
// no vault yet
|
|
6077
6375
|
}
|
|
6078
6376
|
},
|
|
6079
6377
|
[SOLANA_MAINNET_CHAIN_ID]: {
|
|
6080
6378
|
[spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL.address]: {
|
|
6081
6379
|
asset: "0x0c09e69a4528945de6d16c7e469dea6996fdf636",
|
|
6082
6380
|
decimal: 9,
|
|
6083
|
-
symbol: "
|
|
6084
|
-
name: "
|
|
6085
|
-
vault:
|
|
6381
|
+
symbol: "SOL",
|
|
6382
|
+
name: "Solana",
|
|
6383
|
+
vault: hubVaults.sodaSOL.address
|
|
6086
6384
|
},
|
|
6087
6385
|
[spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6088
6386
|
asset: "0x14C65b1CDc0B821569081b1F77342dA0D0CbF439",
|
|
6089
6387
|
decimal: 9,
|
|
6090
6388
|
symbol: "bnUSD",
|
|
6091
6389
|
name: "bnUSD",
|
|
6092
|
-
vault:
|
|
6390
|
+
vault: hubVaults.bnUSD.address
|
|
6093
6391
|
},
|
|
6094
6392
|
[spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6095
|
-
asset: "
|
|
6393
|
+
asset: "0xC3f020057510ffE10Ceb882e1B48238b43d78a5e",
|
|
6096
6394
|
decimal: 6,
|
|
6097
6395
|
symbol: "USDC",
|
|
6098
6396
|
name: "USD Coin",
|
|
6099
|
-
vault:
|
|
6397
|
+
vault: hubVaults.sodaUSDC.address
|
|
6100
6398
|
}
|
|
6101
6399
|
},
|
|
6102
6400
|
[ICON_MAINNET_CHAIN_ID]: {
|
|
@@ -6105,6 +6403,14 @@ var hubAssets = {
|
|
|
6105
6403
|
decimal: 18,
|
|
6106
6404
|
symbol: "ICX",
|
|
6107
6405
|
name: "ICON",
|
|
6406
|
+
vault: "0x"
|
|
6407
|
+
// no vault yet
|
|
6408
|
+
},
|
|
6409
|
+
[spokeChainConfig[ICON_MAINNET_CHAIN_ID].addresses.wICX]: {
|
|
6410
|
+
asset: "0xb66cB7D841272AF6BaA8b8119007EdEE35d2C24F",
|
|
6411
|
+
decimal: 18,
|
|
6412
|
+
symbol: "wICX",
|
|
6413
|
+
name: "ICON",
|
|
6108
6414
|
vault: "0x0000000000000000000000000000000000000000"
|
|
6109
6415
|
},
|
|
6110
6416
|
[spokeChainConfig[ICON_MAINNET_CHAIN_ID].bnUSD]: {
|
|
@@ -6112,7 +6418,7 @@ var hubAssets = {
|
|
|
6112
6418
|
decimal: 18,
|
|
6113
6419
|
symbol: "bnUSD",
|
|
6114
6420
|
name: "bnUSD",
|
|
6115
|
-
vault:
|
|
6421
|
+
vault: hubVaults.IbnUSD.address
|
|
6116
6422
|
}
|
|
6117
6423
|
}
|
|
6118
6424
|
};
|
|
@@ -6120,25 +6426,26 @@ var DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
|
|
|
6120
6426
|
var solverConfig = {
|
|
6121
6427
|
[SONIC_MAINNET_CHAIN_ID]: {
|
|
6122
6428
|
intentsContract: "0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef",
|
|
6123
|
-
solverApiEndpoint: "https://
|
|
6124
|
-
// TODO replace with mainnet
|
|
6429
|
+
solverApiEndpoint: "https://sodax-solver-staging.iconblockchain.xyz"
|
|
6125
6430
|
}
|
|
6126
6431
|
};
|
|
6127
6432
|
var getSolverConfig = (chainId) => solverConfig[chainId];
|
|
6128
6433
|
var solverSupportedTokens = {
|
|
6129
6434
|
[SONIC_MAINNET_CHAIN_ID]: [
|
|
6130
|
-
spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
|
|
6131
|
-
spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6132
|
-
spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
|
|
6133
|
-
spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic
|
|
6435
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6436
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6437
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6438
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6134
6439
|
],
|
|
6135
6440
|
[AVALANCHE_MAINNET_CHAIN_ID]: [
|
|
6136
6441
|
spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.AVAX,
|
|
6137
6442
|
spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDT,
|
|
6138
6443
|
spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6444
|
+
// spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6139
6445
|
],
|
|
6140
6446
|
[ARBITRUM_MAINNET_CHAIN_ID]: [
|
|
6141
6447
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6448
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6142
6449
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC,
|
|
6143
6450
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6144
6451
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
@@ -6148,6 +6455,7 @@ var solverSupportedTokens = {
|
|
|
6148
6455
|
],
|
|
6149
6456
|
[BASE_MAINNET_CHAIN_ID]: [
|
|
6150
6457
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6458
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6151
6459
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6152
6460
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6153
6461
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
@@ -6155,43 +6463,62 @@ var solverSupportedTokens = {
|
|
|
6155
6463
|
],
|
|
6156
6464
|
[OPTIMISM_MAINNET_CHAIN_ID]: [
|
|
6157
6465
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6466
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6158
6467
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6159
6468
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6160
|
-
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6469
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH, // NOTE: Not Implemented
|
|
6161
6470
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT
|
|
6162
6471
|
],
|
|
6163
6472
|
[POLYGON_MAINNET_CHAIN_ID]: [
|
|
6164
6473
|
spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.POL,
|
|
6474
|
+
// spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6165
6475
|
spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6166
6476
|
],
|
|
6167
6477
|
[BSC_MAINNET_CHAIN_ID]: [
|
|
6168
6478
|
spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.BNB,
|
|
6169
6479
|
spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.ETHB,
|
|
6170
6480
|
spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.BTCB,
|
|
6481
|
+
// spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6171
6482
|
spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6172
6483
|
],
|
|
6173
6484
|
[SOLANA_MAINNET_CHAIN_ID]: [
|
|
6174
6485
|
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL,
|
|
6486
|
+
// spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6175
6487
|
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6176
6488
|
],
|
|
6177
6489
|
[ICON_MAINNET_CHAIN_ID]: [
|
|
6178
6490
|
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.ICX,
|
|
6179
6491
|
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.wICX,
|
|
6180
6492
|
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6493
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.BALN, // NOTE: Not Implemented
|
|
6494
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.OMM, // NOTE: Not Implemented
|
|
6181
6495
|
],
|
|
6182
6496
|
[STELLAR_MAINNET_CHAIN_ID]: [
|
|
6183
6497
|
spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.XLM,
|
|
6498
|
+
// spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6184
6499
|
spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6185
6500
|
],
|
|
6186
6501
|
[SUI_MAINNET_CHAIN_ID]: [
|
|
6187
6502
|
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.SUI,
|
|
6188
|
-
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.
|
|
6503
|
+
// spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6504
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6505
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.afSUI,
|
|
6506
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.mSUI,
|
|
6507
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.haSUI,
|
|
6508
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.vSUI,
|
|
6509
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.yapSUI,
|
|
6510
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.trevinSUI
|
|
6189
6511
|
],
|
|
6190
6512
|
[INJECTIVE_MAINNET_CHAIN_ID]: [
|
|
6191
6513
|
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
|
|
6514
|
+
// spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6192
6515
|
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6193
6516
|
],
|
|
6194
|
-
[NIBIRU_MAINNET_CHAIN_ID]: [
|
|
6517
|
+
[NIBIRU_MAINNET_CHAIN_ID]: [
|
|
6518
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.NIBI, // NOTE: Not Implemented
|
|
6519
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6520
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Not Implemented
|
|
6521
|
+
]
|
|
6195
6522
|
};
|
|
6196
6523
|
var getSupportedSolverTokens = (chainId) => solverSupportedTokens[chainId];
|
|
6197
6524
|
var isSolverSupportedToken = (chainId, token) => solverSupportedTokens[chainId].some((t) => t.address.toLowerCase() === token.toLowerCase());
|
|
@@ -6216,8 +6543,8 @@ var moneyMarketSupportedTokens = {
|
|
|
6216
6543
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6217
6544
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6218
6545
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC,
|
|
6219
|
-
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6220
|
-
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6546
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6547
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6221
6548
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.tBTC,
|
|
6222
6549
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDT,
|
|
6223
6550
|
spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
@@ -6225,17 +6552,17 @@ var moneyMarketSupportedTokens = {
|
|
|
6225
6552
|
[BASE_MAINNET_CHAIN_ID]: [
|
|
6226
6553
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6227
6554
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6228
|
-
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6555
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6229
6556
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6230
|
-
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6557
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6231
6558
|
spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.cbBTC
|
|
6232
6559
|
],
|
|
6233
6560
|
[OPTIMISM_MAINNET_CHAIN_ID]: [
|
|
6234
6561
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6235
6562
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6236
6563
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6237
|
-
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6238
|
-
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6564
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6565
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6239
6566
|
spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT
|
|
6240
6567
|
],
|
|
6241
6568
|
[POLYGON_MAINNET_CHAIN_ID]: [
|
|
@@ -6251,12 +6578,13 @@ var moneyMarketSupportedTokens = {
|
|
|
6251
6578
|
],
|
|
6252
6579
|
[SOLANA_MAINNET_CHAIN_ID]: [
|
|
6253
6580
|
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL,
|
|
6254
|
-
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6581
|
+
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6582
|
+
spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6255
6583
|
],
|
|
6256
6584
|
[ICON_MAINNET_CHAIN_ID]: [
|
|
6257
|
-
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.ICX,
|
|
6258
|
-
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6259
|
-
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.wICX
|
|
6585
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.ICX,
|
|
6586
|
+
spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6587
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.wICX,
|
|
6260
6588
|
],
|
|
6261
6589
|
[STELLAR_MAINNET_CHAIN_ID]: [
|
|
6262
6590
|
spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.XLM,
|
|
@@ -6264,11 +6592,13 @@ var moneyMarketSupportedTokens = {
|
|
|
6264
6592
|
],
|
|
6265
6593
|
[SUI_MAINNET_CHAIN_ID]: [
|
|
6266
6594
|
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.SUI,
|
|
6267
|
-
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6595
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6596
|
+
spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6268
6597
|
],
|
|
6269
6598
|
[INJECTIVE_MAINNET_CHAIN_ID]: [
|
|
6270
6599
|
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
|
|
6271
|
-
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6600
|
+
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6601
|
+
spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6272
6602
|
],
|
|
6273
6603
|
[NIBIRU_MAINNET_CHAIN_ID]: [],
|
|
6274
6604
|
[SONIC_MAINNET_CHAIN_ID]: [
|
|
@@ -6281,119 +6611,16 @@ var moneyMarketSupportedTokens = {
|
|
|
6281
6611
|
};
|
|
6282
6612
|
var isMoneyMarketSupportedToken = (chainId, token) => moneyMarketSupportedTokens[chainId].some((t) => t.address.toLowerCase() === token.toLowerCase());
|
|
6283
6613
|
var getSupportedMoneyMarketTokens = (chainId) => moneyMarketSupportedTokens[chainId];
|
|
6284
|
-
var
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
var hubVaults = {
|
|
6295
|
-
sodaAVAX: {
|
|
6296
|
-
// SODA AVAX vault
|
|
6297
|
-
address: "0x14238d267557e9d799016ad635b53cd15935d290",
|
|
6298
|
-
reserves: [
|
|
6299
|
-
// hub asset addresses contained in the vault
|
|
6300
|
-
"0xc9e4f0b6195f389d9d2b639f2878b7674eb9d8cd"
|
|
6301
|
-
// AvalancheAVAX hub asset
|
|
6302
|
-
]
|
|
6303
|
-
},
|
|
6304
|
-
sodaBNB: {
|
|
6305
|
-
// SODA BNB vault
|
|
6306
|
-
address: "0x40cd41b35db9e5109ae7e54b44de8625db320e6b",
|
|
6307
|
-
reserves: [
|
|
6308
|
-
// hub asset addresses contained in the vault
|
|
6309
|
-
"0x13b70564b1ec12876b20fab5d1bb630311312f4f"
|
|
6310
|
-
// BSC BNB hub asset
|
|
6311
|
-
]
|
|
6312
|
-
},
|
|
6313
|
-
sodaETH: {
|
|
6314
|
-
// SODA ETH vault
|
|
6315
|
-
address: "0x4effb5813271699683c25c734f4dabc45b363709",
|
|
6316
|
-
reserves: [
|
|
6317
|
-
// hub asset addresses contained in the vault
|
|
6318
|
-
"0x70178089842be7f8e4726b33f0d1569db8021faa",
|
|
6319
|
-
// BASE ETH hub asset
|
|
6320
|
-
"0xad332860dd3b6f0e63f4f66e9457900917ac78cd",
|
|
6321
|
-
// Optimism ETH hub asset
|
|
6322
|
-
"0xdcd9578b51ef55239b6e68629d822a8d97c95b86",
|
|
6323
|
-
// Arbitrum ETH hub asset
|
|
6324
|
-
"0x57fc2ac5701e463ae261adbd6c99fbeb48ce5293"
|
|
6325
|
-
// BSC ETH hub asset
|
|
6326
|
-
]
|
|
6327
|
-
},
|
|
6328
|
-
sodaBTC: {
|
|
6329
|
-
// SODA BTC vault
|
|
6330
|
-
address: "0x7a1a5555842ad2d0ed274d09b5c4406a95799d5d",
|
|
6331
|
-
reserves: [
|
|
6332
|
-
// hub asset addresses contained in the vault
|
|
6333
|
-
"0x2803a23a3ba6b09e57d1c71dec0d9efdbb00a27f",
|
|
6334
|
-
// BASE cbBTC hub asset,
|
|
6335
|
-
"0xfb0acb1b2720b620935f50a6dd3f7fea52b2fcbe",
|
|
6336
|
-
// Arbitrum wBTC hub asset
|
|
6337
|
-
"0x96fc8540736f1598b7e235e6de8814062b3b5d3b",
|
|
6338
|
-
// Arbitrum tBTC hub asset,
|
|
6339
|
-
"0xd8a24c71fea5bb81c66c01e532de7d9b11e13905"
|
|
6340
|
-
// BSC BTCB hub asset
|
|
6341
|
-
]
|
|
6342
|
-
},
|
|
6343
|
-
sodaSUI: {
|
|
6344
|
-
// SODA SUI vault
|
|
6345
|
-
address: "0xdc5b4b00f98347e95b9f94911213dab4c687e1e3",
|
|
6346
|
-
reserves: [
|
|
6347
|
-
// hub asset addresses contained in the vault
|
|
6348
|
-
"0x4676b2a551b25c04e235553c1c81019337384673"
|
|
6349
|
-
// SUI SUI hub asset
|
|
6350
|
-
]
|
|
6351
|
-
},
|
|
6352
|
-
sodaINJ: {
|
|
6353
|
-
// SODA INJ vault
|
|
6354
|
-
address: "0x1f22279c89b213944b7ea41dacb0a868ddcdfd13",
|
|
6355
|
-
reserves: [
|
|
6356
|
-
// hub asset addresses contained in the vault
|
|
6357
|
-
"0xd375590b4955f6ea5623f799153f9b787a3bd319"
|
|
6358
|
-
// Injective INJ hub asset
|
|
6359
|
-
]
|
|
6360
|
-
},
|
|
6361
|
-
sodaXLM: {
|
|
6362
|
-
// SODA XLM vault
|
|
6363
|
-
address: "0x6bc8c37cba91f76e68c9e6d689a9c21e4d32079b",
|
|
6364
|
-
reserves: [
|
|
6365
|
-
// hub asset addresses contained in the vault
|
|
6366
|
-
"0x8ac68af223907fb1b893086601a3d99e00f2fa9d"
|
|
6367
|
-
// Stellar XLM hub asset
|
|
6368
|
-
]
|
|
6369
|
-
},
|
|
6370
|
-
sodaSOL: {
|
|
6371
|
-
// SODA SOL vault
|
|
6372
|
-
address: "0xdea692287e2ce8cb08fa52917be0f16b1dacdc87",
|
|
6373
|
-
reserves: [
|
|
6374
|
-
// hub asset addresses contained in the vault
|
|
6375
|
-
"0x0c09e69a4528945de6d16c7e469dea6996fdf636"
|
|
6376
|
-
// Solana SOL hub asset
|
|
6377
|
-
]
|
|
6378
|
-
}
|
|
6379
|
-
};
|
|
6380
|
-
var hubVaultsAddressSet = new Set(
|
|
6381
|
-
Object.values(hubVaults).map((vault) => vault.address.toLowerCase())
|
|
6382
|
-
);
|
|
6383
|
-
var moneyMarketReserveHubAssetsSet = new Set(
|
|
6384
|
-
Object.values(hubVaults).flatMap((vault) => vault.reserves.map((reserve) => reserve.toLowerCase()))
|
|
6385
|
-
);
|
|
6386
|
-
var isMoneyMarketReserveHubAsset = (hubAsset) => moneyMarketReserveHubAssetsSet.has(hubAsset.toLowerCase());
|
|
6387
|
-
var moneyMarketReserveAssets = [
|
|
6388
|
-
hubVaults["sodaAVAX"].address,
|
|
6389
|
-
hubVaults["sodaBNB"].address,
|
|
6390
|
-
hubVaults["sodaETH"].address,
|
|
6391
|
-
hubVaults["sodaBTC"].address,
|
|
6392
|
-
hubVaults["sodaSUI"].address,
|
|
6393
|
-
hubVaults["sodaINJ"].address,
|
|
6394
|
-
hubVaults["sodaXLM"].address,
|
|
6395
|
-
hubVaults["sodaSOL"].address,
|
|
6396
|
-
getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID).bnUSDVault
|
|
6614
|
+
var hubVaultsAddressSet = new Set(
|
|
6615
|
+
Object.values(hubVaults).map((vault) => vault.address.toLowerCase())
|
|
6616
|
+
);
|
|
6617
|
+
var moneyMarketReserveHubAssetsSet = new Set(
|
|
6618
|
+
Object.values(hubVaults).flatMap((vault) => vault.reserves.map((reserve) => reserve.toLowerCase()))
|
|
6619
|
+
);
|
|
6620
|
+
var isMoneyMarketReserveHubAsset = (hubAsset) => moneyMarketReserveHubAssetsSet.has(hubAsset.toLowerCase());
|
|
6621
|
+
var moneyMarketReserveAssets = [
|
|
6622
|
+
...Object.values(hubVaults).map((vault) => vault.address),
|
|
6623
|
+
getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID).bnUSDVault
|
|
6397
6624
|
];
|
|
6398
6625
|
var isMoneyMarketReserveAsset = (asset) => moneyMarketReserveAssets.map((a) => a.toLowerCase()).includes(asset.toLowerCase());
|
|
6399
6626
|
var originalAssetTohubAssetMap = new Map(
|
|
@@ -6739,28 +6966,164 @@ var EvmSpokeProvider = class {
|
|
|
6739
6966
|
}
|
|
6740
6967
|
}
|
|
6741
6968
|
};
|
|
6969
|
+
var CustomStellarAccount = class {
|
|
6970
|
+
accountId;
|
|
6971
|
+
sequenceNumber;
|
|
6972
|
+
startingSequenceNumber;
|
|
6973
|
+
constructor({ account_id, sequence }) {
|
|
6974
|
+
this.accountId = account_id;
|
|
6975
|
+
this.sequenceNumber = BigInt(sequence);
|
|
6976
|
+
this.startingSequenceNumber = BigInt(sequence);
|
|
6977
|
+
}
|
|
6978
|
+
getSequenceNumber() {
|
|
6979
|
+
return this.sequenceNumber;
|
|
6980
|
+
}
|
|
6981
|
+
getStartingSequenceNumber() {
|
|
6982
|
+
return this.startingSequenceNumber;
|
|
6983
|
+
}
|
|
6984
|
+
getAccountId() {
|
|
6985
|
+
return this.accountId;
|
|
6986
|
+
}
|
|
6987
|
+
getAccountClone() {
|
|
6988
|
+
return new Account(this.accountId, this.sequenceNumber.toString());
|
|
6989
|
+
}
|
|
6990
|
+
incrementSequenceNumber() {
|
|
6991
|
+
this.sequenceNumber++;
|
|
6992
|
+
}
|
|
6993
|
+
decrementSequenceNumber() {
|
|
6994
|
+
if (this.sequenceNumber > this.startingSequenceNumber) {
|
|
6995
|
+
this.sequenceNumber--;
|
|
6996
|
+
}
|
|
6997
|
+
throw new Error(
|
|
6998
|
+
`Sequence number cannot be decremented below the starting sequence number: ${this.startingSequenceNumber}`
|
|
6999
|
+
);
|
|
7000
|
+
}
|
|
7001
|
+
resetSequenceNumber() {
|
|
7002
|
+
this.sequenceNumber = this.startingSequenceNumber;
|
|
7003
|
+
}
|
|
7004
|
+
};
|
|
7005
|
+
var CustomSorobanServer = class extends SorobanRpc.Server {
|
|
7006
|
+
customHeaders;
|
|
7007
|
+
constructor(serverUrl, customHeaders) {
|
|
7008
|
+
super(serverUrl, {
|
|
7009
|
+
allowHttp: true
|
|
7010
|
+
});
|
|
7011
|
+
this.customHeaders = customHeaders;
|
|
7012
|
+
}
|
|
7013
|
+
async getNetwork() {
|
|
7014
|
+
const requestOptions = {
|
|
7015
|
+
method: "POST",
|
|
7016
|
+
headers: {
|
|
7017
|
+
"Content-Type": "application/json",
|
|
7018
|
+
...this.customHeaders
|
|
7019
|
+
},
|
|
7020
|
+
body: JSON.stringify({
|
|
7021
|
+
id: 1,
|
|
7022
|
+
jsonrpc: "2.0",
|
|
7023
|
+
method: "getNetwork"
|
|
7024
|
+
})
|
|
7025
|
+
};
|
|
7026
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7027
|
+
if (!response.ok) {
|
|
7028
|
+
throw new Error(`HTTP error getting network! status: ${response.status}`);
|
|
7029
|
+
}
|
|
7030
|
+
return response.json().then((json) => json.result);
|
|
7031
|
+
}
|
|
7032
|
+
async simulateTransaction(tx) {
|
|
7033
|
+
const requestOptions = {
|
|
7034
|
+
method: "POST",
|
|
7035
|
+
headers: {
|
|
7036
|
+
"Content-Type": "application/json",
|
|
7037
|
+
...this.customHeaders
|
|
7038
|
+
},
|
|
7039
|
+
body: JSON.stringify({
|
|
7040
|
+
id: 1,
|
|
7041
|
+
jsonrpc: "2.0",
|
|
7042
|
+
method: "simulateTransaction",
|
|
7043
|
+
params: {
|
|
7044
|
+
transaction: tx.toXDR()
|
|
7045
|
+
}
|
|
7046
|
+
})
|
|
7047
|
+
};
|
|
7048
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7049
|
+
if (!response.ok) {
|
|
7050
|
+
throw new Error(`HTTP error simulating TX! status: ${response.status}`);
|
|
7051
|
+
}
|
|
7052
|
+
return response.json().then((json) => json.result);
|
|
7053
|
+
}
|
|
7054
|
+
async sendTransaction(tx) {
|
|
7055
|
+
const requestOptions = {
|
|
7056
|
+
method: "POST",
|
|
7057
|
+
headers: {
|
|
7058
|
+
"Content-Type": "application/json",
|
|
7059
|
+
...this.customHeaders
|
|
7060
|
+
},
|
|
7061
|
+
body: JSON.stringify({
|
|
7062
|
+
id: 1,
|
|
7063
|
+
jsonrpc: "2.0",
|
|
7064
|
+
method: "sendTransaction",
|
|
7065
|
+
params: {
|
|
7066
|
+
transaction: tx.toXDR()
|
|
7067
|
+
}
|
|
7068
|
+
})
|
|
7069
|
+
};
|
|
7070
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7071
|
+
if (!response.ok) {
|
|
7072
|
+
throw new Error(`HTTP error submitting TX! status: ${response.status}`);
|
|
7073
|
+
}
|
|
7074
|
+
return response.json().then((json) => json.result);
|
|
7075
|
+
}
|
|
7076
|
+
async getTransaction(hash) {
|
|
7077
|
+
const requestOptions = {
|
|
7078
|
+
method: "POST",
|
|
7079
|
+
headers: {
|
|
7080
|
+
"Content-Type": "application/json",
|
|
7081
|
+
...this.customHeaders
|
|
7082
|
+
},
|
|
7083
|
+
body: JSON.stringify({
|
|
7084
|
+
id: 1,
|
|
7085
|
+
jsonrpc: "2.0",
|
|
7086
|
+
method: "getTransaction",
|
|
7087
|
+
params: { hash }
|
|
7088
|
+
})
|
|
7089
|
+
};
|
|
7090
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7091
|
+
if (!response.ok) {
|
|
7092
|
+
throw new Error(`HTTP error getting TX! status: ${response.status}`);
|
|
7093
|
+
}
|
|
7094
|
+
return response.json().then((json) => json.result);
|
|
7095
|
+
}
|
|
7096
|
+
};
|
|
6742
7097
|
var StellarSpokeProvider = class {
|
|
6743
7098
|
server;
|
|
7099
|
+
sorobanServer;
|
|
6744
7100
|
contract;
|
|
6745
7101
|
chainConfig;
|
|
6746
7102
|
walletProvider;
|
|
6747
|
-
constructor(walletProvider,
|
|
6748
|
-
this.server = new
|
|
7103
|
+
constructor(walletProvider, config, rpcConfig) {
|
|
7104
|
+
this.server = new Horizon.Server(
|
|
7105
|
+
rpcConfig && rpcConfig.horizonRpcUrl ? rpcConfig.horizonRpcUrl : config.horizonRpcUrl,
|
|
7106
|
+
{ allowHttp: true }
|
|
7107
|
+
);
|
|
7108
|
+
this.sorobanServer = new CustomSorobanServer(
|
|
7109
|
+
rpcConfig && rpcConfig.sorobanRpcUrl ? rpcConfig.sorobanRpcUrl : config.sorobanRpcUrl,
|
|
7110
|
+
{}
|
|
7111
|
+
);
|
|
6749
7112
|
this.walletProvider = walletProvider;
|
|
6750
|
-
this.contract = new Contract(
|
|
7113
|
+
this.contract = new Contract(config.addresses.assetManager);
|
|
6751
7114
|
this.chainConfig = config;
|
|
6752
7115
|
}
|
|
6753
7116
|
async getBalance(tokenAddress) {
|
|
6754
7117
|
const [network, walletAddress] = await Promise.all([
|
|
6755
|
-
this.
|
|
7118
|
+
this.sorobanServer.getNetwork(),
|
|
6756
7119
|
this.walletProvider.getWalletAddress()
|
|
6757
7120
|
]);
|
|
6758
|
-
const sourceAccount = await this.
|
|
7121
|
+
const sourceAccount = await this.sorobanServer.getAccount(walletAddress);
|
|
6759
7122
|
const tx = new TransactionBuilder(sourceAccount, {
|
|
6760
7123
|
fee: BASE_FEE,
|
|
6761
7124
|
networkPassphrase: network.passphrase
|
|
6762
7125
|
}).addOperation(this.contract.call("get_token_balance", nativeToScVal(tokenAddress, { type: "address" }))).setTimeout(TimeoutInfinite).build();
|
|
6763
|
-
const result = await this.
|
|
7126
|
+
const result = await this.sorobanServer.simulateTransaction(tx);
|
|
6764
7127
|
if (rpc.Api.isSimulationError(result)) {
|
|
6765
7128
|
throw new Error("Failed to simulate transaction");
|
|
6766
7129
|
}
|
|
@@ -6770,32 +7133,112 @@ var StellarSpokeProvider = class {
|
|
|
6770
7133
|
}
|
|
6771
7134
|
throw new Error("result undefined");
|
|
6772
7135
|
}
|
|
7136
|
+
async buildPriorityStellarTransaction(account, network, operation) {
|
|
7137
|
+
const simulationForFee = await this.sorobanServer.simulateTransaction(
|
|
7138
|
+
new TransactionBuilder(account.getAccountClone(), {
|
|
7139
|
+
fee: BASE_FEE,
|
|
7140
|
+
networkPassphrase: network.passphrase
|
|
7141
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7142
|
+
);
|
|
7143
|
+
if (!rpc.Api.isSimulationSuccess(simulationForFee)) {
|
|
7144
|
+
throw new Error(`Simulation error: ${JSON.stringify(simulationForFee)}`);
|
|
7145
|
+
}
|
|
7146
|
+
const priorityTransaction = new TransactionBuilder(account.getAccountClone(), {
|
|
7147
|
+
fee: (BigInt(simulationForFee.minResourceFee) + BigInt(STELLAR_PRIORITY_FEE) + BigInt(BASE_FEE.toString())).toString(),
|
|
7148
|
+
networkPassphrase: network.passphrase
|
|
7149
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build();
|
|
7150
|
+
const simulation = await this.sorobanServer.simulateTransaction(priorityTransaction);
|
|
7151
|
+
return [SorobanRpc.assembleTransaction(priorityTransaction, simulation).build(), simulation];
|
|
7152
|
+
}
|
|
7153
|
+
handleSendTransactionError(response) {
|
|
7154
|
+
if (response.status === "ERROR") {
|
|
7155
|
+
throw new Error(
|
|
7156
|
+
`Transaction failed: status: ${response.status}, hash: ${response.hash}, errorResult: ${JSON.stringify({
|
|
7157
|
+
name: response?.errorResult?.result()?.switch()?.name ?? "unknown",
|
|
7158
|
+
value: response?.errorResult?.result()?.switch()?.value ?? "unknown"
|
|
7159
|
+
})}, diagnosticEvents: ${JSON.stringify(response?.diagnosticEvents ?? "{}")}`
|
|
7160
|
+
);
|
|
7161
|
+
}
|
|
7162
|
+
return response;
|
|
7163
|
+
}
|
|
7164
|
+
async signAndSendTransaction(tx, waitForTransaction = true) {
|
|
7165
|
+
const signedTransaction = await this.walletProvider.signTransaction(tx.toXDR());
|
|
7166
|
+
const signedTx = TransactionBuilder.fromXDR(signedTransaction, tx.networkPassphrase);
|
|
7167
|
+
const response = this.handleSendTransactionError(await this.sorobanServer.sendTransaction(signedTx));
|
|
7168
|
+
if (waitForTransaction) {
|
|
7169
|
+
return await this.waitForTransaction(response.hash);
|
|
7170
|
+
}
|
|
7171
|
+
return response.hash;
|
|
7172
|
+
}
|
|
7173
|
+
async waitForTransaction(hash, attempts = 60) {
|
|
7174
|
+
if (attempts === 0) {
|
|
7175
|
+
throw new Error(
|
|
7176
|
+
"[StellarSpokeProvider.waitForTransaction] Timeout error. Transaction not found after 5 attempts"
|
|
7177
|
+
);
|
|
7178
|
+
}
|
|
7179
|
+
const response = await this.sorobanServer.getTransaction(hash);
|
|
7180
|
+
if (response.status === rpc.Api.GetTransactionStatus.SUCCESS) {
|
|
7181
|
+
return hash;
|
|
7182
|
+
}
|
|
7183
|
+
if (response.status === rpc.Api.GetTransactionStatus.FAILED) {
|
|
7184
|
+
throw response;
|
|
7185
|
+
}
|
|
7186
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
7187
|
+
return this.waitForTransaction(hash, attempts - 1);
|
|
7188
|
+
}
|
|
7189
|
+
async submitOrRestoreAndRetry(account, network, tx, operation, simulation) {
|
|
7190
|
+
const initialSimulation = simulation ?? await this.sorobanServer.simulateTransaction(tx);
|
|
7191
|
+
if (!rpc.Api.isSimulationSuccess(initialSimulation)) {
|
|
7192
|
+
throw new Error(
|
|
7193
|
+
`[StellarSpokeProvider.submitOrRestoreAndRetry] Simulation Failed: ${JSON.stringify(initialSimulation)}`
|
|
7194
|
+
);
|
|
7195
|
+
}
|
|
7196
|
+
let restored = false;
|
|
7197
|
+
if (rpc.Api.isSimulationRestore(initialSimulation)) {
|
|
7198
|
+
try {
|
|
7199
|
+
await this.handleSimulationRestore(
|
|
7200
|
+
initialSimulation.restorePreamble.minResourceFee,
|
|
7201
|
+
initialSimulation.restorePreamble.transactionData.build(),
|
|
7202
|
+
account,
|
|
7203
|
+
network
|
|
7204
|
+
);
|
|
7205
|
+
restored = true;
|
|
7206
|
+
} catch (error) {
|
|
7207
|
+
throw new Error(
|
|
7208
|
+
`[StellarSpokeProvider.submitOrRestoreAndRetry] Simulation Restore Failed: ${JSON.stringify(error)}`
|
|
7209
|
+
);
|
|
7210
|
+
}
|
|
7211
|
+
}
|
|
7212
|
+
if (!restored) {
|
|
7213
|
+
return await this.signAndSendTransaction(tx);
|
|
7214
|
+
}
|
|
7215
|
+
const newAccount = account.getAccountClone();
|
|
7216
|
+
newAccount.incrementSequenceNumber();
|
|
7217
|
+
return await this.signAndSendTransaction(
|
|
7218
|
+
new TransactionBuilder(newAccount, {
|
|
7219
|
+
fee: BASE_FEE,
|
|
7220
|
+
networkPassphrase: network.passphrase
|
|
7221
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7222
|
+
);
|
|
7223
|
+
}
|
|
7224
|
+
async handleSimulationRestore(minResourceFee, transactionData, account, network) {
|
|
7225
|
+
const totalFee = (BigInt(BASE_FEE) + BigInt(STELLAR_PRIORITY_FEE) + BigInt(minResourceFee)).toString();
|
|
7226
|
+
return this.signAndSendTransaction(
|
|
7227
|
+
new TransactionBuilder(account.getAccountClone(), { fee: totalFee }).setNetworkPassphrase(network.passphrase).setSorobanData(transactionData).addOperation(Operation.restoreFootprint({})).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7228
|
+
);
|
|
7229
|
+
}
|
|
6773
7230
|
async deposit(token, amount, recipient, data, raw) {
|
|
6774
7231
|
try {
|
|
6775
7232
|
const [network, walletAddress] = await Promise.all([
|
|
6776
|
-
this.
|
|
7233
|
+
this.sorobanServer.getNetwork(),
|
|
6777
7234
|
this.walletProvider.getWalletAddress()
|
|
6778
7235
|
]);
|
|
6779
|
-
const
|
|
6780
|
-
const
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
}).addOperation(
|
|
6784
|
-
this.contract.call(
|
|
6785
|
-
"transfer",
|
|
6786
|
-
nativeToScVal(Address.fromString(walletAddress), { type: "address" }),
|
|
6787
|
-
nativeToScVal(Address.fromString(token), {
|
|
6788
|
-
type: "address"
|
|
6789
|
-
}),
|
|
6790
|
-
nativeToScVal(BigInt(amount), { type: "u128" }),
|
|
6791
|
-
nativeToScVal(recipient),
|
|
6792
|
-
nativeToScVal(Buffer.from(data), { type: "bytes" })
|
|
6793
|
-
)
|
|
6794
|
-
).setTimeout(100).build();
|
|
6795
|
-
const simResult = await this.server.simulateTransaction(simulateTx);
|
|
6796
|
-
const tx = rpc.assembleTransaction(simulateTx, simResult).build();
|
|
7236
|
+
const accountResponse = await this.server.loadAccount(walletAddress);
|
|
7237
|
+
const stellarAccount = new CustomStellarAccount(accountResponse);
|
|
7238
|
+
const depositCall = this.buildDepositCall(walletAddress, token, amount, recipient, data);
|
|
7239
|
+
const [priorityTx, simulation] = await this.buildPriorityStellarTransaction(stellarAccount, network, depositCall);
|
|
6797
7240
|
if (raw) {
|
|
6798
|
-
const transactionXdr =
|
|
7241
|
+
const transactionXdr = priorityTx.toXDR();
|
|
6799
7242
|
return {
|
|
6800
7243
|
from: walletAddress,
|
|
6801
7244
|
to: this.chainConfig.addresses.assetManager,
|
|
@@ -6803,16 +7246,8 @@ var StellarSpokeProvider = class {
|
|
|
6803
7246
|
data: transactionXdr
|
|
6804
7247
|
};
|
|
6805
7248
|
}
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
const sendResponse = await this.server.sendTransaction(
|
|
6809
|
-
TransactionBuilder.fromXDR(signedTx, tx.networkPassphrase)
|
|
6810
|
-
);
|
|
6811
|
-
if (sendResponse.hash) {
|
|
6812
|
-
return `0x${sendResponse.hash}`;
|
|
6813
|
-
}
|
|
6814
|
-
}
|
|
6815
|
-
throw new Error("Failed to create transaction");
|
|
7249
|
+
const hash = await this.submitOrRestoreAndRetry(stellarAccount, network, priorityTx, depositCall, simulation);
|
|
7250
|
+
return `${hash}`;
|
|
6816
7251
|
} catch (error) {
|
|
6817
7252
|
console.error("Error during deposit:", error);
|
|
6818
7253
|
throw error;
|
|
@@ -6821,27 +7256,19 @@ var StellarSpokeProvider = class {
|
|
|
6821
7256
|
async sendMessage(dst_chain_id, dst_address, payload, raw) {
|
|
6822
7257
|
try {
|
|
6823
7258
|
const [network, walletAddress] = await Promise.all([
|
|
6824
|
-
this.
|
|
7259
|
+
this.sorobanServer.getNetwork(),
|
|
6825
7260
|
this.walletProvider.getWalletAddress()
|
|
6826
7261
|
]);
|
|
6827
|
-
const
|
|
6828
|
-
const
|
|
6829
|
-
const
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
nativeToScVal(Address.fromString(walletAddress), { type: "address" }),
|
|
6836
|
-
nativeToScVal(dst_chain_id, { type: "u128" }),
|
|
6837
|
-
nativeToScVal(Buffer.from(dst_address), { type: "bytes" }),
|
|
6838
|
-
nativeToScVal(Buffer.from(payload), { type: "bytes" })
|
|
6839
|
-
)
|
|
6840
|
-
).setTimeout(100).build();
|
|
6841
|
-
const simResult = await this.server.simulateTransaction(simulateTx);
|
|
6842
|
-
const tx = rpc.assembleTransaction(simulateTx, simResult).build();
|
|
7262
|
+
const accountResponse = await this.server.loadAccount(walletAddress);
|
|
7263
|
+
const stellarAccount = new CustomStellarAccount(accountResponse);
|
|
7264
|
+
const sendMessageCall = this.buildSendMessageCall(walletAddress, dst_chain_id, dst_address, payload);
|
|
7265
|
+
const [priorityTx, simulation] = await this.buildPriorityStellarTransaction(
|
|
7266
|
+
stellarAccount,
|
|
7267
|
+
network,
|
|
7268
|
+
sendMessageCall
|
|
7269
|
+
);
|
|
6843
7270
|
if (raw) {
|
|
6844
|
-
const transactionXdr =
|
|
7271
|
+
const transactionXdr = priorityTx.toXDR();
|
|
6845
7272
|
return {
|
|
6846
7273
|
from: walletAddress,
|
|
6847
7274
|
to: this.chainConfig.addresses.assetManager,
|
|
@@ -6849,21 +7276,35 @@ var StellarSpokeProvider = class {
|
|
|
6849
7276
|
data: transactionXdr
|
|
6850
7277
|
};
|
|
6851
7278
|
}
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
const sendResponse = await this.server.sendTransaction(
|
|
6855
|
-
TransactionBuilder.fromXDR(signedTx, tx.networkPassphrase)
|
|
6856
|
-
);
|
|
6857
|
-
if (sendResponse.hash) {
|
|
6858
|
-
return `0x${sendResponse.hash}`;
|
|
6859
|
-
}
|
|
6860
|
-
}
|
|
6861
|
-
throw new Error("Failed to create transaction");
|
|
7279
|
+
const hash = await this.submitOrRestoreAndRetry(stellarAccount, network, priorityTx, sendMessageCall, simulation);
|
|
7280
|
+
return `${hash}`;
|
|
6862
7281
|
} catch (error) {
|
|
6863
|
-
console.error("Error during
|
|
7282
|
+
console.error("Error during sendMessage:", error);
|
|
6864
7283
|
throw error;
|
|
6865
7284
|
}
|
|
6866
7285
|
}
|
|
7286
|
+
buildDepositCall(walletAddress, token, amount, recipient, data) {
|
|
7287
|
+
return this.contract.call(
|
|
7288
|
+
"transfer",
|
|
7289
|
+
nativeToScVal(Address.fromString(walletAddress), { type: "address" }),
|
|
7290
|
+
nativeToScVal(Address.fromString(token), {
|
|
7291
|
+
type: "address"
|
|
7292
|
+
}),
|
|
7293
|
+
nativeToScVal(BigInt(amount), { type: "u128" }),
|
|
7294
|
+
nativeToScVal(Buffer.from(recipient), { type: "bytes" }),
|
|
7295
|
+
nativeToScVal(Buffer.from(data), { type: "bytes" })
|
|
7296
|
+
);
|
|
7297
|
+
}
|
|
7298
|
+
buildSendMessageCall(walletAddress, dst_chain_id, dst_address, payload) {
|
|
7299
|
+
const connection = new Contract(this.chainConfig.addresses.connection);
|
|
7300
|
+
return connection.call(
|
|
7301
|
+
"send_message",
|
|
7302
|
+
nativeToScVal(Address.fromString(walletAddress), { type: "address" }),
|
|
7303
|
+
nativeToScVal(dst_chain_id, { type: "u128" }),
|
|
7304
|
+
nativeToScVal(Buffer.from(dst_address), { type: "bytes" }),
|
|
7305
|
+
nativeToScVal(Buffer.from(payload), { type: "bytes" })
|
|
7306
|
+
);
|
|
7307
|
+
}
|
|
6867
7308
|
static getAddressBCSBytes(stellaraddress) {
|
|
6868
7309
|
return `0x${Address.fromString(stellaraddress).toScVal().toXDR("hex")}`;
|
|
6869
7310
|
}
|
|
@@ -7634,9 +8075,13 @@ function encodeAddress(spokeChainId, address) {
|
|
|
7634
8075
|
case "injective-1":
|
|
7635
8076
|
return toHex(Buffer.from(address, "utf-8"));
|
|
7636
8077
|
case "0x1.icon":
|
|
7637
|
-
return
|
|
8078
|
+
return toHex(Buffer.from(address.replace("cx", "01").replace("hx", "00") ?? "f8", "hex"));
|
|
7638
8079
|
case "sui":
|
|
7639
8080
|
return toHex(bcs.Address.serialize(address).toBytes());
|
|
8081
|
+
case "solana":
|
|
8082
|
+
return toHex(Buffer.from(new PublicKey(address).toBytes()));
|
|
8083
|
+
case "stellar":
|
|
8084
|
+
return `0x${Address.fromString(address).toScVal().toXDR("hex")}`;
|
|
7640
8085
|
default:
|
|
7641
8086
|
return address;
|
|
7642
8087
|
}
|
|
@@ -7889,10 +8334,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7889
8334
|
* @param params - The parameters for the supply transaction.
|
|
7890
8335
|
* @param spokeProvider - The spoke provider.
|
|
7891
8336
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
7892
|
-
* @returns {Promise<Result<[
|
|
8337
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the transaction result and the hub transaction hash or error
|
|
7893
8338
|
*
|
|
7894
8339
|
* @example
|
|
7895
|
-
* const result = await moneyMarketService.
|
|
8340
|
+
* const result = await moneyMarketService.supply(
|
|
7896
8341
|
* {
|
|
7897
8342
|
* token: '0x...', // Address of the token (spoke chain address) to supply
|
|
7898
8343
|
* amount: 1000n, // Amount to supply (in token decimals)
|
|
@@ -7911,40 +8356,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7911
8356
|
* ] = result.value;
|
|
7912
8357
|
* console.log('Supply transaction hashes:', { spokeTxHash, hubTxHash });
|
|
7913
8358
|
*/
|
|
7914
|
-
async
|
|
8359
|
+
async supply(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
7915
8360
|
try {
|
|
7916
|
-
const txResult = await this.
|
|
8361
|
+
const txResult = await this.createSupplyIntent(params, spokeProvider);
|
|
7917
8362
|
if (!txResult.ok) {
|
|
7918
|
-
return
|
|
7919
|
-
ok: false,
|
|
7920
|
-
error: {
|
|
7921
|
-
code: "SUPPLY_FAILED",
|
|
7922
|
-
error: txResult.error
|
|
7923
|
-
}
|
|
7924
|
-
};
|
|
8363
|
+
return txResult;
|
|
7925
8364
|
}
|
|
7926
8365
|
const packetResult = await relayTxAndWaitPacket(
|
|
7927
8366
|
txResult.value,
|
|
8367
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
7928
8368
|
spokeProvider,
|
|
7929
8369
|
this.config.relayerApiEndpoint,
|
|
7930
8370
|
timeout
|
|
7931
8371
|
);
|
|
7932
8372
|
if (!packetResult.ok) {
|
|
7933
|
-
return
|
|
8373
|
+
return {
|
|
8374
|
+
ok: false,
|
|
8375
|
+
error: {
|
|
8376
|
+
code: packetResult.error.code,
|
|
8377
|
+
data: {
|
|
8378
|
+
error: packetResult.error,
|
|
8379
|
+
payload: txResult.value
|
|
8380
|
+
}
|
|
8381
|
+
}
|
|
8382
|
+
};
|
|
7934
8383
|
}
|
|
7935
8384
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
7936
8385
|
} catch (error) {
|
|
7937
8386
|
return {
|
|
7938
8387
|
ok: false,
|
|
7939
8388
|
error: {
|
|
7940
|
-
code: "
|
|
7941
|
-
|
|
8389
|
+
code: "SUPPLY_UNKNOWN_ERROR",
|
|
8390
|
+
data: {
|
|
8391
|
+
error,
|
|
8392
|
+
payload: params
|
|
8393
|
+
}
|
|
7942
8394
|
}
|
|
7943
8395
|
};
|
|
7944
8396
|
}
|
|
7945
8397
|
}
|
|
7946
8398
|
/**
|
|
7947
|
-
*
|
|
8399
|
+
* Create supply intent only (without submitting to Solver API)
|
|
7948
8400
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
7949
8401
|
* In order to successfully supply tokens, you need to:
|
|
7950
8402
|
* 1. Check if the allowance is sufficient
|
|
@@ -7959,7 +8411,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7959
8411
|
*
|
|
7960
8412
|
* @example
|
|
7961
8413
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
7962
|
-
* const result = await moneyMarketService.
|
|
8414
|
+
* const result = await moneyMarketService.createSupplyIntent(
|
|
7963
8415
|
* {
|
|
7964
8416
|
* token: "0x123...", // token address
|
|
7965
8417
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -7975,7 +8427,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7975
8427
|
* console.error('Supply failed:', result.error);
|
|
7976
8428
|
* }
|
|
7977
8429
|
*/
|
|
7978
|
-
async
|
|
8430
|
+
async createSupplyIntent(params, spokeProvider, raw) {
|
|
7979
8431
|
try {
|
|
7980
8432
|
invariant2(params.action === "supply", "Invalid action");
|
|
7981
8433
|
invariant2(params.token.length > 0, "Token is required");
|
|
@@ -7991,7 +8443,12 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7991
8443
|
this.hubProvider,
|
|
7992
8444
|
spokeProvider
|
|
7993
8445
|
);
|
|
7994
|
-
const data = this.
|
|
8446
|
+
const data = this.buildSupplyData(
|
|
8447
|
+
params.token,
|
|
8448
|
+
hubWallet,
|
|
8449
|
+
params.amount,
|
|
8450
|
+
spokeProvider.chainConfig.chain.id
|
|
8451
|
+
);
|
|
7995
8452
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
7996
8453
|
const txResult = await SpokeService.deposit(
|
|
7997
8454
|
{
|
|
@@ -8007,14 +8464,21 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8007
8464
|
);
|
|
8008
8465
|
return {
|
|
8009
8466
|
ok: true,
|
|
8010
|
-
value: txResult
|
|
8467
|
+
value: txResult,
|
|
8468
|
+
data: {
|
|
8469
|
+
address: hubWallet,
|
|
8470
|
+
payload: data
|
|
8471
|
+
}
|
|
8011
8472
|
};
|
|
8012
8473
|
} catch (error) {
|
|
8013
8474
|
return {
|
|
8014
8475
|
ok: false,
|
|
8015
8476
|
error: {
|
|
8016
|
-
code: "
|
|
8017
|
-
|
|
8477
|
+
code: "CREATE_SUPPLY_INTENT_FAILED",
|
|
8478
|
+
data: {
|
|
8479
|
+
error,
|
|
8480
|
+
payload: params
|
|
8481
|
+
}
|
|
8018
8482
|
}
|
|
8019
8483
|
};
|
|
8020
8484
|
}
|
|
@@ -8024,10 +8488,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8024
8488
|
* @param params - The parameters for the borrow transaction.
|
|
8025
8489
|
* @param spokeProvider - The spoke provider.
|
|
8026
8490
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8027
|
-
* @returns {Promise<Result<[
|
|
8491
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the transaction result and the hub transaction hash or error
|
|
8028
8492
|
*
|
|
8029
8493
|
* @example
|
|
8030
|
-
* const result = await moneyMarketService.
|
|
8494
|
+
* const result = await moneyMarketService.borrow(
|
|
8031
8495
|
* {
|
|
8032
8496
|
* token: '0x...', // Address of the token (spoke chain address) to borrow
|
|
8033
8497
|
* amount: 1000n, // Amount to borrow (in token decimals)
|
|
@@ -8046,40 +8510,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8046
8510
|
* ] = result.value;
|
|
8047
8511
|
* console.log('Borrow transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8048
8512
|
*/
|
|
8049
|
-
async
|
|
8513
|
+
async borrow(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8050
8514
|
try {
|
|
8051
|
-
const txResult = await this.
|
|
8515
|
+
const txResult = await this.createBorrowIntent(params, spokeProvider);
|
|
8052
8516
|
if (!txResult.ok) {
|
|
8053
|
-
return
|
|
8054
|
-
ok: false,
|
|
8055
|
-
error: {
|
|
8056
|
-
code: "BORROW_FAILED",
|
|
8057
|
-
error: txResult.error
|
|
8058
|
-
}
|
|
8059
|
-
};
|
|
8517
|
+
return txResult;
|
|
8060
8518
|
}
|
|
8061
8519
|
const packetResult = await relayTxAndWaitPacket(
|
|
8062
8520
|
txResult.value,
|
|
8521
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8063
8522
|
spokeProvider,
|
|
8064
8523
|
this.config.relayerApiEndpoint,
|
|
8065
8524
|
timeout
|
|
8066
8525
|
);
|
|
8067
8526
|
if (!packetResult.ok) {
|
|
8068
|
-
return
|
|
8527
|
+
return {
|
|
8528
|
+
ok: false,
|
|
8529
|
+
error: {
|
|
8530
|
+
code: packetResult.error.code,
|
|
8531
|
+
data: {
|
|
8532
|
+
error: packetResult.error,
|
|
8533
|
+
payload: txResult.value
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8536
|
+
};
|
|
8069
8537
|
}
|
|
8070
8538
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8071
8539
|
} catch (error) {
|
|
8072
8540
|
return {
|
|
8073
8541
|
ok: false,
|
|
8074
8542
|
error: {
|
|
8075
|
-
code: "
|
|
8076
|
-
|
|
8543
|
+
code: "BORROW_UNKNOWN_ERROR",
|
|
8544
|
+
data: {
|
|
8545
|
+
error,
|
|
8546
|
+
payload: params
|
|
8547
|
+
}
|
|
8077
8548
|
}
|
|
8078
8549
|
};
|
|
8079
8550
|
}
|
|
8080
8551
|
}
|
|
8081
8552
|
/**
|
|
8082
|
-
*
|
|
8553
|
+
* Create borrow intent only (without submitting to Solver API)
|
|
8083
8554
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8084
8555
|
* In order to successfully borrow tokens, you need to:
|
|
8085
8556
|
* 1. Execute the borrow transaction on the spoke chain
|
|
@@ -8092,13 +8563,13 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8092
8563
|
*
|
|
8093
8564
|
* @example
|
|
8094
8565
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8095
|
-
* const result = await moneyMarketService.
|
|
8566
|
+
* const result = await moneyMarketService.createBorrowIntent(
|
|
8096
8567
|
* {
|
|
8097
8568
|
* token: "0x123...", // token address
|
|
8098
8569
|
* amount: 1000000000000000000n // 1 token in wei
|
|
8099
8570
|
* },
|
|
8100
8571
|
* spokeProvider,
|
|
8101
|
-
* raw // Optional: true = return the raw transaction data, false =
|
|
8572
|
+
* raw // Optional: true = return the raw transaction data, false = execute and return the transaction hash (default: false)
|
|
8102
8573
|
* );
|
|
8103
8574
|
*
|
|
8104
8575
|
* if (result.ok) {
|
|
@@ -8108,7 +8579,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8108
8579
|
* console.error('Borrow failed:', result.error);
|
|
8109
8580
|
* }
|
|
8110
8581
|
*/
|
|
8111
|
-
async
|
|
8582
|
+
async createBorrowIntent(params, spokeProvider, raw) {
|
|
8112
8583
|
invariant2(params.action === "borrow", "Invalid action");
|
|
8113
8584
|
invariant2(params.token.length > 0, "Token is required");
|
|
8114
8585
|
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8123,7 +8594,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8123
8594
|
this.hubProvider,
|
|
8124
8595
|
spokeProvider
|
|
8125
8596
|
);
|
|
8126
|
-
const data = this.
|
|
8597
|
+
const data = this.buildBorrowData(
|
|
8127
8598
|
hubWallet,
|
|
8128
8599
|
walletAddressBytes,
|
|
8129
8600
|
params.token,
|
|
@@ -8131,7 +8602,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8131
8602
|
spokeProvider.chainConfig.chain.id
|
|
8132
8603
|
);
|
|
8133
8604
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
8134
|
-
return {
|
|
8605
|
+
return {
|
|
8606
|
+
ok: true,
|
|
8607
|
+
value: txResult,
|
|
8608
|
+
data: {
|
|
8609
|
+
address: hubWallet,
|
|
8610
|
+
payload: data
|
|
8611
|
+
}
|
|
8612
|
+
};
|
|
8135
8613
|
}
|
|
8136
8614
|
/**
|
|
8137
8615
|
* Withdraw tokens from the money market pool, relay the transaction to the hub and submit the intent to the Solver API
|
|
@@ -8139,10 +8617,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8139
8617
|
* @param params - The parameters for the withdraw transaction.
|
|
8140
8618
|
* @param spokeProvider - The spoke provider.
|
|
8141
8619
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8142
|
-
* @returns {Promise<Result<[
|
|
8620
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the spoke and hub transaction hashes or error
|
|
8143
8621
|
*
|
|
8144
8622
|
* @example
|
|
8145
|
-
* const result = await moneyMarketService.
|
|
8623
|
+
* const result = await moneyMarketService.withdraw(
|
|
8146
8624
|
* {
|
|
8147
8625
|
* token: '0x...', // Address of the token (spoke chain address) to withdraw
|
|
8148
8626
|
* amount: 1000n, // Amount to withdraw (in token decimals)
|
|
@@ -8161,40 +8639,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8161
8639
|
* ] = result.value;
|
|
8162
8640
|
* console.log('Withdraw transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8163
8641
|
*/
|
|
8164
|
-
async
|
|
8642
|
+
async withdraw(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8165
8643
|
try {
|
|
8166
|
-
const txResult = await this.
|
|
8644
|
+
const txResult = await this.createWithdrawIntent(params, spokeProvider);
|
|
8167
8645
|
if (!txResult.ok) {
|
|
8168
|
-
return
|
|
8169
|
-
ok: false,
|
|
8170
|
-
error: {
|
|
8171
|
-
code: "WITHDRAW_FAILED",
|
|
8172
|
-
error: txResult.error
|
|
8173
|
-
}
|
|
8174
|
-
};
|
|
8646
|
+
return txResult;
|
|
8175
8647
|
}
|
|
8176
8648
|
const packetResult = await relayTxAndWaitPacket(
|
|
8177
8649
|
txResult.value,
|
|
8650
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8178
8651
|
spokeProvider,
|
|
8179
8652
|
this.config.relayerApiEndpoint,
|
|
8180
8653
|
timeout
|
|
8181
8654
|
);
|
|
8182
8655
|
if (!packetResult.ok) {
|
|
8183
|
-
return
|
|
8656
|
+
return {
|
|
8657
|
+
ok: false,
|
|
8658
|
+
error: {
|
|
8659
|
+
code: packetResult.error.code,
|
|
8660
|
+
data: {
|
|
8661
|
+
error: packetResult.error,
|
|
8662
|
+
payload: txResult.value
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
};
|
|
8184
8666
|
}
|
|
8185
8667
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8186
8668
|
} catch (error) {
|
|
8187
8669
|
return {
|
|
8188
8670
|
ok: false,
|
|
8189
8671
|
error: {
|
|
8190
|
-
code: "
|
|
8191
|
-
|
|
8672
|
+
code: "WITHDRAW_UNKNOWN_ERROR",
|
|
8673
|
+
data: {
|
|
8674
|
+
error,
|
|
8675
|
+
payload: params
|
|
8676
|
+
}
|
|
8192
8677
|
}
|
|
8193
8678
|
};
|
|
8194
8679
|
}
|
|
8195
8680
|
}
|
|
8196
8681
|
/**
|
|
8197
|
-
*
|
|
8682
|
+
* Create withdraw intent only (without submitting to Solver API)
|
|
8198
8683
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8199
8684
|
* In order to successfully withdraw tokens, you need to:
|
|
8200
8685
|
* 1. Execute the withdraw transaction on the spoke chain
|
|
@@ -8207,7 +8692,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8207
8692
|
*
|
|
8208
8693
|
* @example
|
|
8209
8694
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8210
|
-
* const result = await moneyMarketService.
|
|
8695
|
+
* const result = await moneyMarketService.createWithdrawIntent(
|
|
8211
8696
|
* {
|
|
8212
8697
|
* token: "0x123...", // token address
|
|
8213
8698
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -8223,7 +8708,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8223
8708
|
* console.error('Withdraw failed:', result.error);
|
|
8224
8709
|
* }
|
|
8225
8710
|
*/
|
|
8226
|
-
async
|
|
8711
|
+
async createWithdrawIntent(params, spokeProvider, raw) {
|
|
8227
8712
|
invariant2(params.action === "withdraw", "Invalid action");
|
|
8228
8713
|
invariant2(params.token.length > 0, "Token is required");
|
|
8229
8714
|
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8238,7 +8723,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8238
8723
|
this.hubProvider,
|
|
8239
8724
|
spokeProvider
|
|
8240
8725
|
);
|
|
8241
|
-
const data = this.
|
|
8726
|
+
const data = this.buildWithdrawData(
|
|
8242
8727
|
hubWallet,
|
|
8243
8728
|
walletAddressBytes,
|
|
8244
8729
|
params.token,
|
|
@@ -8246,7 +8731,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8246
8731
|
spokeProvider.chainConfig.chain.id
|
|
8247
8732
|
);
|
|
8248
8733
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
8249
|
-
return {
|
|
8734
|
+
return {
|
|
8735
|
+
ok: true,
|
|
8736
|
+
value: txResult,
|
|
8737
|
+
data: {
|
|
8738
|
+
address: hubWallet,
|
|
8739
|
+
payload: data
|
|
8740
|
+
}
|
|
8741
|
+
};
|
|
8250
8742
|
}
|
|
8251
8743
|
/**
|
|
8252
8744
|
* Repay tokens to the money market pool, relay the transaction to the hub and submit the intent to the Solver API
|
|
@@ -8254,10 +8746,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8254
8746
|
* @param params - The parameters for the repay transaction.
|
|
8255
8747
|
* @param spokeProvider - The spoke provider.
|
|
8256
8748
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8257
|
-
* @returns {Promise<Result<[
|
|
8749
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the spoke and hub transaction hashes or error
|
|
8258
8750
|
*
|
|
8259
8751
|
* @example
|
|
8260
|
-
* const result = await moneyMarketService.
|
|
8752
|
+
* const result = await moneyMarketService.repay(
|
|
8261
8753
|
* {
|
|
8262
8754
|
* token: '0x...', // Address of the token (spoke chain address) to repay
|
|
8263
8755
|
* amount: 1000n, // Amount to repay (in token decimals)
|
|
@@ -8276,40 +8768,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8276
8768
|
* ] = result.value;
|
|
8277
8769
|
* console.log('Repay transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8278
8770
|
*/
|
|
8279
|
-
async
|
|
8771
|
+
async repay(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8280
8772
|
try {
|
|
8281
|
-
const txResult = await this.
|
|
8773
|
+
const txResult = await this.createRepayIntent(params, spokeProvider);
|
|
8282
8774
|
if (!txResult.ok) {
|
|
8283
|
-
return
|
|
8284
|
-
ok: false,
|
|
8285
|
-
error: {
|
|
8286
|
-
code: "REPAY_FAILED",
|
|
8287
|
-
error: txResult.error
|
|
8288
|
-
}
|
|
8289
|
-
};
|
|
8775
|
+
return txResult;
|
|
8290
8776
|
}
|
|
8291
8777
|
const packetResult = await relayTxAndWaitPacket(
|
|
8292
8778
|
txResult.value,
|
|
8779
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8293
8780
|
spokeProvider,
|
|
8294
8781
|
this.config.relayerApiEndpoint,
|
|
8295
8782
|
timeout
|
|
8296
8783
|
);
|
|
8297
8784
|
if (!packetResult.ok) {
|
|
8298
|
-
return
|
|
8785
|
+
return {
|
|
8786
|
+
ok: false,
|
|
8787
|
+
error: {
|
|
8788
|
+
code: packetResult.error.code,
|
|
8789
|
+
data: {
|
|
8790
|
+
error: packetResult.error,
|
|
8791
|
+
payload: txResult.value
|
|
8792
|
+
}
|
|
8793
|
+
}
|
|
8794
|
+
};
|
|
8299
8795
|
}
|
|
8300
8796
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8301
8797
|
} catch (error) {
|
|
8302
8798
|
return {
|
|
8303
8799
|
ok: false,
|
|
8304
8800
|
error: {
|
|
8305
|
-
code: "
|
|
8306
|
-
|
|
8801
|
+
code: "REPAY_UNKNOWN_ERROR",
|
|
8802
|
+
data: {
|
|
8803
|
+
error,
|
|
8804
|
+
payload: params
|
|
8805
|
+
}
|
|
8307
8806
|
}
|
|
8308
8807
|
};
|
|
8309
8808
|
}
|
|
8310
8809
|
}
|
|
8311
8810
|
/**
|
|
8312
|
-
*
|
|
8811
|
+
* Create repay intent only (without submitting to Solver API)
|
|
8313
8812
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8314
8813
|
* In order to successfully repay tokens, you need to:
|
|
8315
8814
|
* 1. Check if the allowance is sufficient
|
|
@@ -8324,7 +8823,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8324
8823
|
*
|
|
8325
8824
|
* @example
|
|
8326
8825
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8327
|
-
* const result = await moneyMarketService.
|
|
8826
|
+
* const result = await moneyMarketService.createRepayIntent(
|
|
8328
8827
|
* {
|
|
8329
8828
|
* token: "0x123...", // token address
|
|
8330
8829
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -8340,7 +8839,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8340
8839
|
* console.error('Repay failed:', result.error);
|
|
8341
8840
|
* }
|
|
8342
8841
|
*/
|
|
8343
|
-
async
|
|
8842
|
+
async createRepayIntent(params, spokeProvider, raw) {
|
|
8344
8843
|
invariant2(params.action === "repay", "Invalid action");
|
|
8345
8844
|
invariant2(params.token.length > 0, "Token is required");
|
|
8346
8845
|
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8355,7 +8854,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8355
8854
|
this.hubProvider,
|
|
8356
8855
|
spokeProvider
|
|
8357
8856
|
);
|
|
8358
|
-
const data = this.
|
|
8857
|
+
const data = this.buildRepayData(params.token, hubWallet, params.amount, spokeProvider.chainConfig.chain.id);
|
|
8359
8858
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
8360
8859
|
const txResult = await SpokeService.deposit(
|
|
8361
8860
|
{
|
|
@@ -8369,7 +8868,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8369
8868
|
this.hubProvider,
|
|
8370
8869
|
raw
|
|
8371
8870
|
);
|
|
8372
|
-
return {
|
|
8871
|
+
return {
|
|
8872
|
+
ok: true,
|
|
8873
|
+
value: txResult,
|
|
8874
|
+
data: {
|
|
8875
|
+
address: hubWallet,
|
|
8876
|
+
payload: data
|
|
8877
|
+
}
|
|
8878
|
+
};
|
|
8373
8879
|
}
|
|
8374
8880
|
/**
|
|
8375
8881
|
* Build transaction data for supplying to the money market pool
|
|
@@ -8379,7 +8885,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8379
8885
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8380
8886
|
* @returns {Hex} The transaction data.
|
|
8381
8887
|
*/
|
|
8382
|
-
|
|
8888
|
+
buildSupplyData(token, to, amount, spokeChainId) {
|
|
8383
8889
|
const calls = [];
|
|
8384
8890
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8385
8891
|
invariant2(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
@@ -8407,7 +8913,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8407
8913
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8408
8914
|
* @returns {Hex} The transaction data.
|
|
8409
8915
|
*/
|
|
8410
|
-
|
|
8916
|
+
buildBorrowData(from, to, token, amount, spokeChainId) {
|
|
8411
8917
|
invariant2(isValidSpokeChainId(spokeChainId), `Invalid spokeChainId: ${spokeChainId}`);
|
|
8412
8918
|
invariant2(
|
|
8413
8919
|
isValidOriginalAssetAddress(spokeChainId, token),
|
|
@@ -8482,7 +8988,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8482
8988
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8483
8989
|
* @returns {Hex} The transaction data.
|
|
8484
8990
|
*/
|
|
8485
|
-
|
|
8991
|
+
buildWithdrawData(from, to, token, amount, spokeChainId) {
|
|
8486
8992
|
const calls = [];
|
|
8487
8993
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8488
8994
|
if (!assetConfig) {
|
|
@@ -8533,11 +9039,11 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8533
9039
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8534
9040
|
* @returns {Hex} The transaction data.
|
|
8535
9041
|
*/
|
|
8536
|
-
|
|
9042
|
+
buildRepayData(token, to, amount, spokeChainId) {
|
|
8537
9043
|
const calls = [];
|
|
8538
9044
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8539
9045
|
if (!assetConfig) {
|
|
8540
|
-
throw new Error("[
|
|
9046
|
+
throw new Error("[buildRepayData] Hub asset not found");
|
|
8541
9047
|
}
|
|
8542
9048
|
const assetAddress = assetConfig.asset;
|
|
8543
9049
|
const vaultAddress = assetConfig.vault;
|
|
@@ -9037,10 +9543,7 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
9037
9543
|
}
|
|
9038
9544
|
return spokeProvider.walletProvider.sendTransaction({
|
|
9039
9545
|
from: walletAddress,
|
|
9040
|
-
to: isNativeToken(spokeProvider.chainConfig.chain.id, token) ?
|
|
9041
|
-
// wICX address
|
|
9042
|
-
"cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
|
|
9043
|
-
) : token,
|
|
9546
|
+
to: isNativeToken(spokeProvider.chainConfig.chain.id, token) ? spokeProvider.chainConfig.addresses.wICX : token,
|
|
9044
9547
|
value,
|
|
9045
9548
|
nid: spokeProvider.chainConfig.nid,
|
|
9046
9549
|
method: "transfer",
|
|
@@ -9160,7 +9663,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9160
9663
|
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
9161
9664
|
const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9162
9665
|
spokeProvider.chainConfig.chain.id,
|
|
9163
|
-
|
|
9666
|
+
encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9164
9667
|
hubProvider
|
|
9165
9668
|
);
|
|
9166
9669
|
return _SolanaSpokeService.transfer(
|
|
@@ -9168,7 +9671,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9168
9671
|
token: new PublicKey(params.token),
|
|
9169
9672
|
recipient: userWallet,
|
|
9170
9673
|
amount: params.amount.toString(),
|
|
9171
|
-
data: params.data
|
|
9674
|
+
data: keccak256(params.data)
|
|
9172
9675
|
},
|
|
9173
9676
|
spokeProvider,
|
|
9174
9677
|
raw
|
|
@@ -9202,7 +9705,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9202
9705
|
*/
|
|
9203
9706
|
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
9204
9707
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9205
|
-
return _SolanaSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
9708
|
+
return _SolanaSpokeService.call(BigInt(relayId), from, keccak256(payload), spokeProvider, raw);
|
|
9206
9709
|
}
|
|
9207
9710
|
static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
|
|
9208
9711
|
let depositInstruction;
|
|
@@ -9755,9 +10258,9 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
9755
10258
|
}
|
|
9756
10259
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
9757
10260
|
}
|
|
9758
|
-
static async
|
|
10261
|
+
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
|
|
9759
10262
|
const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
9760
|
-
const withdrawCall = moneyMarketService.
|
|
10263
|
+
const withdrawCall = moneyMarketService.buildWithdrawData(
|
|
9761
10264
|
userRouter,
|
|
9762
10265
|
from,
|
|
9763
10266
|
withdrawInfo.token,
|
|
@@ -9858,6 +10361,51 @@ function isConfiguredSolverConfig(value) {
|
|
|
9858
10361
|
function isConfiguredMoneyMarketConfig(value) {
|
|
9859
10362
|
return typeof value === "object" && value !== null && "lendingPool" in value && "uiPoolDataProvider" in value && "poolAddressesProvider" in value && "bnUSD" in value && "bnUSDVault" in value;
|
|
9860
10363
|
}
|
|
10364
|
+
function isIntentCreationFailedError(error) {
|
|
10365
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATION_FAILED" && "data" in error && typeof error.data === "object" && error.data !== null && "payload" in error.data && "error" in error.data;
|
|
10366
|
+
}
|
|
10367
|
+
function isIntentSubmitTxFailedError(error) {
|
|
10368
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SUBMIT_TX_FAILED" && "data" in error && typeof error.data === "object" && error.data !== null && "payload" in error.data && "error" in error.data;
|
|
10369
|
+
}
|
|
10370
|
+
function isIntentPostExecutionFailedError(error) {
|
|
10371
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "POST_EXECUTION_FAILED" && "data" in error && typeof error.data === "object" && error.data !== null && "detail" in error.data;
|
|
10372
|
+
}
|
|
10373
|
+
function isWaitUntilIntentExecutedFailed(error) {
|
|
10374
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "RELAY_TIMEOUT" && "data" in error && typeof error.data === "object" && error.data !== null && "payload" in error.data && "error" in error.data;
|
|
10375
|
+
}
|
|
10376
|
+
function isIntentCreationUnknownError(error) {
|
|
10377
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "UNKNOWN" && "data" in error && typeof error.data === "object" && error.data !== null && "payload" in error.data && "error" in error.data;
|
|
10378
|
+
}
|
|
10379
|
+
function isMoneyMarketSubmitTxFailedError(error) {
|
|
10380
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SUBMIT_TX_FAILED";
|
|
10381
|
+
}
|
|
10382
|
+
function isMoneyMarketRelayTimeoutError(error) {
|
|
10383
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "RELAY_TIMEOUT";
|
|
10384
|
+
}
|
|
10385
|
+
function isMoneyMarketCreateSupplyIntentFailedError(error) {
|
|
10386
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_SUPPLY_INTENT_FAILED";
|
|
10387
|
+
}
|
|
10388
|
+
function isMoneyMarketCreateBorrowIntentFailedError(error) {
|
|
10389
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_BORROW_INTENT_FAILED";
|
|
10390
|
+
}
|
|
10391
|
+
function isMoneyMarketCreateWithdrawIntentFailedError(error) {
|
|
10392
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_WITHDRAW_INTENT_FAILED";
|
|
10393
|
+
}
|
|
10394
|
+
function isMoneyMarketCreateRepayIntentFailedError(error) {
|
|
10395
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_REPAY_INTENT_FAILED";
|
|
10396
|
+
}
|
|
10397
|
+
function isMoneyMarketSupplyUnknownError(error) {
|
|
10398
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SUPPLY_UNKNOWN_ERROR";
|
|
10399
|
+
}
|
|
10400
|
+
function isMoneyMarketBorrowUnknownError(error) {
|
|
10401
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "BORROW_UNKNOWN_ERROR";
|
|
10402
|
+
}
|
|
10403
|
+
function isMoneyMarketWithdrawUnknownError(error) {
|
|
10404
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "WITHDRAW_UNKNOWN_ERROR";
|
|
10405
|
+
}
|
|
10406
|
+
function isMoneyMarketRepayUnknownError(error) {
|
|
10407
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "REPAY_UNKNOWN_ERROR";
|
|
10408
|
+
}
|
|
9861
10409
|
|
|
9862
10410
|
// src/services/spoke/SpokeService.ts
|
|
9863
10411
|
var SpokeService = class {
|
|
@@ -10054,12 +10602,12 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10054
10602
|
} catch (e) {
|
|
10055
10603
|
console.error("Error getting transaction packets", e);
|
|
10056
10604
|
}
|
|
10057
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
10605
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
10058
10606
|
}
|
|
10059
10607
|
return {
|
|
10060
10608
|
ok: false,
|
|
10061
10609
|
error: {
|
|
10062
|
-
code: "
|
|
10610
|
+
code: "RELAY_TIMEOUT",
|
|
10063
10611
|
data: {
|
|
10064
10612
|
payload,
|
|
10065
10613
|
error: {
|
|
@@ -10073,7 +10621,7 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10073
10621
|
return {
|
|
10074
10622
|
ok: false,
|
|
10075
10623
|
error: {
|
|
10076
|
-
code: "
|
|
10624
|
+
code: "RELAY_TIMEOUT",
|
|
10077
10625
|
data: {
|
|
10078
10626
|
payload,
|
|
10079
10627
|
error: e
|
|
@@ -10082,12 +10630,16 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10082
10630
|
};
|
|
10083
10631
|
}
|
|
10084
10632
|
}
|
|
10085
|
-
async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
10633
|
+
async function relayTxAndWaitPacket(spokeTxHash, data, spokeProvider, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
10086
10634
|
try {
|
|
10087
10635
|
const intentRelayChainId = getIntentRelayChainId(spokeProvider.chainConfig.chain.id).toString();
|
|
10088
10636
|
const submitPayload = {
|
|
10089
10637
|
action: "submit",
|
|
10090
|
-
params: {
|
|
10638
|
+
params: data ? {
|
|
10639
|
+
chain_id: intentRelayChainId,
|
|
10640
|
+
tx_hash: spokeTxHash,
|
|
10641
|
+
data
|
|
10642
|
+
} : {
|
|
10091
10643
|
chain_id: intentRelayChainId,
|
|
10092
10644
|
tx_hash: spokeTxHash
|
|
10093
10645
|
}
|
|
@@ -10112,7 +10664,7 @@ async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoi
|
|
|
10112
10664
|
return {
|
|
10113
10665
|
ok: false,
|
|
10114
10666
|
error: {
|
|
10115
|
-
code: "
|
|
10667
|
+
code: "RELAY_TIMEOUT",
|
|
10116
10668
|
error: packet.error
|
|
10117
10669
|
}
|
|
10118
10670
|
};
|
|
@@ -10125,7 +10677,7 @@ async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoi
|
|
|
10125
10677
|
return {
|
|
10126
10678
|
ok: false,
|
|
10127
10679
|
error: {
|
|
10128
|
-
code: "
|
|
10680
|
+
code: "SUBMIT_TX_FAILED",
|
|
10129
10681
|
error
|
|
10130
10682
|
}
|
|
10131
10683
|
};
|
|
@@ -10163,6 +10715,8 @@ var EvmSolverService = class _EvmSolverService {
|
|
|
10163
10715
|
outputToken,
|
|
10164
10716
|
srcChain: getIntentRelayChainId(createIntentParams.srcChain),
|
|
10165
10717
|
dstChain: getIntentRelayChainId(createIntentParams.dstChain),
|
|
10718
|
+
srcAddress: encodeAddress(createIntentParams.srcChain, createIntentParams.srcAddress),
|
|
10719
|
+
dstAddress: encodeAddress(createIntentParams.dstChain, createIntentParams.dstAddress),
|
|
10166
10720
|
intentId: randomUint256(),
|
|
10167
10721
|
creator: creatorHubWalletAddress,
|
|
10168
10722
|
data: feeData
|
|
@@ -10390,7 +10944,7 @@ var SolverApiService = class {
|
|
|
10390
10944
|
* }
|
|
10391
10945
|
* }
|
|
10392
10946
|
*/
|
|
10393
|
-
static async postExecution(
|
|
10947
|
+
static async postExecution(request, config) {
|
|
10394
10948
|
try {
|
|
10395
10949
|
const response = await retry(
|
|
10396
10950
|
() => fetch(`${config.solverApiEndpoint}/execute`, {
|
|
@@ -10398,7 +10952,7 @@ var SolverApiService = class {
|
|
|
10398
10952
|
headers: {
|
|
10399
10953
|
"Content-Type": "application/json"
|
|
10400
10954
|
},
|
|
10401
|
-
body: JSON.stringify(
|
|
10955
|
+
body: JSON.stringify(request)
|
|
10402
10956
|
})
|
|
10403
10957
|
);
|
|
10404
10958
|
if (!response.ok) {
|
|
@@ -10424,15 +10978,15 @@ var SolverApiService = class {
|
|
|
10424
10978
|
};
|
|
10425
10979
|
}
|
|
10426
10980
|
}
|
|
10427
|
-
static async getStatus(
|
|
10428
|
-
invariant2(
|
|
10981
|
+
static async getStatus(request, config) {
|
|
10982
|
+
invariant2(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
|
|
10429
10983
|
try {
|
|
10430
10984
|
const response = await fetch(`${config.solverApiEndpoint}/status`, {
|
|
10431
10985
|
method: "POST",
|
|
10432
10986
|
headers: {
|
|
10433
10987
|
"Content-Type": "application/json"
|
|
10434
10988
|
},
|
|
10435
|
-
body: JSON.stringify(
|
|
10989
|
+
body: JSON.stringify(request)
|
|
10436
10990
|
});
|
|
10437
10991
|
if (!response.ok) {
|
|
10438
10992
|
return {
|
|
@@ -10491,8 +11045,8 @@ var SolverService = class {
|
|
|
10491
11045
|
}
|
|
10492
11046
|
/**
|
|
10493
11047
|
* Request a quote from the solver API
|
|
10494
|
-
* @param {
|
|
10495
|
-
* @returns {Promise<Result<
|
|
11048
|
+
* @param {SolverIntentQuoteRequest} payload - The solver intent quote request
|
|
11049
|
+
* @returns {Promise<Result<SolverIntentQuoteResponse, SolverErrorResponse>>} The intent quote response
|
|
10496
11050
|
*
|
|
10497
11051
|
* @example
|
|
10498
11052
|
* const payload = {
|
|
@@ -10502,7 +11056,7 @@ var SolverService = class {
|
|
|
10502
11056
|
* "token_dst_blockchain_id":"0xa4b1.arbitrum",
|
|
10503
11057
|
* "amount":1000000000000000n,
|
|
10504
11058
|
* "quote_type": "exact_input"
|
|
10505
|
-
* } satisfies
|
|
11059
|
+
* } satisfies SolverIntentQuoteRequest
|
|
10506
11060
|
*
|
|
10507
11061
|
* const response = await solverService.getQuote(payload);
|
|
10508
11062
|
*
|
|
@@ -10533,15 +11087,16 @@ var SolverService = class {
|
|
|
10533
11087
|
}
|
|
10534
11088
|
/**
|
|
10535
11089
|
* Get the status of an intent from Solver API
|
|
10536
|
-
*
|
|
10537
|
-
* @
|
|
11090
|
+
* NOTE: intentHash should be retrieved from relay packet dst_tx_hash property (see createAndSubmitIntent)
|
|
11091
|
+
* @param {SolverIntentStatusRequest} request - The intent status request
|
|
11092
|
+
* @returns {Promise<Result<SolverIntentStatusResponse, SolverErrorResponse>>} The solver intent status response
|
|
10538
11093
|
*
|
|
10539
11094
|
* @example
|
|
10540
|
-
* const
|
|
10541
|
-
* "
|
|
10542
|
-
* } satisfies
|
|
11095
|
+
* const request = {
|
|
11096
|
+
* "intent_tx_hash": "a0dd7652-b360-4123-ab2d-78cfbcd20c6b" // destination tx hash from relay packet
|
|
11097
|
+
* } satisfies SolverIntentStatusRequest
|
|
10543
11098
|
*
|
|
10544
|
-
* const response = await solverService.getStatus(
|
|
11099
|
+
* const response = await solverService.getStatus(request);
|
|
10545
11100
|
*
|
|
10546
11101
|
* if (response.ok) {
|
|
10547
11102
|
* const { status, intent_hash } = response.value;
|
|
@@ -10551,20 +11106,20 @@ var SolverService = class {
|
|
|
10551
11106
|
* // handle error
|
|
10552
11107
|
* }
|
|
10553
11108
|
*/
|
|
10554
|
-
async getStatus(
|
|
10555
|
-
return SolverApiService.getStatus(
|
|
11109
|
+
async getStatus(request) {
|
|
11110
|
+
return SolverApiService.getStatus(request, this.config);
|
|
10556
11111
|
}
|
|
10557
11112
|
/**
|
|
10558
11113
|
* Post execution of intent order transaction executed on hub chain to Solver API
|
|
10559
|
-
* @param {
|
|
10560
|
-
* @returns {Promise<Result<
|
|
11114
|
+
* @param {SolverExecutionRequest} request - The intent execution request
|
|
11115
|
+
* @returns {Promise<Result<SolverExecutionResponse, SolverErrorResponse>>} The intent execution response
|
|
10561
11116
|
*
|
|
10562
11117
|
* @example
|
|
10563
|
-
* const
|
|
11118
|
+
* const request = {
|
|
10564
11119
|
* "intent_tx_hash": "0xba3dce19347264db32ced212ff1a2036f20d9d2c7493d06af15027970be061af",
|
|
10565
|
-
* } satisfies
|
|
11120
|
+
* } satisfies SolverExecutionRequest
|
|
10566
11121
|
*
|
|
10567
|
-
* const response = await solverService.postExecution(
|
|
11122
|
+
* const response = await solverService.postExecution(request);
|
|
10568
11123
|
*
|
|
10569
11124
|
* if (response.ok) {
|
|
10570
11125
|
* const { answer, intent_hash } = response.value;
|
|
@@ -10574,28 +11129,121 @@ var SolverService = class {
|
|
|
10574
11129
|
* // handle error
|
|
10575
11130
|
* }
|
|
10576
11131
|
*/
|
|
10577
|
-
async postExecution(
|
|
10578
|
-
return SolverApiService.postExecution(
|
|
11132
|
+
async postExecution(request) {
|
|
11133
|
+
return SolverApiService.postExecution(request, this.config);
|
|
10579
11134
|
}
|
|
10580
11135
|
/**
|
|
10581
|
-
*
|
|
10582
|
-
* @param {
|
|
10583
|
-
* @
|
|
10584
|
-
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
10585
|
-
* @returns {Promise<Result<[IntentExecutionResponse, Intent, PacketData], IntentSubmitError<IntentSubmitErrorCode>>>} The intent execution response, intent, and packet data
|
|
11136
|
+
* Submit intent transaction to the relayer API
|
|
11137
|
+
* @param {IntentRelayRequest<'submit'>} submitPayload - The intent relay request
|
|
11138
|
+
* @returns {Promise<Result<GetRelayResponse<'submit'>, IntentError<'SUBMIT_TX_FAILED'>>>} The intent relay response
|
|
10586
11139
|
*
|
|
10587
11140
|
* @example
|
|
10588
|
-
* const
|
|
10589
|
-
* "
|
|
10590
|
-
* "
|
|
11141
|
+
* const submitPayload = {
|
|
11142
|
+
* "action": "submit",
|
|
11143
|
+
* "params": {
|
|
11144
|
+
* "chain_id": "0x38.bsc",
|
|
11145
|
+
* "tx_hash": "0xba3dce19347264db32ced212ff1a2036f20d9d2c7493d06af15027970be061af",
|
|
11146
|
+
* },
|
|
11147
|
+
* } satisfies IntentRelayRequest<'submit'>;
|
|
11148
|
+
*
|
|
11149
|
+
* const submitResult = await solverService.submitIntent(submitPayload);
|
|
11150
|
+
*
|
|
11151
|
+
* if (submitResult.ok) {
|
|
11152
|
+
* const { success, message } = submitResult.value;
|
|
11153
|
+
* console.log('Success:', success);
|
|
11154
|
+
* console.log('Message:', message);
|
|
11155
|
+
* } else {
|
|
11156
|
+
* // handle error
|
|
11157
|
+
* }
|
|
11158
|
+
*/
|
|
11159
|
+
async submitIntent(submitPayload) {
|
|
11160
|
+
try {
|
|
11161
|
+
const submitResult = await submitTransaction(submitPayload, this.config.relayerApiEndpoint);
|
|
11162
|
+
if (!submitResult.success) {
|
|
11163
|
+
return {
|
|
11164
|
+
ok: false,
|
|
11165
|
+
error: {
|
|
11166
|
+
code: "SUBMIT_TX_FAILED",
|
|
11167
|
+
data: {
|
|
11168
|
+
payload: submitPayload,
|
|
11169
|
+
error: new Error(submitResult.message)
|
|
11170
|
+
}
|
|
11171
|
+
}
|
|
11172
|
+
};
|
|
11173
|
+
}
|
|
11174
|
+
return {
|
|
11175
|
+
ok: true,
|
|
11176
|
+
value: submitResult
|
|
11177
|
+
};
|
|
11178
|
+
} catch (error) {
|
|
11179
|
+
return {
|
|
11180
|
+
ok: false,
|
|
11181
|
+
error: {
|
|
11182
|
+
code: "SUBMIT_TX_FAILED",
|
|
11183
|
+
data: {
|
|
11184
|
+
payload: submitPayload,
|
|
11185
|
+
error
|
|
11186
|
+
}
|
|
11187
|
+
}
|
|
11188
|
+
};
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
11191
|
+
/**
|
|
11192
|
+
* Swap is a syntatic sugar for createAndSubmitIntent that creates an intent and submits it to the Solver API and Relayer API
|
|
11193
|
+
* @param {CreateIntentParams} payload - The intent to create
|
|
11194
|
+
* @param {ISpokeProvider} spokeProvider - The spoke provider
|
|
11195
|
+
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
11196
|
+
* @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
|
|
11197
|
+
*
|
|
11198
|
+
* @example
|
|
11199
|
+
* const payload = {
|
|
11200
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
11201
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
11202
|
+
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
11203
|
+
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
11204
|
+
* "deadline": 0n, // Optional timestamp after which intent expires (0 = no deadline)
|
|
11205
|
+
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
11206
|
+
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
11207
|
+
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
11208
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11209
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
11210
|
+
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
11211
|
+
* "data": "0x..", // Additional arbitrary data
|
|
11212
|
+
* } satisfies CreateIntentParams;
|
|
11213
|
+
*
|
|
11214
|
+
* const swapResult = await solverService.swap(payload, spokeProvider);
|
|
11215
|
+
*
|
|
11216
|
+
* if (swapResult.ok) {
|
|
11217
|
+
* const [solverExecutionResponse, intent, packetData] = swapResult.value;
|
|
11218
|
+
* console.log('Intent execution response:', solverExecutionResponse);
|
|
11219
|
+
* console.log('Intent:', intent);
|
|
11220
|
+
* console.log('Packet data:', packetData);
|
|
11221
|
+
* } else {
|
|
11222
|
+
* // handle error
|
|
11223
|
+
* }
|
|
11224
|
+
*/
|
|
11225
|
+
async swap(payload, spokeProvider, fee, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
11226
|
+
return this.createAndSubmitIntent(payload, spokeProvider, fee, timeout);
|
|
11227
|
+
}
|
|
11228
|
+
/**
|
|
11229
|
+
* Creates an intent and submits it to the Solver API and Relayer API
|
|
11230
|
+
* @param {CreateIntentParams} payload - The intent to create
|
|
11231
|
+
* @param {ISpokeProvider} spokeProvider - The spoke provider
|
|
11232
|
+
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
11233
|
+
* @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
|
|
11234
|
+
*
|
|
11235
|
+
* @example
|
|
11236
|
+
* const payload = {
|
|
11237
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
11238
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
10591
11239
|
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
10592
11240
|
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
10593
11241
|
* "deadline": 0n, // Optional timestamp after which intent expires (0 = no deadline)
|
|
10594
11242
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10595
11243
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10596
11244
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10597
|
-
* "srcAddress": "0x..", // Source address
|
|
10598
|
-
* "dstAddress": "0x...", // Destination address
|
|
11245
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11246
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10599
11247
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10600
11248
|
* "data": "0x..", // Additional arbitrary data
|
|
10601
11249
|
* } satisfies CreateIntentParams;
|
|
@@ -10603,8 +11251,8 @@ var SolverService = class {
|
|
|
10603
11251
|
* const createAndSubmitIntentResult = await solverService.createAndSubmitIntent(payload, spokeProvider);
|
|
10604
11252
|
*
|
|
10605
11253
|
* if (createAndSubmitIntentResult.ok) {
|
|
10606
|
-
* const [
|
|
10607
|
-
* console.log('Intent execution response:',
|
|
11254
|
+
* const [solverExecutionResponse, intent, packetData] = createAndSubmitIntentResult.value;
|
|
11255
|
+
* console.log('Intent execution response:', solverExecutionResponse);
|
|
10608
11256
|
* console.log('Intent:', intent);
|
|
10609
11257
|
* console.log('Packet data:', packetData);
|
|
10610
11258
|
* } else {
|
|
@@ -10615,32 +11263,30 @@ var SolverService = class {
|
|
|
10615
11263
|
try {
|
|
10616
11264
|
const createIntentResult = await this.createIntent(payload, spokeProvider, fee, false);
|
|
10617
11265
|
if (!createIntentResult.ok) {
|
|
10618
|
-
return
|
|
10619
|
-
ok: false,
|
|
10620
|
-
error: createIntentResult.error
|
|
10621
|
-
};
|
|
11266
|
+
return createIntentResult;
|
|
10622
11267
|
}
|
|
10623
|
-
const [spokeTxHash, intent] = createIntentResult.value;
|
|
11268
|
+
const [spokeTxHash, intent, data] = createIntentResult.value;
|
|
10624
11269
|
const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
|
|
10625
|
-
const submitPayload = {
|
|
11270
|
+
const submitPayload = payload.srcChain === SOLANA_MAINNET_CHAIN_ID && data ? {
|
|
11271
|
+
action: "submit",
|
|
11272
|
+
params: {
|
|
11273
|
+
chain_id: intentRelayChainId,
|
|
11274
|
+
tx_hash: spokeTxHash,
|
|
11275
|
+
data: {
|
|
11276
|
+
address: intent.creator,
|
|
11277
|
+
payload: data
|
|
11278
|
+
}
|
|
11279
|
+
}
|
|
11280
|
+
} : {
|
|
10626
11281
|
action: "submit",
|
|
10627
11282
|
params: {
|
|
10628
11283
|
chain_id: intentRelayChainId,
|
|
10629
11284
|
tx_hash: spokeTxHash
|
|
10630
11285
|
}
|
|
10631
11286
|
};
|
|
10632
|
-
const submitResult = await
|
|
10633
|
-
if (!submitResult.
|
|
10634
|
-
return
|
|
10635
|
-
ok: false,
|
|
10636
|
-
error: {
|
|
10637
|
-
code: "SUBMIT_TX_FAILED",
|
|
10638
|
-
data: {
|
|
10639
|
-
payload: submitPayload,
|
|
10640
|
-
apiUrl: this.config.relayerApiEndpoint
|
|
10641
|
-
}
|
|
10642
|
-
}
|
|
10643
|
-
};
|
|
11287
|
+
const submitResult = await this.submitIntent(submitPayload);
|
|
11288
|
+
if (!submitResult.ok) {
|
|
11289
|
+
return submitResult;
|
|
10644
11290
|
}
|
|
10645
11291
|
const packet = await waitUntilIntentExecuted({
|
|
10646
11292
|
intentRelayChainId,
|
|
@@ -10699,8 +11345,8 @@ var SolverService = class {
|
|
|
10699
11345
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10700
11346
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10701
11347
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10702
|
-
* "srcAddress": "0x..", // Source address
|
|
10703
|
-
* "dstAddress": "0x...", // Destination address
|
|
11348
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11349
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10704
11350
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10705
11351
|
* "data": "0x..", // Additional arbitrary data
|
|
10706
11352
|
* } satisfies CreateIntentParams;
|
|
@@ -10762,10 +11408,16 @@ var SolverService = class {
|
|
|
10762
11408
|
*
|
|
10763
11409
|
* const txReceipt = approveResult.value;
|
|
10764
11410
|
*/
|
|
10765
|
-
async approve(token, amount,
|
|
11411
|
+
async approve(token, amount, spokeProvider, raw) {
|
|
10766
11412
|
try {
|
|
10767
11413
|
if (spokeProvider instanceof EvmSpokeProvider || spokeProvider instanceof SonicSpokeProvider) {
|
|
10768
|
-
const result = await Erc20Service.approve(
|
|
11414
|
+
const result = await Erc20Service.approve(
|
|
11415
|
+
token,
|
|
11416
|
+
amount,
|
|
11417
|
+
spokeProvider.chainConfig.addresses.assetManager,
|
|
11418
|
+
spokeProvider,
|
|
11419
|
+
raw
|
|
11420
|
+
);
|
|
10769
11421
|
return {
|
|
10770
11422
|
ok: true,
|
|
10771
11423
|
value: result
|
|
@@ -10785,11 +11437,11 @@ var SolverService = class {
|
|
|
10785
11437
|
/**
|
|
10786
11438
|
* Creates an intent by handling token approval and intent creation
|
|
10787
11439
|
* NOTE: This method does not submit the intent to the Solver API
|
|
10788
|
-
* @param {CreateIntentParams} params - The intent to create
|
|
11440
|
+
* @param {Omit<CreateIntentParams, 'srcAddress'>} params - The intent to create
|
|
10789
11441
|
* @param {SpokeProvider} spokeProvider - The spoke provider
|
|
10790
11442
|
* @param {boolean} raw - Whether to return the raw transaction
|
|
10791
11443
|
* @param {PartnerFee} fee - The fee to apply to the intent
|
|
10792
|
-
* @returns {Promise<Result<[TxReturnType<S, R>, Intent & FeeAmount],
|
|
11444
|
+
* @returns {Promise<Result<[TxReturnType<S, R>, Intent & FeeAmount], IntentError<'CREATION_FAILED'>>>} The encoded contract call
|
|
10793
11445
|
*
|
|
10794
11446
|
* @example
|
|
10795
11447
|
* const payload = {
|
|
@@ -10801,8 +11453,8 @@ var SolverService = class {
|
|
|
10801
11453
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10802
11454
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10803
11455
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10804
|
-
* "srcAddress": "0x..", // Source address
|
|
10805
|
-
* "dstAddress": "0x...", // Destination address
|
|
11456
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11457
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10806
11458
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10807
11459
|
* "data": "0x..", // Additional arbitrary data
|
|
10808
11460
|
* } satisfies CreateIntentParams;
|
|
@@ -10826,7 +11478,12 @@ var SolverService = class {
|
|
|
10826
11478
|
invariant2(isValidSpokeChainId(params.srcChain), `Invalid spoke chain (params.srcChain): ${params.srcChain}`);
|
|
10827
11479
|
invariant2(isValidSpokeChainId(params.dstChain), `Invalid spoke chain (params.dstChain): ${params.dstChain}`);
|
|
10828
11480
|
try {
|
|
10829
|
-
const
|
|
11481
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
11482
|
+
invariant2(
|
|
11483
|
+
params.srcAddress.toLowerCase() === walletAddress.toLowerCase(),
|
|
11484
|
+
"srcAddress must be the same as wallet address"
|
|
11485
|
+
);
|
|
11486
|
+
const walletAddressBytes = encodeAddress(params.srcChain, walletAddress);
|
|
10830
11487
|
const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
|
|
10831
11488
|
params.srcChain,
|
|
10832
11489
|
walletAddressBytes,
|
|
@@ -10834,12 +11491,14 @@ var SolverService = class {
|
|
|
10834
11491
|
spokeProvider
|
|
10835
11492
|
);
|
|
10836
11493
|
const [data, intent, feeAmount] = EvmSolverService.constructCreateIntentData(
|
|
10837
|
-
|
|
11494
|
+
{
|
|
11495
|
+
...params,
|
|
11496
|
+
srcAddress: walletAddress
|
|
11497
|
+
},
|
|
10838
11498
|
creatorHubWalletAddress,
|
|
10839
11499
|
this.config,
|
|
10840
11500
|
fee
|
|
10841
11501
|
);
|
|
10842
|
-
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10843
11502
|
const txResult = await SpokeService.deposit(
|
|
10844
11503
|
{
|
|
10845
11504
|
from: walletAddress,
|
|
@@ -10854,7 +11513,7 @@ var SolverService = class {
|
|
|
10854
11513
|
);
|
|
10855
11514
|
return {
|
|
10856
11515
|
ok: true,
|
|
10857
|
-
value: [txResult, { ...intent, feeAmount }]
|
|
11516
|
+
value: [txResult, { ...intent, feeAmount }, data]
|
|
10858
11517
|
};
|
|
10859
11518
|
} catch (error) {
|
|
10860
11519
|
return {
|
|
@@ -10877,20 +11536,37 @@ var SolverService = class {
|
|
|
10877
11536
|
* @returns {Promise<TxReturnType<T, R>>} The encoded contract call
|
|
10878
11537
|
*/
|
|
10879
11538
|
async cancelIntent(intent, spokeProvider, raw) {
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
spokeProvider.chainConfig.chain.id
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
11539
|
+
try {
|
|
11540
|
+
invariant2(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
|
|
11541
|
+
invariant2(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
|
|
11542
|
+
const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
|
|
11543
|
+
const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
|
|
11544
|
+
spokeProvider.chainConfig.chain.id,
|
|
11545
|
+
walletAddressBytes,
|
|
11546
|
+
this.hubProvider,
|
|
11547
|
+
spokeProvider
|
|
11548
|
+
);
|
|
11549
|
+
const calls = [];
|
|
11550
|
+
const intentsContract = this.config.intentsContract;
|
|
11551
|
+
calls.push(EvmSolverService.encodeCancelIntent(intent, intentsContract));
|
|
11552
|
+
const data = encodeContractCalls(calls);
|
|
11553
|
+
const txResult = await SpokeService.callWallet(
|
|
11554
|
+
creatorHubWalletAddress,
|
|
11555
|
+
data,
|
|
11556
|
+
spokeProvider,
|
|
11557
|
+
this.hubProvider,
|
|
11558
|
+
raw
|
|
11559
|
+
);
|
|
11560
|
+
return {
|
|
11561
|
+
ok: true,
|
|
11562
|
+
value: txResult
|
|
11563
|
+
};
|
|
11564
|
+
} catch (error) {
|
|
11565
|
+
return {
|
|
11566
|
+
ok: false,
|
|
11567
|
+
error
|
|
11568
|
+
};
|
|
11569
|
+
}
|
|
10894
11570
|
}
|
|
10895
11571
|
/**
|
|
10896
11572
|
* Gets an intent from a transaction hash (on Hub chain)
|
|
@@ -10910,6 +11586,939 @@ var SolverService = class {
|
|
|
10910
11586
|
}
|
|
10911
11587
|
};
|
|
10912
11588
|
|
|
11589
|
+
// src/abis/icxSwap.abi.ts
|
|
11590
|
+
var icxSwapAbi = [
|
|
11591
|
+
{
|
|
11592
|
+
type: "constructor",
|
|
11593
|
+
inputs: [],
|
|
11594
|
+
stateMutability: "nonpayable"
|
|
11595
|
+
},
|
|
11596
|
+
{
|
|
11597
|
+
type: "function",
|
|
11598
|
+
name: "ICX",
|
|
11599
|
+
inputs: [],
|
|
11600
|
+
outputs: [
|
|
11601
|
+
{
|
|
11602
|
+
name: "",
|
|
11603
|
+
type: "address",
|
|
11604
|
+
internalType: "contract IERC20"
|
|
11605
|
+
}
|
|
11606
|
+
],
|
|
11607
|
+
stateMutability: "view"
|
|
11608
|
+
},
|
|
11609
|
+
{
|
|
11610
|
+
type: "function",
|
|
11611
|
+
name: "UPGRADE_INTERFACE_VERSION",
|
|
11612
|
+
inputs: [],
|
|
11613
|
+
outputs: [
|
|
11614
|
+
{
|
|
11615
|
+
name: "",
|
|
11616
|
+
type: "string",
|
|
11617
|
+
internalType: "string"
|
|
11618
|
+
}
|
|
11619
|
+
],
|
|
11620
|
+
stateMutability: "view"
|
|
11621
|
+
},
|
|
11622
|
+
{
|
|
11623
|
+
type: "function",
|
|
11624
|
+
name: "getImplementation",
|
|
11625
|
+
inputs: [],
|
|
11626
|
+
outputs: [
|
|
11627
|
+
{
|
|
11628
|
+
name: "",
|
|
11629
|
+
type: "address",
|
|
11630
|
+
internalType: "address"
|
|
11631
|
+
}
|
|
11632
|
+
],
|
|
11633
|
+
stateMutability: "view"
|
|
11634
|
+
},
|
|
11635
|
+
{
|
|
11636
|
+
type: "function",
|
|
11637
|
+
name: "initialize",
|
|
11638
|
+
inputs: [],
|
|
11639
|
+
outputs: [],
|
|
11640
|
+
stateMutability: "nonpayable"
|
|
11641
|
+
},
|
|
11642
|
+
{
|
|
11643
|
+
type: "function",
|
|
11644
|
+
name: "owner",
|
|
11645
|
+
inputs: [],
|
|
11646
|
+
outputs: [
|
|
11647
|
+
{
|
|
11648
|
+
name: "",
|
|
11649
|
+
type: "address",
|
|
11650
|
+
internalType: "address"
|
|
11651
|
+
}
|
|
11652
|
+
],
|
|
11653
|
+
stateMutability: "view"
|
|
11654
|
+
},
|
|
11655
|
+
{
|
|
11656
|
+
type: "function",
|
|
11657
|
+
name: "pendingMigrations",
|
|
11658
|
+
inputs: [
|
|
11659
|
+
{
|
|
11660
|
+
name: "",
|
|
11661
|
+
type: "uint256",
|
|
11662
|
+
internalType: "uint256"
|
|
11663
|
+
}
|
|
11664
|
+
],
|
|
11665
|
+
outputs: [
|
|
11666
|
+
{
|
|
11667
|
+
name: "user",
|
|
11668
|
+
type: "address",
|
|
11669
|
+
internalType: "address"
|
|
11670
|
+
},
|
|
11671
|
+
{
|
|
11672
|
+
name: "to",
|
|
11673
|
+
type: "address",
|
|
11674
|
+
internalType: "address"
|
|
11675
|
+
},
|
|
11676
|
+
{
|
|
11677
|
+
name: "amount",
|
|
11678
|
+
type: "uint256",
|
|
11679
|
+
internalType: "uint256"
|
|
11680
|
+
},
|
|
11681
|
+
{
|
|
11682
|
+
name: "timestamp",
|
|
11683
|
+
type: "uint256",
|
|
11684
|
+
internalType: "uint256"
|
|
11685
|
+
}
|
|
11686
|
+
],
|
|
11687
|
+
stateMutability: "view"
|
|
11688
|
+
},
|
|
11689
|
+
{
|
|
11690
|
+
type: "function",
|
|
11691
|
+
name: "reverseSwap",
|
|
11692
|
+
inputs: [
|
|
11693
|
+
{
|
|
11694
|
+
name: "amount",
|
|
11695
|
+
type: "uint256",
|
|
11696
|
+
internalType: "uint256"
|
|
11697
|
+
},
|
|
11698
|
+
{
|
|
11699
|
+
name: "to",
|
|
11700
|
+
type: "address",
|
|
11701
|
+
internalType: "address"
|
|
11702
|
+
}
|
|
11703
|
+
],
|
|
11704
|
+
outputs: [],
|
|
11705
|
+
stateMutability: "nonpayable"
|
|
11706
|
+
},
|
|
11707
|
+
{
|
|
11708
|
+
type: "function",
|
|
11709
|
+
name: "reverseSwapEnabled",
|
|
11710
|
+
inputs: [],
|
|
11711
|
+
outputs: [
|
|
11712
|
+
{
|
|
11713
|
+
name: "",
|
|
11714
|
+
type: "bool",
|
|
11715
|
+
internalType: "bool"
|
|
11716
|
+
}
|
|
11717
|
+
],
|
|
11718
|
+
stateMutability: "view"
|
|
11719
|
+
},
|
|
11720
|
+
{
|
|
11721
|
+
type: "function",
|
|
11722
|
+
name: "sodax",
|
|
11723
|
+
inputs: [],
|
|
11724
|
+
outputs: [
|
|
11725
|
+
{
|
|
11726
|
+
name: "",
|
|
11727
|
+
type: "address",
|
|
11728
|
+
internalType: "contract IERC20"
|
|
11729
|
+
}
|
|
11730
|
+
],
|
|
11731
|
+
stateMutability: "view"
|
|
11732
|
+
},
|
|
11733
|
+
{
|
|
11734
|
+
type: "function",
|
|
11735
|
+
name: "swap",
|
|
11736
|
+
inputs: [
|
|
11737
|
+
{
|
|
11738
|
+
name: "amount",
|
|
11739
|
+
type: "uint256",
|
|
11740
|
+
internalType: "uint256"
|
|
11741
|
+
},
|
|
11742
|
+
{
|
|
11743
|
+
name: "to",
|
|
11744
|
+
type: "address",
|
|
11745
|
+
internalType: "address"
|
|
11746
|
+
}
|
|
11747
|
+
],
|
|
11748
|
+
outputs: [],
|
|
11749
|
+
stateMutability: "nonpayable"
|
|
11750
|
+
},
|
|
11751
|
+
{
|
|
11752
|
+
type: "event",
|
|
11753
|
+
name: "Initialized",
|
|
11754
|
+
inputs: [
|
|
11755
|
+
{
|
|
11756
|
+
name: "version",
|
|
11757
|
+
type: "uint64",
|
|
11758
|
+
indexed: false,
|
|
11759
|
+
internalType: "uint64"
|
|
11760
|
+
}
|
|
11761
|
+
],
|
|
11762
|
+
anonymous: false
|
|
11763
|
+
},
|
|
11764
|
+
{
|
|
11765
|
+
type: "event",
|
|
11766
|
+
name: "OwnershipTransferStarted",
|
|
11767
|
+
inputs: [
|
|
11768
|
+
{
|
|
11769
|
+
name: "previousOwner",
|
|
11770
|
+
type: "address",
|
|
11771
|
+
indexed: true,
|
|
11772
|
+
internalType: "address"
|
|
11773
|
+
},
|
|
11774
|
+
{
|
|
11775
|
+
name: "newOwner",
|
|
11776
|
+
type: "address",
|
|
11777
|
+
indexed: true,
|
|
11778
|
+
internalType: "address"
|
|
11779
|
+
}
|
|
11780
|
+
],
|
|
11781
|
+
anonymous: false
|
|
11782
|
+
},
|
|
11783
|
+
{
|
|
11784
|
+
type: "event",
|
|
11785
|
+
name: "OwnershipTransferred",
|
|
11786
|
+
inputs: [
|
|
11787
|
+
{
|
|
11788
|
+
name: "previousOwner",
|
|
11789
|
+
type: "address",
|
|
11790
|
+
indexed: true,
|
|
11791
|
+
internalType: "address"
|
|
11792
|
+
},
|
|
11793
|
+
{
|
|
11794
|
+
name: "newOwner",
|
|
11795
|
+
type: "address",
|
|
11796
|
+
indexed: true,
|
|
11797
|
+
internalType: "address"
|
|
11798
|
+
}
|
|
11799
|
+
],
|
|
11800
|
+
anonymous: false
|
|
11801
|
+
},
|
|
11802
|
+
{
|
|
11803
|
+
type: "event",
|
|
11804
|
+
name: "PendingMigrationApproved",
|
|
11805
|
+
inputs: [
|
|
11806
|
+
{
|
|
11807
|
+
name: "index",
|
|
11808
|
+
type: "uint256",
|
|
11809
|
+
indexed: false,
|
|
11810
|
+
internalType: "uint256"
|
|
11811
|
+
},
|
|
11812
|
+
{
|
|
11813
|
+
name: "user",
|
|
11814
|
+
type: "address",
|
|
11815
|
+
indexed: true,
|
|
11816
|
+
internalType: "address"
|
|
11817
|
+
},
|
|
11818
|
+
{
|
|
11819
|
+
name: "amount",
|
|
11820
|
+
type: "uint256",
|
|
11821
|
+
indexed: false,
|
|
11822
|
+
internalType: "uint256"
|
|
11823
|
+
}
|
|
11824
|
+
],
|
|
11825
|
+
anonymous: false
|
|
11826
|
+
},
|
|
11827
|
+
{
|
|
11828
|
+
type: "event",
|
|
11829
|
+
name: "PendingMigrationCreated",
|
|
11830
|
+
inputs: [
|
|
11831
|
+
{
|
|
11832
|
+
name: "user",
|
|
11833
|
+
type: "address",
|
|
11834
|
+
indexed: true,
|
|
11835
|
+
internalType: "address"
|
|
11836
|
+
},
|
|
11837
|
+
{
|
|
11838
|
+
name: "amount",
|
|
11839
|
+
type: "uint256",
|
|
11840
|
+
indexed: false,
|
|
11841
|
+
internalType: "uint256"
|
|
11842
|
+
},
|
|
11843
|
+
{
|
|
11844
|
+
name: "index",
|
|
11845
|
+
type: "uint256",
|
|
11846
|
+
indexed: false,
|
|
11847
|
+
internalType: "uint256"
|
|
11848
|
+
}
|
|
11849
|
+
],
|
|
11850
|
+
anonymous: false
|
|
11851
|
+
},
|
|
11852
|
+
{
|
|
11853
|
+
type: "event",
|
|
11854
|
+
name: "ReverseSwap",
|
|
11855
|
+
inputs: [
|
|
11856
|
+
{
|
|
11857
|
+
name: "user",
|
|
11858
|
+
type: "address",
|
|
11859
|
+
indexed: true,
|
|
11860
|
+
internalType: "address"
|
|
11861
|
+
},
|
|
11862
|
+
{
|
|
11863
|
+
name: "sodaxAmount",
|
|
11864
|
+
type: "uint256",
|
|
11865
|
+
indexed: false,
|
|
11866
|
+
internalType: "uint256"
|
|
11867
|
+
},
|
|
11868
|
+
{
|
|
11869
|
+
name: "ICXAmount",
|
|
11870
|
+
type: "uint256",
|
|
11871
|
+
indexed: false,
|
|
11872
|
+
internalType: "uint256"
|
|
11873
|
+
}
|
|
11874
|
+
],
|
|
11875
|
+
anonymous: false
|
|
11876
|
+
},
|
|
11877
|
+
{
|
|
11878
|
+
type: "event",
|
|
11879
|
+
name: "ReverseSwapToggled",
|
|
11880
|
+
inputs: [
|
|
11881
|
+
{
|
|
11882
|
+
name: "enabled",
|
|
11883
|
+
type: "bool",
|
|
11884
|
+
indexed: false,
|
|
11885
|
+
internalType: "bool"
|
|
11886
|
+
}
|
|
11887
|
+
],
|
|
11888
|
+
anonymous: false
|
|
11889
|
+
},
|
|
11890
|
+
{
|
|
11891
|
+
type: "event",
|
|
11892
|
+
name: "Swap",
|
|
11893
|
+
inputs: [
|
|
11894
|
+
{
|
|
11895
|
+
name: "user",
|
|
11896
|
+
type: "address",
|
|
11897
|
+
indexed: true,
|
|
11898
|
+
internalType: "address"
|
|
11899
|
+
},
|
|
11900
|
+
{
|
|
11901
|
+
name: "ICXAmount",
|
|
11902
|
+
type: "uint256",
|
|
11903
|
+
indexed: false,
|
|
11904
|
+
internalType: "uint256"
|
|
11905
|
+
},
|
|
11906
|
+
{
|
|
11907
|
+
name: "sodaxAmount",
|
|
11908
|
+
type: "uint256",
|
|
11909
|
+
indexed: false,
|
|
11910
|
+
internalType: "uint256"
|
|
11911
|
+
}
|
|
11912
|
+
],
|
|
11913
|
+
anonymous: false
|
|
11914
|
+
},
|
|
11915
|
+
{
|
|
11916
|
+
type: "event",
|
|
11917
|
+
name: "Upgraded",
|
|
11918
|
+
inputs: [
|
|
11919
|
+
{
|
|
11920
|
+
name: "implementation",
|
|
11921
|
+
type: "address",
|
|
11922
|
+
indexed: true,
|
|
11923
|
+
internalType: "address"
|
|
11924
|
+
}
|
|
11925
|
+
],
|
|
11926
|
+
anonymous: false
|
|
11927
|
+
},
|
|
11928
|
+
{
|
|
11929
|
+
type: "error",
|
|
11930
|
+
name: "AddressEmptyCode",
|
|
11931
|
+
inputs: [
|
|
11932
|
+
{
|
|
11933
|
+
name: "target",
|
|
11934
|
+
type: "address",
|
|
11935
|
+
internalType: "address"
|
|
11936
|
+
}
|
|
11937
|
+
]
|
|
11938
|
+
},
|
|
11939
|
+
{
|
|
11940
|
+
type: "error",
|
|
11941
|
+
name: "ERC1967InvalidImplementation",
|
|
11942
|
+
inputs: [
|
|
11943
|
+
{
|
|
11944
|
+
name: "implementation",
|
|
11945
|
+
type: "address",
|
|
11946
|
+
internalType: "address"
|
|
11947
|
+
}
|
|
11948
|
+
]
|
|
11949
|
+
},
|
|
11950
|
+
{
|
|
11951
|
+
type: "error",
|
|
11952
|
+
name: "ERC1967NonPayable",
|
|
11953
|
+
inputs: []
|
|
11954
|
+
},
|
|
11955
|
+
{
|
|
11956
|
+
type: "error",
|
|
11957
|
+
name: "FailedCall",
|
|
11958
|
+
inputs: []
|
|
11959
|
+
},
|
|
11960
|
+
{
|
|
11961
|
+
type: "error",
|
|
11962
|
+
name: "InvalidInitialization",
|
|
11963
|
+
inputs: []
|
|
11964
|
+
},
|
|
11965
|
+
{
|
|
11966
|
+
type: "error",
|
|
11967
|
+
name: "NotInitializing",
|
|
11968
|
+
inputs: []
|
|
11969
|
+
},
|
|
11970
|
+
{
|
|
11971
|
+
type: "error",
|
|
11972
|
+
name: "OwnableInvalidOwner",
|
|
11973
|
+
inputs: [
|
|
11974
|
+
{
|
|
11975
|
+
name: "owner",
|
|
11976
|
+
type: "address",
|
|
11977
|
+
internalType: "address"
|
|
11978
|
+
}
|
|
11979
|
+
]
|
|
11980
|
+
},
|
|
11981
|
+
{
|
|
11982
|
+
type: "error",
|
|
11983
|
+
name: "OwnableUnauthorizedAccount",
|
|
11984
|
+
inputs: [
|
|
11985
|
+
{
|
|
11986
|
+
name: "account",
|
|
11987
|
+
type: "address",
|
|
11988
|
+
internalType: "address"
|
|
11989
|
+
}
|
|
11990
|
+
]
|
|
11991
|
+
},
|
|
11992
|
+
{
|
|
11993
|
+
type: "error",
|
|
11994
|
+
name: "ReentrancyGuardReentrantCall",
|
|
11995
|
+
inputs: []
|
|
11996
|
+
},
|
|
11997
|
+
{
|
|
11998
|
+
type: "error",
|
|
11999
|
+
name: "SafeERC20FailedOperation",
|
|
12000
|
+
inputs: [
|
|
12001
|
+
{
|
|
12002
|
+
name: "token",
|
|
12003
|
+
type: "address",
|
|
12004
|
+
internalType: "address"
|
|
12005
|
+
}
|
|
12006
|
+
]
|
|
12007
|
+
},
|
|
12008
|
+
{
|
|
12009
|
+
type: "error",
|
|
12010
|
+
name: "UUPSUnauthorizedCallContext",
|
|
12011
|
+
inputs: []
|
|
12012
|
+
},
|
|
12013
|
+
{
|
|
12014
|
+
type: "error",
|
|
12015
|
+
name: "UUPSUnsupportedProxiableUUID",
|
|
12016
|
+
inputs: [
|
|
12017
|
+
{
|
|
12018
|
+
name: "slot",
|
|
12019
|
+
type: "bytes32",
|
|
12020
|
+
internalType: "bytes32"
|
|
12021
|
+
}
|
|
12022
|
+
]
|
|
12023
|
+
}
|
|
12024
|
+
];
|
|
12025
|
+
var IcxMigrationService = class {
|
|
12026
|
+
hubProvider;
|
|
12027
|
+
constructor(hubProvider) {
|
|
12028
|
+
this.hubProvider = hubProvider;
|
|
12029
|
+
}
|
|
12030
|
+
/**
|
|
12031
|
+
* Retrieves the available amount of SODA tokens in the ICX migration contract.
|
|
12032
|
+
* This represents the amount of tokens available for migration.
|
|
12033
|
+
*
|
|
12034
|
+
* @returns The available balance of SODA tokens in the migration contract
|
|
12035
|
+
*/
|
|
12036
|
+
async getAvailableAmount() {
|
|
12037
|
+
const balance = await this.hubProvider.publicClient.readContract({
|
|
12038
|
+
address: this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12039
|
+
abi: erc20Abi,
|
|
12040
|
+
functionName: "balanceOf",
|
|
12041
|
+
args: [this.hubProvider.chainConfig.addresses.icxMigration]
|
|
12042
|
+
});
|
|
12043
|
+
return balance;
|
|
12044
|
+
}
|
|
12045
|
+
/**
|
|
12046
|
+
* Generates transaction data for migrating wICX tokens from ICON to the hub chain.
|
|
12047
|
+
* This method creates the necessary contract calls to:
|
|
12048
|
+
* 1. Approve the migration contract to spend the wICX tokens
|
|
12049
|
+
* 2. Execute the migration swap
|
|
12050
|
+
*
|
|
12051
|
+
* @param params - The migration parameters including token address, amount, and recipient
|
|
12052
|
+
* @returns Encoded transaction data for the migration operation
|
|
12053
|
+
* @throws Will throw an error if the hub asset configuration is not found
|
|
12054
|
+
*/
|
|
12055
|
+
migrateData(params) {
|
|
12056
|
+
const calls = [];
|
|
12057
|
+
const assetConfig = getHubAssetInfo(ICON_MAINNET_CHAIN_ID, params.icx);
|
|
12058
|
+
invariant2(assetConfig, `hub asset not found for spoke chain token (token): ${params.icx}`);
|
|
12059
|
+
calls.push(
|
|
12060
|
+
Erc20Service.encodeApprove(assetConfig.asset, this.hubProvider.chainConfig.addresses.icxMigration, params.amount)
|
|
12061
|
+
);
|
|
12062
|
+
calls.push(this.encodeMigrate(params.amount, params.to));
|
|
12063
|
+
return encodeContractCalls(calls);
|
|
12064
|
+
}
|
|
12065
|
+
/**
|
|
12066
|
+
* Generates transaction data for migrating back tokens to the ICON chain.
|
|
12067
|
+
* @param params - The migration parameters including token address, amount, and recipient
|
|
12068
|
+
* @returns Encoded transaction data for the migration operation
|
|
12069
|
+
* @throws Will throw an error if the hub asset configuration is not found
|
|
12070
|
+
*/
|
|
12071
|
+
revertMigration(params) {
|
|
12072
|
+
const calls = [];
|
|
12073
|
+
const assetConfig = getHubAssetInfo(ICON_MAINNET_CHAIN_ID, params.wICX);
|
|
12074
|
+
invariant2(assetConfig, `hub asset not found for spoke chain token (token): ${params.wICX}`);
|
|
12075
|
+
calls.push(
|
|
12076
|
+
Erc20Service.encodeApprove(
|
|
12077
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12078
|
+
this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12079
|
+
params.amount
|
|
12080
|
+
)
|
|
12081
|
+
);
|
|
12082
|
+
calls.push(this.encodeRevertMigration(params.amount, params.userWallet));
|
|
12083
|
+
calls.push(
|
|
12084
|
+
EvmAssetManagerService.encodeTransfer(
|
|
12085
|
+
assetConfig.asset,
|
|
12086
|
+
params.to,
|
|
12087
|
+
params.amount,
|
|
12088
|
+
this.hubProvider.chainConfig.addresses.assetManager
|
|
12089
|
+
)
|
|
12090
|
+
);
|
|
12091
|
+
return encodeContractCalls(calls);
|
|
12092
|
+
}
|
|
12093
|
+
/**
|
|
12094
|
+
* Encodes a migration transaction for the ICX swap contract.
|
|
12095
|
+
* This creates the contract call data for swapping wICX tokens to SODA tokens.
|
|
12096
|
+
*
|
|
12097
|
+
* @param amount - The amount of wICX tokens to migrate
|
|
12098
|
+
* @param to - The address that will receive the migrated SODA tokens
|
|
12099
|
+
* @returns The encoded contract call for the migration operation
|
|
12100
|
+
*/
|
|
12101
|
+
encodeMigrate(amount, to) {
|
|
12102
|
+
return {
|
|
12103
|
+
address: this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12104
|
+
value: 0n,
|
|
12105
|
+
data: encodeFunctionData({
|
|
12106
|
+
abi: icxSwapAbi,
|
|
12107
|
+
functionName: "swap",
|
|
12108
|
+
args: [amount, to]
|
|
12109
|
+
})
|
|
12110
|
+
};
|
|
12111
|
+
}
|
|
12112
|
+
/**
|
|
12113
|
+
* Encodes a revert migration transaction for the ICX swap contract.
|
|
12114
|
+
* This creates the contract call data for swapping SODA tokens to wICX tokens.
|
|
12115
|
+
*
|
|
12116
|
+
* @param amount - The amount of wICX tokens to migrate
|
|
12117
|
+
* @param to - The address that will receive the migrated SODA tokens
|
|
12118
|
+
* @returns The encoded contract call for the migration operation
|
|
12119
|
+
*/
|
|
12120
|
+
encodeRevertMigration(amount, to) {
|
|
12121
|
+
return {
|
|
12122
|
+
address: this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12123
|
+
value: 0n,
|
|
12124
|
+
data: encodeFunctionData({
|
|
12125
|
+
abi: icxSwapAbi,
|
|
12126
|
+
functionName: "reverseSwap",
|
|
12127
|
+
args: [amount, to]
|
|
12128
|
+
})
|
|
12129
|
+
};
|
|
12130
|
+
}
|
|
12131
|
+
};
|
|
12132
|
+
var MigrationService = class {
|
|
12133
|
+
icxMigration;
|
|
12134
|
+
hubProvider;
|
|
12135
|
+
config;
|
|
12136
|
+
constructor(hubProvider, config) {
|
|
12137
|
+
this.hubProvider = hubProvider;
|
|
12138
|
+
this.icxMigration = new IcxMigrationService(hubProvider);
|
|
12139
|
+
this.config = config ?? {
|
|
12140
|
+
relayerApiEndpoint: DEFAULT_RELAYER_API_ENDPOINT
|
|
12141
|
+
};
|
|
12142
|
+
}
|
|
12143
|
+
async migrateData(params) {
|
|
12144
|
+
return this.icxMigration.migrateData(params);
|
|
12145
|
+
}
|
|
12146
|
+
/**
|
|
12147
|
+
* Checks if the allowance is valid for the migration transaction.
|
|
12148
|
+
* @param params - The parameters for the migration transaction.
|
|
12149
|
+
* @param spokeProvider - The spoke provider.
|
|
12150
|
+
* @returns {Promise<Result<boolean>>} - Returns the result of the allowance check or error
|
|
12151
|
+
*
|
|
12152
|
+
* @example
|
|
12153
|
+
* const result = await migrationService.isAllowanceValid(
|
|
12154
|
+
* {
|
|
12155
|
+
* token: 'ICX', // Token to migrate
|
|
12156
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12157
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12158
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12159
|
+
* action: 'migrate', // Action to perform (migrate or revert)
|
|
12160
|
+
* },
|
|
12161
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12162
|
+
* );
|
|
12163
|
+
*
|
|
12164
|
+
*/
|
|
12165
|
+
async isAllowanceValid(params, spokeProvider) {
|
|
12166
|
+
try {
|
|
12167
|
+
if (params.action === "migrate") {
|
|
12168
|
+
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
12169
|
+
invariant2(isAddress(params.to) || isIconAddress(params.to), "To address is required");
|
|
12170
|
+
invariant2(
|
|
12171
|
+
spokeProvider instanceof IconSpokeProvider,
|
|
12172
|
+
"Spoke provider must be an instance of IconSpokeProvider"
|
|
12173
|
+
);
|
|
12174
|
+
invariant2(
|
|
12175
|
+
params.icx.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.icx.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
12176
|
+
"Token must be wICX or native ICX token"
|
|
12177
|
+
);
|
|
12178
|
+
invariant2(params.token === "ICX", "Token must be ICX");
|
|
12179
|
+
return {
|
|
12180
|
+
ok: true,
|
|
12181
|
+
value: true
|
|
12182
|
+
};
|
|
12183
|
+
}
|
|
12184
|
+
if (params.action === "revert") {
|
|
12185
|
+
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
12186
|
+
invariant2(isAddress(params.to) || isIconAddress(params.to), "To address is required");
|
|
12187
|
+
invariant2(
|
|
12188
|
+
spokeProvider instanceof SonicSpokeProvider,
|
|
12189
|
+
"Spoke provider must be an instance of SonicSpokeProvider"
|
|
12190
|
+
);
|
|
12191
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12192
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12193
|
+
return await Erc20Service.isAllowanceValid(
|
|
12194
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12195
|
+
params.amount,
|
|
12196
|
+
wallet,
|
|
12197
|
+
userRouter,
|
|
12198
|
+
spokeProvider
|
|
12199
|
+
);
|
|
12200
|
+
}
|
|
12201
|
+
return {
|
|
12202
|
+
ok: false,
|
|
12203
|
+
error: new Error("Invalid action")
|
|
12204
|
+
};
|
|
12205
|
+
} catch (error) {
|
|
12206
|
+
return {
|
|
12207
|
+
ok: false,
|
|
12208
|
+
error
|
|
12209
|
+
};
|
|
12210
|
+
}
|
|
12211
|
+
}
|
|
12212
|
+
/**
|
|
12213
|
+
* Approves the amount spending for the revert migration transaction.
|
|
12214
|
+
* @param params - The parameters for the revert migration transaction.
|
|
12215
|
+
* @param spokeProvider - The spoke provider.
|
|
12216
|
+
* @param raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12217
|
+
* @returns {Promise<Result<TxReturnType<S, R>>>} - Returns the raw transaction payload or transaction hash
|
|
12218
|
+
*
|
|
12219
|
+
* @example
|
|
12220
|
+
* const result = await migrationService.approve(
|
|
12221
|
+
* {
|
|
12222
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12223
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12224
|
+
* action: 'revert',
|
|
12225
|
+
* },
|
|
12226
|
+
* spokeProvider, // SonicSpokeProvider instance
|
|
12227
|
+
* true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
|
|
12228
|
+
* );
|
|
12229
|
+
*
|
|
12230
|
+
*/
|
|
12231
|
+
async approve(params, spokeProvider, raw) {
|
|
12232
|
+
try {
|
|
12233
|
+
if (params.action === "revert") {
|
|
12234
|
+
invariant2(params.amount > 0n, "Amount must be greater than 0");
|
|
12235
|
+
invariant2(params.to.length > 0, "To address is required");
|
|
12236
|
+
invariant2(
|
|
12237
|
+
spokeProvider instanceof SonicSpokeProvider,
|
|
12238
|
+
"Spoke provider must be an instance of SonicSpokeProvider"
|
|
12239
|
+
);
|
|
12240
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12241
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12242
|
+
const result = await Erc20Service.approve(
|
|
12243
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12244
|
+
params.amount,
|
|
12245
|
+
userRouter,
|
|
12246
|
+
spokeProvider,
|
|
12247
|
+
raw
|
|
12248
|
+
);
|
|
12249
|
+
return {
|
|
12250
|
+
ok: true,
|
|
12251
|
+
value: result
|
|
12252
|
+
};
|
|
12253
|
+
}
|
|
12254
|
+
return {
|
|
12255
|
+
ok: false,
|
|
12256
|
+
error: new Error("Invalid action")
|
|
12257
|
+
};
|
|
12258
|
+
} catch (error) {
|
|
12259
|
+
return {
|
|
12260
|
+
ok: false,
|
|
12261
|
+
error
|
|
12262
|
+
};
|
|
12263
|
+
}
|
|
12264
|
+
}
|
|
12265
|
+
/**
|
|
12266
|
+
* Creates a migration intent and submits (relays) it to the hub chain.
|
|
12267
|
+
* @param params - The parameters for the migration transaction.
|
|
12268
|
+
* @param spokeProvider - The spoke provider.
|
|
12269
|
+
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
12270
|
+
* @returns {Promise<Result<[Hex, Hex], MigrationError<'MIGRATION_FAILED'> | MigrationError<'CREATE_MIGRATION_INTENT_FAILED'> | RelayError>>}
|
|
12271
|
+
* Returns a Result containing a tuple of [spokeTxHash, hubTxHash] if successful,
|
|
12272
|
+
* or an error describing why the migration or relay failed.
|
|
12273
|
+
*
|
|
12274
|
+
* @example
|
|
12275
|
+
* const result = await migrationService.createAndSubmitMigrateIntent(
|
|
12276
|
+
* {
|
|
12277
|
+
* token: 'ICX', // Token to migrate
|
|
12278
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12279
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12280
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12281
|
+
* action: 'migrate',
|
|
12282
|
+
* },
|
|
12283
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12284
|
+
* 30000 // Optional timeout in milliseconds (default: 60000, i.e. 60 seconds)
|
|
12285
|
+
* );
|
|
12286
|
+
*
|
|
12287
|
+
* if (!result.ok) {
|
|
12288
|
+
* // Handle error
|
|
12289
|
+
* }
|
|
12290
|
+
*
|
|
12291
|
+
* const [
|
|
12292
|
+
* spokeTxHash, // transaction hash on the spoke chain
|
|
12293
|
+
* hubTxHash, // transaction hash on the hub chain (i.e. the transaction that was relayed to the hub)
|
|
12294
|
+
* ] = result.value;
|
|
12295
|
+
* console.log('Migration transaction hashes:', { spokeTxHash, hubTxHash });
|
|
12296
|
+
*/
|
|
12297
|
+
async createAndSubmitMigrateIntent(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
12298
|
+
try {
|
|
12299
|
+
const txResult = await this.createMigrateIntent(params, spokeProvider);
|
|
12300
|
+
if (!txResult.ok) {
|
|
12301
|
+
return {
|
|
12302
|
+
ok: false,
|
|
12303
|
+
error: txResult.error
|
|
12304
|
+
};
|
|
12305
|
+
}
|
|
12306
|
+
const packetResult = await relayTxAndWaitPacket(
|
|
12307
|
+
txResult.value,
|
|
12308
|
+
void 0,
|
|
12309
|
+
spokeProvider,
|
|
12310
|
+
this.config.relayerApiEndpoint,
|
|
12311
|
+
timeout
|
|
12312
|
+
);
|
|
12313
|
+
if (!packetResult.ok) {
|
|
12314
|
+
return packetResult;
|
|
12315
|
+
}
|
|
12316
|
+
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
12317
|
+
} catch (error) {
|
|
12318
|
+
return {
|
|
12319
|
+
ok: false,
|
|
12320
|
+
error: {
|
|
12321
|
+
code: "MIGRATION_FAILED",
|
|
12322
|
+
data: {
|
|
12323
|
+
payload: params,
|
|
12324
|
+
error
|
|
12325
|
+
}
|
|
12326
|
+
}
|
|
12327
|
+
};
|
|
12328
|
+
}
|
|
12329
|
+
}
|
|
12330
|
+
/**
|
|
12331
|
+
* Creates a revert migration (SODA to ICX) intent and submits (relays) it to the spoke chain.
|
|
12332
|
+
* @param params - The parameters for the revert migration transaction.
|
|
12333
|
+
* @param spokeProvider - The SonicSpokeProvider instance.
|
|
12334
|
+
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
12335
|
+
*
|
|
12336
|
+
* @returns {Promise<Result<[Hex, Hex], MigrationError<'REVERT_MIGRATION_FAILED'> | MigrationError<'CREATE_REVERT_MIGRATION_INTENT_FAILED'> | RelayError>>}
|
|
12337
|
+
* Returns a Result containing a tuple of [hubTxHash, spokeTxHash] if successful,
|
|
12338
|
+
* or an error describing why the revert migration or relay failed.
|
|
12339
|
+
*
|
|
12340
|
+
*
|
|
12341
|
+
* @example
|
|
12342
|
+
* const result = await migrationService.createAndSubmitRevertMigrationIntent(
|
|
12343
|
+
* {
|
|
12344
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12345
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12346
|
+
* action: 'revert',
|
|
12347
|
+
* },
|
|
12348
|
+
* spokeProvider, // SonicSpokeProvider instance
|
|
12349
|
+
* 30000 // Optional timeout in milliseconds (default: 60000, i.e. 60 seconds)
|
|
12350
|
+
* );
|
|
12351
|
+
*
|
|
12352
|
+
* if (!result.ok) {
|
|
12353
|
+
* // Handle error
|
|
12354
|
+
* }
|
|
12355
|
+
*
|
|
12356
|
+
* const [
|
|
12357
|
+
* hubTxHash, // transaction hash on the hub chain
|
|
12358
|
+
* spokeTxHash, // transaction hash on the spoke chain (i.e. the transaction that was relayed to the spoke)
|
|
12359
|
+
* ] = result.value;
|
|
12360
|
+
* console.log('Revert migration transaction hashes:', { hubTxHash, spokeTxHash });
|
|
12361
|
+
*/
|
|
12362
|
+
async createAndSubmitRevertMigrationIntent(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
12363
|
+
try {
|
|
12364
|
+
const txResult = await this.createRevertMigrationIntent(params, spokeProvider);
|
|
12365
|
+
if (!txResult.ok) {
|
|
12366
|
+
return txResult;
|
|
12367
|
+
}
|
|
12368
|
+
const packetResult = await relayTxAndWaitPacket(
|
|
12369
|
+
txResult.value,
|
|
12370
|
+
void 0,
|
|
12371
|
+
spokeProvider,
|
|
12372
|
+
this.config.relayerApiEndpoint,
|
|
12373
|
+
timeout
|
|
12374
|
+
);
|
|
12375
|
+
if (!packetResult.ok) {
|
|
12376
|
+
return packetResult;
|
|
12377
|
+
}
|
|
12378
|
+
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
12379
|
+
} catch (error) {
|
|
12380
|
+
return {
|
|
12381
|
+
ok: false,
|
|
12382
|
+
error: {
|
|
12383
|
+
code: "REVERT_MIGRATION_FAILED",
|
|
12384
|
+
data: {
|
|
12385
|
+
payload: params,
|
|
12386
|
+
error
|
|
12387
|
+
}
|
|
12388
|
+
}
|
|
12389
|
+
};
|
|
12390
|
+
}
|
|
12391
|
+
}
|
|
12392
|
+
/**
|
|
12393
|
+
* Migrates ICX or wICX tokens from ICON to the hub chain.
|
|
12394
|
+
* This function handles the migration of ICX or wICX tokens to SODA tokens on the hub chain.
|
|
12395
|
+
* Note: This function does not relay the transaction to the spoke chain.
|
|
12396
|
+
* You should call the `isAllowanceValid` function before calling this function to check if the allowance is valid.
|
|
12397
|
+
* You should call the `relayTxAndWaitPacket` function after calling this function to relay the transaction to the spoke chain.
|
|
12398
|
+
*
|
|
12399
|
+
* @param {MigrationParams} params - The parameters for the migration transaction.
|
|
12400
|
+
* @param {IconSpokeProvider} spokeProvider - The spoke provider.
|
|
12401
|
+
* @param {boolean} raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12402
|
+
* @returns {Promise<Result<TxReturnType<IconSpokeProvider, R>, MigrationError<'CREATE_MIGRATION_INTENT_FAILED'>>>} - Returns the raw transaction payload or transaction hash
|
|
12403
|
+
*
|
|
12404
|
+
* @example
|
|
12405
|
+
* const result = await migrationService.createMigrateIntent(
|
|
12406
|
+
* {
|
|
12407
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12408
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12409
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12410
|
+
* },
|
|
12411
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12412
|
+
* true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
|
|
12413
|
+
* );
|
|
12414
|
+
*
|
|
12415
|
+
* if (!result.ok) {
|
|
12416
|
+
* // Handle error
|
|
12417
|
+
* }
|
|
12418
|
+
*/
|
|
12419
|
+
async createMigrateIntent(params, spokeProvider, raw) {
|
|
12420
|
+
try {
|
|
12421
|
+
invariant2(params.amount > 0, "Amount must be greater than 0");
|
|
12422
|
+
invariant2(isAddress(params.to), "Recipient address is required");
|
|
12423
|
+
invariant2(
|
|
12424
|
+
params.icx.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.icx.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
12425
|
+
"Token must be wICX or native ICX token"
|
|
12426
|
+
);
|
|
12427
|
+
invariant2(spokeProvider instanceof IconSpokeProvider, "Spoke provider must be an instance of IconSpokeProvider");
|
|
12428
|
+
invariant2(params.token === "ICX", "Token must be ICX");
|
|
12429
|
+
const availableAmount = await this.icxMigration.getAvailableAmount();
|
|
12430
|
+
if (availableAmount < params.amount) {
|
|
12431
|
+
throw new Error(
|
|
12432
|
+
`Insufficient liquidity. Available: ${availableAmount.toString()}, Requested: ${params.amount.toString()}`
|
|
12433
|
+
);
|
|
12434
|
+
}
|
|
12435
|
+
const migrationData = this.icxMigration.migrateData(params);
|
|
12436
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
12437
|
+
const txResult = await SpokeService.deposit(
|
|
12438
|
+
{
|
|
12439
|
+
from: walletAddress,
|
|
12440
|
+
token: params.icx,
|
|
12441
|
+
amount: params.amount,
|
|
12442
|
+
data: migrationData
|
|
12443
|
+
},
|
|
12444
|
+
spokeProvider,
|
|
12445
|
+
this.hubProvider,
|
|
12446
|
+
raw
|
|
12447
|
+
);
|
|
12448
|
+
return {
|
|
12449
|
+
ok: true,
|
|
12450
|
+
value: txResult
|
|
12451
|
+
};
|
|
12452
|
+
} catch (error) {
|
|
12453
|
+
return {
|
|
12454
|
+
ok: false,
|
|
12455
|
+
error: {
|
|
12456
|
+
code: "CREATE_MIGRATION_INTENT_FAILED",
|
|
12457
|
+
data: {
|
|
12458
|
+
payload: params,
|
|
12459
|
+
error
|
|
12460
|
+
}
|
|
12461
|
+
}
|
|
12462
|
+
};
|
|
12463
|
+
}
|
|
12464
|
+
}
|
|
12465
|
+
/**
|
|
12466
|
+
* Creates a revert migration intent transaction on the hub chain.
|
|
12467
|
+
* Note: This function does not relay the transaction to the spoke chain.
|
|
12468
|
+
* You should call the `isAllowanceValid` function before calling this function to check if the allowance is valid.
|
|
12469
|
+
* You should call the `relayTxAndWaitPacket` function after calling this function to relay the transaction to the spoke chain.
|
|
12470
|
+
* @param {IcxCreateRevertMigrationParams} - The parameters for the revert migration transaction.
|
|
12471
|
+
* @param {SonicSpokeProvider} spokeProvider - The spoke provider.
|
|
12472
|
+
* @param {boolean} raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12473
|
+
* @returns {Promise<Result<TxReturnType<SonicSpokeProvider, R>, MigrationError<'CREATE_REVERT_MIGRATION_INTENT_FAILED'>>>} - Returns the transaction hash or error
|
|
12474
|
+
*
|
|
12475
|
+
* @example
|
|
12476
|
+
* const result = await migrationService.createRevertMigrationIntent(
|
|
12477
|
+
* {
|
|
12478
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12479
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12480
|
+
* action: 'revert',
|
|
12481
|
+
* },
|
|
12482
|
+
*/
|
|
12483
|
+
async createRevertMigrationIntent(params, spokeProvider, raw) {
|
|
12484
|
+
try {
|
|
12485
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12486
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12487
|
+
const data = this.icxMigration.revertMigration({
|
|
12488
|
+
wICX: spokeChainConfig[ICON_MAINNET_CHAIN_ID].addresses.wICX,
|
|
12489
|
+
amount: params.amount,
|
|
12490
|
+
to: encodeAddress(ICON_MAINNET_CHAIN_ID, params.to),
|
|
12491
|
+
userWallet: userRouter
|
|
12492
|
+
});
|
|
12493
|
+
const txResult = await SonicSpokeService.deposit(
|
|
12494
|
+
{
|
|
12495
|
+
from: wallet,
|
|
12496
|
+
token: this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12497
|
+
amount: params.amount,
|
|
12498
|
+
data
|
|
12499
|
+
},
|
|
12500
|
+
spokeProvider,
|
|
12501
|
+
raw
|
|
12502
|
+
);
|
|
12503
|
+
return {
|
|
12504
|
+
ok: true,
|
|
12505
|
+
value: txResult
|
|
12506
|
+
};
|
|
12507
|
+
} catch (error) {
|
|
12508
|
+
return {
|
|
12509
|
+
ok: false,
|
|
12510
|
+
error: {
|
|
12511
|
+
code: "CREATE_REVERT_MIGRATION_INTENT_FAILED",
|
|
12512
|
+
data: {
|
|
12513
|
+
payload: params,
|
|
12514
|
+
error
|
|
12515
|
+
}
|
|
12516
|
+
}
|
|
12517
|
+
};
|
|
12518
|
+
}
|
|
12519
|
+
}
|
|
12520
|
+
};
|
|
12521
|
+
|
|
10913
12522
|
// src/entities/Sodax.ts
|
|
10914
12523
|
var Sodax = class {
|
|
10915
12524
|
config;
|
|
@@ -10917,6 +12526,8 @@ var Sodax = class {
|
|
|
10917
12526
|
// Solver service enabling intent based swaps
|
|
10918
12527
|
moneyMarket;
|
|
10919
12528
|
// Money Market service enabling cross-chain lending and borrowing
|
|
12529
|
+
migration;
|
|
12530
|
+
// ICX migration service enabling ICX migration to SODA
|
|
10920
12531
|
hubProvider;
|
|
10921
12532
|
// hub provider for the hub chain (e.g. Sonic mainnet)
|
|
10922
12533
|
relayerApiEndpoint;
|
|
@@ -10927,40 +12538,41 @@ var Sodax = class {
|
|
|
10927
12538
|
this.hubProvider = new EvmHubProvider(config?.hubProviderConfig);
|
|
10928
12539
|
this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
|
|
10929
12540
|
this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService(void 0, this.hubProvider, this.relayerApiEndpoint);
|
|
12541
|
+
this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
|
|
10930
12542
|
}
|
|
10931
12543
|
};
|
|
10932
12544
|
|
|
10933
12545
|
// src/types.ts
|
|
10934
|
-
var
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
return
|
|
10941
|
-
})(
|
|
10942
|
-
var
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
return
|
|
10962
|
-
})(
|
|
12546
|
+
var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
|
|
12547
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["NOT_FOUND"] = -1] = "NOT_FOUND";
|
|
12548
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["NOT_STARTED_YET"] = 1] = "NOT_STARTED_YET";
|
|
12549
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["STARTED_NOT_FINISHED"] = 2] = "STARTED_NOT_FINISHED";
|
|
12550
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["SOLVED"] = 3] = "SOLVED";
|
|
12551
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["FAILED"] = 4] = "FAILED";
|
|
12552
|
+
return SolverIntentStatusCode2;
|
|
12553
|
+
})(SolverIntentStatusCode || {});
|
|
12554
|
+
var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
|
|
12555
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_PATH_FOUND"] = -4] = "NO_PATH_FOUND";
|
|
12556
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_PRIVATE_LIQUIDITY"] = -5] = "NO_PRIVATE_LIQUIDITY";
|
|
12557
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NOT_ENOUGH_PRIVATE_LIQUIDITY"] = -8] = "NOT_ENOUGH_PRIVATE_LIQUIDITY";
|
|
12558
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_EXECUTION_MODULE_FOUND"] = -7] = "NO_EXECUTION_MODULE_FOUND";
|
|
12559
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_NOT_FOUND"] = -8] = "QUOTE_NOT_FOUND";
|
|
12560
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_NOT_MATCH"] = -9] = "QUOTE_NOT_MATCH";
|
|
12561
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_DATA_NOT_MATCH_QUOTE"] = -10] = "INTENT_DATA_NOT_MATCH_QUOTE";
|
|
12562
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_GAS_HANDLER_FOR_BLOCKCHAIN"] = -11] = "NO_GAS_HANDLER_FOR_BLOCKCHAIN";
|
|
12563
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_NOT_FOUND"] = -12] = "INTENT_NOT_FOUND";
|
|
12564
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_EXPIRED"] = -13] = "QUOTE_EXPIRED";
|
|
12565
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["MAX_INPUT_AMOUNT"] = -14] = "MAX_INPUT_AMOUNT";
|
|
12566
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["MAX_DIFF_OUTPUT"] = -15] = "MAX_DIFF_OUTPUT";
|
|
12567
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["STOPPED"] = -16] = "STOPPED";
|
|
12568
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_ORACLE_MODULE_FOUND"] = -17] = "NO_ORACLE_MODULE_FOUND";
|
|
12569
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NEGATIVE_INPUT_AMOUNT"] = -18] = "NEGATIVE_INPUT_AMOUNT";
|
|
12570
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_ALREADY_IN_ORDERBOOK"] = -19] = "INTENT_ALREADY_IN_ORDERBOOK";
|
|
12571
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["CREATE_INTENT_ORDER_FAILED"] = -998] = "CREATE_INTENT_ORDER_FAILED";
|
|
12572
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["UNKNOWN"] = -999] = "UNKNOWN";
|
|
12573
|
+
return SolverIntentErrorCode2;
|
|
12574
|
+
})(SolverIntentErrorCode || {});
|
|
10963
12575
|
|
|
10964
|
-
export { BigIntToHex, CWSpokeProvider, 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, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IntentCreatedEventAbi, IntentDataType,
|
|
12576
|
+
export { BigIntToHex, CWSpokeProvider, 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, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, IntentCreatedEventAbi, IntentDataType, IntentsAbi, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isCWSpokeProvider, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, originalAssetTohubAssetMap, poolAbi, randomUint256, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, variableDebtTokenAbi, vaultTokenAbi, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
10965
12577
|
//# sourceMappingURL=index.mjs.map
|
|
10966
12578
|
//# sourceMappingURL=index.mjs.map
|