@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.cjs
CHANGED
|
@@ -5103,6 +5103,8 @@ var DEFAULT_RETRY_DELAY_MS = 2e3;
|
|
|
5103
5103
|
var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
|
|
5104
5104
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
5105
5105
|
var FEE_PERCENTAGE_SCALE = 10000n;
|
|
5106
|
+
var STELLAR_PRIORITY_FEE = "10000";
|
|
5107
|
+
var STELLAR_DEFAULT_TX_TIMEOUT_SECONDS = 100;
|
|
5106
5108
|
var VAULT_TOKEN_DECIMALS = 18;
|
|
5107
5109
|
var INTENT_RELAY_CHAIN_IDS = {
|
|
5108
5110
|
AVAX: 6n,
|
|
@@ -5187,7 +5189,9 @@ var hubChainConfig = {
|
|
|
5187
5189
|
addresses: {
|
|
5188
5190
|
assetManager: "0x60c5681bD1DB4e50735c4cA3386005A4BA4937C0",
|
|
5189
5191
|
hubWallet: "0xA0ed3047D358648F2C0583B415CffCA571FDB544",
|
|
5190
|
-
xTokenManager: "0x5bD2843de9D6b0e6A05d0FB742072274EA3C6CA3"
|
|
5192
|
+
xTokenManager: "0x5bD2843de9D6b0e6A05d0FB742072274EA3C6CA3",
|
|
5193
|
+
icxMigration: "0x8Af7cae2c8377BEDD8820A5ad096AaFA29D839cc",
|
|
5194
|
+
sodaToken: "0x8515352CB9832D1d379D52366D1E995ADd358420"
|
|
5191
5195
|
},
|
|
5192
5196
|
nativeToken: "0x0000000000000000000000000000000000000000",
|
|
5193
5197
|
supportedTokens: []
|
|
@@ -5237,6 +5241,12 @@ var spokeChainConfig = {
|
|
|
5237
5241
|
name: "Wrapped Sonic",
|
|
5238
5242
|
decimals: 18,
|
|
5239
5243
|
address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
|
|
5244
|
+
},
|
|
5245
|
+
SODA: {
|
|
5246
|
+
symbol: "SODA",
|
|
5247
|
+
name: "SODAX",
|
|
5248
|
+
decimals: 18,
|
|
5249
|
+
address: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963"
|
|
5240
5250
|
}
|
|
5241
5251
|
}
|
|
5242
5252
|
},
|
|
@@ -5272,8 +5282,8 @@ var spokeChainConfig = {
|
|
|
5272
5282
|
}
|
|
5273
5283
|
},
|
|
5274
5284
|
gasPrice: "500000",
|
|
5275
|
-
rpcUrl: "https://
|
|
5276
|
-
wsUrl: "https://
|
|
5285
|
+
rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/i3q5fE3cYSFBE4Lcg1kS5",
|
|
5286
|
+
wsUrl: "https://solana-mainnet.g.alchemy.com/v2/i3q5fE3cYSFBE4Lcg1kS5",
|
|
5277
5287
|
walletAddress: ""
|
|
5278
5288
|
},
|
|
5279
5289
|
[types.AVALANCHE_MAINNET_CHAIN_ID]: {
|
|
@@ -5367,12 +5377,6 @@ var spokeChainConfig = {
|
|
|
5367
5377
|
decimals: 18,
|
|
5368
5378
|
address: "0xA256dd181C3f6E5eC68C6869f5D50a712d47212e"
|
|
5369
5379
|
},
|
|
5370
|
-
WETH: {
|
|
5371
|
-
symbol: "WETH",
|
|
5372
|
-
name: "Wrapped Ether",
|
|
5373
|
-
decimals: 18,
|
|
5374
|
-
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
|
|
5375
|
-
},
|
|
5376
5380
|
wstETH: {
|
|
5377
5381
|
symbol: "wstETH",
|
|
5378
5382
|
name: "Wrapped stETH",
|
|
@@ -5664,9 +5668,10 @@ var spokeChainConfig = {
|
|
|
5664
5668
|
},
|
|
5665
5669
|
nativeToken: "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
|
|
5666
5670
|
bnUSD: "CD6YBFFWMU2UJHX2NGRJ7RN76IJVTCC7MRA46DUBXNB7E6W7H7JRJ2CX",
|
|
5667
|
-
|
|
5671
|
+
horizonRpcUrl: "https://horizon.stellar.org",
|
|
5672
|
+
sorobanRpcUrl: "https://rpc.ankr.com/stellar_soroban",
|
|
5668
5673
|
chain: {
|
|
5669
|
-
name: "
|
|
5674
|
+
name: "Stellar",
|
|
5670
5675
|
id: types.STELLAR_MAINNET_CHAIN_ID,
|
|
5671
5676
|
type: "STELLAR"
|
|
5672
5677
|
}
|
|
@@ -5697,6 +5702,42 @@ var spokeChainConfig = {
|
|
|
5697
5702
|
name: "USD Coin",
|
|
5698
5703
|
decimals: 6,
|
|
5699
5704
|
address: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
|
|
5705
|
+
},
|
|
5706
|
+
afSUI: {
|
|
5707
|
+
symbol: "afSUI",
|
|
5708
|
+
name: "Aftermath Staked Sui",
|
|
5709
|
+
decimals: 9,
|
|
5710
|
+
address: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
|
|
5711
|
+
},
|
|
5712
|
+
mSUI: {
|
|
5713
|
+
symbol: "mSUI",
|
|
5714
|
+
name: "Mirai Staked SUI",
|
|
5715
|
+
decimals: 9,
|
|
5716
|
+
address: "0x922d15d7f55c13fd790f6e54397470ec592caa2b508df292a2e8553f3d3b274f::msui::MSUI"
|
|
5717
|
+
},
|
|
5718
|
+
haSUI: {
|
|
5719
|
+
symbol: "haSUI",
|
|
5720
|
+
name: "haSUI",
|
|
5721
|
+
decimals: 9,
|
|
5722
|
+
address: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
5723
|
+
},
|
|
5724
|
+
vSUI: {
|
|
5725
|
+
symbol: "vSUI",
|
|
5726
|
+
name: "Volo Staked SUI",
|
|
5727
|
+
decimals: 9,
|
|
5728
|
+
address: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
|
|
5729
|
+
},
|
|
5730
|
+
yapSUI: {
|
|
5731
|
+
symbol: "yapSUI",
|
|
5732
|
+
name: "Yap Staked SUI",
|
|
5733
|
+
decimals: 9,
|
|
5734
|
+
address: "0x83f1bb8c91ecd1fd313344058b0eed94d63c54e41d8d1ae5bff1353443517d65::yap_sui::YAP_SUI"
|
|
5735
|
+
},
|
|
5736
|
+
trevinSUI: {
|
|
5737
|
+
symbol: "trevinSUI",
|
|
5738
|
+
name: "Trevin Staked SUI",
|
|
5739
|
+
decimals: 9,
|
|
5740
|
+
address: "0x502867b177303bf1bf226245fcdd3403c177e78d175a55a56c0602c7ff51c7fa::trevin_sui::TREVIN_SUI"
|
|
5700
5741
|
}
|
|
5701
5742
|
},
|
|
5702
5743
|
nativeToken: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
@@ -5712,7 +5753,8 @@ var spokeChainConfig = {
|
|
|
5712
5753
|
addresses: {
|
|
5713
5754
|
assetManager: "cx1be33c283c7dc7617181d1b21a6a2309e71b1ee7",
|
|
5714
5755
|
connection: "cxe5cdf3b0f26967b0efc72d470d57bbf534268f94",
|
|
5715
|
-
rateLimit: "cxbbdcea9e6757023a046067ba8daa3c4c50304358"
|
|
5756
|
+
rateLimit: "cxbbdcea9e6757023a046067ba8daa3c4c50304358",
|
|
5757
|
+
wICX: "cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
|
|
5716
5758
|
},
|
|
5717
5759
|
chain: {
|
|
5718
5760
|
id: types.ICON_MAINNET_CHAIN_ID,
|
|
@@ -5744,6 +5786,201 @@ var spokeChainConfig = {
|
|
|
5744
5786
|
nid: "0x1"
|
|
5745
5787
|
}
|
|
5746
5788
|
};
|
|
5789
|
+
var HubVaultSymbols = [
|
|
5790
|
+
"sodaAVAX",
|
|
5791
|
+
"sodaBNB",
|
|
5792
|
+
"sodaETH",
|
|
5793
|
+
"sodaBTC",
|
|
5794
|
+
"sodaSUI",
|
|
5795
|
+
"sodaINJ",
|
|
5796
|
+
"sodaXLM",
|
|
5797
|
+
"sodaSOL",
|
|
5798
|
+
"sodaSODA",
|
|
5799
|
+
"sodaUSDT",
|
|
5800
|
+
"sodaUSDC",
|
|
5801
|
+
"bnUSD",
|
|
5802
|
+
"sodaPOL",
|
|
5803
|
+
"sodaNIBI",
|
|
5804
|
+
"sodaS",
|
|
5805
|
+
"IbnUSD"
|
|
5806
|
+
];
|
|
5807
|
+
var hubVaults = {
|
|
5808
|
+
IbnUSD: {
|
|
5809
|
+
address: "0x9D4b663Eb075d2a1C7B8eaEFB9eCCC0510388B51",
|
|
5810
|
+
reserves: [
|
|
5811
|
+
// hub asset addresses contained in the vault
|
|
5812
|
+
"0x654DdDf32a9a2aC53f5FB54bf1e93F66791f8047",
|
|
5813
|
+
"0xddf6AD38F9C9451C1F4cDf369040F6869e37393e",
|
|
5814
|
+
"0x1559B52d2e165da1505a542EA37C543c9137f52a"
|
|
5815
|
+
]
|
|
5816
|
+
},
|
|
5817
|
+
sodaS: {
|
|
5818
|
+
address: "0x62ecc3eeb80a162c57624b3ff80313fe69f5203e",
|
|
5819
|
+
reserves: [
|
|
5820
|
+
// hub asset addresses contained in the vault
|
|
5821
|
+
"0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38"
|
|
5822
|
+
]
|
|
5823
|
+
},
|
|
5824
|
+
sodaNIBI: {
|
|
5825
|
+
address: "0xc6c85287a8b173a509c2f198bb719a8a5a2d0c68",
|
|
5826
|
+
reserves: [
|
|
5827
|
+
// hub asset addresses contained in the vault
|
|
5828
|
+
"0xe0064414c2c1a636a9424c7a17d86fbf7fd3f190"
|
|
5829
|
+
]
|
|
5830
|
+
},
|
|
5831
|
+
sodaPOL: {
|
|
5832
|
+
address: "0x208ed38f4783328aa9ebfec360d32e7520a9b779",
|
|
5833
|
+
reserves: [
|
|
5834
|
+
// hub asset addresses contained in the vault
|
|
5835
|
+
"0x9ee17486571917837210824b0d4cadfe3b324d12"
|
|
5836
|
+
]
|
|
5837
|
+
},
|
|
5838
|
+
bnUSD: {
|
|
5839
|
+
address: "0xe801ca34e19abcbfea12025378d19c4fbe250131",
|
|
5840
|
+
reserves: [
|
|
5841
|
+
// hub asset addresses contained in the vault
|
|
5842
|
+
"0xabbb91c0617090f0028bdc27597cd0d038f3a833",
|
|
5843
|
+
"0xbdf1f453fcb61424011bbddcb96cfdb30f3fe876",
|
|
5844
|
+
"0x94dc79ce9c515ba4ae4d195da8e6ab86c69bfc38",
|
|
5845
|
+
"0x5ce6c1c51ff762cf3acd21396257046f694168b6",
|
|
5846
|
+
"0xdf5639d91359866f266b56d60d98ede9feedd100",
|
|
5847
|
+
"0x238384ae2b4f0ec189ecb5031859ba306b2679c5",
|
|
5848
|
+
"0x419ca9054e44e94ceab52846ecdc3997439bbca6",
|
|
5849
|
+
"0x18f85f9e80ff9496eebd5979a051af16ce751567",
|
|
5850
|
+
"0x289cda1043b4ce26bdca3c12e534f56b24308a5b",
|
|
5851
|
+
"0x23225ab8e63fca4070296678cb46566d57e1bbe3",
|
|
5852
|
+
"0x14c65b1cdc0b821569081b1f77342da0d0cbf439",
|
|
5853
|
+
"0xdf23097b9aeb917bf8fb70e99b6c528fffa35364",
|
|
5854
|
+
"0x11b93c162aabffd026539bb3b9f9ec22c8b7ef8a",
|
|
5855
|
+
"0x69425ffb14704124a58d6f69d510f74a59d9a5bc",
|
|
5856
|
+
"0x9d4b663eb075d2a1c7b8eaefb9eccc0510388b51"
|
|
5857
|
+
]
|
|
5858
|
+
},
|
|
5859
|
+
sodaSODA: {
|
|
5860
|
+
// SODA SODA vault
|
|
5861
|
+
address: "0x21685e341de7844135329914be6bd8d16982d834",
|
|
5862
|
+
reserves: [
|
|
5863
|
+
// hub asset addresses contained in the vault
|
|
5864
|
+
"0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
|
|
5865
|
+
// SODA SODA hub asset
|
|
5866
|
+
]
|
|
5867
|
+
},
|
|
5868
|
+
sodaAVAX: {
|
|
5869
|
+
// SODA AVAX vault
|
|
5870
|
+
address: "0x14238d267557e9d799016ad635b53cd15935d290",
|
|
5871
|
+
reserves: [
|
|
5872
|
+
// hub asset addresses contained in the vault
|
|
5873
|
+
"0xc9e4f0b6195f389d9d2b639f2878b7674eb9d8cd"
|
|
5874
|
+
// AvalancheAVAX hub asset
|
|
5875
|
+
]
|
|
5876
|
+
},
|
|
5877
|
+
sodaBNB: {
|
|
5878
|
+
// SODA BNB vault
|
|
5879
|
+
address: "0x40cd41b35db9e5109ae7e54b44de8625db320e6b",
|
|
5880
|
+
reserves: [
|
|
5881
|
+
// hub asset addresses contained in the vault
|
|
5882
|
+
"0x13b70564b1ec12876b20fab5d1bb630311312f4f"
|
|
5883
|
+
// BSC BNB hub asset
|
|
5884
|
+
]
|
|
5885
|
+
},
|
|
5886
|
+
sodaETH: {
|
|
5887
|
+
// SODA ETH vault
|
|
5888
|
+
address: "0x4effb5813271699683c25c734f4dabc45b363709",
|
|
5889
|
+
reserves: [
|
|
5890
|
+
// hub asset addresses contained in the vault
|
|
5891
|
+
"0x70178089842be7f8e4726b33f0d1569db8021faa",
|
|
5892
|
+
// BASE ETH hub asset
|
|
5893
|
+
"0xad332860dd3b6f0e63f4f66e9457900917ac78cd",
|
|
5894
|
+
// Optimism ETH hub asset
|
|
5895
|
+
"0xdcd9578b51ef55239b6e68629d822a8d97c95b86",
|
|
5896
|
+
// Arbitrum ETH hub asset
|
|
5897
|
+
"0x57fc2ac5701e463ae261adbd6c99fbeb48ce5293",
|
|
5898
|
+
// BSC ETH hub asset
|
|
5899
|
+
"0x50c42deacd8fc9773493ed674b675be577f2634b"
|
|
5900
|
+
// Sonic WETH hub asset
|
|
5901
|
+
]
|
|
5902
|
+
},
|
|
5903
|
+
sodaBTC: {
|
|
5904
|
+
// SODA BTC vault
|
|
5905
|
+
address: "0x7a1a5555842ad2d0ed274d09b5c4406a95799d5d",
|
|
5906
|
+
reserves: [
|
|
5907
|
+
// hub asset addresses contained in the vault
|
|
5908
|
+
"0x2803a23a3ba6b09e57d1c71dec0d9efdbb00a27f",
|
|
5909
|
+
// BASE cbBTC hub asset,
|
|
5910
|
+
"0xfb0acb1b2720b620935f50a6dd3f7fea52b2fcbe",
|
|
5911
|
+
// Arbitrum wBTC hub asset
|
|
5912
|
+
"0x96fc8540736f1598b7e235e6de8814062b3b5d3b",
|
|
5913
|
+
// Arbitrum tBTC hub asset,
|
|
5914
|
+
"0xd8a24c71fea5bb81c66c01e532de7d9b11e13905"
|
|
5915
|
+
// BSC BTCB hub asset
|
|
5916
|
+
]
|
|
5917
|
+
},
|
|
5918
|
+
sodaSUI: {
|
|
5919
|
+
// SODA SUI vault
|
|
5920
|
+
address: "0xdc5b4b00f98347e95b9f94911213dab4c687e1e3",
|
|
5921
|
+
reserves: [
|
|
5922
|
+
// hub asset addresses contained in the vault
|
|
5923
|
+
"0x4676b2a551b25c04e235553c1c81019337384673"
|
|
5924
|
+
// SUI SUI hub asset
|
|
5925
|
+
]
|
|
5926
|
+
},
|
|
5927
|
+
sodaINJ: {
|
|
5928
|
+
// SODA INJ vault
|
|
5929
|
+
address: "0x1f22279c89b213944b7ea41dacb0a868ddcdfd13",
|
|
5930
|
+
reserves: [
|
|
5931
|
+
// hub asset addresses contained in the vault
|
|
5932
|
+
"0xd375590b4955f6ea5623f799153f9b787a3bd319"
|
|
5933
|
+
// Injective INJ hub asset
|
|
5934
|
+
]
|
|
5935
|
+
},
|
|
5936
|
+
sodaXLM: {
|
|
5937
|
+
// SODA XLM vault
|
|
5938
|
+
address: "0x6bc8c37cba91f76e68c9e6d689a9c21e4d32079b",
|
|
5939
|
+
reserves: [
|
|
5940
|
+
// hub asset addresses contained in the vault
|
|
5941
|
+
"0x8ac68af223907fb1b893086601a3d99e00f2fa9d"
|
|
5942
|
+
// Stellar XLM hub asset
|
|
5943
|
+
]
|
|
5944
|
+
},
|
|
5945
|
+
sodaSOL: {
|
|
5946
|
+
// SODA SOL vault
|
|
5947
|
+
address: "0xdea692287e2ce8cb08fa52917be0f16b1dacdc87",
|
|
5948
|
+
reserves: [
|
|
5949
|
+
// hub asset addresses contained in the vault
|
|
5950
|
+
"0x0c09e69a4528945de6d16c7e469dea6996fdf636"
|
|
5951
|
+
// Solana SOL hub asset
|
|
5952
|
+
]
|
|
5953
|
+
},
|
|
5954
|
+
sodaUSDT: {
|
|
5955
|
+
// SODA USDT vault
|
|
5956
|
+
address: "0xbdf1f453fcb61424011bbddcb96cfdb30f3fe876",
|
|
5957
|
+
reserves: [
|
|
5958
|
+
// hub asset addresses contained in the vault
|
|
5959
|
+
"0x41fd5c169e014e2a657b9de3553f7a7b735fe47a",
|
|
5960
|
+
"0xc168067d95109003805ac865ae556e8476dc69bc",
|
|
5961
|
+
"0x3c0a80c6a1110fc80309382b3989ec626c135ee9",
|
|
5962
|
+
"0x6047828dc181963ba44974801ff68e538da5eaf9"
|
|
5963
|
+
// Sonic USDT
|
|
5964
|
+
]
|
|
5965
|
+
},
|
|
5966
|
+
sodaUSDC: {
|
|
5967
|
+
address: "0xabbb91c0617090f0028bdc27597cd0d038f3a833",
|
|
5968
|
+
reserves: [
|
|
5969
|
+
"0x41abf4b1559ff709ef8150079bcb26db1fffd117",
|
|
5970
|
+
"0x72e852545b024ddcbc5b70c1bcbdaa025164259c",
|
|
5971
|
+
"0xb7c213cbd24967de9838fa014668fddb338f724b",
|
|
5972
|
+
"0xdb7bda65c3a1c51d64dc4444e418684677334109",
|
|
5973
|
+
"0xa36893ba308b332fdebfa95916d1df3a2e3cf8b3",
|
|
5974
|
+
"0x29219dd400f2bf60e5a23d13be72b486d4038894",
|
|
5975
|
+
"0x5635369c8a29a081d26c2e9e28012fca548ba0cb",
|
|
5976
|
+
"0x3d73437dd81b3f9ec82752beb1752f03a8531710",
|
|
5977
|
+
"0x4bc1211faa06fb50ff61a70331f56167ae511057",
|
|
5978
|
+
"0x348007b53f25a9a857ab8ea81ec9e3ccbcf440f2",
|
|
5979
|
+
"0xc3f020057510ffe10ceb882e1b48238b43d78a5e",
|
|
5980
|
+
"0x9d58508ad10d34048a11640735ca5075bba07b35"
|
|
5981
|
+
]
|
|
5982
|
+
}
|
|
5983
|
+
};
|
|
5747
5984
|
var hubAssets = {
|
|
5748
5985
|
[types.SONIC_MAINNET_CHAIN_ID]: {
|
|
5749
5986
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].nativeToken]: {
|
|
@@ -5751,35 +5988,42 @@ var hubAssets = {
|
|
|
5751
5988
|
decimal: 18,
|
|
5752
5989
|
symbol: "S",
|
|
5753
5990
|
name: "Sonic",
|
|
5754
|
-
vault:
|
|
5991
|
+
vault: hubVaults.sodaS.address
|
|
5755
5992
|
},
|
|
5756
5993
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic.address]: {
|
|
5757
5994
|
asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
5758
5995
|
decimal: 18,
|
|
5759
5996
|
symbol: "wSonic",
|
|
5760
5997
|
name: "Sonic",
|
|
5761
|
-
vault:
|
|
5998
|
+
vault: hubVaults.sodaS.address
|
|
5762
5999
|
},
|
|
5763
6000
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address]: {
|
|
5764
6001
|
asset: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b",
|
|
5765
6002
|
decimal: 18,
|
|
5766
6003
|
symbol: "WETH",
|
|
5767
6004
|
name: "Wrapped Ethereum",
|
|
5768
|
-
vault:
|
|
6005
|
+
vault: hubVaults.sodaETH.address
|
|
5769
6006
|
},
|
|
5770
6007
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5771
6008
|
asset: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
|
|
5772
6009
|
decimal: 6,
|
|
5773
6010
|
symbol: "USDC ",
|
|
5774
6011
|
name: "USD Coin",
|
|
5775
|
-
vault:
|
|
6012
|
+
vault: hubVaults.sodaUSDC.address
|
|
5776
6013
|
},
|
|
5777
6014
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5778
6015
|
asset: "0x6047828dc181963ba44974801ff68e538da5eaf9",
|
|
5779
6016
|
decimal: 6,
|
|
5780
6017
|
symbol: "USDT",
|
|
5781
6018
|
name: "Tether USD",
|
|
5782
|
-
vault:
|
|
6019
|
+
vault: hubVaults.sodaUSDT.address
|
|
6020
|
+
},
|
|
6021
|
+
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address]: {
|
|
6022
|
+
asset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
|
|
6023
|
+
decimal: 18,
|
|
6024
|
+
symbol: "SODA",
|
|
6025
|
+
name: "SODA",
|
|
6026
|
+
vault: hubVaults.sodaSODA.address
|
|
5783
6027
|
}
|
|
5784
6028
|
},
|
|
5785
6029
|
[types.AVALANCHE_MAINNET_CHAIN_ID]: {
|
|
@@ -5788,28 +6032,28 @@ var hubAssets = {
|
|
|
5788
6032
|
decimal: 18,
|
|
5789
6033
|
symbol: "AVAX",
|
|
5790
6034
|
name: "AVAX",
|
|
5791
|
-
vault:
|
|
6035
|
+
vault: hubVaults.sodaAVAX.address
|
|
5792
6036
|
},
|
|
5793
6037
|
[spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5794
6038
|
asset: "0x41Fd5c169e014e2A657B9de3553f7a7b735Fe47A",
|
|
5795
6039
|
decimal: 6,
|
|
5796
6040
|
symbol: "USDT",
|
|
5797
6041
|
name: "Tether USD",
|
|
5798
|
-
vault:
|
|
6042
|
+
vault: hubVaults.sodaUSDT.address
|
|
5799
6043
|
},
|
|
5800
6044
|
[spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5801
6045
|
asset: "0x41abF4B1559FF709Ef8150079BcB26DB1Fffd117",
|
|
5802
6046
|
decimal: 6,
|
|
5803
6047
|
symbol: "USDC",
|
|
5804
6048
|
name: "USD Coin",
|
|
5805
|
-
vault:
|
|
6049
|
+
vault: hubVaults.sodaUSDC.address
|
|
5806
6050
|
},
|
|
5807
6051
|
[spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5808
6052
|
asset: "0x289cDa1043b4Ce26BDCa3c12E534f56b24308A5B",
|
|
5809
6053
|
decimal: 18,
|
|
5810
6054
|
symbol: "bnUSD",
|
|
5811
6055
|
name: "bnUSD",
|
|
5812
|
-
vault:
|
|
6056
|
+
vault: hubVaults.bnUSD.address
|
|
5813
6057
|
}
|
|
5814
6058
|
},
|
|
5815
6059
|
[types.ARBITRUM_MAINNET_CHAIN_ID]: {
|
|
@@ -5818,56 +6062,58 @@ var hubAssets = {
|
|
|
5818
6062
|
decimal: 18,
|
|
5819
6063
|
symbol: "ETH",
|
|
5820
6064
|
name: "Ethereum",
|
|
5821
|
-
vault:
|
|
6065
|
+
vault: hubVaults.sodaETH.address
|
|
5822
6066
|
},
|
|
5823
6067
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC.address]: {
|
|
5824
6068
|
asset: "0xfB0ACB1b2720B620935F50a6dd3F7FEA52b2FCBe",
|
|
5825
6069
|
decimal: 8,
|
|
5826
6070
|
symbol: "WBTC",
|
|
5827
6071
|
name: "Wrapped Bitcoin",
|
|
5828
|
-
vault:
|
|
6072
|
+
vault: hubVaults.sodaBTC.address
|
|
5829
6073
|
},
|
|
5830
6074
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5831
6075
|
asset: "0x08D5cf039De35627fD5C0f48B8AF4a1647a462E8",
|
|
5832
6076
|
decimal: 18,
|
|
5833
6077
|
symbol: "weETH",
|
|
5834
6078
|
name: "Wrapped eETH",
|
|
5835
|
-
vault: "
|
|
6079
|
+
vault: "0x"
|
|
6080
|
+
// no vault yet
|
|
5836
6081
|
},
|
|
5837
6082
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5838
6083
|
asset: "0x2D5A7837D68b0c2CC4b14C2af2a1F0Ef420DDDc5",
|
|
5839
6084
|
decimal: 18,
|
|
5840
6085
|
symbol: "wstETH",
|
|
5841
6086
|
name: "Wrapped Staked Ethereum",
|
|
5842
|
-
vault: "
|
|
6087
|
+
vault: "0x"
|
|
6088
|
+
// no vault yet
|
|
5843
6089
|
},
|
|
5844
6090
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.tBTC.address]: {
|
|
5845
6091
|
asset: "0x96Fc8540736f1598b7E235e6dE8814062b3b5d3B",
|
|
5846
6092
|
decimal: 18,
|
|
5847
6093
|
symbol: "tBTC",
|
|
5848
6094
|
name: "Arbitrum tBTC",
|
|
5849
|
-
vault:
|
|
6095
|
+
vault: hubVaults.sodaBTC.address
|
|
5850
6096
|
},
|
|
5851
6097
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5852
6098
|
asset: "0x3C0a80C6a1110fC80309382b3989eC626c135eE9",
|
|
5853
6099
|
decimal: 6,
|
|
5854
6100
|
symbol: "USDT",
|
|
5855
6101
|
name: "Tether USD",
|
|
5856
|
-
vault:
|
|
6102
|
+
vault: hubVaults.sodaUSDT.address
|
|
5857
6103
|
},
|
|
5858
6104
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5859
6105
|
asset: "0xdB7BdA65c3a1C51D64dC4444e418684677334109",
|
|
5860
6106
|
decimal: 6,
|
|
5861
6107
|
symbol: "USDC",
|
|
5862
6108
|
name: "USD Coin",
|
|
5863
|
-
vault:
|
|
6109
|
+
vault: hubVaults.sodaUSDC.address
|
|
5864
6110
|
},
|
|
5865
6111
|
[spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5866
6112
|
asset: "0x419cA9054E44E94ceAb52846eCdC3997439BBcA6",
|
|
5867
6113
|
decimal: 18,
|
|
5868
6114
|
symbol: "bnUSD",
|
|
5869
6115
|
name: "bnUSD",
|
|
5870
|
-
vault:
|
|
6116
|
+
vault: hubVaults.bnUSD.address
|
|
5871
6117
|
}
|
|
5872
6118
|
},
|
|
5873
6119
|
[types.BASE_MAINNET_CHAIN_ID]: {
|
|
@@ -5876,42 +6122,44 @@ var hubAssets = {
|
|
|
5876
6122
|
decimal: 18,
|
|
5877
6123
|
symbol: "ETH",
|
|
5878
6124
|
name: "Ethereum",
|
|
5879
|
-
vault:
|
|
6125
|
+
vault: hubVaults.sodaETH.address
|
|
5880
6126
|
},
|
|
5881
6127
|
[spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.cbBTC.address]: {
|
|
5882
6128
|
asset: "0x2803a23a3BA6b09e57D1c71deC0D9eFdBB00A27F",
|
|
5883
6129
|
decimal: 8,
|
|
5884
6130
|
symbol: "cbBTC",
|
|
5885
6131
|
name: "Coinbase Wrapped BTC",
|
|
5886
|
-
vault:
|
|
6132
|
+
vault: hubVaults.sodaBTC.address
|
|
5887
6133
|
},
|
|
5888
6134
|
[spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5889
6135
|
asset: "0x72E852545B024ddCbc5b70C1bCBDAA025164259C",
|
|
5890
6136
|
decimal: 6,
|
|
5891
6137
|
symbol: "USDC",
|
|
5892
6138
|
name: "USD Coin",
|
|
5893
|
-
vault:
|
|
6139
|
+
vault: hubVaults.sodaUSDC.address
|
|
5894
6140
|
},
|
|
5895
6141
|
[spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5896
6142
|
asset: "0xDF5639D91359866f266b56D60d98edE9fEEDd100",
|
|
5897
6143
|
decimal: 18,
|
|
5898
6144
|
symbol: "bnUSD",
|
|
5899
6145
|
name: "bnUSD",
|
|
5900
|
-
vault:
|
|
6146
|
+
vault: hubVaults.bnUSD.address
|
|
5901
6147
|
},
|
|
5902
6148
|
[spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5903
6149
|
asset: "0x55e0ad45eb97493b3045eee417fb6726cb85dfd4",
|
|
5904
6150
|
decimal: 18,
|
|
5905
6151
|
symbol: "weETH",
|
|
5906
6152
|
name: "Wrapped eETH",
|
|
5907
|
-
vault: "
|
|
6153
|
+
vault: "0x"
|
|
6154
|
+
// no vault yet
|
|
5908
6155
|
},
|
|
5909
6156
|
[spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5910
6157
|
asset: "0x494aaeaefdf5964d4ed400174e8c5b98c00957aa",
|
|
5911
6158
|
decimal: 18,
|
|
5912
6159
|
symbol: "wstETH",
|
|
5913
6160
|
name: "Wrapped Staked Ethereum",
|
|
5914
|
-
vault: "
|
|
6161
|
+
vault: "0x"
|
|
6162
|
+
// no vault yet
|
|
5915
6163
|
}
|
|
5916
6164
|
},
|
|
5917
6165
|
[types.OPTIMISM_MAINNET_CHAIN_ID]: {
|
|
@@ -5920,42 +6168,44 @@ var hubAssets = {
|
|
|
5920
6168
|
decimal: 18,
|
|
5921
6169
|
symbol: "ETH",
|
|
5922
6170
|
name: "Ethereum",
|
|
5923
|
-
vault:
|
|
6171
|
+
vault: hubVaults.sodaETH.address
|
|
5924
6172
|
},
|
|
5925
6173
|
[spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5926
6174
|
asset: "0x238384AE2b4F0EC189ecB5031859bA306B2679c5",
|
|
5927
6175
|
decimal: 18,
|
|
5928
6176
|
symbol: "bnUSD",
|
|
5929
6177
|
name: "bnUSD",
|
|
5930
|
-
vault:
|
|
6178
|
+
vault: hubVaults.bnUSD.address
|
|
5931
6179
|
},
|
|
5932
6180
|
[spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
5933
6181
|
asset: "0xb7C213CbD24967dE9838fa014668FDDB338f724B",
|
|
5934
6182
|
decimal: 6,
|
|
5935
6183
|
symbol: "USDC",
|
|
5936
6184
|
name: "USD Coin",
|
|
5937
|
-
vault:
|
|
6185
|
+
vault: hubVaults.sodaUSDC.address
|
|
5938
6186
|
},
|
|
5939
6187
|
[spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH.address]: {
|
|
5940
6188
|
asset: "0x61e26f611090CdC6bc79A7Bf156b0fD10f1fC212",
|
|
5941
6189
|
decimal: 18,
|
|
5942
6190
|
symbol: "wstETH",
|
|
5943
6191
|
name: "Wrapped Staked Ethereum",
|
|
5944
|
-
vault: "
|
|
6192
|
+
vault: "0x"
|
|
6193
|
+
// no vault yet
|
|
5945
6194
|
},
|
|
5946
6195
|
[spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH.address]: {
|
|
5947
6196
|
asset: "0xE121c0Dc2B33c00ff31ee3D902D248cc3f19Ea50",
|
|
5948
6197
|
decimal: 18,
|
|
5949
6198
|
symbol: "weETH",
|
|
5950
6199
|
name: "Wrapped eETH",
|
|
5951
|
-
vault: "
|
|
6200
|
+
vault: "0x"
|
|
6201
|
+
// no vault yet
|
|
5952
6202
|
},
|
|
5953
6203
|
[spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
|
|
5954
6204
|
asset: "0xc168067d95109003805aC865ae556e8476DC69bc",
|
|
5955
6205
|
decimal: 6,
|
|
5956
6206
|
symbol: "USDT",
|
|
5957
6207
|
name: "Tether USD",
|
|
5958
|
-
vault:
|
|
6208
|
+
vault: hubVaults.sodaUSDT.address
|
|
5959
6209
|
}
|
|
5960
6210
|
},
|
|
5961
6211
|
[types.NIBIRU_MAINNET_CHAIN_ID]: {
|
|
@@ -5964,14 +6214,14 @@ var hubAssets = {
|
|
|
5964
6214
|
decimal: 18,
|
|
5965
6215
|
symbol: "NIBI",
|
|
5966
6216
|
name: "Nibiru",
|
|
5967
|
-
vault:
|
|
6217
|
+
vault: hubVaults.sodaNIBI.address
|
|
5968
6218
|
},
|
|
5969
6219
|
[spokeChainConfig[types.NIBIRU_MAINNET_CHAIN_ID].bnUSD]: {
|
|
5970
6220
|
asset: "0x11b93C162aABFfD026539bb3B9F9eC22c8b7ef8a",
|
|
5971
6221
|
decimal: 18,
|
|
5972
6222
|
symbol: "bnUSD",
|
|
5973
6223
|
name: "bnUSD",
|
|
5974
|
-
vault:
|
|
6224
|
+
vault: hubVaults.bnUSD.address
|
|
5975
6225
|
}
|
|
5976
6226
|
},
|
|
5977
6227
|
[types.BSC_MAINNET_CHAIN_ID]: {
|
|
@@ -5980,35 +6230,35 @@ var hubAssets = {
|
|
|
5980
6230
|
decimal: 18,
|
|
5981
6231
|
symbol: "BNB",
|
|
5982
6232
|
name: "BNB",
|
|
5983
|
-
vault:
|
|
6233
|
+
vault: hubVaults.sodaBNB.address
|
|
5984
6234
|
},
|
|
5985
6235
|
[spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.ETHB.address]: {
|
|
5986
6236
|
asset: "0x57fC2aC5701e463ae261AdBd6C99FBeB48Ce5293",
|
|
5987
6237
|
decimal: 18,
|
|
5988
6238
|
symbol: "ETHB",
|
|
5989
6239
|
name: "Wrapped Ethereum",
|
|
5990
|
-
vault:
|
|
6240
|
+
vault: hubVaults.sodaETH.address
|
|
5991
6241
|
},
|
|
5992
6242
|
[spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.BTCB.address]: {
|
|
5993
6243
|
asset: "0xD8A24c71FEa5bB81c66C01e532dE7d9B11e13905",
|
|
5994
6244
|
decimal: 18,
|
|
5995
6245
|
symbol: "BTCB",
|
|
5996
6246
|
name: "Wrapped Bitcoin",
|
|
5997
|
-
vault:
|
|
6247
|
+
vault: hubVaults.sodaBTC.address
|
|
5998
6248
|
},
|
|
5999
6249
|
[spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6000
6250
|
asset: "0x5Ce6C1c51ff762cF3acD21396257046f694168b6",
|
|
6001
6251
|
decimal: 18,
|
|
6002
6252
|
symbol: "bnUSD",
|
|
6003
6253
|
name: "bnUSD",
|
|
6004
|
-
vault:
|
|
6254
|
+
vault: hubVaults.bnUSD.address
|
|
6005
6255
|
},
|
|
6006
6256
|
[spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6007
6257
|
asset: "0x9d58508ad10d34048a11640735ca5075bba07b35",
|
|
6008
6258
|
decimal: 18,
|
|
6009
6259
|
symbol: "USDC",
|
|
6010
6260
|
name: "USD Coin",
|
|
6011
|
-
vault:
|
|
6261
|
+
vault: hubVaults.sodaUSDC.address
|
|
6012
6262
|
}
|
|
6013
6263
|
},
|
|
6014
6264
|
[types.POLYGON_MAINNET_CHAIN_ID]: {
|
|
@@ -6017,21 +6267,21 @@ var hubAssets = {
|
|
|
6017
6267
|
decimal: 18,
|
|
6018
6268
|
symbol: "MATIC",
|
|
6019
6269
|
name: "Polygon",
|
|
6020
|
-
vault:
|
|
6270
|
+
vault: hubVaults.sodaPOL.address
|
|
6021
6271
|
},
|
|
6022
6272
|
[spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6023
6273
|
asset: "0x18f85f9E80ff9496EeBD5979a051AF16Ce751567",
|
|
6024
6274
|
decimal: 18,
|
|
6025
6275
|
symbol: "bnUSD",
|
|
6026
6276
|
name: "bnUSD",
|
|
6027
|
-
vault:
|
|
6277
|
+
vault: hubVaults.bnUSD.address
|
|
6028
6278
|
},
|
|
6029
6279
|
[spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6030
6280
|
asset: "0xa36893ba308b332FDEbfa95916D1dF3a2e3CF8B3",
|
|
6031
6281
|
decimal: 6,
|
|
6032
6282
|
symbol: "USDC",
|
|
6033
6283
|
name: "USD Coin",
|
|
6034
|
-
vault:
|
|
6284
|
+
vault: hubVaults.sodaUSDC.address
|
|
6035
6285
|
}
|
|
6036
6286
|
},
|
|
6037
6287
|
[types.INJECTIVE_MAINNET_CHAIN_ID]: {
|
|
@@ -6040,21 +6290,21 @@ var hubAssets = {
|
|
|
6040
6290
|
decimal: 18,
|
|
6041
6291
|
symbol: "INJ",
|
|
6042
6292
|
name: "Injective",
|
|
6043
|
-
vault:
|
|
6293
|
+
vault: hubVaults.sodaINJ.address
|
|
6044
6294
|
},
|
|
6045
6295
|
[spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6046
6296
|
asset: "0x69425FFb14704124A58d6F69d510f74A59D9a5bC",
|
|
6047
6297
|
decimal: 18,
|
|
6048
6298
|
symbol: "bnUSD",
|
|
6049
6299
|
name: "bnUSD",
|
|
6050
|
-
vault:
|
|
6300
|
+
vault: hubVaults.bnUSD.address
|
|
6051
6301
|
},
|
|
6052
6302
|
[spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6053
6303
|
asset: "0x4bc1211faa06fb50ff61a70331f56167ae511057",
|
|
6054
6304
|
decimal: 6,
|
|
6055
6305
|
symbol: "USDC",
|
|
6056
6306
|
name: "USD Coin",
|
|
6057
|
-
vault:
|
|
6307
|
+
vault: hubVaults.sodaUSDC.address
|
|
6058
6308
|
}
|
|
6059
6309
|
},
|
|
6060
6310
|
[types.STELLAR_MAINNET_CHAIN_ID]: {
|
|
@@ -6063,21 +6313,21 @@ var hubAssets = {
|
|
|
6063
6313
|
decimal: 7,
|
|
6064
6314
|
symbol: "XLM",
|
|
6065
6315
|
name: "Stellar Lumens",
|
|
6066
|
-
vault:
|
|
6316
|
+
vault: hubVaults.sodaXLM.address
|
|
6067
6317
|
},
|
|
6068
6318
|
[spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6069
6319
|
asset: "0x23225Ab8E63FCa4070296678cb46566d57E1BBe3",
|
|
6070
6320
|
decimal: 7,
|
|
6071
6321
|
symbol: "bnUSD",
|
|
6072
6322
|
name: "bnUSD",
|
|
6073
|
-
vault:
|
|
6323
|
+
vault: hubVaults.bnUSD.address
|
|
6074
6324
|
},
|
|
6075
6325
|
[spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6076
6326
|
asset: "0x348007B53F25A9A857aB8eA81ec9E3CCBCf440f2",
|
|
6077
6327
|
decimal: 7,
|
|
6078
6328
|
symbol: "USDC",
|
|
6079
6329
|
name: "USD Coin",
|
|
6080
|
-
vault:
|
|
6330
|
+
vault: hubVaults.sodaUSDC.address
|
|
6081
6331
|
}
|
|
6082
6332
|
},
|
|
6083
6333
|
[types.SUI_MAINNET_CHAIN_ID]: {
|
|
@@ -6086,44 +6336,92 @@ var hubAssets = {
|
|
|
6086
6336
|
decimal: 9,
|
|
6087
6337
|
symbol: "SUI",
|
|
6088
6338
|
name: "Sui",
|
|
6089
|
-
vault:
|
|
6339
|
+
vault: hubVaults.sodaSUI.address
|
|
6090
6340
|
},
|
|
6091
6341
|
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6092
6342
|
asset: "0xDf23097B9AEb917Bf8fb70e99b6c528fffA35364",
|
|
6093
6343
|
decimal: 9,
|
|
6094
6344
|
symbol: "bnUSD",
|
|
6095
6345
|
name: "bnUSD",
|
|
6096
|
-
vault:
|
|
6346
|
+
vault: hubVaults.bnUSD.address
|
|
6097
6347
|
},
|
|
6098
6348
|
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6099
6349
|
asset: "0x5635369c8a29A081d26C2e9e28012FCa548BA0Cb",
|
|
6100
6350
|
decimal: 6,
|
|
6101
6351
|
symbol: "USDC",
|
|
6102
6352
|
name: "USD Coin",
|
|
6103
|
-
vault:
|
|
6353
|
+
vault: hubVaults.sodaUSDC.address
|
|
6354
|
+
},
|
|
6355
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.afSUI.address]: {
|
|
6356
|
+
asset: "0x039666bd0cbc96a66c40e8541af465beaa81aa7e",
|
|
6357
|
+
decimal: 9,
|
|
6358
|
+
symbol: "afSUI",
|
|
6359
|
+
name: "afSUI",
|
|
6360
|
+
vault: "0x"
|
|
6361
|
+
// no vault yet
|
|
6362
|
+
},
|
|
6363
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.mSUI.address]: {
|
|
6364
|
+
asset: "0xb202c674c9a79b5681e981ba0daa782b3ceeebbe",
|
|
6365
|
+
decimal: 9,
|
|
6366
|
+
symbol: "mSUI",
|
|
6367
|
+
name: "mSUI",
|
|
6368
|
+
vault: "0x"
|
|
6369
|
+
// no vault yet
|
|
6370
|
+
},
|
|
6371
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.haSUI.address]: {
|
|
6372
|
+
asset: "0x67a26d11fce15e8b33ac97230d36cae1c52c35e7",
|
|
6373
|
+
decimal: 9,
|
|
6374
|
+
symbol: "haSUI",
|
|
6375
|
+
name: "haSUI",
|
|
6376
|
+
vault: "0x"
|
|
6377
|
+
// no vault yet
|
|
6378
|
+
},
|
|
6379
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.vSUI.address]: {
|
|
6380
|
+
asset: "0x025715bcda08db06c795cd5bf944e2081468d99a",
|
|
6381
|
+
decimal: 9,
|
|
6382
|
+
symbol: "vSUI",
|
|
6383
|
+
name: "vSUI",
|
|
6384
|
+
vault: "0x"
|
|
6385
|
+
// no vault yet
|
|
6386
|
+
},
|
|
6387
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.yapSUI.address]: {
|
|
6388
|
+
asset: "0xac509404f3a3ca3f7766baf65be45a52b1cfccd7",
|
|
6389
|
+
decimal: 9,
|
|
6390
|
+
symbol: "yapSUI",
|
|
6391
|
+
name: "yapSUI",
|
|
6392
|
+
vault: "0x"
|
|
6393
|
+
// no vault yet
|
|
6394
|
+
},
|
|
6395
|
+
[spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.trevinSUI.address]: {
|
|
6396
|
+
asset: "0x514569c788b096595672e0f68ec72387a22ac67b",
|
|
6397
|
+
decimal: 9,
|
|
6398
|
+
symbol: "trevinSUI",
|
|
6399
|
+
name: "trevinSUI",
|
|
6400
|
+
vault: "0x"
|
|
6401
|
+
// no vault yet
|
|
6104
6402
|
}
|
|
6105
6403
|
},
|
|
6106
6404
|
[types.SOLANA_MAINNET_CHAIN_ID]: {
|
|
6107
6405
|
[spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL.address]: {
|
|
6108
6406
|
asset: "0x0c09e69a4528945de6d16c7e469dea6996fdf636",
|
|
6109
6407
|
decimal: 9,
|
|
6110
|
-
symbol: "
|
|
6111
|
-
name: "
|
|
6112
|
-
vault:
|
|
6408
|
+
symbol: "SOL",
|
|
6409
|
+
name: "Solana",
|
|
6410
|
+
vault: hubVaults.sodaSOL.address
|
|
6113
6411
|
},
|
|
6114
6412
|
[spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].bnUSD]: {
|
|
6115
6413
|
asset: "0x14C65b1CDc0B821569081b1F77342dA0D0CbF439",
|
|
6116
6414
|
decimal: 9,
|
|
6117
6415
|
symbol: "bnUSD",
|
|
6118
6416
|
name: "bnUSD",
|
|
6119
|
-
vault:
|
|
6417
|
+
vault: hubVaults.bnUSD.address
|
|
6120
6418
|
},
|
|
6121
6419
|
[spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
|
|
6122
|
-
asset: "
|
|
6420
|
+
asset: "0xC3f020057510ffE10Ceb882e1B48238b43d78a5e",
|
|
6123
6421
|
decimal: 6,
|
|
6124
6422
|
symbol: "USDC",
|
|
6125
6423
|
name: "USD Coin",
|
|
6126
|
-
vault:
|
|
6424
|
+
vault: hubVaults.sodaUSDC.address
|
|
6127
6425
|
}
|
|
6128
6426
|
},
|
|
6129
6427
|
[types.ICON_MAINNET_CHAIN_ID]: {
|
|
@@ -6132,6 +6430,14 @@ var hubAssets = {
|
|
|
6132
6430
|
decimal: 18,
|
|
6133
6431
|
symbol: "ICX",
|
|
6134
6432
|
name: "ICON",
|
|
6433
|
+
vault: "0x"
|
|
6434
|
+
// no vault yet
|
|
6435
|
+
},
|
|
6436
|
+
[spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].addresses.wICX]: {
|
|
6437
|
+
asset: "0xb66cB7D841272AF6BaA8b8119007EdEE35d2C24F",
|
|
6438
|
+
decimal: 18,
|
|
6439
|
+
symbol: "wICX",
|
|
6440
|
+
name: "ICON",
|
|
6135
6441
|
vault: "0x0000000000000000000000000000000000000000"
|
|
6136
6442
|
},
|
|
6137
6443
|
[spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].bnUSD]: {
|
|
@@ -6139,7 +6445,7 @@ var hubAssets = {
|
|
|
6139
6445
|
decimal: 18,
|
|
6140
6446
|
symbol: "bnUSD",
|
|
6141
6447
|
name: "bnUSD",
|
|
6142
|
-
vault:
|
|
6448
|
+
vault: hubVaults.IbnUSD.address
|
|
6143
6449
|
}
|
|
6144
6450
|
}
|
|
6145
6451
|
};
|
|
@@ -6147,25 +6453,26 @@ var DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
|
|
|
6147
6453
|
var solverConfig = {
|
|
6148
6454
|
[types.SONIC_MAINNET_CHAIN_ID]: {
|
|
6149
6455
|
intentsContract: "0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef",
|
|
6150
|
-
solverApiEndpoint: "https://
|
|
6151
|
-
// TODO replace with mainnet
|
|
6456
|
+
solverApiEndpoint: "https://sodax-solver-staging.iconblockchain.xyz"
|
|
6152
6457
|
}
|
|
6153
6458
|
};
|
|
6154
6459
|
var getSolverConfig = (chainId) => solverConfig[chainId];
|
|
6155
6460
|
var solverSupportedTokens = {
|
|
6156
6461
|
[types.SONIC_MAINNET_CHAIN_ID]: [
|
|
6157
|
-
spokeChainConfig[
|
|
6158
|
-
spokeChainConfig[
|
|
6159
|
-
spokeChainConfig[
|
|
6160
|
-
spokeChainConfig[
|
|
6462
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6463
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6464
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6465
|
+
// spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic, // NOTE: Planned for next release (1 - 2 weeks)
|
|
6161
6466
|
],
|
|
6162
6467
|
[types.AVALANCHE_MAINNET_CHAIN_ID]: [
|
|
6163
6468
|
spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.AVAX,
|
|
6164
6469
|
spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDT,
|
|
6165
6470
|
spokeChainConfig[types.AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6471
|
+
// spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6166
6472
|
],
|
|
6167
6473
|
[types.ARBITRUM_MAINNET_CHAIN_ID]: [
|
|
6168
6474
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6475
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6169
6476
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC,
|
|
6170
6477
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6171
6478
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
@@ -6175,6 +6482,7 @@ var solverSupportedTokens = {
|
|
|
6175
6482
|
],
|
|
6176
6483
|
[types.BASE_MAINNET_CHAIN_ID]: [
|
|
6177
6484
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6485
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6178
6486
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6179
6487
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6180
6488
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
@@ -6182,43 +6490,62 @@ var solverSupportedTokens = {
|
|
|
6182
6490
|
],
|
|
6183
6491
|
[types.OPTIMISM_MAINNET_CHAIN_ID]: [
|
|
6184
6492
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6493
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6185
6494
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6186
6495
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6187
|
-
spokeChainConfig[
|
|
6496
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH, // NOTE: Not Implemented
|
|
6188
6497
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT
|
|
6189
6498
|
],
|
|
6190
6499
|
[types.POLYGON_MAINNET_CHAIN_ID]: [
|
|
6191
6500
|
spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.POL,
|
|
6501
|
+
// spokeChainConfig[POLYGON_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6192
6502
|
spokeChainConfig[types.POLYGON_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6193
6503
|
],
|
|
6194
6504
|
[types.BSC_MAINNET_CHAIN_ID]: [
|
|
6195
6505
|
spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.BNB,
|
|
6196
6506
|
spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.ETHB,
|
|
6197
6507
|
spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.BTCB,
|
|
6508
|
+
// spokeChainConfig[BSC_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6198
6509
|
spokeChainConfig[types.BSC_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6199
6510
|
],
|
|
6200
6511
|
[types.SOLANA_MAINNET_CHAIN_ID]: [
|
|
6201
6512
|
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL,
|
|
6513
|
+
// spokeChainConfig[SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6202
6514
|
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6203
6515
|
],
|
|
6204
6516
|
[types.ICON_MAINNET_CHAIN_ID]: [
|
|
6205
6517
|
spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].supportedTokens.ICX,
|
|
6206
6518
|
spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].supportedTokens.wICX,
|
|
6207
6519
|
spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6520
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.BALN, // NOTE: Not Implemented
|
|
6521
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.OMM, // NOTE: Not Implemented
|
|
6208
6522
|
],
|
|
6209
6523
|
[types.STELLAR_MAINNET_CHAIN_ID]: [
|
|
6210
6524
|
spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.XLM,
|
|
6525
|
+
// spokeChainConfig[STELLAR_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6211
6526
|
spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6212
6527
|
],
|
|
6213
6528
|
[types.SUI_MAINNET_CHAIN_ID]: [
|
|
6214
6529
|
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.SUI,
|
|
6215
|
-
spokeChainConfig[
|
|
6530
|
+
// spokeChainConfig[SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6531
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6532
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.afSUI,
|
|
6533
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.mSUI,
|
|
6534
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.haSUI,
|
|
6535
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.vSUI,
|
|
6536
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.yapSUI,
|
|
6537
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.trevinSUI
|
|
6216
6538
|
],
|
|
6217
6539
|
[types.INJECTIVE_MAINNET_CHAIN_ID]: [
|
|
6218
6540
|
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
|
|
6541
|
+
// spokeChainConfig[INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6219
6542
|
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6220
6543
|
],
|
|
6221
|
-
[types.NIBIRU_MAINNET_CHAIN_ID]: [
|
|
6544
|
+
[types.NIBIRU_MAINNET_CHAIN_ID]: [
|
|
6545
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.NIBI, // NOTE: Not Implemented
|
|
6546
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.bnUSD, // NOTE: Not Implemented
|
|
6547
|
+
// spokeChainConfig[NIBIRU_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Not Implemented
|
|
6548
|
+
]
|
|
6222
6549
|
};
|
|
6223
6550
|
var getSupportedSolverTokens = (chainId) => solverSupportedTokens[chainId];
|
|
6224
6551
|
var isSolverSupportedToken = (chainId, token) => solverSupportedTokens[chainId].some((t) => t.address.toLowerCase() === token.toLowerCase());
|
|
@@ -6243,8 +6570,8 @@ var moneyMarketSupportedTokens = {
|
|
|
6243
6570
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6244
6571
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6245
6572
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.WBTC,
|
|
6246
|
-
spokeChainConfig[
|
|
6247
|
-
spokeChainConfig[
|
|
6573
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6574
|
+
// spokeChainConfig[ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6248
6575
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.tBTC,
|
|
6249
6576
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDT,
|
|
6250
6577
|
spokeChainConfig[types.ARBITRUM_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
@@ -6252,17 +6579,17 @@ var moneyMarketSupportedTokens = {
|
|
|
6252
6579
|
[types.BASE_MAINNET_CHAIN_ID]: [
|
|
6253
6580
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6254
6581
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6255
|
-
spokeChainConfig[
|
|
6582
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6256
6583
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6257
|
-
spokeChainConfig[
|
|
6584
|
+
// spokeChainConfig[BASE_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6258
6585
|
spokeChainConfig[types.BASE_MAINNET_CHAIN_ID].supportedTokens.cbBTC
|
|
6259
6586
|
],
|
|
6260
6587
|
[types.OPTIMISM_MAINNET_CHAIN_ID]: [
|
|
6261
6588
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.ETH,
|
|
6262
6589
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6263
6590
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDC,
|
|
6264
|
-
spokeChainConfig[
|
|
6265
|
-
spokeChainConfig[
|
|
6591
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.wstETH,
|
|
6592
|
+
// spokeChainConfig[OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.weETH,
|
|
6266
6593
|
spokeChainConfig[types.OPTIMISM_MAINNET_CHAIN_ID].supportedTokens.USDT
|
|
6267
6594
|
],
|
|
6268
6595
|
[types.POLYGON_MAINNET_CHAIN_ID]: [
|
|
@@ -6278,12 +6605,13 @@ var moneyMarketSupportedTokens = {
|
|
|
6278
6605
|
],
|
|
6279
6606
|
[types.SOLANA_MAINNET_CHAIN_ID]: [
|
|
6280
6607
|
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.SOL,
|
|
6281
|
-
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6608
|
+
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6609
|
+
spokeChainConfig[types.SOLANA_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6282
6610
|
],
|
|
6283
6611
|
[types.ICON_MAINNET_CHAIN_ID]: [
|
|
6284
|
-
spokeChainConfig[
|
|
6285
|
-
spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6286
|
-
spokeChainConfig[
|
|
6612
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.ICX,
|
|
6613
|
+
spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6614
|
+
// spokeChainConfig[ICON_MAINNET_CHAIN_ID].supportedTokens.wICX,
|
|
6287
6615
|
],
|
|
6288
6616
|
[types.STELLAR_MAINNET_CHAIN_ID]: [
|
|
6289
6617
|
spokeChainConfig[types.STELLAR_MAINNET_CHAIN_ID].supportedTokens.XLM,
|
|
@@ -6291,11 +6619,13 @@ var moneyMarketSupportedTokens = {
|
|
|
6291
6619
|
],
|
|
6292
6620
|
[types.SUI_MAINNET_CHAIN_ID]: [
|
|
6293
6621
|
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.SUI,
|
|
6294
|
-
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6622
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6623
|
+
spokeChainConfig[types.SUI_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6295
6624
|
],
|
|
6296
6625
|
[types.INJECTIVE_MAINNET_CHAIN_ID]: [
|
|
6297
6626
|
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.INJ,
|
|
6298
|
-
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD
|
|
6627
|
+
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.bnUSD,
|
|
6628
|
+
spokeChainConfig[types.INJECTIVE_MAINNET_CHAIN_ID].supportedTokens.USDC
|
|
6299
6629
|
],
|
|
6300
6630
|
[types.NIBIRU_MAINNET_CHAIN_ID]: [],
|
|
6301
6631
|
[types.SONIC_MAINNET_CHAIN_ID]: [
|
|
@@ -6308,119 +6638,16 @@ var moneyMarketSupportedTokens = {
|
|
|
6308
6638
|
};
|
|
6309
6639
|
var isMoneyMarketSupportedToken = (chainId, token) => moneyMarketSupportedTokens[chainId].some((t) => t.address.toLowerCase() === token.toLowerCase());
|
|
6310
6640
|
var getSupportedMoneyMarketTokens = (chainId) => moneyMarketSupportedTokens[chainId];
|
|
6311
|
-
var
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
var hubVaults = {
|
|
6322
|
-
sodaAVAX: {
|
|
6323
|
-
// SODA AVAX vault
|
|
6324
|
-
address: "0x14238d267557e9d799016ad635b53cd15935d290",
|
|
6325
|
-
reserves: [
|
|
6326
|
-
// hub asset addresses contained in the vault
|
|
6327
|
-
"0xc9e4f0b6195f389d9d2b639f2878b7674eb9d8cd"
|
|
6328
|
-
// AvalancheAVAX hub asset
|
|
6329
|
-
]
|
|
6330
|
-
},
|
|
6331
|
-
sodaBNB: {
|
|
6332
|
-
// SODA BNB vault
|
|
6333
|
-
address: "0x40cd41b35db9e5109ae7e54b44de8625db320e6b",
|
|
6334
|
-
reserves: [
|
|
6335
|
-
// hub asset addresses contained in the vault
|
|
6336
|
-
"0x13b70564b1ec12876b20fab5d1bb630311312f4f"
|
|
6337
|
-
// BSC BNB hub asset
|
|
6338
|
-
]
|
|
6339
|
-
},
|
|
6340
|
-
sodaETH: {
|
|
6341
|
-
// SODA ETH vault
|
|
6342
|
-
address: "0x4effb5813271699683c25c734f4dabc45b363709",
|
|
6343
|
-
reserves: [
|
|
6344
|
-
// hub asset addresses contained in the vault
|
|
6345
|
-
"0x70178089842be7f8e4726b33f0d1569db8021faa",
|
|
6346
|
-
// BASE ETH hub asset
|
|
6347
|
-
"0xad332860dd3b6f0e63f4f66e9457900917ac78cd",
|
|
6348
|
-
// Optimism ETH hub asset
|
|
6349
|
-
"0xdcd9578b51ef55239b6e68629d822a8d97c95b86",
|
|
6350
|
-
// Arbitrum ETH hub asset
|
|
6351
|
-
"0x57fc2ac5701e463ae261adbd6c99fbeb48ce5293"
|
|
6352
|
-
// BSC ETH hub asset
|
|
6353
|
-
]
|
|
6354
|
-
},
|
|
6355
|
-
sodaBTC: {
|
|
6356
|
-
// SODA BTC vault
|
|
6357
|
-
address: "0x7a1a5555842ad2d0ed274d09b5c4406a95799d5d",
|
|
6358
|
-
reserves: [
|
|
6359
|
-
// hub asset addresses contained in the vault
|
|
6360
|
-
"0x2803a23a3ba6b09e57d1c71dec0d9efdbb00a27f",
|
|
6361
|
-
// BASE cbBTC hub asset,
|
|
6362
|
-
"0xfb0acb1b2720b620935f50a6dd3f7fea52b2fcbe",
|
|
6363
|
-
// Arbitrum wBTC hub asset
|
|
6364
|
-
"0x96fc8540736f1598b7e235e6de8814062b3b5d3b",
|
|
6365
|
-
// Arbitrum tBTC hub asset,
|
|
6366
|
-
"0xd8a24c71fea5bb81c66c01e532de7d9b11e13905"
|
|
6367
|
-
// BSC BTCB hub asset
|
|
6368
|
-
]
|
|
6369
|
-
},
|
|
6370
|
-
sodaSUI: {
|
|
6371
|
-
// SODA SUI vault
|
|
6372
|
-
address: "0xdc5b4b00f98347e95b9f94911213dab4c687e1e3",
|
|
6373
|
-
reserves: [
|
|
6374
|
-
// hub asset addresses contained in the vault
|
|
6375
|
-
"0x4676b2a551b25c04e235553c1c81019337384673"
|
|
6376
|
-
// SUI SUI hub asset
|
|
6377
|
-
]
|
|
6378
|
-
},
|
|
6379
|
-
sodaINJ: {
|
|
6380
|
-
// SODA INJ vault
|
|
6381
|
-
address: "0x1f22279c89b213944b7ea41dacb0a868ddcdfd13",
|
|
6382
|
-
reserves: [
|
|
6383
|
-
// hub asset addresses contained in the vault
|
|
6384
|
-
"0xd375590b4955f6ea5623f799153f9b787a3bd319"
|
|
6385
|
-
// Injective INJ hub asset
|
|
6386
|
-
]
|
|
6387
|
-
},
|
|
6388
|
-
sodaXLM: {
|
|
6389
|
-
// SODA XLM vault
|
|
6390
|
-
address: "0x6bc8c37cba91f76e68c9e6d689a9c21e4d32079b",
|
|
6391
|
-
reserves: [
|
|
6392
|
-
// hub asset addresses contained in the vault
|
|
6393
|
-
"0x8ac68af223907fb1b893086601a3d99e00f2fa9d"
|
|
6394
|
-
// Stellar XLM hub asset
|
|
6395
|
-
]
|
|
6396
|
-
},
|
|
6397
|
-
sodaSOL: {
|
|
6398
|
-
// SODA SOL vault
|
|
6399
|
-
address: "0xdea692287e2ce8cb08fa52917be0f16b1dacdc87",
|
|
6400
|
-
reserves: [
|
|
6401
|
-
// hub asset addresses contained in the vault
|
|
6402
|
-
"0x0c09e69a4528945de6d16c7e469dea6996fdf636"
|
|
6403
|
-
// Solana SOL hub asset
|
|
6404
|
-
]
|
|
6405
|
-
}
|
|
6406
|
-
};
|
|
6407
|
-
var hubVaultsAddressSet = new Set(
|
|
6408
|
-
Object.values(hubVaults).map((vault) => vault.address.toLowerCase())
|
|
6409
|
-
);
|
|
6410
|
-
var moneyMarketReserveHubAssetsSet = new Set(
|
|
6411
|
-
Object.values(hubVaults).flatMap((vault) => vault.reserves.map((reserve) => reserve.toLowerCase()))
|
|
6412
|
-
);
|
|
6413
|
-
var isMoneyMarketReserveHubAsset = (hubAsset) => moneyMarketReserveHubAssetsSet.has(hubAsset.toLowerCase());
|
|
6414
|
-
var moneyMarketReserveAssets = [
|
|
6415
|
-
hubVaults["sodaAVAX"].address,
|
|
6416
|
-
hubVaults["sodaBNB"].address,
|
|
6417
|
-
hubVaults["sodaETH"].address,
|
|
6418
|
-
hubVaults["sodaBTC"].address,
|
|
6419
|
-
hubVaults["sodaSUI"].address,
|
|
6420
|
-
hubVaults["sodaINJ"].address,
|
|
6421
|
-
hubVaults["sodaXLM"].address,
|
|
6422
|
-
hubVaults["sodaSOL"].address,
|
|
6423
|
-
getMoneyMarketConfig(types.SONIC_MAINNET_CHAIN_ID).bnUSDVault
|
|
6641
|
+
var hubVaultsAddressSet = new Set(
|
|
6642
|
+
Object.values(hubVaults).map((vault) => vault.address.toLowerCase())
|
|
6643
|
+
);
|
|
6644
|
+
var moneyMarketReserveHubAssetsSet = new Set(
|
|
6645
|
+
Object.values(hubVaults).flatMap((vault) => vault.reserves.map((reserve) => reserve.toLowerCase()))
|
|
6646
|
+
);
|
|
6647
|
+
var isMoneyMarketReserveHubAsset = (hubAsset) => moneyMarketReserveHubAssetsSet.has(hubAsset.toLowerCase());
|
|
6648
|
+
var moneyMarketReserveAssets = [
|
|
6649
|
+
...Object.values(hubVaults).map((vault) => vault.address),
|
|
6650
|
+
getMoneyMarketConfig(types.SONIC_MAINNET_CHAIN_ID).bnUSDVault
|
|
6424
6651
|
];
|
|
6425
6652
|
var isMoneyMarketReserveAsset = (asset) => moneyMarketReserveAssets.map((a) => a.toLowerCase()).includes(asset.toLowerCase());
|
|
6426
6653
|
var originalAssetTohubAssetMap = new Map(
|
|
@@ -6766,28 +6993,164 @@ var EvmSpokeProvider = class {
|
|
|
6766
6993
|
}
|
|
6767
6994
|
}
|
|
6768
6995
|
};
|
|
6996
|
+
var CustomStellarAccount = class {
|
|
6997
|
+
accountId;
|
|
6998
|
+
sequenceNumber;
|
|
6999
|
+
startingSequenceNumber;
|
|
7000
|
+
constructor({ account_id, sequence }) {
|
|
7001
|
+
this.accountId = account_id;
|
|
7002
|
+
this.sequenceNumber = BigInt(sequence);
|
|
7003
|
+
this.startingSequenceNumber = BigInt(sequence);
|
|
7004
|
+
}
|
|
7005
|
+
getSequenceNumber() {
|
|
7006
|
+
return this.sequenceNumber;
|
|
7007
|
+
}
|
|
7008
|
+
getStartingSequenceNumber() {
|
|
7009
|
+
return this.startingSequenceNumber;
|
|
7010
|
+
}
|
|
7011
|
+
getAccountId() {
|
|
7012
|
+
return this.accountId;
|
|
7013
|
+
}
|
|
7014
|
+
getAccountClone() {
|
|
7015
|
+
return new stellarSdk.Account(this.accountId, this.sequenceNumber.toString());
|
|
7016
|
+
}
|
|
7017
|
+
incrementSequenceNumber() {
|
|
7018
|
+
this.sequenceNumber++;
|
|
7019
|
+
}
|
|
7020
|
+
decrementSequenceNumber() {
|
|
7021
|
+
if (this.sequenceNumber > this.startingSequenceNumber) {
|
|
7022
|
+
this.sequenceNumber--;
|
|
7023
|
+
}
|
|
7024
|
+
throw new Error(
|
|
7025
|
+
`Sequence number cannot be decremented below the starting sequence number: ${this.startingSequenceNumber}`
|
|
7026
|
+
);
|
|
7027
|
+
}
|
|
7028
|
+
resetSequenceNumber() {
|
|
7029
|
+
this.sequenceNumber = this.startingSequenceNumber;
|
|
7030
|
+
}
|
|
7031
|
+
};
|
|
7032
|
+
var CustomSorobanServer = class extends stellarSdk.SorobanRpc.Server {
|
|
7033
|
+
customHeaders;
|
|
7034
|
+
constructor(serverUrl, customHeaders) {
|
|
7035
|
+
super(serverUrl, {
|
|
7036
|
+
allowHttp: true
|
|
7037
|
+
});
|
|
7038
|
+
this.customHeaders = customHeaders;
|
|
7039
|
+
}
|
|
7040
|
+
async getNetwork() {
|
|
7041
|
+
const requestOptions = {
|
|
7042
|
+
method: "POST",
|
|
7043
|
+
headers: {
|
|
7044
|
+
"Content-Type": "application/json",
|
|
7045
|
+
...this.customHeaders
|
|
7046
|
+
},
|
|
7047
|
+
body: JSON.stringify({
|
|
7048
|
+
id: 1,
|
|
7049
|
+
jsonrpc: "2.0",
|
|
7050
|
+
method: "getNetwork"
|
|
7051
|
+
})
|
|
7052
|
+
};
|
|
7053
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7054
|
+
if (!response.ok) {
|
|
7055
|
+
throw new Error(`HTTP error getting network! status: ${response.status}`);
|
|
7056
|
+
}
|
|
7057
|
+
return response.json().then((json) => json.result);
|
|
7058
|
+
}
|
|
7059
|
+
async simulateTransaction(tx) {
|
|
7060
|
+
const requestOptions = {
|
|
7061
|
+
method: "POST",
|
|
7062
|
+
headers: {
|
|
7063
|
+
"Content-Type": "application/json",
|
|
7064
|
+
...this.customHeaders
|
|
7065
|
+
},
|
|
7066
|
+
body: JSON.stringify({
|
|
7067
|
+
id: 1,
|
|
7068
|
+
jsonrpc: "2.0",
|
|
7069
|
+
method: "simulateTransaction",
|
|
7070
|
+
params: {
|
|
7071
|
+
transaction: tx.toXDR()
|
|
7072
|
+
}
|
|
7073
|
+
})
|
|
7074
|
+
};
|
|
7075
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7076
|
+
if (!response.ok) {
|
|
7077
|
+
throw new Error(`HTTP error simulating TX! status: ${response.status}`);
|
|
7078
|
+
}
|
|
7079
|
+
return response.json().then((json) => json.result);
|
|
7080
|
+
}
|
|
7081
|
+
async sendTransaction(tx) {
|
|
7082
|
+
const requestOptions = {
|
|
7083
|
+
method: "POST",
|
|
7084
|
+
headers: {
|
|
7085
|
+
"Content-Type": "application/json",
|
|
7086
|
+
...this.customHeaders
|
|
7087
|
+
},
|
|
7088
|
+
body: JSON.stringify({
|
|
7089
|
+
id: 1,
|
|
7090
|
+
jsonrpc: "2.0",
|
|
7091
|
+
method: "sendTransaction",
|
|
7092
|
+
params: {
|
|
7093
|
+
transaction: tx.toXDR()
|
|
7094
|
+
}
|
|
7095
|
+
})
|
|
7096
|
+
};
|
|
7097
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7098
|
+
if (!response.ok) {
|
|
7099
|
+
throw new Error(`HTTP error submitting TX! status: ${response.status}`);
|
|
7100
|
+
}
|
|
7101
|
+
return response.json().then((json) => json.result);
|
|
7102
|
+
}
|
|
7103
|
+
async getTransaction(hash) {
|
|
7104
|
+
const requestOptions = {
|
|
7105
|
+
method: "POST",
|
|
7106
|
+
headers: {
|
|
7107
|
+
"Content-Type": "application/json",
|
|
7108
|
+
...this.customHeaders
|
|
7109
|
+
},
|
|
7110
|
+
body: JSON.stringify({
|
|
7111
|
+
id: 1,
|
|
7112
|
+
jsonrpc: "2.0",
|
|
7113
|
+
method: "getTransaction",
|
|
7114
|
+
params: { hash }
|
|
7115
|
+
})
|
|
7116
|
+
};
|
|
7117
|
+
const response = await fetch(`${this.serverURL}`, requestOptions);
|
|
7118
|
+
if (!response.ok) {
|
|
7119
|
+
throw new Error(`HTTP error getting TX! status: ${response.status}`);
|
|
7120
|
+
}
|
|
7121
|
+
return response.json().then((json) => json.result);
|
|
7122
|
+
}
|
|
7123
|
+
};
|
|
6769
7124
|
var StellarSpokeProvider = class {
|
|
6770
7125
|
server;
|
|
7126
|
+
sorobanServer;
|
|
6771
7127
|
contract;
|
|
6772
7128
|
chainConfig;
|
|
6773
7129
|
walletProvider;
|
|
6774
|
-
constructor(walletProvider,
|
|
6775
|
-
this.server = new stellarSdk.
|
|
7130
|
+
constructor(walletProvider, config, rpcConfig) {
|
|
7131
|
+
this.server = new stellarSdk.Horizon.Server(
|
|
7132
|
+
rpcConfig && rpcConfig.horizonRpcUrl ? rpcConfig.horizonRpcUrl : config.horizonRpcUrl,
|
|
7133
|
+
{ allowHttp: true }
|
|
7134
|
+
);
|
|
7135
|
+
this.sorobanServer = new CustomSorobanServer(
|
|
7136
|
+
rpcConfig && rpcConfig.sorobanRpcUrl ? rpcConfig.sorobanRpcUrl : config.sorobanRpcUrl,
|
|
7137
|
+
{}
|
|
7138
|
+
);
|
|
6776
7139
|
this.walletProvider = walletProvider;
|
|
6777
|
-
this.contract = new stellarSdk.Contract(
|
|
7140
|
+
this.contract = new stellarSdk.Contract(config.addresses.assetManager);
|
|
6778
7141
|
this.chainConfig = config;
|
|
6779
7142
|
}
|
|
6780
7143
|
async getBalance(tokenAddress) {
|
|
6781
7144
|
const [network, walletAddress] = await Promise.all([
|
|
6782
|
-
this.
|
|
7145
|
+
this.sorobanServer.getNetwork(),
|
|
6783
7146
|
this.walletProvider.getWalletAddress()
|
|
6784
7147
|
]);
|
|
6785
|
-
const sourceAccount = await this.
|
|
7148
|
+
const sourceAccount = await this.sorobanServer.getAccount(walletAddress);
|
|
6786
7149
|
const tx = new stellarSdk.TransactionBuilder(sourceAccount, {
|
|
6787
7150
|
fee: stellarSdk.BASE_FEE,
|
|
6788
7151
|
networkPassphrase: network.passphrase
|
|
6789
7152
|
}).addOperation(this.contract.call("get_token_balance", stellarSdk.nativeToScVal(tokenAddress, { type: "address" }))).setTimeout(stellarSdk.TimeoutInfinite).build();
|
|
6790
|
-
const result = await this.
|
|
7153
|
+
const result = await this.sorobanServer.simulateTransaction(tx);
|
|
6791
7154
|
if (stellarSdk.rpc.Api.isSimulationError(result)) {
|
|
6792
7155
|
throw new Error("Failed to simulate transaction");
|
|
6793
7156
|
}
|
|
@@ -6797,32 +7160,112 @@ var StellarSpokeProvider = class {
|
|
|
6797
7160
|
}
|
|
6798
7161
|
throw new Error("result undefined");
|
|
6799
7162
|
}
|
|
7163
|
+
async buildPriorityStellarTransaction(account, network, operation) {
|
|
7164
|
+
const simulationForFee = await this.sorobanServer.simulateTransaction(
|
|
7165
|
+
new stellarSdk.TransactionBuilder(account.getAccountClone(), {
|
|
7166
|
+
fee: stellarSdk.BASE_FEE,
|
|
7167
|
+
networkPassphrase: network.passphrase
|
|
7168
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7169
|
+
);
|
|
7170
|
+
if (!stellarSdk.rpc.Api.isSimulationSuccess(simulationForFee)) {
|
|
7171
|
+
throw new Error(`Simulation error: ${JSON.stringify(simulationForFee)}`);
|
|
7172
|
+
}
|
|
7173
|
+
const priorityTransaction = new stellarSdk.TransactionBuilder(account.getAccountClone(), {
|
|
7174
|
+
fee: (BigInt(simulationForFee.minResourceFee) + BigInt(STELLAR_PRIORITY_FEE) + BigInt(stellarSdk.BASE_FEE.toString())).toString(),
|
|
7175
|
+
networkPassphrase: network.passphrase
|
|
7176
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build();
|
|
7177
|
+
const simulation = await this.sorobanServer.simulateTransaction(priorityTransaction);
|
|
7178
|
+
return [stellarSdk.SorobanRpc.assembleTransaction(priorityTransaction, simulation).build(), simulation];
|
|
7179
|
+
}
|
|
7180
|
+
handleSendTransactionError(response) {
|
|
7181
|
+
if (response.status === "ERROR") {
|
|
7182
|
+
throw new Error(
|
|
7183
|
+
`Transaction failed: status: ${response.status}, hash: ${response.hash}, errorResult: ${JSON.stringify({
|
|
7184
|
+
name: response?.errorResult?.result()?.switch()?.name ?? "unknown",
|
|
7185
|
+
value: response?.errorResult?.result()?.switch()?.value ?? "unknown"
|
|
7186
|
+
})}, diagnosticEvents: ${JSON.stringify(response?.diagnosticEvents ?? "{}")}`
|
|
7187
|
+
);
|
|
7188
|
+
}
|
|
7189
|
+
return response;
|
|
7190
|
+
}
|
|
7191
|
+
async signAndSendTransaction(tx, waitForTransaction = true) {
|
|
7192
|
+
const signedTransaction = await this.walletProvider.signTransaction(tx.toXDR());
|
|
7193
|
+
const signedTx = stellarSdk.TransactionBuilder.fromXDR(signedTransaction, tx.networkPassphrase);
|
|
7194
|
+
const response = this.handleSendTransactionError(await this.sorobanServer.sendTransaction(signedTx));
|
|
7195
|
+
if (waitForTransaction) {
|
|
7196
|
+
return await this.waitForTransaction(response.hash);
|
|
7197
|
+
}
|
|
7198
|
+
return response.hash;
|
|
7199
|
+
}
|
|
7200
|
+
async waitForTransaction(hash, attempts = 60) {
|
|
7201
|
+
if (attempts === 0) {
|
|
7202
|
+
throw new Error(
|
|
7203
|
+
"[StellarSpokeProvider.waitForTransaction] Timeout error. Transaction not found after 5 attempts"
|
|
7204
|
+
);
|
|
7205
|
+
}
|
|
7206
|
+
const response = await this.sorobanServer.getTransaction(hash);
|
|
7207
|
+
if (response.status === stellarSdk.rpc.Api.GetTransactionStatus.SUCCESS) {
|
|
7208
|
+
return hash;
|
|
7209
|
+
}
|
|
7210
|
+
if (response.status === stellarSdk.rpc.Api.GetTransactionStatus.FAILED) {
|
|
7211
|
+
throw response;
|
|
7212
|
+
}
|
|
7213
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
7214
|
+
return this.waitForTransaction(hash, attempts - 1);
|
|
7215
|
+
}
|
|
7216
|
+
async submitOrRestoreAndRetry(account, network, tx, operation, simulation) {
|
|
7217
|
+
const initialSimulation = simulation ?? await this.sorobanServer.simulateTransaction(tx);
|
|
7218
|
+
if (!stellarSdk.rpc.Api.isSimulationSuccess(initialSimulation)) {
|
|
7219
|
+
throw new Error(
|
|
7220
|
+
`[StellarSpokeProvider.submitOrRestoreAndRetry] Simulation Failed: ${JSON.stringify(initialSimulation)}`
|
|
7221
|
+
);
|
|
7222
|
+
}
|
|
7223
|
+
let restored = false;
|
|
7224
|
+
if (stellarSdk.rpc.Api.isSimulationRestore(initialSimulation)) {
|
|
7225
|
+
try {
|
|
7226
|
+
await this.handleSimulationRestore(
|
|
7227
|
+
initialSimulation.restorePreamble.minResourceFee,
|
|
7228
|
+
initialSimulation.restorePreamble.transactionData.build(),
|
|
7229
|
+
account,
|
|
7230
|
+
network
|
|
7231
|
+
);
|
|
7232
|
+
restored = true;
|
|
7233
|
+
} catch (error) {
|
|
7234
|
+
throw new Error(
|
|
7235
|
+
`[StellarSpokeProvider.submitOrRestoreAndRetry] Simulation Restore Failed: ${JSON.stringify(error)}`
|
|
7236
|
+
);
|
|
7237
|
+
}
|
|
7238
|
+
}
|
|
7239
|
+
if (!restored) {
|
|
7240
|
+
return await this.signAndSendTransaction(tx);
|
|
7241
|
+
}
|
|
7242
|
+
const newAccount = account.getAccountClone();
|
|
7243
|
+
newAccount.incrementSequenceNumber();
|
|
7244
|
+
return await this.signAndSendTransaction(
|
|
7245
|
+
new stellarSdk.TransactionBuilder(newAccount, {
|
|
7246
|
+
fee: stellarSdk.BASE_FEE,
|
|
7247
|
+
networkPassphrase: network.passphrase
|
|
7248
|
+
}).addOperation(operation).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7249
|
+
);
|
|
7250
|
+
}
|
|
7251
|
+
async handleSimulationRestore(minResourceFee, transactionData, account, network) {
|
|
7252
|
+
const totalFee = (BigInt(stellarSdk.BASE_FEE) + BigInt(STELLAR_PRIORITY_FEE) + BigInt(minResourceFee)).toString();
|
|
7253
|
+
return this.signAndSendTransaction(
|
|
7254
|
+
new stellarSdk.TransactionBuilder(account.getAccountClone(), { fee: totalFee }).setNetworkPassphrase(network.passphrase).setSorobanData(transactionData).addOperation(stellarSdk.Operation.restoreFootprint({})).setTimeout(STELLAR_DEFAULT_TX_TIMEOUT_SECONDS).build()
|
|
7255
|
+
);
|
|
7256
|
+
}
|
|
6800
7257
|
async deposit(token, amount, recipient, data, raw) {
|
|
6801
7258
|
try {
|
|
6802
7259
|
const [network, walletAddress] = await Promise.all([
|
|
6803
|
-
this.
|
|
7260
|
+
this.sorobanServer.getNetwork(),
|
|
6804
7261
|
this.walletProvider.getWalletAddress()
|
|
6805
7262
|
]);
|
|
6806
|
-
const
|
|
6807
|
-
const
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
}).addOperation(
|
|
6811
|
-
this.contract.call(
|
|
6812
|
-
"transfer",
|
|
6813
|
-
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(walletAddress), { type: "address" }),
|
|
6814
|
-
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(token), {
|
|
6815
|
-
type: "address"
|
|
6816
|
-
}),
|
|
6817
|
-
stellarSdk.nativeToScVal(BigInt(amount), { type: "u128" }),
|
|
6818
|
-
stellarSdk.nativeToScVal(recipient),
|
|
6819
|
-
stellarSdk.nativeToScVal(Buffer.from(data), { type: "bytes" })
|
|
6820
|
-
)
|
|
6821
|
-
).setTimeout(100).build();
|
|
6822
|
-
const simResult = await this.server.simulateTransaction(simulateTx);
|
|
6823
|
-
const tx = stellarSdk.rpc.assembleTransaction(simulateTx, simResult).build();
|
|
7263
|
+
const accountResponse = await this.server.loadAccount(walletAddress);
|
|
7264
|
+
const stellarAccount = new CustomStellarAccount(accountResponse);
|
|
7265
|
+
const depositCall = this.buildDepositCall(walletAddress, token, amount, recipient, data);
|
|
7266
|
+
const [priorityTx, simulation] = await this.buildPriorityStellarTransaction(stellarAccount, network, depositCall);
|
|
6824
7267
|
if (raw) {
|
|
6825
|
-
const transactionXdr =
|
|
7268
|
+
const transactionXdr = priorityTx.toXDR();
|
|
6826
7269
|
return {
|
|
6827
7270
|
from: walletAddress,
|
|
6828
7271
|
to: this.chainConfig.addresses.assetManager,
|
|
@@ -6830,16 +7273,8 @@ var StellarSpokeProvider = class {
|
|
|
6830
7273
|
data: transactionXdr
|
|
6831
7274
|
};
|
|
6832
7275
|
}
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
const sendResponse = await this.server.sendTransaction(
|
|
6836
|
-
stellarSdk.TransactionBuilder.fromXDR(signedTx, tx.networkPassphrase)
|
|
6837
|
-
);
|
|
6838
|
-
if (sendResponse.hash) {
|
|
6839
|
-
return `0x${sendResponse.hash}`;
|
|
6840
|
-
}
|
|
6841
|
-
}
|
|
6842
|
-
throw new Error("Failed to create transaction");
|
|
7276
|
+
const hash = await this.submitOrRestoreAndRetry(stellarAccount, network, priorityTx, depositCall, simulation);
|
|
7277
|
+
return `${hash}`;
|
|
6843
7278
|
} catch (error) {
|
|
6844
7279
|
console.error("Error during deposit:", error);
|
|
6845
7280
|
throw error;
|
|
@@ -6848,27 +7283,19 @@ var StellarSpokeProvider = class {
|
|
|
6848
7283
|
async sendMessage(dst_chain_id, dst_address, payload, raw) {
|
|
6849
7284
|
try {
|
|
6850
7285
|
const [network, walletAddress] = await Promise.all([
|
|
6851
|
-
this.
|
|
7286
|
+
this.sorobanServer.getNetwork(),
|
|
6852
7287
|
this.walletProvider.getWalletAddress()
|
|
6853
7288
|
]);
|
|
6854
|
-
const
|
|
6855
|
-
const
|
|
6856
|
-
const
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(walletAddress), { type: "address" }),
|
|
6863
|
-
stellarSdk.nativeToScVal(dst_chain_id, { type: "u128" }),
|
|
6864
|
-
stellarSdk.nativeToScVal(Buffer.from(dst_address), { type: "bytes" }),
|
|
6865
|
-
stellarSdk.nativeToScVal(Buffer.from(payload), { type: "bytes" })
|
|
6866
|
-
)
|
|
6867
|
-
).setTimeout(100).build();
|
|
6868
|
-
const simResult = await this.server.simulateTransaction(simulateTx);
|
|
6869
|
-
const tx = stellarSdk.rpc.assembleTransaction(simulateTx, simResult).build();
|
|
7289
|
+
const accountResponse = await this.server.loadAccount(walletAddress);
|
|
7290
|
+
const stellarAccount = new CustomStellarAccount(accountResponse);
|
|
7291
|
+
const sendMessageCall = this.buildSendMessageCall(walletAddress, dst_chain_id, dst_address, payload);
|
|
7292
|
+
const [priorityTx, simulation] = await this.buildPriorityStellarTransaction(
|
|
7293
|
+
stellarAccount,
|
|
7294
|
+
network,
|
|
7295
|
+
sendMessageCall
|
|
7296
|
+
);
|
|
6870
7297
|
if (raw) {
|
|
6871
|
-
const transactionXdr =
|
|
7298
|
+
const transactionXdr = priorityTx.toXDR();
|
|
6872
7299
|
return {
|
|
6873
7300
|
from: walletAddress,
|
|
6874
7301
|
to: this.chainConfig.addresses.assetManager,
|
|
@@ -6876,21 +7303,35 @@ var StellarSpokeProvider = class {
|
|
|
6876
7303
|
data: transactionXdr
|
|
6877
7304
|
};
|
|
6878
7305
|
}
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
const sendResponse = await this.server.sendTransaction(
|
|
6882
|
-
stellarSdk.TransactionBuilder.fromXDR(signedTx, tx.networkPassphrase)
|
|
6883
|
-
);
|
|
6884
|
-
if (sendResponse.hash) {
|
|
6885
|
-
return `0x${sendResponse.hash}`;
|
|
6886
|
-
}
|
|
6887
|
-
}
|
|
6888
|
-
throw new Error("Failed to create transaction");
|
|
7306
|
+
const hash = await this.submitOrRestoreAndRetry(stellarAccount, network, priorityTx, sendMessageCall, simulation);
|
|
7307
|
+
return `${hash}`;
|
|
6889
7308
|
} catch (error) {
|
|
6890
|
-
console.error("Error during
|
|
7309
|
+
console.error("Error during sendMessage:", error);
|
|
6891
7310
|
throw error;
|
|
6892
7311
|
}
|
|
6893
7312
|
}
|
|
7313
|
+
buildDepositCall(walletAddress, token, amount, recipient, data) {
|
|
7314
|
+
return this.contract.call(
|
|
7315
|
+
"transfer",
|
|
7316
|
+
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(walletAddress), { type: "address" }),
|
|
7317
|
+
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(token), {
|
|
7318
|
+
type: "address"
|
|
7319
|
+
}),
|
|
7320
|
+
stellarSdk.nativeToScVal(BigInt(amount), { type: "u128" }),
|
|
7321
|
+
stellarSdk.nativeToScVal(Buffer.from(recipient), { type: "bytes" }),
|
|
7322
|
+
stellarSdk.nativeToScVal(Buffer.from(data), { type: "bytes" })
|
|
7323
|
+
);
|
|
7324
|
+
}
|
|
7325
|
+
buildSendMessageCall(walletAddress, dst_chain_id, dst_address, payload) {
|
|
7326
|
+
const connection = new stellarSdk.Contract(this.chainConfig.addresses.connection);
|
|
7327
|
+
return connection.call(
|
|
7328
|
+
"send_message",
|
|
7329
|
+
stellarSdk.nativeToScVal(stellarSdk.Address.fromString(walletAddress), { type: "address" }),
|
|
7330
|
+
stellarSdk.nativeToScVal(dst_chain_id, { type: "u128" }),
|
|
7331
|
+
stellarSdk.nativeToScVal(Buffer.from(dst_address), { type: "bytes" }),
|
|
7332
|
+
stellarSdk.nativeToScVal(Buffer.from(payload), { type: "bytes" })
|
|
7333
|
+
);
|
|
7334
|
+
}
|
|
6894
7335
|
static getAddressBCSBytes(stellaraddress) {
|
|
6895
7336
|
return `0x${stellarSdk.Address.fromString(stellaraddress).toScVal().toXDR("hex")}`;
|
|
6896
7337
|
}
|
|
@@ -7661,9 +8102,13 @@ function encodeAddress(spokeChainId, address) {
|
|
|
7661
8102
|
case "injective-1":
|
|
7662
8103
|
return viem.toHex(Buffer.from(address, "utf-8"));
|
|
7663
8104
|
case "0x1.icon":
|
|
7664
|
-
return
|
|
8105
|
+
return viem.toHex(Buffer.from(address.replace("cx", "01").replace("hx", "00") ?? "f8", "hex"));
|
|
7665
8106
|
case "sui":
|
|
7666
8107
|
return viem.toHex(bcs.bcs.Address.serialize(address).toBytes());
|
|
8108
|
+
case "solana":
|
|
8109
|
+
return viem.toHex(Buffer.from(new web3_js.PublicKey(address).toBytes()));
|
|
8110
|
+
case "stellar":
|
|
8111
|
+
return `0x${stellarSdk.Address.fromString(address).toScVal().toXDR("hex")}`;
|
|
7667
8112
|
default:
|
|
7668
8113
|
return address;
|
|
7669
8114
|
}
|
|
@@ -7916,10 +8361,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7916
8361
|
* @param params - The parameters for the supply transaction.
|
|
7917
8362
|
* @param spokeProvider - The spoke provider.
|
|
7918
8363
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
7919
|
-
* @returns {Promise<Result<[
|
|
8364
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the transaction result and the hub transaction hash or error
|
|
7920
8365
|
*
|
|
7921
8366
|
* @example
|
|
7922
|
-
* const result = await moneyMarketService.
|
|
8367
|
+
* const result = await moneyMarketService.supply(
|
|
7923
8368
|
* {
|
|
7924
8369
|
* token: '0x...', // Address of the token (spoke chain address) to supply
|
|
7925
8370
|
* amount: 1000n, // Amount to supply (in token decimals)
|
|
@@ -7938,40 +8383,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7938
8383
|
* ] = result.value;
|
|
7939
8384
|
* console.log('Supply transaction hashes:', { spokeTxHash, hubTxHash });
|
|
7940
8385
|
*/
|
|
7941
|
-
async
|
|
8386
|
+
async supply(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
7942
8387
|
try {
|
|
7943
|
-
const txResult = await this.
|
|
8388
|
+
const txResult = await this.createSupplyIntent(params, spokeProvider);
|
|
7944
8389
|
if (!txResult.ok) {
|
|
7945
|
-
return
|
|
7946
|
-
ok: false,
|
|
7947
|
-
error: {
|
|
7948
|
-
code: "SUPPLY_FAILED",
|
|
7949
|
-
error: txResult.error
|
|
7950
|
-
}
|
|
7951
|
-
};
|
|
8390
|
+
return txResult;
|
|
7952
8391
|
}
|
|
7953
8392
|
const packetResult = await relayTxAndWaitPacket(
|
|
7954
8393
|
txResult.value,
|
|
8394
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
7955
8395
|
spokeProvider,
|
|
7956
8396
|
this.config.relayerApiEndpoint,
|
|
7957
8397
|
timeout
|
|
7958
8398
|
);
|
|
7959
8399
|
if (!packetResult.ok) {
|
|
7960
|
-
return
|
|
8400
|
+
return {
|
|
8401
|
+
ok: false,
|
|
8402
|
+
error: {
|
|
8403
|
+
code: packetResult.error.code,
|
|
8404
|
+
data: {
|
|
8405
|
+
error: packetResult.error,
|
|
8406
|
+
payload: txResult.value
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
};
|
|
7961
8410
|
}
|
|
7962
8411
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
7963
8412
|
} catch (error) {
|
|
7964
8413
|
return {
|
|
7965
8414
|
ok: false,
|
|
7966
8415
|
error: {
|
|
7967
|
-
code: "
|
|
7968
|
-
|
|
8416
|
+
code: "SUPPLY_UNKNOWN_ERROR",
|
|
8417
|
+
data: {
|
|
8418
|
+
error,
|
|
8419
|
+
payload: params
|
|
8420
|
+
}
|
|
7969
8421
|
}
|
|
7970
8422
|
};
|
|
7971
8423
|
}
|
|
7972
8424
|
}
|
|
7973
8425
|
/**
|
|
7974
|
-
*
|
|
8426
|
+
* Create supply intent only (without submitting to Solver API)
|
|
7975
8427
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
7976
8428
|
* In order to successfully supply tokens, you need to:
|
|
7977
8429
|
* 1. Check if the allowance is sufficient
|
|
@@ -7986,7 +8438,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
7986
8438
|
*
|
|
7987
8439
|
* @example
|
|
7988
8440
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
7989
|
-
* const result = await moneyMarketService.
|
|
8441
|
+
* const result = await moneyMarketService.createSupplyIntent(
|
|
7990
8442
|
* {
|
|
7991
8443
|
* token: "0x123...", // token address
|
|
7992
8444
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -8002,7 +8454,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8002
8454
|
* console.error('Supply failed:', result.error);
|
|
8003
8455
|
* }
|
|
8004
8456
|
*/
|
|
8005
|
-
async
|
|
8457
|
+
async createSupplyIntent(params, spokeProvider, raw) {
|
|
8006
8458
|
try {
|
|
8007
8459
|
invariant2__default.default(params.action === "supply", "Invalid action");
|
|
8008
8460
|
invariant2__default.default(params.token.length > 0, "Token is required");
|
|
@@ -8018,7 +8470,12 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8018
8470
|
this.hubProvider,
|
|
8019
8471
|
spokeProvider
|
|
8020
8472
|
);
|
|
8021
|
-
const data = this.
|
|
8473
|
+
const data = this.buildSupplyData(
|
|
8474
|
+
params.token,
|
|
8475
|
+
hubWallet,
|
|
8476
|
+
params.amount,
|
|
8477
|
+
spokeProvider.chainConfig.chain.id
|
|
8478
|
+
);
|
|
8022
8479
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
8023
8480
|
const txResult = await SpokeService.deposit(
|
|
8024
8481
|
{
|
|
@@ -8034,14 +8491,21 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8034
8491
|
);
|
|
8035
8492
|
return {
|
|
8036
8493
|
ok: true,
|
|
8037
|
-
value: txResult
|
|
8494
|
+
value: txResult,
|
|
8495
|
+
data: {
|
|
8496
|
+
address: hubWallet,
|
|
8497
|
+
payload: data
|
|
8498
|
+
}
|
|
8038
8499
|
};
|
|
8039
8500
|
} catch (error) {
|
|
8040
8501
|
return {
|
|
8041
8502
|
ok: false,
|
|
8042
8503
|
error: {
|
|
8043
|
-
code: "
|
|
8044
|
-
|
|
8504
|
+
code: "CREATE_SUPPLY_INTENT_FAILED",
|
|
8505
|
+
data: {
|
|
8506
|
+
error,
|
|
8507
|
+
payload: params
|
|
8508
|
+
}
|
|
8045
8509
|
}
|
|
8046
8510
|
};
|
|
8047
8511
|
}
|
|
@@ -8051,10 +8515,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8051
8515
|
* @param params - The parameters for the borrow transaction.
|
|
8052
8516
|
* @param spokeProvider - The spoke provider.
|
|
8053
8517
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8054
|
-
* @returns {Promise<Result<[
|
|
8518
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the transaction result and the hub transaction hash or error
|
|
8055
8519
|
*
|
|
8056
8520
|
* @example
|
|
8057
|
-
* const result = await moneyMarketService.
|
|
8521
|
+
* const result = await moneyMarketService.borrow(
|
|
8058
8522
|
* {
|
|
8059
8523
|
* token: '0x...', // Address of the token (spoke chain address) to borrow
|
|
8060
8524
|
* amount: 1000n, // Amount to borrow (in token decimals)
|
|
@@ -8073,40 +8537,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8073
8537
|
* ] = result.value;
|
|
8074
8538
|
* console.log('Borrow transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8075
8539
|
*/
|
|
8076
|
-
async
|
|
8540
|
+
async borrow(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8077
8541
|
try {
|
|
8078
|
-
const txResult = await this.
|
|
8542
|
+
const txResult = await this.createBorrowIntent(params, spokeProvider);
|
|
8079
8543
|
if (!txResult.ok) {
|
|
8080
|
-
return
|
|
8081
|
-
ok: false,
|
|
8082
|
-
error: {
|
|
8083
|
-
code: "BORROW_FAILED",
|
|
8084
|
-
error: txResult.error
|
|
8085
|
-
}
|
|
8086
|
-
};
|
|
8544
|
+
return txResult;
|
|
8087
8545
|
}
|
|
8088
8546
|
const packetResult = await relayTxAndWaitPacket(
|
|
8089
8547
|
txResult.value,
|
|
8548
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8090
8549
|
spokeProvider,
|
|
8091
8550
|
this.config.relayerApiEndpoint,
|
|
8092
8551
|
timeout
|
|
8093
8552
|
);
|
|
8094
8553
|
if (!packetResult.ok) {
|
|
8095
|
-
return
|
|
8554
|
+
return {
|
|
8555
|
+
ok: false,
|
|
8556
|
+
error: {
|
|
8557
|
+
code: packetResult.error.code,
|
|
8558
|
+
data: {
|
|
8559
|
+
error: packetResult.error,
|
|
8560
|
+
payload: txResult.value
|
|
8561
|
+
}
|
|
8562
|
+
}
|
|
8563
|
+
};
|
|
8096
8564
|
}
|
|
8097
8565
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8098
8566
|
} catch (error) {
|
|
8099
8567
|
return {
|
|
8100
8568
|
ok: false,
|
|
8101
8569
|
error: {
|
|
8102
|
-
code: "
|
|
8103
|
-
|
|
8570
|
+
code: "BORROW_UNKNOWN_ERROR",
|
|
8571
|
+
data: {
|
|
8572
|
+
error,
|
|
8573
|
+
payload: params
|
|
8574
|
+
}
|
|
8104
8575
|
}
|
|
8105
8576
|
};
|
|
8106
8577
|
}
|
|
8107
8578
|
}
|
|
8108
8579
|
/**
|
|
8109
|
-
*
|
|
8580
|
+
* Create borrow intent only (without submitting to Solver API)
|
|
8110
8581
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8111
8582
|
* In order to successfully borrow tokens, you need to:
|
|
8112
8583
|
* 1. Execute the borrow transaction on the spoke chain
|
|
@@ -8119,13 +8590,13 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8119
8590
|
*
|
|
8120
8591
|
* @example
|
|
8121
8592
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8122
|
-
* const result = await moneyMarketService.
|
|
8593
|
+
* const result = await moneyMarketService.createBorrowIntent(
|
|
8123
8594
|
* {
|
|
8124
8595
|
* token: "0x123...", // token address
|
|
8125
8596
|
* amount: 1000000000000000000n // 1 token in wei
|
|
8126
8597
|
* },
|
|
8127
8598
|
* spokeProvider,
|
|
8128
|
-
* raw // Optional: true = return the raw transaction data, false =
|
|
8599
|
+
* raw // Optional: true = return the raw transaction data, false = execute and return the transaction hash (default: false)
|
|
8129
8600
|
* );
|
|
8130
8601
|
*
|
|
8131
8602
|
* if (result.ok) {
|
|
@@ -8135,7 +8606,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8135
8606
|
* console.error('Borrow failed:', result.error);
|
|
8136
8607
|
* }
|
|
8137
8608
|
*/
|
|
8138
|
-
async
|
|
8609
|
+
async createBorrowIntent(params, spokeProvider, raw) {
|
|
8139
8610
|
invariant2__default.default(params.action === "borrow", "Invalid action");
|
|
8140
8611
|
invariant2__default.default(params.token.length > 0, "Token is required");
|
|
8141
8612
|
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8150,7 +8621,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8150
8621
|
this.hubProvider,
|
|
8151
8622
|
spokeProvider
|
|
8152
8623
|
);
|
|
8153
|
-
const data = this.
|
|
8624
|
+
const data = this.buildBorrowData(
|
|
8154
8625
|
hubWallet,
|
|
8155
8626
|
walletAddressBytes,
|
|
8156
8627
|
params.token,
|
|
@@ -8158,7 +8629,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8158
8629
|
spokeProvider.chainConfig.chain.id
|
|
8159
8630
|
);
|
|
8160
8631
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
8161
|
-
return {
|
|
8632
|
+
return {
|
|
8633
|
+
ok: true,
|
|
8634
|
+
value: txResult,
|
|
8635
|
+
data: {
|
|
8636
|
+
address: hubWallet,
|
|
8637
|
+
payload: data
|
|
8638
|
+
}
|
|
8639
|
+
};
|
|
8162
8640
|
}
|
|
8163
8641
|
/**
|
|
8164
8642
|
* Withdraw tokens from the money market pool, relay the transaction to the hub and submit the intent to the Solver API
|
|
@@ -8166,10 +8644,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8166
8644
|
* @param params - The parameters for the withdraw transaction.
|
|
8167
8645
|
* @param spokeProvider - The spoke provider.
|
|
8168
8646
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8169
|
-
* @returns {Promise<Result<[
|
|
8647
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the spoke and hub transaction hashes or error
|
|
8170
8648
|
*
|
|
8171
8649
|
* @example
|
|
8172
|
-
* const result = await moneyMarketService.
|
|
8650
|
+
* const result = await moneyMarketService.withdraw(
|
|
8173
8651
|
* {
|
|
8174
8652
|
* token: '0x...', // Address of the token (spoke chain address) to withdraw
|
|
8175
8653
|
* amount: 1000n, // Amount to withdraw (in token decimals)
|
|
@@ -8188,40 +8666,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8188
8666
|
* ] = result.value;
|
|
8189
8667
|
* console.log('Withdraw transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8190
8668
|
*/
|
|
8191
|
-
async
|
|
8669
|
+
async withdraw(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8192
8670
|
try {
|
|
8193
|
-
const txResult = await this.
|
|
8671
|
+
const txResult = await this.createWithdrawIntent(params, spokeProvider);
|
|
8194
8672
|
if (!txResult.ok) {
|
|
8195
|
-
return
|
|
8196
|
-
ok: false,
|
|
8197
|
-
error: {
|
|
8198
|
-
code: "WITHDRAW_FAILED",
|
|
8199
|
-
error: txResult.error
|
|
8200
|
-
}
|
|
8201
|
-
};
|
|
8673
|
+
return txResult;
|
|
8202
8674
|
}
|
|
8203
8675
|
const packetResult = await relayTxAndWaitPacket(
|
|
8204
8676
|
txResult.value,
|
|
8677
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8205
8678
|
spokeProvider,
|
|
8206
8679
|
this.config.relayerApiEndpoint,
|
|
8207
8680
|
timeout
|
|
8208
8681
|
);
|
|
8209
8682
|
if (!packetResult.ok) {
|
|
8210
|
-
return
|
|
8683
|
+
return {
|
|
8684
|
+
ok: false,
|
|
8685
|
+
error: {
|
|
8686
|
+
code: packetResult.error.code,
|
|
8687
|
+
data: {
|
|
8688
|
+
error: packetResult.error,
|
|
8689
|
+
payload: txResult.value
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8692
|
+
};
|
|
8211
8693
|
}
|
|
8212
8694
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8213
8695
|
} catch (error) {
|
|
8214
8696
|
return {
|
|
8215
8697
|
ok: false,
|
|
8216
8698
|
error: {
|
|
8217
|
-
code: "
|
|
8218
|
-
|
|
8699
|
+
code: "WITHDRAW_UNKNOWN_ERROR",
|
|
8700
|
+
data: {
|
|
8701
|
+
error,
|
|
8702
|
+
payload: params
|
|
8703
|
+
}
|
|
8219
8704
|
}
|
|
8220
8705
|
};
|
|
8221
8706
|
}
|
|
8222
8707
|
}
|
|
8223
8708
|
/**
|
|
8224
|
-
*
|
|
8709
|
+
* Create withdraw intent only (without submitting to Solver API)
|
|
8225
8710
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8226
8711
|
* In order to successfully withdraw tokens, you need to:
|
|
8227
8712
|
* 1. Execute the withdraw transaction on the spoke chain
|
|
@@ -8234,7 +8719,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8234
8719
|
*
|
|
8235
8720
|
* @example
|
|
8236
8721
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8237
|
-
* const result = await moneyMarketService.
|
|
8722
|
+
* const result = await moneyMarketService.createWithdrawIntent(
|
|
8238
8723
|
* {
|
|
8239
8724
|
* token: "0x123...", // token address
|
|
8240
8725
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -8250,7 +8735,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8250
8735
|
* console.error('Withdraw failed:', result.error);
|
|
8251
8736
|
* }
|
|
8252
8737
|
*/
|
|
8253
|
-
async
|
|
8738
|
+
async createWithdrawIntent(params, spokeProvider, raw) {
|
|
8254
8739
|
invariant2__default.default(params.action === "withdraw", "Invalid action");
|
|
8255
8740
|
invariant2__default.default(params.token.length > 0, "Token is required");
|
|
8256
8741
|
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8265,7 +8750,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8265
8750
|
this.hubProvider,
|
|
8266
8751
|
spokeProvider
|
|
8267
8752
|
);
|
|
8268
|
-
const data = this.
|
|
8753
|
+
const data = this.buildWithdrawData(
|
|
8269
8754
|
hubWallet,
|
|
8270
8755
|
walletAddressBytes,
|
|
8271
8756
|
params.token,
|
|
@@ -8273,7 +8758,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8273
8758
|
spokeProvider.chainConfig.chain.id
|
|
8274
8759
|
);
|
|
8275
8760
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
8276
|
-
return {
|
|
8761
|
+
return {
|
|
8762
|
+
ok: true,
|
|
8763
|
+
value: txResult,
|
|
8764
|
+
data: {
|
|
8765
|
+
address: hubWallet,
|
|
8766
|
+
payload: data
|
|
8767
|
+
}
|
|
8768
|
+
};
|
|
8277
8769
|
}
|
|
8278
8770
|
/**
|
|
8279
8771
|
* Repay tokens to the money market pool, relay the transaction to the hub and submit the intent to the Solver API
|
|
@@ -8281,10 +8773,10 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8281
8773
|
* @param params - The parameters for the repay transaction.
|
|
8282
8774
|
* @param spokeProvider - The spoke provider.
|
|
8283
8775
|
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
8284
|
-
* @returns {Promise<Result<[
|
|
8776
|
+
* @returns {Promise<Result<[SpokeTxHash, HubTxHash], MoneyMarketError>>} - Returns the spoke and hub transaction hashes or error
|
|
8285
8777
|
*
|
|
8286
8778
|
* @example
|
|
8287
|
-
* const result = await moneyMarketService.
|
|
8779
|
+
* const result = await moneyMarketService.repay(
|
|
8288
8780
|
* {
|
|
8289
8781
|
* token: '0x...', // Address of the token (spoke chain address) to repay
|
|
8290
8782
|
* amount: 1000n, // Amount to repay (in token decimals)
|
|
@@ -8303,40 +8795,47 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8303
8795
|
* ] = result.value;
|
|
8304
8796
|
* console.log('Repay transaction hashes:', { spokeTxHash, hubTxHash });
|
|
8305
8797
|
*/
|
|
8306
|
-
async
|
|
8798
|
+
async repay(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
8307
8799
|
try {
|
|
8308
|
-
const txResult = await this.
|
|
8800
|
+
const txResult = await this.createRepayIntent(params, spokeProvider);
|
|
8309
8801
|
if (!txResult.ok) {
|
|
8310
|
-
return
|
|
8311
|
-
ok: false,
|
|
8312
|
-
error: {
|
|
8313
|
-
code: "REPAY_FAILED",
|
|
8314
|
-
error: txResult.error
|
|
8315
|
-
}
|
|
8316
|
-
};
|
|
8802
|
+
return txResult;
|
|
8317
8803
|
}
|
|
8318
8804
|
const packetResult = await relayTxAndWaitPacket(
|
|
8319
8805
|
txResult.value,
|
|
8806
|
+
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
8320
8807
|
spokeProvider,
|
|
8321
8808
|
this.config.relayerApiEndpoint,
|
|
8322
8809
|
timeout
|
|
8323
8810
|
);
|
|
8324
8811
|
if (!packetResult.ok) {
|
|
8325
|
-
return
|
|
8812
|
+
return {
|
|
8813
|
+
ok: false,
|
|
8814
|
+
error: {
|
|
8815
|
+
code: packetResult.error.code,
|
|
8816
|
+
data: {
|
|
8817
|
+
error: packetResult.error,
|
|
8818
|
+
payload: txResult.value
|
|
8819
|
+
}
|
|
8820
|
+
}
|
|
8821
|
+
};
|
|
8326
8822
|
}
|
|
8327
8823
|
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
8328
8824
|
} catch (error) {
|
|
8329
8825
|
return {
|
|
8330
8826
|
ok: false,
|
|
8331
8827
|
error: {
|
|
8332
|
-
code: "
|
|
8333
|
-
|
|
8828
|
+
code: "REPAY_UNKNOWN_ERROR",
|
|
8829
|
+
data: {
|
|
8830
|
+
error,
|
|
8831
|
+
payload: params
|
|
8832
|
+
}
|
|
8334
8833
|
}
|
|
8335
8834
|
};
|
|
8336
8835
|
}
|
|
8337
8836
|
}
|
|
8338
8837
|
/**
|
|
8339
|
-
*
|
|
8838
|
+
* Create repay intent only (without submitting to Solver API)
|
|
8340
8839
|
* NOTE: This method does not submit the intent to the Solver API, it only executes the transaction on the spoke chain
|
|
8341
8840
|
* In order to successfully repay tokens, you need to:
|
|
8342
8841
|
* 1. Check if the allowance is sufficient
|
|
@@ -8351,7 +8850,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8351
8850
|
*
|
|
8352
8851
|
* @example
|
|
8353
8852
|
* const moneyMarketService = new MoneyMarketService(config);
|
|
8354
|
-
* const result = await moneyMarketService.
|
|
8853
|
+
* const result = await moneyMarketService.createRepayIntent(
|
|
8355
8854
|
* {
|
|
8356
8855
|
* token: "0x123...", // token address
|
|
8357
8856
|
* amount: 1000000000000000000n // 1 token in wei
|
|
@@ -8367,7 +8866,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8367
8866
|
* console.error('Repay failed:', result.error);
|
|
8368
8867
|
* }
|
|
8369
8868
|
*/
|
|
8370
|
-
async
|
|
8869
|
+
async createRepayIntent(params, spokeProvider, raw) {
|
|
8371
8870
|
invariant2__default.default(params.action === "repay", "Invalid action");
|
|
8372
8871
|
invariant2__default.default(params.token.length > 0, "Token is required");
|
|
8373
8872
|
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
@@ -8382,7 +8881,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8382
8881
|
this.hubProvider,
|
|
8383
8882
|
spokeProvider
|
|
8384
8883
|
);
|
|
8385
|
-
const data = this.
|
|
8884
|
+
const data = this.buildRepayData(params.token, hubWallet, params.amount, spokeProvider.chainConfig.chain.id);
|
|
8386
8885
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
8387
8886
|
const txResult = await SpokeService.deposit(
|
|
8388
8887
|
{
|
|
@@ -8396,7 +8895,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8396
8895
|
this.hubProvider,
|
|
8397
8896
|
raw
|
|
8398
8897
|
);
|
|
8399
|
-
return {
|
|
8898
|
+
return {
|
|
8899
|
+
ok: true,
|
|
8900
|
+
value: txResult,
|
|
8901
|
+
data: {
|
|
8902
|
+
address: hubWallet,
|
|
8903
|
+
payload: data
|
|
8904
|
+
}
|
|
8905
|
+
};
|
|
8400
8906
|
}
|
|
8401
8907
|
/**
|
|
8402
8908
|
* Build transaction data for supplying to the money market pool
|
|
@@ -8406,7 +8912,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8406
8912
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8407
8913
|
* @returns {Hex} The transaction data.
|
|
8408
8914
|
*/
|
|
8409
|
-
|
|
8915
|
+
buildSupplyData(token, to, amount, spokeChainId) {
|
|
8410
8916
|
const calls = [];
|
|
8411
8917
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8412
8918
|
invariant2__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
@@ -8434,7 +8940,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8434
8940
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8435
8941
|
* @returns {Hex} The transaction data.
|
|
8436
8942
|
*/
|
|
8437
|
-
|
|
8943
|
+
buildBorrowData(from, to, token, amount, spokeChainId) {
|
|
8438
8944
|
invariant2__default.default(isValidSpokeChainId(spokeChainId), `Invalid spokeChainId: ${spokeChainId}`);
|
|
8439
8945
|
invariant2__default.default(
|
|
8440
8946
|
isValidOriginalAssetAddress(spokeChainId, token),
|
|
@@ -8509,7 +9015,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8509
9015
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8510
9016
|
* @returns {Hex} The transaction data.
|
|
8511
9017
|
*/
|
|
8512
|
-
|
|
9018
|
+
buildWithdrawData(from, to, token, amount, spokeChainId) {
|
|
8513
9019
|
const calls = [];
|
|
8514
9020
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8515
9021
|
if (!assetConfig) {
|
|
@@ -8560,11 +9066,11 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
8560
9066
|
* @param spokeChainId - The chain ID of the spoke chain
|
|
8561
9067
|
* @returns {Hex} The transaction data.
|
|
8562
9068
|
*/
|
|
8563
|
-
|
|
9069
|
+
buildRepayData(token, to, amount, spokeChainId) {
|
|
8564
9070
|
const calls = [];
|
|
8565
9071
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
8566
9072
|
if (!assetConfig) {
|
|
8567
|
-
throw new Error("[
|
|
9073
|
+
throw new Error("[buildRepayData] Hub asset not found");
|
|
8568
9074
|
}
|
|
8569
9075
|
const assetAddress = assetConfig.asset;
|
|
8570
9076
|
const vaultAddress = assetConfig.vault;
|
|
@@ -9064,10 +9570,7 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
9064
9570
|
}
|
|
9065
9571
|
return spokeProvider.walletProvider.sendTransaction({
|
|
9066
9572
|
from: walletAddress,
|
|
9067
|
-
to: isNativeToken(spokeProvider.chainConfig.chain.id, token) ?
|
|
9068
|
-
// wICX address
|
|
9069
|
-
"cx3975b43d260fb8ec802cef6e60c2f4d07486f11d"
|
|
9070
|
-
) : token,
|
|
9573
|
+
to: isNativeToken(spokeProvider.chainConfig.chain.id, token) ? spokeProvider.chainConfig.addresses.wICX : token,
|
|
9071
9574
|
value,
|
|
9072
9575
|
nid: spokeProvider.chainConfig.nid,
|
|
9073
9576
|
method: "transfer",
|
|
@@ -9187,7 +9690,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9187
9690
|
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
9188
9691
|
const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9189
9692
|
spokeProvider.chainConfig.chain.id,
|
|
9190
|
-
|
|
9693
|
+
encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9191
9694
|
hubProvider
|
|
9192
9695
|
);
|
|
9193
9696
|
return _SolanaSpokeService.transfer(
|
|
@@ -9195,7 +9698,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9195
9698
|
token: new web3_js.PublicKey(params.token),
|
|
9196
9699
|
recipient: userWallet,
|
|
9197
9700
|
amount: params.amount.toString(),
|
|
9198
|
-
data: params.data
|
|
9701
|
+
data: viem.keccak256(params.data)
|
|
9199
9702
|
},
|
|
9200
9703
|
spokeProvider,
|
|
9201
9704
|
raw
|
|
@@ -9229,7 +9732,7 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9229
9732
|
*/
|
|
9230
9733
|
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
9231
9734
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9232
|
-
return _SolanaSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
9735
|
+
return _SolanaSpokeService.call(BigInt(relayId), from, viem.keccak256(payload), spokeProvider, raw);
|
|
9233
9736
|
}
|
|
9234
9737
|
static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
|
|
9235
9738
|
let depositInstruction;
|
|
@@ -9782,9 +10285,9 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
9782
10285
|
}
|
|
9783
10286
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
9784
10287
|
}
|
|
9785
|
-
static async
|
|
10288
|
+
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
|
|
9786
10289
|
const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
9787
|
-
const withdrawCall = moneyMarketService.
|
|
10290
|
+
const withdrawCall = moneyMarketService.buildWithdrawData(
|
|
9788
10291
|
userRouter,
|
|
9789
10292
|
from,
|
|
9790
10293
|
withdrawInfo.token,
|
|
@@ -9885,6 +10388,51 @@ function isConfiguredSolverConfig(value) {
|
|
|
9885
10388
|
function isConfiguredMoneyMarketConfig(value) {
|
|
9886
10389
|
return typeof value === "object" && value !== null && "lendingPool" in value && "uiPoolDataProvider" in value && "poolAddressesProvider" in value && "bnUSD" in value && "bnUSDVault" in value;
|
|
9887
10390
|
}
|
|
10391
|
+
function isIntentCreationFailedError(error) {
|
|
10392
|
+
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;
|
|
10393
|
+
}
|
|
10394
|
+
function isIntentSubmitTxFailedError(error) {
|
|
10395
|
+
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;
|
|
10396
|
+
}
|
|
10397
|
+
function isIntentPostExecutionFailedError(error) {
|
|
10398
|
+
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;
|
|
10399
|
+
}
|
|
10400
|
+
function isWaitUntilIntentExecutedFailed(error) {
|
|
10401
|
+
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;
|
|
10402
|
+
}
|
|
10403
|
+
function isIntentCreationUnknownError(error) {
|
|
10404
|
+
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;
|
|
10405
|
+
}
|
|
10406
|
+
function isMoneyMarketSubmitTxFailedError(error) {
|
|
10407
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SUBMIT_TX_FAILED";
|
|
10408
|
+
}
|
|
10409
|
+
function isMoneyMarketRelayTimeoutError(error) {
|
|
10410
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "RELAY_TIMEOUT";
|
|
10411
|
+
}
|
|
10412
|
+
function isMoneyMarketCreateSupplyIntentFailedError(error) {
|
|
10413
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_SUPPLY_INTENT_FAILED";
|
|
10414
|
+
}
|
|
10415
|
+
function isMoneyMarketCreateBorrowIntentFailedError(error) {
|
|
10416
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_BORROW_INTENT_FAILED";
|
|
10417
|
+
}
|
|
10418
|
+
function isMoneyMarketCreateWithdrawIntentFailedError(error) {
|
|
10419
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_WITHDRAW_INTENT_FAILED";
|
|
10420
|
+
}
|
|
10421
|
+
function isMoneyMarketCreateRepayIntentFailedError(error) {
|
|
10422
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "CREATE_REPAY_INTENT_FAILED";
|
|
10423
|
+
}
|
|
10424
|
+
function isMoneyMarketSupplyUnknownError(error) {
|
|
10425
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "SUPPLY_UNKNOWN_ERROR";
|
|
10426
|
+
}
|
|
10427
|
+
function isMoneyMarketBorrowUnknownError(error) {
|
|
10428
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "BORROW_UNKNOWN_ERROR";
|
|
10429
|
+
}
|
|
10430
|
+
function isMoneyMarketWithdrawUnknownError(error) {
|
|
10431
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "WITHDRAW_UNKNOWN_ERROR";
|
|
10432
|
+
}
|
|
10433
|
+
function isMoneyMarketRepayUnknownError(error) {
|
|
10434
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "REPAY_UNKNOWN_ERROR";
|
|
10435
|
+
}
|
|
9888
10436
|
|
|
9889
10437
|
// src/services/spoke/SpokeService.ts
|
|
9890
10438
|
var SpokeService = class {
|
|
@@ -10081,12 +10629,12 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10081
10629
|
} catch (e) {
|
|
10082
10630
|
console.error("Error getting transaction packets", e);
|
|
10083
10631
|
}
|
|
10084
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
10632
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
10085
10633
|
}
|
|
10086
10634
|
return {
|
|
10087
10635
|
ok: false,
|
|
10088
10636
|
error: {
|
|
10089
|
-
code: "
|
|
10637
|
+
code: "RELAY_TIMEOUT",
|
|
10090
10638
|
data: {
|
|
10091
10639
|
payload,
|
|
10092
10640
|
error: {
|
|
@@ -10100,7 +10648,7 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10100
10648
|
return {
|
|
10101
10649
|
ok: false,
|
|
10102
10650
|
error: {
|
|
10103
|
-
code: "
|
|
10651
|
+
code: "RELAY_TIMEOUT",
|
|
10104
10652
|
data: {
|
|
10105
10653
|
payload,
|
|
10106
10654
|
error: e
|
|
@@ -10109,12 +10657,16 @@ async function waitUntilIntentExecuted(payload) {
|
|
|
10109
10657
|
};
|
|
10110
10658
|
}
|
|
10111
10659
|
}
|
|
10112
|
-
async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
10660
|
+
async function relayTxAndWaitPacket(spokeTxHash, data, spokeProvider, relayerApiEndpoint, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
10113
10661
|
try {
|
|
10114
10662
|
const intentRelayChainId = getIntentRelayChainId(spokeProvider.chainConfig.chain.id).toString();
|
|
10115
10663
|
const submitPayload = {
|
|
10116
10664
|
action: "submit",
|
|
10117
|
-
params: {
|
|
10665
|
+
params: data ? {
|
|
10666
|
+
chain_id: intentRelayChainId,
|
|
10667
|
+
tx_hash: spokeTxHash,
|
|
10668
|
+
data
|
|
10669
|
+
} : {
|
|
10118
10670
|
chain_id: intentRelayChainId,
|
|
10119
10671
|
tx_hash: spokeTxHash
|
|
10120
10672
|
}
|
|
@@ -10139,7 +10691,7 @@ async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoi
|
|
|
10139
10691
|
return {
|
|
10140
10692
|
ok: false,
|
|
10141
10693
|
error: {
|
|
10142
|
-
code: "
|
|
10694
|
+
code: "RELAY_TIMEOUT",
|
|
10143
10695
|
error: packet.error
|
|
10144
10696
|
}
|
|
10145
10697
|
};
|
|
@@ -10152,7 +10704,7 @@ async function relayTxAndWaitPacket(spokeTxHash, spokeProvider, relayerApiEndpoi
|
|
|
10152
10704
|
return {
|
|
10153
10705
|
ok: false,
|
|
10154
10706
|
error: {
|
|
10155
|
-
code: "
|
|
10707
|
+
code: "SUBMIT_TX_FAILED",
|
|
10156
10708
|
error
|
|
10157
10709
|
}
|
|
10158
10710
|
};
|
|
@@ -10190,6 +10742,8 @@ var EvmSolverService = class _EvmSolverService {
|
|
|
10190
10742
|
outputToken,
|
|
10191
10743
|
srcChain: getIntentRelayChainId(createIntentParams.srcChain),
|
|
10192
10744
|
dstChain: getIntentRelayChainId(createIntentParams.dstChain),
|
|
10745
|
+
srcAddress: encodeAddress(createIntentParams.srcChain, createIntentParams.srcAddress),
|
|
10746
|
+
dstAddress: encodeAddress(createIntentParams.dstChain, createIntentParams.dstAddress),
|
|
10193
10747
|
intentId: randomUint256(),
|
|
10194
10748
|
creator: creatorHubWalletAddress,
|
|
10195
10749
|
data: feeData
|
|
@@ -10417,7 +10971,7 @@ var SolverApiService = class {
|
|
|
10417
10971
|
* }
|
|
10418
10972
|
* }
|
|
10419
10973
|
*/
|
|
10420
|
-
static async postExecution(
|
|
10974
|
+
static async postExecution(request, config) {
|
|
10421
10975
|
try {
|
|
10422
10976
|
const response = await retry(
|
|
10423
10977
|
() => fetch(`${config.solverApiEndpoint}/execute`, {
|
|
@@ -10425,7 +10979,7 @@ var SolverApiService = class {
|
|
|
10425
10979
|
headers: {
|
|
10426
10980
|
"Content-Type": "application/json"
|
|
10427
10981
|
},
|
|
10428
|
-
body: JSON.stringify(
|
|
10982
|
+
body: JSON.stringify(request)
|
|
10429
10983
|
})
|
|
10430
10984
|
);
|
|
10431
10985
|
if (!response.ok) {
|
|
@@ -10451,15 +11005,15 @@ var SolverApiService = class {
|
|
|
10451
11005
|
};
|
|
10452
11006
|
}
|
|
10453
11007
|
}
|
|
10454
|
-
static async getStatus(
|
|
10455
|
-
invariant2__default.default(
|
|
11008
|
+
static async getStatus(request, config) {
|
|
11009
|
+
invariant2__default.default(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
|
|
10456
11010
|
try {
|
|
10457
11011
|
const response = await fetch(`${config.solverApiEndpoint}/status`, {
|
|
10458
11012
|
method: "POST",
|
|
10459
11013
|
headers: {
|
|
10460
11014
|
"Content-Type": "application/json"
|
|
10461
11015
|
},
|
|
10462
|
-
body: JSON.stringify(
|
|
11016
|
+
body: JSON.stringify(request)
|
|
10463
11017
|
});
|
|
10464
11018
|
if (!response.ok) {
|
|
10465
11019
|
return {
|
|
@@ -10518,8 +11072,8 @@ var SolverService = class {
|
|
|
10518
11072
|
}
|
|
10519
11073
|
/**
|
|
10520
11074
|
* Request a quote from the solver API
|
|
10521
|
-
* @param {
|
|
10522
|
-
* @returns {Promise<Result<
|
|
11075
|
+
* @param {SolverIntentQuoteRequest} payload - The solver intent quote request
|
|
11076
|
+
* @returns {Promise<Result<SolverIntentQuoteResponse, SolverErrorResponse>>} The intent quote response
|
|
10523
11077
|
*
|
|
10524
11078
|
* @example
|
|
10525
11079
|
* const payload = {
|
|
@@ -10529,7 +11083,7 @@ var SolverService = class {
|
|
|
10529
11083
|
* "token_dst_blockchain_id":"0xa4b1.arbitrum",
|
|
10530
11084
|
* "amount":1000000000000000n,
|
|
10531
11085
|
* "quote_type": "exact_input"
|
|
10532
|
-
* } satisfies
|
|
11086
|
+
* } satisfies SolverIntentQuoteRequest
|
|
10533
11087
|
*
|
|
10534
11088
|
* const response = await solverService.getQuote(payload);
|
|
10535
11089
|
*
|
|
@@ -10560,15 +11114,16 @@ var SolverService = class {
|
|
|
10560
11114
|
}
|
|
10561
11115
|
/**
|
|
10562
11116
|
* Get the status of an intent from Solver API
|
|
10563
|
-
*
|
|
10564
|
-
* @
|
|
11117
|
+
* NOTE: intentHash should be retrieved from relay packet dst_tx_hash property (see createAndSubmitIntent)
|
|
11118
|
+
* @param {SolverIntentStatusRequest} request - The intent status request
|
|
11119
|
+
* @returns {Promise<Result<SolverIntentStatusResponse, SolverErrorResponse>>} The solver intent status response
|
|
10565
11120
|
*
|
|
10566
11121
|
* @example
|
|
10567
|
-
* const
|
|
10568
|
-
* "
|
|
10569
|
-
* } satisfies
|
|
11122
|
+
* const request = {
|
|
11123
|
+
* "intent_tx_hash": "a0dd7652-b360-4123-ab2d-78cfbcd20c6b" // destination tx hash from relay packet
|
|
11124
|
+
* } satisfies SolverIntentStatusRequest
|
|
10570
11125
|
*
|
|
10571
|
-
* const response = await solverService.getStatus(
|
|
11126
|
+
* const response = await solverService.getStatus(request);
|
|
10572
11127
|
*
|
|
10573
11128
|
* if (response.ok) {
|
|
10574
11129
|
* const { status, intent_hash } = response.value;
|
|
@@ -10578,20 +11133,20 @@ var SolverService = class {
|
|
|
10578
11133
|
* // handle error
|
|
10579
11134
|
* }
|
|
10580
11135
|
*/
|
|
10581
|
-
async getStatus(
|
|
10582
|
-
return SolverApiService.getStatus(
|
|
11136
|
+
async getStatus(request) {
|
|
11137
|
+
return SolverApiService.getStatus(request, this.config);
|
|
10583
11138
|
}
|
|
10584
11139
|
/**
|
|
10585
11140
|
* Post execution of intent order transaction executed on hub chain to Solver API
|
|
10586
|
-
* @param {
|
|
10587
|
-
* @returns {Promise<Result<
|
|
11141
|
+
* @param {SolverExecutionRequest} request - The intent execution request
|
|
11142
|
+
* @returns {Promise<Result<SolverExecutionResponse, SolverErrorResponse>>} The intent execution response
|
|
10588
11143
|
*
|
|
10589
11144
|
* @example
|
|
10590
|
-
* const
|
|
11145
|
+
* const request = {
|
|
10591
11146
|
* "intent_tx_hash": "0xba3dce19347264db32ced212ff1a2036f20d9d2c7493d06af15027970be061af",
|
|
10592
|
-
* } satisfies
|
|
11147
|
+
* } satisfies SolverExecutionRequest
|
|
10593
11148
|
*
|
|
10594
|
-
* const response = await solverService.postExecution(
|
|
11149
|
+
* const response = await solverService.postExecution(request);
|
|
10595
11150
|
*
|
|
10596
11151
|
* if (response.ok) {
|
|
10597
11152
|
* const { answer, intent_hash } = response.value;
|
|
@@ -10601,28 +11156,121 @@ var SolverService = class {
|
|
|
10601
11156
|
* // handle error
|
|
10602
11157
|
* }
|
|
10603
11158
|
*/
|
|
10604
|
-
async postExecution(
|
|
10605
|
-
return SolverApiService.postExecution(
|
|
11159
|
+
async postExecution(request) {
|
|
11160
|
+
return SolverApiService.postExecution(request, this.config);
|
|
10606
11161
|
}
|
|
10607
11162
|
/**
|
|
10608
|
-
*
|
|
10609
|
-
* @param {
|
|
10610
|
-
* @
|
|
10611
|
-
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
10612
|
-
* @returns {Promise<Result<[IntentExecutionResponse, Intent, PacketData], IntentSubmitError<IntentSubmitErrorCode>>>} The intent execution response, intent, and packet data
|
|
11163
|
+
* Submit intent transaction to the relayer API
|
|
11164
|
+
* @param {IntentRelayRequest<'submit'>} submitPayload - The intent relay request
|
|
11165
|
+
* @returns {Promise<Result<GetRelayResponse<'submit'>, IntentError<'SUBMIT_TX_FAILED'>>>} The intent relay response
|
|
10613
11166
|
*
|
|
10614
11167
|
* @example
|
|
10615
|
-
* const
|
|
10616
|
-
* "
|
|
10617
|
-
* "
|
|
11168
|
+
* const submitPayload = {
|
|
11169
|
+
* "action": "submit",
|
|
11170
|
+
* "params": {
|
|
11171
|
+
* "chain_id": "0x38.bsc",
|
|
11172
|
+
* "tx_hash": "0xba3dce19347264db32ced212ff1a2036f20d9d2c7493d06af15027970be061af",
|
|
11173
|
+
* },
|
|
11174
|
+
* } satisfies IntentRelayRequest<'submit'>;
|
|
11175
|
+
*
|
|
11176
|
+
* const submitResult = await solverService.submitIntent(submitPayload);
|
|
11177
|
+
*
|
|
11178
|
+
* if (submitResult.ok) {
|
|
11179
|
+
* const { success, message } = submitResult.value;
|
|
11180
|
+
* console.log('Success:', success);
|
|
11181
|
+
* console.log('Message:', message);
|
|
11182
|
+
* } else {
|
|
11183
|
+
* // handle error
|
|
11184
|
+
* }
|
|
11185
|
+
*/
|
|
11186
|
+
async submitIntent(submitPayload) {
|
|
11187
|
+
try {
|
|
11188
|
+
const submitResult = await submitTransaction(submitPayload, this.config.relayerApiEndpoint);
|
|
11189
|
+
if (!submitResult.success) {
|
|
11190
|
+
return {
|
|
11191
|
+
ok: false,
|
|
11192
|
+
error: {
|
|
11193
|
+
code: "SUBMIT_TX_FAILED",
|
|
11194
|
+
data: {
|
|
11195
|
+
payload: submitPayload,
|
|
11196
|
+
error: new Error(submitResult.message)
|
|
11197
|
+
}
|
|
11198
|
+
}
|
|
11199
|
+
};
|
|
11200
|
+
}
|
|
11201
|
+
return {
|
|
11202
|
+
ok: true,
|
|
11203
|
+
value: submitResult
|
|
11204
|
+
};
|
|
11205
|
+
} catch (error) {
|
|
11206
|
+
return {
|
|
11207
|
+
ok: false,
|
|
11208
|
+
error: {
|
|
11209
|
+
code: "SUBMIT_TX_FAILED",
|
|
11210
|
+
data: {
|
|
11211
|
+
payload: submitPayload,
|
|
11212
|
+
error
|
|
11213
|
+
}
|
|
11214
|
+
}
|
|
11215
|
+
};
|
|
11216
|
+
}
|
|
11217
|
+
}
|
|
11218
|
+
/**
|
|
11219
|
+
* Swap is a syntatic sugar for createAndSubmitIntent that creates an intent and submits it to the Solver API and Relayer API
|
|
11220
|
+
* @param {CreateIntentParams} payload - The intent to create
|
|
11221
|
+
* @param {ISpokeProvider} spokeProvider - The spoke provider
|
|
11222
|
+
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
11223
|
+
* @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
|
|
11224
|
+
*
|
|
11225
|
+
* @example
|
|
11226
|
+
* const payload = {
|
|
11227
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
11228
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
11229
|
+
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
11230
|
+
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
11231
|
+
* "deadline": 0n, // Optional timestamp after which intent expires (0 = no deadline)
|
|
11232
|
+
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
11233
|
+
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
11234
|
+
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
11235
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11236
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
11237
|
+
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
11238
|
+
* "data": "0x..", // Additional arbitrary data
|
|
11239
|
+
* } satisfies CreateIntentParams;
|
|
11240
|
+
*
|
|
11241
|
+
* const swapResult = await solverService.swap(payload, spokeProvider);
|
|
11242
|
+
*
|
|
11243
|
+
* if (swapResult.ok) {
|
|
11244
|
+
* const [solverExecutionResponse, intent, packetData] = swapResult.value;
|
|
11245
|
+
* console.log('Intent execution response:', solverExecutionResponse);
|
|
11246
|
+
* console.log('Intent:', intent);
|
|
11247
|
+
* console.log('Packet data:', packetData);
|
|
11248
|
+
* } else {
|
|
11249
|
+
* // handle error
|
|
11250
|
+
* }
|
|
11251
|
+
*/
|
|
11252
|
+
async swap(payload, spokeProvider, fee, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
11253
|
+
return this.createAndSubmitIntent(payload, spokeProvider, fee, timeout);
|
|
11254
|
+
}
|
|
11255
|
+
/**
|
|
11256
|
+
* Creates an intent and submits it to the Solver API and Relayer API
|
|
11257
|
+
* @param {CreateIntentParams} payload - The intent to create
|
|
11258
|
+
* @param {ISpokeProvider} spokeProvider - The spoke provider
|
|
11259
|
+
* @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
11260
|
+
* @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
|
|
11261
|
+
*
|
|
11262
|
+
* @example
|
|
11263
|
+
* const payload = {
|
|
11264
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
11265
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
10618
11266
|
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
10619
11267
|
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
10620
11268
|
* "deadline": 0n, // Optional timestamp after which intent expires (0 = no deadline)
|
|
10621
11269
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10622
11270
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10623
11271
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10624
|
-
* "srcAddress": "0x..", // Source address
|
|
10625
|
-
* "dstAddress": "0x...", // Destination address
|
|
11272
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11273
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10626
11274
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10627
11275
|
* "data": "0x..", // Additional arbitrary data
|
|
10628
11276
|
* } satisfies CreateIntentParams;
|
|
@@ -10630,8 +11278,8 @@ var SolverService = class {
|
|
|
10630
11278
|
* const createAndSubmitIntentResult = await solverService.createAndSubmitIntent(payload, spokeProvider);
|
|
10631
11279
|
*
|
|
10632
11280
|
* if (createAndSubmitIntentResult.ok) {
|
|
10633
|
-
* const [
|
|
10634
|
-
* console.log('Intent execution response:',
|
|
11281
|
+
* const [solverExecutionResponse, intent, packetData] = createAndSubmitIntentResult.value;
|
|
11282
|
+
* console.log('Intent execution response:', solverExecutionResponse);
|
|
10635
11283
|
* console.log('Intent:', intent);
|
|
10636
11284
|
* console.log('Packet data:', packetData);
|
|
10637
11285
|
* } else {
|
|
@@ -10642,32 +11290,30 @@ var SolverService = class {
|
|
|
10642
11290
|
try {
|
|
10643
11291
|
const createIntentResult = await this.createIntent(payload, spokeProvider, fee, false);
|
|
10644
11292
|
if (!createIntentResult.ok) {
|
|
10645
|
-
return
|
|
10646
|
-
ok: false,
|
|
10647
|
-
error: createIntentResult.error
|
|
10648
|
-
};
|
|
11293
|
+
return createIntentResult;
|
|
10649
11294
|
}
|
|
10650
|
-
const [spokeTxHash, intent] = createIntentResult.value;
|
|
11295
|
+
const [spokeTxHash, intent, data] = createIntentResult.value;
|
|
10651
11296
|
const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
|
|
10652
|
-
const submitPayload = {
|
|
11297
|
+
const submitPayload = payload.srcChain === types.SOLANA_MAINNET_CHAIN_ID && data ? {
|
|
11298
|
+
action: "submit",
|
|
11299
|
+
params: {
|
|
11300
|
+
chain_id: intentRelayChainId,
|
|
11301
|
+
tx_hash: spokeTxHash,
|
|
11302
|
+
data: {
|
|
11303
|
+
address: intent.creator,
|
|
11304
|
+
payload: data
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
} : {
|
|
10653
11308
|
action: "submit",
|
|
10654
11309
|
params: {
|
|
10655
11310
|
chain_id: intentRelayChainId,
|
|
10656
11311
|
tx_hash: spokeTxHash
|
|
10657
11312
|
}
|
|
10658
11313
|
};
|
|
10659
|
-
const submitResult = await
|
|
10660
|
-
if (!submitResult.
|
|
10661
|
-
return
|
|
10662
|
-
ok: false,
|
|
10663
|
-
error: {
|
|
10664
|
-
code: "SUBMIT_TX_FAILED",
|
|
10665
|
-
data: {
|
|
10666
|
-
payload: submitPayload,
|
|
10667
|
-
apiUrl: this.config.relayerApiEndpoint
|
|
10668
|
-
}
|
|
10669
|
-
}
|
|
10670
|
-
};
|
|
11314
|
+
const submitResult = await this.submitIntent(submitPayload);
|
|
11315
|
+
if (!submitResult.ok) {
|
|
11316
|
+
return submitResult;
|
|
10671
11317
|
}
|
|
10672
11318
|
const packet = await waitUntilIntentExecuted({
|
|
10673
11319
|
intentRelayChainId,
|
|
@@ -10726,8 +11372,8 @@ var SolverService = class {
|
|
|
10726
11372
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10727
11373
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10728
11374
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10729
|
-
* "srcAddress": "0x..", // Source address
|
|
10730
|
-
* "dstAddress": "0x...", // Destination address
|
|
11375
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11376
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10731
11377
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10732
11378
|
* "data": "0x..", // Additional arbitrary data
|
|
10733
11379
|
* } satisfies CreateIntentParams;
|
|
@@ -10789,10 +11435,16 @@ var SolverService = class {
|
|
|
10789
11435
|
*
|
|
10790
11436
|
* const txReceipt = approveResult.value;
|
|
10791
11437
|
*/
|
|
10792
|
-
async approve(token, amount,
|
|
11438
|
+
async approve(token, amount, spokeProvider, raw) {
|
|
10793
11439
|
try {
|
|
10794
11440
|
if (spokeProvider instanceof EvmSpokeProvider || spokeProvider instanceof SonicSpokeProvider) {
|
|
10795
|
-
const result = await Erc20Service.approve(
|
|
11441
|
+
const result = await Erc20Service.approve(
|
|
11442
|
+
token,
|
|
11443
|
+
amount,
|
|
11444
|
+
spokeProvider.chainConfig.addresses.assetManager,
|
|
11445
|
+
spokeProvider,
|
|
11446
|
+
raw
|
|
11447
|
+
);
|
|
10796
11448
|
return {
|
|
10797
11449
|
ok: true,
|
|
10798
11450
|
value: result
|
|
@@ -10812,11 +11464,11 @@ var SolverService = class {
|
|
|
10812
11464
|
/**
|
|
10813
11465
|
* Creates an intent by handling token approval and intent creation
|
|
10814
11466
|
* NOTE: This method does not submit the intent to the Solver API
|
|
10815
|
-
* @param {CreateIntentParams} params - The intent to create
|
|
11467
|
+
* @param {Omit<CreateIntentParams, 'srcAddress'>} params - The intent to create
|
|
10816
11468
|
* @param {SpokeProvider} spokeProvider - The spoke provider
|
|
10817
11469
|
* @param {boolean} raw - Whether to return the raw transaction
|
|
10818
11470
|
* @param {PartnerFee} fee - The fee to apply to the intent
|
|
10819
|
-
* @returns {Promise<Result<[TxReturnType<S, R>, Intent & FeeAmount],
|
|
11471
|
+
* @returns {Promise<Result<[TxReturnType<S, R>, Intent & FeeAmount], IntentError<'CREATION_FAILED'>>>} The encoded contract call
|
|
10820
11472
|
*
|
|
10821
11473
|
* @example
|
|
10822
11474
|
* const payload = {
|
|
@@ -10828,8 +11480,8 @@ var SolverService = class {
|
|
|
10828
11480
|
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
10829
11481
|
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
10830
11482
|
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
10831
|
-
* "srcAddress": "0x..", // Source address
|
|
10832
|
-
* "dstAddress": "0x...", // Destination address
|
|
11483
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
11484
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
10833
11485
|
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
10834
11486
|
* "data": "0x..", // Additional arbitrary data
|
|
10835
11487
|
* } satisfies CreateIntentParams;
|
|
@@ -10853,7 +11505,12 @@ var SolverService = class {
|
|
|
10853
11505
|
invariant2__default.default(isValidSpokeChainId(params.srcChain), `Invalid spoke chain (params.srcChain): ${params.srcChain}`);
|
|
10854
11506
|
invariant2__default.default(isValidSpokeChainId(params.dstChain), `Invalid spoke chain (params.dstChain): ${params.dstChain}`);
|
|
10855
11507
|
try {
|
|
10856
|
-
const
|
|
11508
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
11509
|
+
invariant2__default.default(
|
|
11510
|
+
params.srcAddress.toLowerCase() === walletAddress.toLowerCase(),
|
|
11511
|
+
"srcAddress must be the same as wallet address"
|
|
11512
|
+
);
|
|
11513
|
+
const walletAddressBytes = encodeAddress(params.srcChain, walletAddress);
|
|
10857
11514
|
const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
|
|
10858
11515
|
params.srcChain,
|
|
10859
11516
|
walletAddressBytes,
|
|
@@ -10861,12 +11518,14 @@ var SolverService = class {
|
|
|
10861
11518
|
spokeProvider
|
|
10862
11519
|
);
|
|
10863
11520
|
const [data, intent, feeAmount] = EvmSolverService.constructCreateIntentData(
|
|
10864
|
-
|
|
11521
|
+
{
|
|
11522
|
+
...params,
|
|
11523
|
+
srcAddress: walletAddress
|
|
11524
|
+
},
|
|
10865
11525
|
creatorHubWalletAddress,
|
|
10866
11526
|
this.config,
|
|
10867
11527
|
fee
|
|
10868
11528
|
);
|
|
10869
|
-
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10870
11529
|
const txResult = await SpokeService.deposit(
|
|
10871
11530
|
{
|
|
10872
11531
|
from: walletAddress,
|
|
@@ -10881,7 +11540,7 @@ var SolverService = class {
|
|
|
10881
11540
|
);
|
|
10882
11541
|
return {
|
|
10883
11542
|
ok: true,
|
|
10884
|
-
value: [txResult, { ...intent, feeAmount }]
|
|
11543
|
+
value: [txResult, { ...intent, feeAmount }, data]
|
|
10885
11544
|
};
|
|
10886
11545
|
} catch (error) {
|
|
10887
11546
|
return {
|
|
@@ -10904,20 +11563,37 @@ var SolverService = class {
|
|
|
10904
11563
|
* @returns {Promise<TxReturnType<T, R>>} The encoded contract call
|
|
10905
11564
|
*/
|
|
10906
11565
|
async cancelIntent(intent, spokeProvider, raw) {
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
spokeProvider.chainConfig.chain.id
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
11566
|
+
try {
|
|
11567
|
+
invariant2__default.default(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
|
|
11568
|
+
invariant2__default.default(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
|
|
11569
|
+
const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
|
|
11570
|
+
const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
|
|
11571
|
+
spokeProvider.chainConfig.chain.id,
|
|
11572
|
+
walletAddressBytes,
|
|
11573
|
+
this.hubProvider,
|
|
11574
|
+
spokeProvider
|
|
11575
|
+
);
|
|
11576
|
+
const calls = [];
|
|
11577
|
+
const intentsContract = this.config.intentsContract;
|
|
11578
|
+
calls.push(EvmSolverService.encodeCancelIntent(intent, intentsContract));
|
|
11579
|
+
const data = encodeContractCalls(calls);
|
|
11580
|
+
const txResult = await SpokeService.callWallet(
|
|
11581
|
+
creatorHubWalletAddress,
|
|
11582
|
+
data,
|
|
11583
|
+
spokeProvider,
|
|
11584
|
+
this.hubProvider,
|
|
11585
|
+
raw
|
|
11586
|
+
);
|
|
11587
|
+
return {
|
|
11588
|
+
ok: true,
|
|
11589
|
+
value: txResult
|
|
11590
|
+
};
|
|
11591
|
+
} catch (error) {
|
|
11592
|
+
return {
|
|
11593
|
+
ok: false,
|
|
11594
|
+
error
|
|
11595
|
+
};
|
|
11596
|
+
}
|
|
10921
11597
|
}
|
|
10922
11598
|
/**
|
|
10923
11599
|
* Gets an intent from a transaction hash (on Hub chain)
|
|
@@ -10937,6 +11613,939 @@ var SolverService = class {
|
|
|
10937
11613
|
}
|
|
10938
11614
|
};
|
|
10939
11615
|
|
|
11616
|
+
// src/abis/icxSwap.abi.ts
|
|
11617
|
+
var icxSwapAbi = [
|
|
11618
|
+
{
|
|
11619
|
+
type: "constructor",
|
|
11620
|
+
inputs: [],
|
|
11621
|
+
stateMutability: "nonpayable"
|
|
11622
|
+
},
|
|
11623
|
+
{
|
|
11624
|
+
type: "function",
|
|
11625
|
+
name: "ICX",
|
|
11626
|
+
inputs: [],
|
|
11627
|
+
outputs: [
|
|
11628
|
+
{
|
|
11629
|
+
name: "",
|
|
11630
|
+
type: "address",
|
|
11631
|
+
internalType: "contract IERC20"
|
|
11632
|
+
}
|
|
11633
|
+
],
|
|
11634
|
+
stateMutability: "view"
|
|
11635
|
+
},
|
|
11636
|
+
{
|
|
11637
|
+
type: "function",
|
|
11638
|
+
name: "UPGRADE_INTERFACE_VERSION",
|
|
11639
|
+
inputs: [],
|
|
11640
|
+
outputs: [
|
|
11641
|
+
{
|
|
11642
|
+
name: "",
|
|
11643
|
+
type: "string",
|
|
11644
|
+
internalType: "string"
|
|
11645
|
+
}
|
|
11646
|
+
],
|
|
11647
|
+
stateMutability: "view"
|
|
11648
|
+
},
|
|
11649
|
+
{
|
|
11650
|
+
type: "function",
|
|
11651
|
+
name: "getImplementation",
|
|
11652
|
+
inputs: [],
|
|
11653
|
+
outputs: [
|
|
11654
|
+
{
|
|
11655
|
+
name: "",
|
|
11656
|
+
type: "address",
|
|
11657
|
+
internalType: "address"
|
|
11658
|
+
}
|
|
11659
|
+
],
|
|
11660
|
+
stateMutability: "view"
|
|
11661
|
+
},
|
|
11662
|
+
{
|
|
11663
|
+
type: "function",
|
|
11664
|
+
name: "initialize",
|
|
11665
|
+
inputs: [],
|
|
11666
|
+
outputs: [],
|
|
11667
|
+
stateMutability: "nonpayable"
|
|
11668
|
+
},
|
|
11669
|
+
{
|
|
11670
|
+
type: "function",
|
|
11671
|
+
name: "owner",
|
|
11672
|
+
inputs: [],
|
|
11673
|
+
outputs: [
|
|
11674
|
+
{
|
|
11675
|
+
name: "",
|
|
11676
|
+
type: "address",
|
|
11677
|
+
internalType: "address"
|
|
11678
|
+
}
|
|
11679
|
+
],
|
|
11680
|
+
stateMutability: "view"
|
|
11681
|
+
},
|
|
11682
|
+
{
|
|
11683
|
+
type: "function",
|
|
11684
|
+
name: "pendingMigrations",
|
|
11685
|
+
inputs: [
|
|
11686
|
+
{
|
|
11687
|
+
name: "",
|
|
11688
|
+
type: "uint256",
|
|
11689
|
+
internalType: "uint256"
|
|
11690
|
+
}
|
|
11691
|
+
],
|
|
11692
|
+
outputs: [
|
|
11693
|
+
{
|
|
11694
|
+
name: "user",
|
|
11695
|
+
type: "address",
|
|
11696
|
+
internalType: "address"
|
|
11697
|
+
},
|
|
11698
|
+
{
|
|
11699
|
+
name: "to",
|
|
11700
|
+
type: "address",
|
|
11701
|
+
internalType: "address"
|
|
11702
|
+
},
|
|
11703
|
+
{
|
|
11704
|
+
name: "amount",
|
|
11705
|
+
type: "uint256",
|
|
11706
|
+
internalType: "uint256"
|
|
11707
|
+
},
|
|
11708
|
+
{
|
|
11709
|
+
name: "timestamp",
|
|
11710
|
+
type: "uint256",
|
|
11711
|
+
internalType: "uint256"
|
|
11712
|
+
}
|
|
11713
|
+
],
|
|
11714
|
+
stateMutability: "view"
|
|
11715
|
+
},
|
|
11716
|
+
{
|
|
11717
|
+
type: "function",
|
|
11718
|
+
name: "reverseSwap",
|
|
11719
|
+
inputs: [
|
|
11720
|
+
{
|
|
11721
|
+
name: "amount",
|
|
11722
|
+
type: "uint256",
|
|
11723
|
+
internalType: "uint256"
|
|
11724
|
+
},
|
|
11725
|
+
{
|
|
11726
|
+
name: "to",
|
|
11727
|
+
type: "address",
|
|
11728
|
+
internalType: "address"
|
|
11729
|
+
}
|
|
11730
|
+
],
|
|
11731
|
+
outputs: [],
|
|
11732
|
+
stateMutability: "nonpayable"
|
|
11733
|
+
},
|
|
11734
|
+
{
|
|
11735
|
+
type: "function",
|
|
11736
|
+
name: "reverseSwapEnabled",
|
|
11737
|
+
inputs: [],
|
|
11738
|
+
outputs: [
|
|
11739
|
+
{
|
|
11740
|
+
name: "",
|
|
11741
|
+
type: "bool",
|
|
11742
|
+
internalType: "bool"
|
|
11743
|
+
}
|
|
11744
|
+
],
|
|
11745
|
+
stateMutability: "view"
|
|
11746
|
+
},
|
|
11747
|
+
{
|
|
11748
|
+
type: "function",
|
|
11749
|
+
name: "sodax",
|
|
11750
|
+
inputs: [],
|
|
11751
|
+
outputs: [
|
|
11752
|
+
{
|
|
11753
|
+
name: "",
|
|
11754
|
+
type: "address",
|
|
11755
|
+
internalType: "contract IERC20"
|
|
11756
|
+
}
|
|
11757
|
+
],
|
|
11758
|
+
stateMutability: "view"
|
|
11759
|
+
},
|
|
11760
|
+
{
|
|
11761
|
+
type: "function",
|
|
11762
|
+
name: "swap",
|
|
11763
|
+
inputs: [
|
|
11764
|
+
{
|
|
11765
|
+
name: "amount",
|
|
11766
|
+
type: "uint256",
|
|
11767
|
+
internalType: "uint256"
|
|
11768
|
+
},
|
|
11769
|
+
{
|
|
11770
|
+
name: "to",
|
|
11771
|
+
type: "address",
|
|
11772
|
+
internalType: "address"
|
|
11773
|
+
}
|
|
11774
|
+
],
|
|
11775
|
+
outputs: [],
|
|
11776
|
+
stateMutability: "nonpayable"
|
|
11777
|
+
},
|
|
11778
|
+
{
|
|
11779
|
+
type: "event",
|
|
11780
|
+
name: "Initialized",
|
|
11781
|
+
inputs: [
|
|
11782
|
+
{
|
|
11783
|
+
name: "version",
|
|
11784
|
+
type: "uint64",
|
|
11785
|
+
indexed: false,
|
|
11786
|
+
internalType: "uint64"
|
|
11787
|
+
}
|
|
11788
|
+
],
|
|
11789
|
+
anonymous: false
|
|
11790
|
+
},
|
|
11791
|
+
{
|
|
11792
|
+
type: "event",
|
|
11793
|
+
name: "OwnershipTransferStarted",
|
|
11794
|
+
inputs: [
|
|
11795
|
+
{
|
|
11796
|
+
name: "previousOwner",
|
|
11797
|
+
type: "address",
|
|
11798
|
+
indexed: true,
|
|
11799
|
+
internalType: "address"
|
|
11800
|
+
},
|
|
11801
|
+
{
|
|
11802
|
+
name: "newOwner",
|
|
11803
|
+
type: "address",
|
|
11804
|
+
indexed: true,
|
|
11805
|
+
internalType: "address"
|
|
11806
|
+
}
|
|
11807
|
+
],
|
|
11808
|
+
anonymous: false
|
|
11809
|
+
},
|
|
11810
|
+
{
|
|
11811
|
+
type: "event",
|
|
11812
|
+
name: "OwnershipTransferred",
|
|
11813
|
+
inputs: [
|
|
11814
|
+
{
|
|
11815
|
+
name: "previousOwner",
|
|
11816
|
+
type: "address",
|
|
11817
|
+
indexed: true,
|
|
11818
|
+
internalType: "address"
|
|
11819
|
+
},
|
|
11820
|
+
{
|
|
11821
|
+
name: "newOwner",
|
|
11822
|
+
type: "address",
|
|
11823
|
+
indexed: true,
|
|
11824
|
+
internalType: "address"
|
|
11825
|
+
}
|
|
11826
|
+
],
|
|
11827
|
+
anonymous: false
|
|
11828
|
+
},
|
|
11829
|
+
{
|
|
11830
|
+
type: "event",
|
|
11831
|
+
name: "PendingMigrationApproved",
|
|
11832
|
+
inputs: [
|
|
11833
|
+
{
|
|
11834
|
+
name: "index",
|
|
11835
|
+
type: "uint256",
|
|
11836
|
+
indexed: false,
|
|
11837
|
+
internalType: "uint256"
|
|
11838
|
+
},
|
|
11839
|
+
{
|
|
11840
|
+
name: "user",
|
|
11841
|
+
type: "address",
|
|
11842
|
+
indexed: true,
|
|
11843
|
+
internalType: "address"
|
|
11844
|
+
},
|
|
11845
|
+
{
|
|
11846
|
+
name: "amount",
|
|
11847
|
+
type: "uint256",
|
|
11848
|
+
indexed: false,
|
|
11849
|
+
internalType: "uint256"
|
|
11850
|
+
}
|
|
11851
|
+
],
|
|
11852
|
+
anonymous: false
|
|
11853
|
+
},
|
|
11854
|
+
{
|
|
11855
|
+
type: "event",
|
|
11856
|
+
name: "PendingMigrationCreated",
|
|
11857
|
+
inputs: [
|
|
11858
|
+
{
|
|
11859
|
+
name: "user",
|
|
11860
|
+
type: "address",
|
|
11861
|
+
indexed: true,
|
|
11862
|
+
internalType: "address"
|
|
11863
|
+
},
|
|
11864
|
+
{
|
|
11865
|
+
name: "amount",
|
|
11866
|
+
type: "uint256",
|
|
11867
|
+
indexed: false,
|
|
11868
|
+
internalType: "uint256"
|
|
11869
|
+
},
|
|
11870
|
+
{
|
|
11871
|
+
name: "index",
|
|
11872
|
+
type: "uint256",
|
|
11873
|
+
indexed: false,
|
|
11874
|
+
internalType: "uint256"
|
|
11875
|
+
}
|
|
11876
|
+
],
|
|
11877
|
+
anonymous: false
|
|
11878
|
+
},
|
|
11879
|
+
{
|
|
11880
|
+
type: "event",
|
|
11881
|
+
name: "ReverseSwap",
|
|
11882
|
+
inputs: [
|
|
11883
|
+
{
|
|
11884
|
+
name: "user",
|
|
11885
|
+
type: "address",
|
|
11886
|
+
indexed: true,
|
|
11887
|
+
internalType: "address"
|
|
11888
|
+
},
|
|
11889
|
+
{
|
|
11890
|
+
name: "sodaxAmount",
|
|
11891
|
+
type: "uint256",
|
|
11892
|
+
indexed: false,
|
|
11893
|
+
internalType: "uint256"
|
|
11894
|
+
},
|
|
11895
|
+
{
|
|
11896
|
+
name: "ICXAmount",
|
|
11897
|
+
type: "uint256",
|
|
11898
|
+
indexed: false,
|
|
11899
|
+
internalType: "uint256"
|
|
11900
|
+
}
|
|
11901
|
+
],
|
|
11902
|
+
anonymous: false
|
|
11903
|
+
},
|
|
11904
|
+
{
|
|
11905
|
+
type: "event",
|
|
11906
|
+
name: "ReverseSwapToggled",
|
|
11907
|
+
inputs: [
|
|
11908
|
+
{
|
|
11909
|
+
name: "enabled",
|
|
11910
|
+
type: "bool",
|
|
11911
|
+
indexed: false,
|
|
11912
|
+
internalType: "bool"
|
|
11913
|
+
}
|
|
11914
|
+
],
|
|
11915
|
+
anonymous: false
|
|
11916
|
+
},
|
|
11917
|
+
{
|
|
11918
|
+
type: "event",
|
|
11919
|
+
name: "Swap",
|
|
11920
|
+
inputs: [
|
|
11921
|
+
{
|
|
11922
|
+
name: "user",
|
|
11923
|
+
type: "address",
|
|
11924
|
+
indexed: true,
|
|
11925
|
+
internalType: "address"
|
|
11926
|
+
},
|
|
11927
|
+
{
|
|
11928
|
+
name: "ICXAmount",
|
|
11929
|
+
type: "uint256",
|
|
11930
|
+
indexed: false,
|
|
11931
|
+
internalType: "uint256"
|
|
11932
|
+
},
|
|
11933
|
+
{
|
|
11934
|
+
name: "sodaxAmount",
|
|
11935
|
+
type: "uint256",
|
|
11936
|
+
indexed: false,
|
|
11937
|
+
internalType: "uint256"
|
|
11938
|
+
}
|
|
11939
|
+
],
|
|
11940
|
+
anonymous: false
|
|
11941
|
+
},
|
|
11942
|
+
{
|
|
11943
|
+
type: "event",
|
|
11944
|
+
name: "Upgraded",
|
|
11945
|
+
inputs: [
|
|
11946
|
+
{
|
|
11947
|
+
name: "implementation",
|
|
11948
|
+
type: "address",
|
|
11949
|
+
indexed: true,
|
|
11950
|
+
internalType: "address"
|
|
11951
|
+
}
|
|
11952
|
+
],
|
|
11953
|
+
anonymous: false
|
|
11954
|
+
},
|
|
11955
|
+
{
|
|
11956
|
+
type: "error",
|
|
11957
|
+
name: "AddressEmptyCode",
|
|
11958
|
+
inputs: [
|
|
11959
|
+
{
|
|
11960
|
+
name: "target",
|
|
11961
|
+
type: "address",
|
|
11962
|
+
internalType: "address"
|
|
11963
|
+
}
|
|
11964
|
+
]
|
|
11965
|
+
},
|
|
11966
|
+
{
|
|
11967
|
+
type: "error",
|
|
11968
|
+
name: "ERC1967InvalidImplementation",
|
|
11969
|
+
inputs: [
|
|
11970
|
+
{
|
|
11971
|
+
name: "implementation",
|
|
11972
|
+
type: "address",
|
|
11973
|
+
internalType: "address"
|
|
11974
|
+
}
|
|
11975
|
+
]
|
|
11976
|
+
},
|
|
11977
|
+
{
|
|
11978
|
+
type: "error",
|
|
11979
|
+
name: "ERC1967NonPayable",
|
|
11980
|
+
inputs: []
|
|
11981
|
+
},
|
|
11982
|
+
{
|
|
11983
|
+
type: "error",
|
|
11984
|
+
name: "FailedCall",
|
|
11985
|
+
inputs: []
|
|
11986
|
+
},
|
|
11987
|
+
{
|
|
11988
|
+
type: "error",
|
|
11989
|
+
name: "InvalidInitialization",
|
|
11990
|
+
inputs: []
|
|
11991
|
+
},
|
|
11992
|
+
{
|
|
11993
|
+
type: "error",
|
|
11994
|
+
name: "NotInitializing",
|
|
11995
|
+
inputs: []
|
|
11996
|
+
},
|
|
11997
|
+
{
|
|
11998
|
+
type: "error",
|
|
11999
|
+
name: "OwnableInvalidOwner",
|
|
12000
|
+
inputs: [
|
|
12001
|
+
{
|
|
12002
|
+
name: "owner",
|
|
12003
|
+
type: "address",
|
|
12004
|
+
internalType: "address"
|
|
12005
|
+
}
|
|
12006
|
+
]
|
|
12007
|
+
},
|
|
12008
|
+
{
|
|
12009
|
+
type: "error",
|
|
12010
|
+
name: "OwnableUnauthorizedAccount",
|
|
12011
|
+
inputs: [
|
|
12012
|
+
{
|
|
12013
|
+
name: "account",
|
|
12014
|
+
type: "address",
|
|
12015
|
+
internalType: "address"
|
|
12016
|
+
}
|
|
12017
|
+
]
|
|
12018
|
+
},
|
|
12019
|
+
{
|
|
12020
|
+
type: "error",
|
|
12021
|
+
name: "ReentrancyGuardReentrantCall",
|
|
12022
|
+
inputs: []
|
|
12023
|
+
},
|
|
12024
|
+
{
|
|
12025
|
+
type: "error",
|
|
12026
|
+
name: "SafeERC20FailedOperation",
|
|
12027
|
+
inputs: [
|
|
12028
|
+
{
|
|
12029
|
+
name: "token",
|
|
12030
|
+
type: "address",
|
|
12031
|
+
internalType: "address"
|
|
12032
|
+
}
|
|
12033
|
+
]
|
|
12034
|
+
},
|
|
12035
|
+
{
|
|
12036
|
+
type: "error",
|
|
12037
|
+
name: "UUPSUnauthorizedCallContext",
|
|
12038
|
+
inputs: []
|
|
12039
|
+
},
|
|
12040
|
+
{
|
|
12041
|
+
type: "error",
|
|
12042
|
+
name: "UUPSUnsupportedProxiableUUID",
|
|
12043
|
+
inputs: [
|
|
12044
|
+
{
|
|
12045
|
+
name: "slot",
|
|
12046
|
+
type: "bytes32",
|
|
12047
|
+
internalType: "bytes32"
|
|
12048
|
+
}
|
|
12049
|
+
]
|
|
12050
|
+
}
|
|
12051
|
+
];
|
|
12052
|
+
var IcxMigrationService = class {
|
|
12053
|
+
hubProvider;
|
|
12054
|
+
constructor(hubProvider) {
|
|
12055
|
+
this.hubProvider = hubProvider;
|
|
12056
|
+
}
|
|
12057
|
+
/**
|
|
12058
|
+
* Retrieves the available amount of SODA tokens in the ICX migration contract.
|
|
12059
|
+
* This represents the amount of tokens available for migration.
|
|
12060
|
+
*
|
|
12061
|
+
* @returns The available balance of SODA tokens in the migration contract
|
|
12062
|
+
*/
|
|
12063
|
+
async getAvailableAmount() {
|
|
12064
|
+
const balance = await this.hubProvider.publicClient.readContract({
|
|
12065
|
+
address: this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12066
|
+
abi: erc20Abi,
|
|
12067
|
+
functionName: "balanceOf",
|
|
12068
|
+
args: [this.hubProvider.chainConfig.addresses.icxMigration]
|
|
12069
|
+
});
|
|
12070
|
+
return balance;
|
|
12071
|
+
}
|
|
12072
|
+
/**
|
|
12073
|
+
* Generates transaction data for migrating wICX tokens from ICON to the hub chain.
|
|
12074
|
+
* This method creates the necessary contract calls to:
|
|
12075
|
+
* 1. Approve the migration contract to spend the wICX tokens
|
|
12076
|
+
* 2. Execute the migration swap
|
|
12077
|
+
*
|
|
12078
|
+
* @param params - The migration parameters including token address, amount, and recipient
|
|
12079
|
+
* @returns Encoded transaction data for the migration operation
|
|
12080
|
+
* @throws Will throw an error if the hub asset configuration is not found
|
|
12081
|
+
*/
|
|
12082
|
+
migrateData(params) {
|
|
12083
|
+
const calls = [];
|
|
12084
|
+
const assetConfig = getHubAssetInfo(types.ICON_MAINNET_CHAIN_ID, params.icx);
|
|
12085
|
+
invariant2__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.icx}`);
|
|
12086
|
+
calls.push(
|
|
12087
|
+
Erc20Service.encodeApprove(assetConfig.asset, this.hubProvider.chainConfig.addresses.icxMigration, params.amount)
|
|
12088
|
+
);
|
|
12089
|
+
calls.push(this.encodeMigrate(params.amount, params.to));
|
|
12090
|
+
return encodeContractCalls(calls);
|
|
12091
|
+
}
|
|
12092
|
+
/**
|
|
12093
|
+
* Generates transaction data for migrating back tokens to the ICON chain.
|
|
12094
|
+
* @param params - The migration parameters including token address, amount, and recipient
|
|
12095
|
+
* @returns Encoded transaction data for the migration operation
|
|
12096
|
+
* @throws Will throw an error if the hub asset configuration is not found
|
|
12097
|
+
*/
|
|
12098
|
+
revertMigration(params) {
|
|
12099
|
+
const calls = [];
|
|
12100
|
+
const assetConfig = getHubAssetInfo(types.ICON_MAINNET_CHAIN_ID, params.wICX);
|
|
12101
|
+
invariant2__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${params.wICX}`);
|
|
12102
|
+
calls.push(
|
|
12103
|
+
Erc20Service.encodeApprove(
|
|
12104
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12105
|
+
this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12106
|
+
params.amount
|
|
12107
|
+
)
|
|
12108
|
+
);
|
|
12109
|
+
calls.push(this.encodeRevertMigration(params.amount, params.userWallet));
|
|
12110
|
+
calls.push(
|
|
12111
|
+
EvmAssetManagerService.encodeTransfer(
|
|
12112
|
+
assetConfig.asset,
|
|
12113
|
+
params.to,
|
|
12114
|
+
params.amount,
|
|
12115
|
+
this.hubProvider.chainConfig.addresses.assetManager
|
|
12116
|
+
)
|
|
12117
|
+
);
|
|
12118
|
+
return encodeContractCalls(calls);
|
|
12119
|
+
}
|
|
12120
|
+
/**
|
|
12121
|
+
* Encodes a migration transaction for the ICX swap contract.
|
|
12122
|
+
* This creates the contract call data for swapping wICX tokens to SODA tokens.
|
|
12123
|
+
*
|
|
12124
|
+
* @param amount - The amount of wICX tokens to migrate
|
|
12125
|
+
* @param to - The address that will receive the migrated SODA tokens
|
|
12126
|
+
* @returns The encoded contract call for the migration operation
|
|
12127
|
+
*/
|
|
12128
|
+
encodeMigrate(amount, to) {
|
|
12129
|
+
return {
|
|
12130
|
+
address: this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12131
|
+
value: 0n,
|
|
12132
|
+
data: viem.encodeFunctionData({
|
|
12133
|
+
abi: icxSwapAbi,
|
|
12134
|
+
functionName: "swap",
|
|
12135
|
+
args: [amount, to]
|
|
12136
|
+
})
|
|
12137
|
+
};
|
|
12138
|
+
}
|
|
12139
|
+
/**
|
|
12140
|
+
* Encodes a revert migration transaction for the ICX swap contract.
|
|
12141
|
+
* This creates the contract call data for swapping SODA tokens to wICX tokens.
|
|
12142
|
+
*
|
|
12143
|
+
* @param amount - The amount of wICX tokens to migrate
|
|
12144
|
+
* @param to - The address that will receive the migrated SODA tokens
|
|
12145
|
+
* @returns The encoded contract call for the migration operation
|
|
12146
|
+
*/
|
|
12147
|
+
encodeRevertMigration(amount, to) {
|
|
12148
|
+
return {
|
|
12149
|
+
address: this.hubProvider.chainConfig.addresses.icxMigration,
|
|
12150
|
+
value: 0n,
|
|
12151
|
+
data: viem.encodeFunctionData({
|
|
12152
|
+
abi: icxSwapAbi,
|
|
12153
|
+
functionName: "reverseSwap",
|
|
12154
|
+
args: [amount, to]
|
|
12155
|
+
})
|
|
12156
|
+
};
|
|
12157
|
+
}
|
|
12158
|
+
};
|
|
12159
|
+
var MigrationService = class {
|
|
12160
|
+
icxMigration;
|
|
12161
|
+
hubProvider;
|
|
12162
|
+
config;
|
|
12163
|
+
constructor(hubProvider, config) {
|
|
12164
|
+
this.hubProvider = hubProvider;
|
|
12165
|
+
this.icxMigration = new IcxMigrationService(hubProvider);
|
|
12166
|
+
this.config = config ?? {
|
|
12167
|
+
relayerApiEndpoint: DEFAULT_RELAYER_API_ENDPOINT
|
|
12168
|
+
};
|
|
12169
|
+
}
|
|
12170
|
+
async migrateData(params) {
|
|
12171
|
+
return this.icxMigration.migrateData(params);
|
|
12172
|
+
}
|
|
12173
|
+
/**
|
|
12174
|
+
* Checks if the allowance is valid for the migration transaction.
|
|
12175
|
+
* @param params - The parameters for the migration transaction.
|
|
12176
|
+
* @param spokeProvider - The spoke provider.
|
|
12177
|
+
* @returns {Promise<Result<boolean>>} - Returns the result of the allowance check or error
|
|
12178
|
+
*
|
|
12179
|
+
* @example
|
|
12180
|
+
* const result = await migrationService.isAllowanceValid(
|
|
12181
|
+
* {
|
|
12182
|
+
* token: 'ICX', // Token to migrate
|
|
12183
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12184
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12185
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12186
|
+
* action: 'migrate', // Action to perform (migrate or revert)
|
|
12187
|
+
* },
|
|
12188
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12189
|
+
* );
|
|
12190
|
+
*
|
|
12191
|
+
*/
|
|
12192
|
+
async isAllowanceValid(params, spokeProvider) {
|
|
12193
|
+
try {
|
|
12194
|
+
if (params.action === "migrate") {
|
|
12195
|
+
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
12196
|
+
invariant2__default.default(viem.isAddress(params.to) || isIconAddress(params.to), "To address is required");
|
|
12197
|
+
invariant2__default.default(
|
|
12198
|
+
spokeProvider instanceof IconSpokeProvider,
|
|
12199
|
+
"Spoke provider must be an instance of IconSpokeProvider"
|
|
12200
|
+
);
|
|
12201
|
+
invariant2__default.default(
|
|
12202
|
+
params.icx.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.icx.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
12203
|
+
"Token must be wICX or native ICX token"
|
|
12204
|
+
);
|
|
12205
|
+
invariant2__default.default(params.token === "ICX", "Token must be ICX");
|
|
12206
|
+
return {
|
|
12207
|
+
ok: true,
|
|
12208
|
+
value: true
|
|
12209
|
+
};
|
|
12210
|
+
}
|
|
12211
|
+
if (params.action === "revert") {
|
|
12212
|
+
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
12213
|
+
invariant2__default.default(viem.isAddress(params.to) || isIconAddress(params.to), "To address is required");
|
|
12214
|
+
invariant2__default.default(
|
|
12215
|
+
spokeProvider instanceof SonicSpokeProvider,
|
|
12216
|
+
"Spoke provider must be an instance of SonicSpokeProvider"
|
|
12217
|
+
);
|
|
12218
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12219
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12220
|
+
return await Erc20Service.isAllowanceValid(
|
|
12221
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12222
|
+
params.amount,
|
|
12223
|
+
wallet,
|
|
12224
|
+
userRouter,
|
|
12225
|
+
spokeProvider
|
|
12226
|
+
);
|
|
12227
|
+
}
|
|
12228
|
+
return {
|
|
12229
|
+
ok: false,
|
|
12230
|
+
error: new Error("Invalid action")
|
|
12231
|
+
};
|
|
12232
|
+
} catch (error) {
|
|
12233
|
+
return {
|
|
12234
|
+
ok: false,
|
|
12235
|
+
error
|
|
12236
|
+
};
|
|
12237
|
+
}
|
|
12238
|
+
}
|
|
12239
|
+
/**
|
|
12240
|
+
* Approves the amount spending for the revert migration transaction.
|
|
12241
|
+
* @param params - The parameters for the revert migration transaction.
|
|
12242
|
+
* @param spokeProvider - The spoke provider.
|
|
12243
|
+
* @param raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12244
|
+
* @returns {Promise<Result<TxReturnType<S, R>>>} - Returns the raw transaction payload or transaction hash
|
|
12245
|
+
*
|
|
12246
|
+
* @example
|
|
12247
|
+
* const result = await migrationService.approve(
|
|
12248
|
+
* {
|
|
12249
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12250
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12251
|
+
* action: 'revert',
|
|
12252
|
+
* },
|
|
12253
|
+
* spokeProvider, // SonicSpokeProvider instance
|
|
12254
|
+
* true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
|
|
12255
|
+
* );
|
|
12256
|
+
*
|
|
12257
|
+
*/
|
|
12258
|
+
async approve(params, spokeProvider, raw) {
|
|
12259
|
+
try {
|
|
12260
|
+
if (params.action === "revert") {
|
|
12261
|
+
invariant2__default.default(params.amount > 0n, "Amount must be greater than 0");
|
|
12262
|
+
invariant2__default.default(params.to.length > 0, "To address is required");
|
|
12263
|
+
invariant2__default.default(
|
|
12264
|
+
spokeProvider instanceof SonicSpokeProvider,
|
|
12265
|
+
"Spoke provider must be an instance of SonicSpokeProvider"
|
|
12266
|
+
);
|
|
12267
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12268
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12269
|
+
const result = await Erc20Service.approve(
|
|
12270
|
+
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12271
|
+
params.amount,
|
|
12272
|
+
userRouter,
|
|
12273
|
+
spokeProvider,
|
|
12274
|
+
raw
|
|
12275
|
+
);
|
|
12276
|
+
return {
|
|
12277
|
+
ok: true,
|
|
12278
|
+
value: result
|
|
12279
|
+
};
|
|
12280
|
+
}
|
|
12281
|
+
return {
|
|
12282
|
+
ok: false,
|
|
12283
|
+
error: new Error("Invalid action")
|
|
12284
|
+
};
|
|
12285
|
+
} catch (error) {
|
|
12286
|
+
return {
|
|
12287
|
+
ok: false,
|
|
12288
|
+
error
|
|
12289
|
+
};
|
|
12290
|
+
}
|
|
12291
|
+
}
|
|
12292
|
+
/**
|
|
12293
|
+
* Creates a migration intent and submits (relays) it to the hub chain.
|
|
12294
|
+
* @param params - The parameters for the migration transaction.
|
|
12295
|
+
* @param spokeProvider - The spoke provider.
|
|
12296
|
+
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
12297
|
+
* @returns {Promise<Result<[Hex, Hex], MigrationError<'MIGRATION_FAILED'> | MigrationError<'CREATE_MIGRATION_INTENT_FAILED'> | RelayError>>}
|
|
12298
|
+
* Returns a Result containing a tuple of [spokeTxHash, hubTxHash] if successful,
|
|
12299
|
+
* or an error describing why the migration or relay failed.
|
|
12300
|
+
*
|
|
12301
|
+
* @example
|
|
12302
|
+
* const result = await migrationService.createAndSubmitMigrateIntent(
|
|
12303
|
+
* {
|
|
12304
|
+
* token: 'ICX', // Token to migrate
|
|
12305
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12306
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12307
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12308
|
+
* action: 'migrate',
|
|
12309
|
+
* },
|
|
12310
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12311
|
+
* 30000 // Optional timeout in milliseconds (default: 60000, i.e. 60 seconds)
|
|
12312
|
+
* );
|
|
12313
|
+
*
|
|
12314
|
+
* if (!result.ok) {
|
|
12315
|
+
* // Handle error
|
|
12316
|
+
* }
|
|
12317
|
+
*
|
|
12318
|
+
* const [
|
|
12319
|
+
* spokeTxHash, // transaction hash on the spoke chain
|
|
12320
|
+
* hubTxHash, // transaction hash on the hub chain (i.e. the transaction that was relayed to the hub)
|
|
12321
|
+
* ] = result.value;
|
|
12322
|
+
* console.log('Migration transaction hashes:', { spokeTxHash, hubTxHash });
|
|
12323
|
+
*/
|
|
12324
|
+
async createAndSubmitMigrateIntent(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
12325
|
+
try {
|
|
12326
|
+
const txResult = await this.createMigrateIntent(params, spokeProvider);
|
|
12327
|
+
if (!txResult.ok) {
|
|
12328
|
+
return {
|
|
12329
|
+
ok: false,
|
|
12330
|
+
error: txResult.error
|
|
12331
|
+
};
|
|
12332
|
+
}
|
|
12333
|
+
const packetResult = await relayTxAndWaitPacket(
|
|
12334
|
+
txResult.value,
|
|
12335
|
+
void 0,
|
|
12336
|
+
spokeProvider,
|
|
12337
|
+
this.config.relayerApiEndpoint,
|
|
12338
|
+
timeout
|
|
12339
|
+
);
|
|
12340
|
+
if (!packetResult.ok) {
|
|
12341
|
+
return packetResult;
|
|
12342
|
+
}
|
|
12343
|
+
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
12344
|
+
} catch (error) {
|
|
12345
|
+
return {
|
|
12346
|
+
ok: false,
|
|
12347
|
+
error: {
|
|
12348
|
+
code: "MIGRATION_FAILED",
|
|
12349
|
+
data: {
|
|
12350
|
+
payload: params,
|
|
12351
|
+
error
|
|
12352
|
+
}
|
|
12353
|
+
}
|
|
12354
|
+
};
|
|
12355
|
+
}
|
|
12356
|
+
}
|
|
12357
|
+
/**
|
|
12358
|
+
* Creates a revert migration (SODA to ICX) intent and submits (relays) it to the spoke chain.
|
|
12359
|
+
* @param params - The parameters for the revert migration transaction.
|
|
12360
|
+
* @param spokeProvider - The SonicSpokeProvider instance.
|
|
12361
|
+
* @param timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
|
|
12362
|
+
*
|
|
12363
|
+
* @returns {Promise<Result<[Hex, Hex], MigrationError<'REVERT_MIGRATION_FAILED'> | MigrationError<'CREATE_REVERT_MIGRATION_INTENT_FAILED'> | RelayError>>}
|
|
12364
|
+
* Returns a Result containing a tuple of [hubTxHash, spokeTxHash] if successful,
|
|
12365
|
+
* or an error describing why the revert migration or relay failed.
|
|
12366
|
+
*
|
|
12367
|
+
*
|
|
12368
|
+
* @example
|
|
12369
|
+
* const result = await migrationService.createAndSubmitRevertMigrationIntent(
|
|
12370
|
+
* {
|
|
12371
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12372
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12373
|
+
* action: 'revert',
|
|
12374
|
+
* },
|
|
12375
|
+
* spokeProvider, // SonicSpokeProvider instance
|
|
12376
|
+
* 30000 // Optional timeout in milliseconds (default: 60000, i.e. 60 seconds)
|
|
12377
|
+
* );
|
|
12378
|
+
*
|
|
12379
|
+
* if (!result.ok) {
|
|
12380
|
+
* // Handle error
|
|
12381
|
+
* }
|
|
12382
|
+
*
|
|
12383
|
+
* const [
|
|
12384
|
+
* hubTxHash, // transaction hash on the hub chain
|
|
12385
|
+
* spokeTxHash, // transaction hash on the spoke chain (i.e. the transaction that was relayed to the spoke)
|
|
12386
|
+
* ] = result.value;
|
|
12387
|
+
* console.log('Revert migration transaction hashes:', { hubTxHash, spokeTxHash });
|
|
12388
|
+
*/
|
|
12389
|
+
async createAndSubmitRevertMigrationIntent(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
12390
|
+
try {
|
|
12391
|
+
const txResult = await this.createRevertMigrationIntent(params, spokeProvider);
|
|
12392
|
+
if (!txResult.ok) {
|
|
12393
|
+
return txResult;
|
|
12394
|
+
}
|
|
12395
|
+
const packetResult = await relayTxAndWaitPacket(
|
|
12396
|
+
txResult.value,
|
|
12397
|
+
void 0,
|
|
12398
|
+
spokeProvider,
|
|
12399
|
+
this.config.relayerApiEndpoint,
|
|
12400
|
+
timeout
|
|
12401
|
+
);
|
|
12402
|
+
if (!packetResult.ok) {
|
|
12403
|
+
return packetResult;
|
|
12404
|
+
}
|
|
12405
|
+
return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
|
|
12406
|
+
} catch (error) {
|
|
12407
|
+
return {
|
|
12408
|
+
ok: false,
|
|
12409
|
+
error: {
|
|
12410
|
+
code: "REVERT_MIGRATION_FAILED",
|
|
12411
|
+
data: {
|
|
12412
|
+
payload: params,
|
|
12413
|
+
error
|
|
12414
|
+
}
|
|
12415
|
+
}
|
|
12416
|
+
};
|
|
12417
|
+
}
|
|
12418
|
+
}
|
|
12419
|
+
/**
|
|
12420
|
+
* Migrates ICX or wICX tokens from ICON to the hub chain.
|
|
12421
|
+
* This function handles the migration of ICX or wICX tokens to SODA tokens on the hub chain.
|
|
12422
|
+
* Note: This function does not relay the transaction to the spoke chain.
|
|
12423
|
+
* You should call the `isAllowanceValid` function before calling this function to check if the allowance is valid.
|
|
12424
|
+
* You should call the `relayTxAndWaitPacket` function after calling this function to relay the transaction to the spoke chain.
|
|
12425
|
+
*
|
|
12426
|
+
* @param {MigrationParams} params - The parameters for the migration transaction.
|
|
12427
|
+
* @param {IconSpokeProvider} spokeProvider - The spoke provider.
|
|
12428
|
+
* @param {boolean} raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12429
|
+
* @returns {Promise<Result<TxReturnType<IconSpokeProvider, R>, MigrationError<'CREATE_MIGRATION_INTENT_FAILED'>>>} - Returns the raw transaction payload or transaction hash
|
|
12430
|
+
*
|
|
12431
|
+
* @example
|
|
12432
|
+
* const result = await migrationService.createMigrateIntent(
|
|
12433
|
+
* {
|
|
12434
|
+
* icx: 'cx...', // Address of the ICX or wICX token to migrate
|
|
12435
|
+
* amount: 1000n, // Amount to migrate (in ICX decimals, usually 18)
|
|
12436
|
+
* to: '0x...', // Address to receive the migrated SODA tokens
|
|
12437
|
+
* },
|
|
12438
|
+
* spokeProvider, // IconSpokeProvider instance
|
|
12439
|
+
* true // Optional raw flag to return the raw transaction hash instead of the transaction receipt
|
|
12440
|
+
* );
|
|
12441
|
+
*
|
|
12442
|
+
* if (!result.ok) {
|
|
12443
|
+
* // Handle error
|
|
12444
|
+
* }
|
|
12445
|
+
*/
|
|
12446
|
+
async createMigrateIntent(params, spokeProvider, raw) {
|
|
12447
|
+
try {
|
|
12448
|
+
invariant2__default.default(params.amount > 0, "Amount must be greater than 0");
|
|
12449
|
+
invariant2__default.default(viem.isAddress(params.to), "Recipient address is required");
|
|
12450
|
+
invariant2__default.default(
|
|
12451
|
+
params.icx.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.icx.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
12452
|
+
"Token must be wICX or native ICX token"
|
|
12453
|
+
);
|
|
12454
|
+
invariant2__default.default(spokeProvider instanceof IconSpokeProvider, "Spoke provider must be an instance of IconSpokeProvider");
|
|
12455
|
+
invariant2__default.default(params.token === "ICX", "Token must be ICX");
|
|
12456
|
+
const availableAmount = await this.icxMigration.getAvailableAmount();
|
|
12457
|
+
if (availableAmount < params.amount) {
|
|
12458
|
+
throw new Error(
|
|
12459
|
+
`Insufficient liquidity. Available: ${availableAmount.toString()}, Requested: ${params.amount.toString()}`
|
|
12460
|
+
);
|
|
12461
|
+
}
|
|
12462
|
+
const migrationData = this.icxMigration.migrateData(params);
|
|
12463
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
12464
|
+
const txResult = await SpokeService.deposit(
|
|
12465
|
+
{
|
|
12466
|
+
from: walletAddress,
|
|
12467
|
+
token: params.icx,
|
|
12468
|
+
amount: params.amount,
|
|
12469
|
+
data: migrationData
|
|
12470
|
+
},
|
|
12471
|
+
spokeProvider,
|
|
12472
|
+
this.hubProvider,
|
|
12473
|
+
raw
|
|
12474
|
+
);
|
|
12475
|
+
return {
|
|
12476
|
+
ok: true,
|
|
12477
|
+
value: txResult
|
|
12478
|
+
};
|
|
12479
|
+
} catch (error) {
|
|
12480
|
+
return {
|
|
12481
|
+
ok: false,
|
|
12482
|
+
error: {
|
|
12483
|
+
code: "CREATE_MIGRATION_INTENT_FAILED",
|
|
12484
|
+
data: {
|
|
12485
|
+
payload: params,
|
|
12486
|
+
error
|
|
12487
|
+
}
|
|
12488
|
+
}
|
|
12489
|
+
};
|
|
12490
|
+
}
|
|
12491
|
+
}
|
|
12492
|
+
/**
|
|
12493
|
+
* Creates a revert migration intent transaction on the hub chain.
|
|
12494
|
+
* Note: This function does not relay the transaction to the spoke chain.
|
|
12495
|
+
* You should call the `isAllowanceValid` function before calling this function to check if the allowance is valid.
|
|
12496
|
+
* You should call the `relayTxAndWaitPacket` function after calling this function to relay the transaction to the spoke chain.
|
|
12497
|
+
* @param {IcxCreateRevertMigrationParams} - The parameters for the revert migration transaction.
|
|
12498
|
+
* @param {SonicSpokeProvider} spokeProvider - The spoke provider.
|
|
12499
|
+
* @param {boolean} raw - Whether to return the raw transaction hash instead of the transaction receipt
|
|
12500
|
+
* @returns {Promise<Result<TxReturnType<SonicSpokeProvider, R>, MigrationError<'CREATE_REVERT_MIGRATION_INTENT_FAILED'>>>} - Returns the transaction hash or error
|
|
12501
|
+
*
|
|
12502
|
+
* @example
|
|
12503
|
+
* const result = await migrationService.createRevertMigrationIntent(
|
|
12504
|
+
* {
|
|
12505
|
+
* amount: 1000n, // Amount of SODA tokens to revert
|
|
12506
|
+
* to: 'hx...', // Icon Address to receive the reverted SODA tokens as ICX
|
|
12507
|
+
* action: 'revert',
|
|
12508
|
+
* },
|
|
12509
|
+
*/
|
|
12510
|
+
async createRevertMigrationIntent(params, spokeProvider, raw) {
|
|
12511
|
+
try {
|
|
12512
|
+
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
12513
|
+
const userRouter = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
12514
|
+
const data = this.icxMigration.revertMigration({
|
|
12515
|
+
wICX: spokeChainConfig[types.ICON_MAINNET_CHAIN_ID].addresses.wICX,
|
|
12516
|
+
amount: params.amount,
|
|
12517
|
+
to: encodeAddress(types.ICON_MAINNET_CHAIN_ID, params.to),
|
|
12518
|
+
userWallet: userRouter
|
|
12519
|
+
});
|
|
12520
|
+
const txResult = await SonicSpokeService.deposit(
|
|
12521
|
+
{
|
|
12522
|
+
from: wallet,
|
|
12523
|
+
token: this.hubProvider.chainConfig.addresses.sodaToken,
|
|
12524
|
+
amount: params.amount,
|
|
12525
|
+
data
|
|
12526
|
+
},
|
|
12527
|
+
spokeProvider,
|
|
12528
|
+
raw
|
|
12529
|
+
);
|
|
12530
|
+
return {
|
|
12531
|
+
ok: true,
|
|
12532
|
+
value: txResult
|
|
12533
|
+
};
|
|
12534
|
+
} catch (error) {
|
|
12535
|
+
return {
|
|
12536
|
+
ok: false,
|
|
12537
|
+
error: {
|
|
12538
|
+
code: "CREATE_REVERT_MIGRATION_INTENT_FAILED",
|
|
12539
|
+
data: {
|
|
12540
|
+
payload: params,
|
|
12541
|
+
error
|
|
12542
|
+
}
|
|
12543
|
+
}
|
|
12544
|
+
};
|
|
12545
|
+
}
|
|
12546
|
+
}
|
|
12547
|
+
};
|
|
12548
|
+
|
|
10940
12549
|
// src/entities/Sodax.ts
|
|
10941
12550
|
var Sodax = class {
|
|
10942
12551
|
config;
|
|
@@ -10944,6 +12553,8 @@ var Sodax = class {
|
|
|
10944
12553
|
// Solver service enabling intent based swaps
|
|
10945
12554
|
moneyMarket;
|
|
10946
12555
|
// Money Market service enabling cross-chain lending and borrowing
|
|
12556
|
+
migration;
|
|
12557
|
+
// ICX migration service enabling ICX migration to SODA
|
|
10947
12558
|
hubProvider;
|
|
10948
12559
|
// hub provider for the hub chain (e.g. Sonic mainnet)
|
|
10949
12560
|
relayerApiEndpoint;
|
|
@@ -10954,39 +12565,40 @@ var Sodax = class {
|
|
|
10954
12565
|
this.hubProvider = new EvmHubProvider(config?.hubProviderConfig);
|
|
10955
12566
|
this.solver = config && config.solver ? new SolverService(config.solver, this.hubProvider, this.relayerApiEndpoint) : new SolverService(void 0, this.hubProvider, this.relayerApiEndpoint);
|
|
10956
12567
|
this.moneyMarket = config && config.moneyMarket ? new MoneyMarketService(config.moneyMarket, this.hubProvider, this.relayerApiEndpoint) : new MoneyMarketService(void 0, this.hubProvider, this.relayerApiEndpoint);
|
|
12568
|
+
this.migration = config && config.migration ? new MigrationService(this.hubProvider, config.migration) : new MigrationService(this.hubProvider);
|
|
10957
12569
|
}
|
|
10958
12570
|
};
|
|
10959
12571
|
|
|
10960
12572
|
// src/types.ts
|
|
10961
|
-
var
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
return
|
|
10968
|
-
})(
|
|
10969
|
-
var
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
return
|
|
10989
|
-
})(
|
|
12573
|
+
var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
|
|
12574
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["NOT_FOUND"] = -1] = "NOT_FOUND";
|
|
12575
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["NOT_STARTED_YET"] = 1] = "NOT_STARTED_YET";
|
|
12576
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["STARTED_NOT_FINISHED"] = 2] = "STARTED_NOT_FINISHED";
|
|
12577
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["SOLVED"] = 3] = "SOLVED";
|
|
12578
|
+
SolverIntentStatusCode2[SolverIntentStatusCode2["FAILED"] = 4] = "FAILED";
|
|
12579
|
+
return SolverIntentStatusCode2;
|
|
12580
|
+
})(SolverIntentStatusCode || {});
|
|
12581
|
+
var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
|
|
12582
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_PATH_FOUND"] = -4] = "NO_PATH_FOUND";
|
|
12583
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_PRIVATE_LIQUIDITY"] = -5] = "NO_PRIVATE_LIQUIDITY";
|
|
12584
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NOT_ENOUGH_PRIVATE_LIQUIDITY"] = -8] = "NOT_ENOUGH_PRIVATE_LIQUIDITY";
|
|
12585
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_EXECUTION_MODULE_FOUND"] = -7] = "NO_EXECUTION_MODULE_FOUND";
|
|
12586
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_NOT_FOUND"] = -8] = "QUOTE_NOT_FOUND";
|
|
12587
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_NOT_MATCH"] = -9] = "QUOTE_NOT_MATCH";
|
|
12588
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_DATA_NOT_MATCH_QUOTE"] = -10] = "INTENT_DATA_NOT_MATCH_QUOTE";
|
|
12589
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_GAS_HANDLER_FOR_BLOCKCHAIN"] = -11] = "NO_GAS_HANDLER_FOR_BLOCKCHAIN";
|
|
12590
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_NOT_FOUND"] = -12] = "INTENT_NOT_FOUND";
|
|
12591
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["QUOTE_EXPIRED"] = -13] = "QUOTE_EXPIRED";
|
|
12592
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["MAX_INPUT_AMOUNT"] = -14] = "MAX_INPUT_AMOUNT";
|
|
12593
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["MAX_DIFF_OUTPUT"] = -15] = "MAX_DIFF_OUTPUT";
|
|
12594
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["STOPPED"] = -16] = "STOPPED";
|
|
12595
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NO_ORACLE_MODULE_FOUND"] = -17] = "NO_ORACLE_MODULE_FOUND";
|
|
12596
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["NEGATIVE_INPUT_AMOUNT"] = -18] = "NEGATIVE_INPUT_AMOUNT";
|
|
12597
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["INTENT_ALREADY_IN_ORDERBOOK"] = -19] = "INTENT_ALREADY_IN_ORDERBOOK";
|
|
12598
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["CREATE_INTENT_ORDER_FAILED"] = -998] = "CREATE_INTENT_ORDER_FAILED";
|
|
12599
|
+
SolverIntentErrorCode2[SolverIntentErrorCode2["UNKNOWN"] = -999] = "UNKNOWN";
|
|
12600
|
+
return SolverIntentErrorCode2;
|
|
12601
|
+
})(SolverIntentErrorCode || {});
|
|
10990
12602
|
|
|
10991
12603
|
exports.BigIntToHex = BigIntToHex;
|
|
10992
12604
|
exports.CWSpokeProvider = CWSpokeProvider;
|
|
@@ -11009,15 +12621,19 @@ exports.HubVaultSymbols = HubVaultSymbols;
|
|
|
11009
12621
|
exports.ICON_TX_RESULT_WAIT_MAX_RETRY = ICON_TX_RESULT_WAIT_MAX_RETRY;
|
|
11010
12622
|
exports.INTENT_RELAY_CHAIN_IDS = INTENT_RELAY_CHAIN_IDS;
|
|
11011
12623
|
exports.IconSpokeProvider = IconSpokeProvider;
|
|
12624
|
+
exports.IcxMigrationService = IcxMigrationService;
|
|
11012
12625
|
exports.IntentCreatedEventAbi = IntentCreatedEventAbi;
|
|
11013
12626
|
exports.IntentDataType = IntentDataType;
|
|
11014
|
-
exports.IntentErrorCode = IntentErrorCode;
|
|
11015
|
-
exports.IntentStatusCode = IntentStatusCode;
|
|
11016
12627
|
exports.IntentsAbi = IntentsAbi;
|
|
11017
12628
|
exports.MAX_UINT256 = MAX_UINT256;
|
|
12629
|
+
exports.MigrationService = MigrationService;
|
|
11018
12630
|
exports.MoneyMarketService = MoneyMarketService;
|
|
12631
|
+
exports.STELLAR_DEFAULT_TX_TIMEOUT_SECONDS = STELLAR_DEFAULT_TX_TIMEOUT_SECONDS;
|
|
12632
|
+
exports.STELLAR_PRIORITY_FEE = STELLAR_PRIORITY_FEE;
|
|
11019
12633
|
exports.Sodax = Sodax;
|
|
11020
12634
|
exports.SolanaSpokeProvider = SolanaSpokeProvider;
|
|
12635
|
+
exports.SolverIntentErrorCode = SolverIntentErrorCode;
|
|
12636
|
+
exports.SolverIntentStatusCode = SolverIntentStatusCode;
|
|
11021
12637
|
exports.SolverService = SolverService;
|
|
11022
12638
|
exports.SonicSpokeProvider = SonicSpokeProvider;
|
|
11023
12639
|
exports.SonicSpokeService = SonicSpokeService;
|
|
@@ -11066,11 +12682,25 @@ exports.isEvmUninitializedConfig = isEvmUninitializedConfig;
|
|
|
11066
12682
|
exports.isEvmUninitializedPrivateKeyConfig = isEvmUninitializedPrivateKeyConfig;
|
|
11067
12683
|
exports.isIconAddress = isIconAddress;
|
|
11068
12684
|
exports.isIconSpokeProvider = isIconSpokeProvider;
|
|
12685
|
+
exports.isIntentCreationFailedError = isIntentCreationFailedError;
|
|
12686
|
+
exports.isIntentCreationUnknownError = isIntentCreationUnknownError;
|
|
12687
|
+
exports.isIntentPostExecutionFailedError = isIntentPostExecutionFailedError;
|
|
11069
12688
|
exports.isIntentRelayChainId = isIntentRelayChainId;
|
|
12689
|
+
exports.isIntentSubmitTxFailedError = isIntentSubmitTxFailedError;
|
|
11070
12690
|
exports.isJsonRpcPayloadResponse = isJsonRpcPayloadResponse;
|
|
12691
|
+
exports.isMoneyMarketBorrowUnknownError = isMoneyMarketBorrowUnknownError;
|
|
12692
|
+
exports.isMoneyMarketCreateBorrowIntentFailedError = isMoneyMarketCreateBorrowIntentFailedError;
|
|
12693
|
+
exports.isMoneyMarketCreateRepayIntentFailedError = isMoneyMarketCreateRepayIntentFailedError;
|
|
12694
|
+
exports.isMoneyMarketCreateSupplyIntentFailedError = isMoneyMarketCreateSupplyIntentFailedError;
|
|
12695
|
+
exports.isMoneyMarketCreateWithdrawIntentFailedError = isMoneyMarketCreateWithdrawIntentFailedError;
|
|
12696
|
+
exports.isMoneyMarketRelayTimeoutError = isMoneyMarketRelayTimeoutError;
|
|
12697
|
+
exports.isMoneyMarketRepayUnknownError = isMoneyMarketRepayUnknownError;
|
|
11071
12698
|
exports.isMoneyMarketReserveAsset = isMoneyMarketReserveAsset;
|
|
11072
12699
|
exports.isMoneyMarketReserveHubAsset = isMoneyMarketReserveHubAsset;
|
|
12700
|
+
exports.isMoneyMarketSubmitTxFailedError = isMoneyMarketSubmitTxFailedError;
|
|
12701
|
+
exports.isMoneyMarketSupplyUnknownError = isMoneyMarketSupplyUnknownError;
|
|
11073
12702
|
exports.isMoneyMarketSupportedToken = isMoneyMarketSupportedToken;
|
|
12703
|
+
exports.isMoneyMarketWithdrawUnknownError = isMoneyMarketWithdrawUnknownError;
|
|
11074
12704
|
exports.isNativeToken = isNativeToken;
|
|
11075
12705
|
exports.isPartnerFeeAmount = isPartnerFeeAmount;
|
|
11076
12706
|
exports.isPartnerFeePercentage = isPartnerFeePercentage;
|
|
@@ -11086,8 +12716,10 @@ exports.isValidHubAsset = isValidHubAsset;
|
|
|
11086
12716
|
exports.isValidIntentRelayChainId = isValidIntentRelayChainId;
|
|
11087
12717
|
exports.isValidOriginalAssetAddress = isValidOriginalAssetAddress;
|
|
11088
12718
|
exports.isValidSpokeChainId = isValidSpokeChainId;
|
|
12719
|
+
exports.isWaitUntilIntentExecutedFailed = isWaitUntilIntentExecutedFailed;
|
|
11089
12720
|
exports.moneyMarketReserveAssets = moneyMarketReserveAssets;
|
|
11090
12721
|
exports.moneyMarketReserveHubAssetsSet = moneyMarketReserveHubAssetsSet;
|
|
12722
|
+
exports.moneyMarketSupportedTokens = moneyMarketSupportedTokens;
|
|
11091
12723
|
exports.originalAssetTohubAssetMap = originalAssetTohubAssetMap;
|
|
11092
12724
|
exports.poolAbi = poolAbi;
|
|
11093
12725
|
exports.randomUint256 = randomUint256;
|