@sodax/sdk 1.0.2-beta → 1.0.3-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +169 -219
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -29
- package/dist/index.d.ts +66 -29
- package/dist/index.mjs +168 -220
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -10209,8 +10209,6 @@ var LendingPoolService = class {
|
|
|
10209
10209
|
});
|
|
10210
10210
|
}
|
|
10211
10211
|
};
|
|
10212
|
-
|
|
10213
|
-
// src/moneyMarket/MoneyMarketDataService.ts
|
|
10214
10212
|
var MoneyMarketDataService = class {
|
|
10215
10213
|
uiPoolDataProviderService;
|
|
10216
10214
|
lendingPoolService;
|
|
@@ -10223,6 +10221,34 @@ var MoneyMarketDataService = class {
|
|
|
10223
10221
|
async getATokenData(aToken) {
|
|
10224
10222
|
return Erc20Service.getErc20Token(aToken, this.hubProvider.publicClient);
|
|
10225
10223
|
}
|
|
10224
|
+
/**
|
|
10225
|
+
* Fetches multiple aToken balances in a single multicall for better performance
|
|
10226
|
+
* @param aTokens - Array of aToken addresses
|
|
10227
|
+
* @param userAddress - User's hub wallet address to fetch balances for
|
|
10228
|
+
* @returns Promise<Map<Address, bigint>> - Map of aToken address to balance
|
|
10229
|
+
*/
|
|
10230
|
+
async getATokensBalances(aTokens, userAddress) {
|
|
10231
|
+
const contracts = aTokens.map((aToken) => ({
|
|
10232
|
+
address: aToken,
|
|
10233
|
+
abi: erc20Abi$1,
|
|
10234
|
+
functionName: "balanceOf",
|
|
10235
|
+
args: [userAddress]
|
|
10236
|
+
}));
|
|
10237
|
+
const results = await this.hubProvider.publicClient.multicall({
|
|
10238
|
+
contracts,
|
|
10239
|
+
allowFailure: false
|
|
10240
|
+
});
|
|
10241
|
+
const balanceMap = /* @__PURE__ */ new Map();
|
|
10242
|
+
let resultIndex = 0;
|
|
10243
|
+
for (const aToken of aTokens) {
|
|
10244
|
+
const result = results[resultIndex];
|
|
10245
|
+
if (result !== void 0) {
|
|
10246
|
+
balanceMap.set(aToken, result);
|
|
10247
|
+
}
|
|
10248
|
+
resultIndex++;
|
|
10249
|
+
}
|
|
10250
|
+
return balanceMap;
|
|
10251
|
+
}
|
|
10226
10252
|
/**
|
|
10227
10253
|
* LendingPool
|
|
10228
10254
|
*/
|
|
@@ -10268,7 +10294,7 @@ var MoneyMarketDataService = class {
|
|
|
10268
10294
|
async getUserReservesData(spokeProvider) {
|
|
10269
10295
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10270
10296
|
const spokeChainId = spokeProvider.chainConfig.chain.id;
|
|
10271
|
-
const hubWalletAddress = await
|
|
10297
|
+
const hubWalletAddress = await HubService.getUserHubWalletAddress(walletAddress, spokeChainId, this.hubProvider);
|
|
10272
10298
|
return this.uiPoolDataProviderService.getUserReservesData(hubWalletAddress);
|
|
10273
10299
|
}
|
|
10274
10300
|
/**
|
|
@@ -10300,7 +10326,7 @@ var MoneyMarketDataService = class {
|
|
|
10300
10326
|
async getUserReservesHumanized(spokeProvider) {
|
|
10301
10327
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10302
10328
|
const spokeChainId = spokeProvider.chainConfig.chain.id;
|
|
10303
|
-
const hubWalletAddress = await
|
|
10329
|
+
const hubWalletAddress = await HubService.getUserHubWalletAddress(walletAddress, spokeChainId, this.hubProvider);
|
|
10304
10330
|
return this.uiPoolDataProviderService.getUserReservesHumanized(hubWalletAddress);
|
|
10305
10331
|
}
|
|
10306
10332
|
/**
|
|
@@ -13865,65 +13891,25 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13865
13891
|
);
|
|
13866
13892
|
}
|
|
13867
13893
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
13868
|
-
if (spokeProvider
|
|
13894
|
+
if (isStellarSpokeProviderType(spokeProvider) && (params.action === "supply" || params.action === "repay")) {
|
|
13869
13895
|
return {
|
|
13870
13896
|
ok: true,
|
|
13871
13897
|
value: await StellarSpokeService.hasSufficientTrustline(params.token, params.amount, spokeProvider)
|
|
13872
13898
|
};
|
|
13873
13899
|
}
|
|
13874
|
-
if (spokeProvider
|
|
13900
|
+
if ((isEvmSpokeProviderType(spokeProvider) || isSonicSpokeProviderType(spokeProvider)) && (params.action === "supply" || params.action === "repay")) {
|
|
13901
|
+
const spender = isHubSpokeProvider(spokeProvider, this.hubProvider) ? await HubService.getUserRouter(
|
|
13902
|
+
walletAddress,
|
|
13903
|
+
this.hubProvider
|
|
13904
|
+
) : spokeProvider.chainConfig.addresses.assetManager;
|
|
13875
13905
|
return await Erc20Service.isAllowanceValid(
|
|
13876
13906
|
params.token,
|
|
13877
13907
|
params.amount,
|
|
13878
13908
|
walletAddress,
|
|
13879
|
-
|
|
13909
|
+
spender,
|
|
13880
13910
|
spokeProvider
|
|
13881
13911
|
);
|
|
13882
13912
|
}
|
|
13883
|
-
if (spokeProvider instanceof SonicSpokeProvider && spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
13884
|
-
if (params.action === "withdraw") {
|
|
13885
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
13886
|
-
params.token,
|
|
13887
|
-
params.amount,
|
|
13888
|
-
params.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13889
|
-
this.data,
|
|
13890
|
-
this.configService
|
|
13891
|
-
);
|
|
13892
|
-
return await SonicSpokeService.isWithdrawApproved(
|
|
13893
|
-
walletAddress,
|
|
13894
|
-
withdrawInfo,
|
|
13895
|
-
spokeProvider
|
|
13896
|
-
);
|
|
13897
|
-
}
|
|
13898
|
-
if (params.action === "borrow") {
|
|
13899
|
-
const borrowInfo = await SonicSpokeService.getBorrowInfo(
|
|
13900
|
-
params.token,
|
|
13901
|
-
params.amount,
|
|
13902
|
-
params.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13903
|
-
this.data,
|
|
13904
|
-
this.configService,
|
|
13905
|
-
this.config
|
|
13906
|
-
);
|
|
13907
|
-
return await SonicSpokeService.isBorrowApproved(
|
|
13908
|
-
walletAddress,
|
|
13909
|
-
borrowInfo,
|
|
13910
|
-
spokeProvider
|
|
13911
|
-
);
|
|
13912
|
-
}
|
|
13913
|
-
if (params.action === "supply" || params.action === "repay") {
|
|
13914
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
13915
|
-
walletAddress,
|
|
13916
|
-
spokeProvider
|
|
13917
|
-
);
|
|
13918
|
-
return await Erc20Service.isAllowanceValid(
|
|
13919
|
-
params.token,
|
|
13920
|
-
params.amount,
|
|
13921
|
-
walletAddress,
|
|
13922
|
-
userRouter,
|
|
13923
|
-
spokeProvider
|
|
13924
|
-
);
|
|
13925
|
-
}
|
|
13926
|
-
}
|
|
13927
13913
|
return {
|
|
13928
13914
|
ok: true,
|
|
13929
13915
|
value: true
|
|
@@ -13979,7 +13965,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13979
13965
|
);
|
|
13980
13966
|
}
|
|
13981
13967
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
13982
|
-
if (spokeProvider
|
|
13968
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
13983
13969
|
invariant6(
|
|
13984
13970
|
params.action === "supply" || params.action === "repay",
|
|
13985
13971
|
"Invalid action (only supply and repay are supported on stellar)"
|
|
@@ -13990,16 +13976,20 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13990
13976
|
value: result
|
|
13991
13977
|
};
|
|
13992
13978
|
}
|
|
13993
|
-
if (spokeProvider
|
|
13979
|
+
if (isEvmSpokeProviderType(spokeProvider) || isSonicSpokeProviderType(spokeProvider)) {
|
|
13994
13980
|
invariant6(
|
|
13995
13981
|
params.action === "supply" || params.action === "repay",
|
|
13996
13982
|
"Invalid action (only supply and repay are supported on evm)"
|
|
13997
13983
|
);
|
|
13998
13984
|
invariant6(isAddress(params.token), "Invalid token address");
|
|
13985
|
+
const spender = isHubSpokeProvider(spokeProvider, this.hubProvider) ? await HubService.getUserRouter(
|
|
13986
|
+
walletAddress,
|
|
13987
|
+
this.hubProvider
|
|
13988
|
+
) : spokeProvider.chainConfig.addresses.assetManager;
|
|
13999
13989
|
const result = await Erc20Service.approve(
|
|
14000
13990
|
params.token,
|
|
14001
13991
|
params.amount,
|
|
14002
|
-
|
|
13992
|
+
spender,
|
|
14003
13993
|
spokeProvider,
|
|
14004
13994
|
raw
|
|
14005
13995
|
);
|
|
@@ -14008,69 +13998,6 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14008
13998
|
value: result
|
|
14009
13999
|
};
|
|
14010
14000
|
}
|
|
14011
|
-
if (spokeProvider instanceof SonicSpokeProvider && spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
14012
|
-
invariant6(
|
|
14013
|
-
params.action === "withdraw" || params.action === "borrow" || params.action === "supply" || params.action === "repay",
|
|
14014
|
-
"Invalid action (only withdraw, borrow, supply and repay are supported on sonic)"
|
|
14015
|
-
);
|
|
14016
|
-
invariant6(isAddress(params.token), "Invalid token address");
|
|
14017
|
-
if (params.action === "withdraw") {
|
|
14018
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
14019
|
-
params.token,
|
|
14020
|
-
params.amount,
|
|
14021
|
-
params?.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
14022
|
-
this.data,
|
|
14023
|
-
this.configService
|
|
14024
|
-
);
|
|
14025
|
-
const result = await SonicSpokeService.approveWithdraw(
|
|
14026
|
-
walletAddress,
|
|
14027
|
-
withdrawInfo,
|
|
14028
|
-
spokeProvider,
|
|
14029
|
-
raw
|
|
14030
|
-
);
|
|
14031
|
-
return {
|
|
14032
|
-
ok: true,
|
|
14033
|
-
value: result
|
|
14034
|
-
};
|
|
14035
|
-
}
|
|
14036
|
-
if (params.action === "borrow") {
|
|
14037
|
-
const borrowInfo = await SonicSpokeService.getBorrowInfo(
|
|
14038
|
-
params.token,
|
|
14039
|
-
params.amount,
|
|
14040
|
-
params?.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
14041
|
-
this.data,
|
|
14042
|
-
this.configService,
|
|
14043
|
-
this.config
|
|
14044
|
-
);
|
|
14045
|
-
const result = await SonicSpokeService.approveBorrow(
|
|
14046
|
-
walletAddress,
|
|
14047
|
-
borrowInfo,
|
|
14048
|
-
spokeProvider,
|
|
14049
|
-
raw
|
|
14050
|
-
);
|
|
14051
|
-
return {
|
|
14052
|
-
ok: true,
|
|
14053
|
-
value: result
|
|
14054
|
-
};
|
|
14055
|
-
}
|
|
14056
|
-
if (params.action === "supply" || params.action === "repay") {
|
|
14057
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
14058
|
-
walletAddress,
|
|
14059
|
-
spokeProvider
|
|
14060
|
-
);
|
|
14061
|
-
const result = await Erc20Service.approve(
|
|
14062
|
-
params.token,
|
|
14063
|
-
params.amount,
|
|
14064
|
-
userRouter,
|
|
14065
|
-
spokeProvider,
|
|
14066
|
-
raw
|
|
14067
|
-
);
|
|
14068
|
-
return {
|
|
14069
|
-
ok: true,
|
|
14070
|
-
value: result
|
|
14071
|
-
};
|
|
14072
|
-
}
|
|
14073
|
-
}
|
|
14074
14001
|
return {
|
|
14075
14002
|
ok: false,
|
|
14076
14003
|
error: new Error("Approve only supported for EVM spoke chains")
|
|
@@ -14129,7 +14056,9 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14129
14056
|
};
|
|
14130
14057
|
}
|
|
14131
14058
|
let intentTxHash = null;
|
|
14132
|
-
if (spokeProvider.chainConfig.chain.id
|
|
14059
|
+
if (spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
14060
|
+
intentTxHash = txResult.value;
|
|
14061
|
+
} else {
|
|
14133
14062
|
const packetResult = await relayTxAndWaitPacket(
|
|
14134
14063
|
txResult.value,
|
|
14135
14064
|
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
@@ -14150,8 +14079,6 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14150
14079
|
};
|
|
14151
14080
|
}
|
|
14152
14081
|
intentTxHash = packetResult.value.dst_tx_hash;
|
|
14153
|
-
} else {
|
|
14154
|
-
intentTxHash = txResult.value;
|
|
14155
14082
|
}
|
|
14156
14083
|
return { ok: true, value: [txResult.value, intentTxHash] };
|
|
14157
14084
|
} catch (error) {
|
|
@@ -14212,13 +14139,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14212
14139
|
this.configService.isMoneyMarketSupportedToken(fromChainId, params.token),
|
|
14213
14140
|
`Unsupported spoke chain (${fromChainId}) token: ${params.token}`
|
|
14214
14141
|
);
|
|
14215
|
-
const fromHubWallet = await
|
|
14216
|
-
|
|
14142
|
+
const [fromHubWallet, toHubWallet] = await Promise.all([
|
|
14143
|
+
HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider),
|
|
14144
|
+
HubService.getUserHubWalletAddress(toAddress, toChainId, this.hubProvider)
|
|
14145
|
+
]);
|
|
14217
14146
|
const data = this.buildSupplyData(fromChainId, params.token, params.amount, toHubWallet);
|
|
14218
14147
|
const txResult = await SpokeService.deposit(
|
|
14219
14148
|
{
|
|
14220
14149
|
from: fromAddress,
|
|
14221
|
-
to:
|
|
14150
|
+
to: fromHubWallet,
|
|
14222
14151
|
token: params.token,
|
|
14223
14152
|
amount: params.amount,
|
|
14224
14153
|
data
|
|
@@ -14298,7 +14227,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14298
14227
|
if (spokeProvider.chainConfig.chain.id !== this.hubProvider.chainConfig.chain.id || params.toChainId && params.toAddress && params.toChainId !== this.hubProvider.chainConfig.chain.id) {
|
|
14299
14228
|
const packetResult = await relayTxAndWaitPacket(
|
|
14300
14229
|
txResult.value,
|
|
14301
|
-
spokeProvider
|
|
14230
|
+
isSolanaSpokeProviderType(spokeProvider) ? txResult.data : void 0,
|
|
14302
14231
|
spokeProvider,
|
|
14303
14232
|
this.config.relayerApiEndpoint,
|
|
14304
14233
|
timeout
|
|
@@ -14367,14 +14296,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14367
14296
|
invariant6(params.action === "borrow", "Invalid action");
|
|
14368
14297
|
invariant6(params.token.length > 0, "Token is required");
|
|
14369
14298
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
14370
|
-
const fromChainId = spokeProvider.chainConfig.chain.id;
|
|
14371
|
-
const fromAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14299
|
+
const fromChainId = params.fromChainId ?? spokeProvider.chainConfig.chain.id;
|
|
14300
|
+
const fromAddress = params.fromAddress ?? await spokeProvider.walletProvider.getWalletAddress();
|
|
14372
14301
|
const toChainId = params.toChainId ?? fromChainId;
|
|
14373
14302
|
const toAddress = params.toAddress ?? fromAddress;
|
|
14374
14303
|
const dstToken = this.configService.getMoneyMarketToken(toChainId, params.token);
|
|
14375
14304
|
invariant6(dstToken, `Money market token not found for spoke chain (${toChainId}) token: ${params.token}`);
|
|
14376
14305
|
const encodedToAddress = encodeAddress(toChainId, toAddress);
|
|
14377
|
-
const fromHubWallet = await
|
|
14306
|
+
const fromHubWallet = await HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider);
|
|
14378
14307
|
const data = this.buildBorrowData(fromHubWallet, encodedToAddress, dstToken.address, params.amount, toChainId);
|
|
14379
14308
|
let txResult;
|
|
14380
14309
|
if (fromChainId === this.hubProvider.chainConfig.chain.id && isSonicSpokeProviderType(spokeProvider)) {
|
|
@@ -14520,29 +14449,9 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14520
14449
|
`Unsupported spoke chain (${toChainId}) token: ${params.token}`
|
|
14521
14450
|
);
|
|
14522
14451
|
const encodedToAddress = encodeAddress(toChainId, toAddress);
|
|
14523
|
-
const fromHubWallet = await
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
14527
|
-
params.token,
|
|
14528
|
-
params.amount,
|
|
14529
|
-
toChainId,
|
|
14530
|
-
this.data,
|
|
14531
|
-
this.configService
|
|
14532
|
-
);
|
|
14533
|
-
data = await SonicSpokeService.buildWithdrawData(
|
|
14534
|
-
fromAddress,
|
|
14535
|
-
withdrawInfo,
|
|
14536
|
-
params.amount,
|
|
14537
|
-
encodedToAddress,
|
|
14538
|
-
toChainId,
|
|
14539
|
-
spokeProvider,
|
|
14540
|
-
this
|
|
14541
|
-
);
|
|
14542
|
-
} else {
|
|
14543
|
-
data = this.buildWithdrawData(fromHubWallet, encodedToAddress, params.token, params.amount, toChainId);
|
|
14544
|
-
}
|
|
14545
|
-
const txResult = spokeProvider instanceof SonicSpokeProvider ? await SonicSpokeService.callWallet(data, spokeProvider, raw) : await SpokeService.callWallet(fromHubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
14452
|
+
const fromHubWallet = await HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider);
|
|
14453
|
+
const data = this.buildWithdrawData(fromHubWallet, encodedToAddress, params.token, params.amount, toChainId);
|
|
14454
|
+
const txResult = isSonicSpokeProviderType(spokeProvider) ? await SonicSpokeService.callWallet(data, spokeProvider, raw) : await SpokeService.callWallet(fromHubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
14546
14455
|
return {
|
|
14547
14456
|
ok: true,
|
|
14548
14457
|
value: txResult,
|
|
@@ -14682,13 +14591,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14682
14591
|
this.configService.isMoneyMarketSupportedToken(fromChainId, params.token),
|
|
14683
14592
|
`Unsupported spoke chain (${fromChainId}) token: ${params.token}`
|
|
14684
14593
|
);
|
|
14685
|
-
const toHubWallet = await
|
|
14686
|
-
|
|
14594
|
+
const [fromHubWallet, toHubWallet] = await Promise.all([
|
|
14595
|
+
HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider),
|
|
14596
|
+
HubService.getUserHubWalletAddress(toAddress, toChainId, this.hubProvider)
|
|
14597
|
+
]);
|
|
14687
14598
|
const data = this.buildRepayData(fromChainId, params.token, params.amount, toHubWallet);
|
|
14688
14599
|
const txResult = await SpokeService.deposit(
|
|
14689
14600
|
{
|
|
14690
14601
|
from: fromAddress,
|
|
14691
|
-
to:
|
|
14602
|
+
to: fromHubWallet,
|
|
14692
14603
|
token: params.token,
|
|
14693
14604
|
amount: params.amount,
|
|
14694
14605
|
data
|
|
@@ -15167,6 +15078,8 @@ var Sodax = class {
|
|
|
15167
15078
|
|
|
15168
15079
|
// src/shared/services/hub/WalletAbstractionService.ts
|
|
15169
15080
|
var WalletAbstractionService = class {
|
|
15081
|
+
constructor() {
|
|
15082
|
+
}
|
|
15170
15083
|
/**
|
|
15171
15084
|
* Gets the hub wallet address for a user based on their spoke chain address.
|
|
15172
15085
|
* @param address - The user's address on the spoke chain
|
|
@@ -15191,6 +15104,40 @@ var WalletAbstractionService = class {
|
|
|
15191
15104
|
);
|
|
15192
15105
|
}
|
|
15193
15106
|
};
|
|
15107
|
+
|
|
15108
|
+
// src/shared/services/hub/HubService.ts
|
|
15109
|
+
var HubService = class _HubService {
|
|
15110
|
+
constructor() {
|
|
15111
|
+
}
|
|
15112
|
+
/**
|
|
15113
|
+
* Get the derived address of a contract deployed with CREATE3.
|
|
15114
|
+
* @param address - User's address on the specified chain as hex
|
|
15115
|
+
* @param hubProvider - Hub provider
|
|
15116
|
+
* @returns {HubAddress} The computed contract address as a EVM address (hex) string
|
|
15117
|
+
*/
|
|
15118
|
+
static async getUserRouter(address, hubProvider) {
|
|
15119
|
+
return hubProvider.publicClient.readContract({
|
|
15120
|
+
address: hubProvider.chainConfig.addresses.walletRouter,
|
|
15121
|
+
abi: sonicWalletFactoryAbi,
|
|
15122
|
+
functionName: "getDeployedAddress",
|
|
15123
|
+
args: [address]
|
|
15124
|
+
});
|
|
15125
|
+
}
|
|
15126
|
+
/**
|
|
15127
|
+
* Gets the hub wallet address for a user based on their spoke chain address.
|
|
15128
|
+
* @param address - The user's address on the spoke chain
|
|
15129
|
+
* @param chainId - spoke chain id
|
|
15130
|
+
* @param hubProvider - The provider for interacting with the hub chain
|
|
15131
|
+
* @returns The user's hub wallet address
|
|
15132
|
+
*/
|
|
15133
|
+
static async getUserHubWalletAddress(address, chainId, hubProvider) {
|
|
15134
|
+
const encodedAddress = encodeAddress(chainId, address);
|
|
15135
|
+
if (chainId === hubProvider.chainConfig.chain.id) {
|
|
15136
|
+
return _HubService.getUserRouter(encodedAddress, hubProvider);
|
|
15137
|
+
}
|
|
15138
|
+
return EvmWalletAbstraction.getUserHubWalletAddress(chainId, encodedAddress, hubProvider);
|
|
15139
|
+
}
|
|
15140
|
+
};
|
|
15194
15141
|
var SuiSpokeService = class _SuiSpokeService {
|
|
15195
15142
|
constructor() {
|
|
15196
15143
|
}
|
|
@@ -15831,6 +15778,9 @@ function parseToStroops(amount) {
|
|
|
15831
15778
|
function sleep(ms) {
|
|
15832
15779
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15833
15780
|
}
|
|
15781
|
+
function isHubSpokeProvider(spokeProvider, hubProvider) {
|
|
15782
|
+
return spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id;
|
|
15783
|
+
}
|
|
15834
15784
|
|
|
15835
15785
|
// src/shared/types.ts
|
|
15836
15786
|
var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
|
|
@@ -16172,7 +16122,7 @@ var BridgeService = class {
|
|
|
16172
16122
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
16173
16123
|
invariant6(params.srcAsset.length > 0, "Source asset is required");
|
|
16174
16124
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
16175
|
-
if (spokeProvider
|
|
16125
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
16176
16126
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
|
|
16177
16127
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
16178
16128
|
params.srcAsset,
|
|
@@ -16195,7 +16145,7 @@ var BridgeService = class {
|
|
|
16195
16145
|
value: allowanceResult.value
|
|
16196
16146
|
};
|
|
16197
16147
|
}
|
|
16198
|
-
if (spokeProvider
|
|
16148
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
16199
16149
|
const allowanceResult = await StellarSpokeService.hasSufficientTrustline(
|
|
16200
16150
|
params.srcAsset,
|
|
16201
16151
|
params.amount,
|
|
@@ -16215,9 +16165,12 @@ var BridgeService = class {
|
|
|
16215
16165
|
value: allowanceResult
|
|
16216
16166
|
};
|
|
16217
16167
|
}
|
|
16218
|
-
if (spokeProvider
|
|
16168
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
16219
16169
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
|
|
16220
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16170
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16171
|
+
walletAddress,
|
|
16172
|
+
spokeProvider
|
|
16173
|
+
);
|
|
16221
16174
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
16222
16175
|
params.srcAsset,
|
|
16223
16176
|
params.amount,
|
|
@@ -16269,7 +16222,7 @@ var BridgeService = class {
|
|
|
16269
16222
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
16270
16223
|
invariant6(params.srcAsset.length > 0, "Source asset is required");
|
|
16271
16224
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
16272
|
-
if (spokeProvider
|
|
16225
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
16273
16226
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
|
|
16274
16227
|
const result = await Erc20Service.approve(
|
|
16275
16228
|
params.srcAsset,
|
|
@@ -16283,14 +16236,14 @@ var BridgeService = class {
|
|
|
16283
16236
|
value: result
|
|
16284
16237
|
};
|
|
16285
16238
|
}
|
|
16286
|
-
if (spokeProvider
|
|
16239
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
16287
16240
|
const result = await StellarSpokeService.requestTrustline(params.srcAsset, params.amount, spokeProvider, raw);
|
|
16288
16241
|
return {
|
|
16289
16242
|
ok: true,
|
|
16290
16243
|
value: result
|
|
16291
16244
|
};
|
|
16292
16245
|
}
|
|
16293
|
-
if (spokeProvider
|
|
16246
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
16294
16247
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
|
|
16295
16248
|
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16296
16249
|
walletAddress,
|
|
@@ -17072,7 +17025,7 @@ var StakingService = class {
|
|
|
17072
17025
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
17073
17026
|
const targetToken = params.action === "stake" || spokeProvider.chainConfig.chain.id !== this.hubProvider.chainConfig.chain.id ? spokeProvider.chainConfig.supportedTokens.SODA?.address : this.hubProvider.chainConfig.addresses.xSoda;
|
|
17074
17027
|
invariant6(targetToken, "Target token not found");
|
|
17075
|
-
if (spokeProvider
|
|
17028
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
17076
17029
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
17077
17030
|
targetToken,
|
|
17078
17031
|
params.amount,
|
|
@@ -17094,7 +17047,7 @@ var StakingService = class {
|
|
|
17094
17047
|
value: allowanceResult.value
|
|
17095
17048
|
};
|
|
17096
17049
|
}
|
|
17097
|
-
if (spokeProvider
|
|
17050
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
17098
17051
|
const userRouter = await SonicSpokeService.getUserRouter(walletAddress, spokeProvider);
|
|
17099
17052
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
17100
17053
|
targetToken,
|
|
@@ -17117,7 +17070,7 @@ var StakingService = class {
|
|
|
17117
17070
|
value: allowanceResult.value
|
|
17118
17071
|
};
|
|
17119
17072
|
}
|
|
17120
|
-
if (spokeProvider
|
|
17073
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
17121
17074
|
return {
|
|
17122
17075
|
ok: true,
|
|
17123
17076
|
value: await StellarSpokeService.hasSufficientTrustline(targetToken, params.amount, spokeProvider)
|
|
@@ -17163,7 +17116,7 @@ var StakingService = class {
|
|
|
17163
17116
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
17164
17117
|
const targetToken = params.action === "stake" || spokeProvider.chainConfig.chain.id !== this.hubProvider.chainConfig.chain.id ? spokeProvider.chainConfig.supportedTokens.SODA?.address : this.hubProvider.chainConfig.addresses.xSoda;
|
|
17165
17118
|
invariant6(targetToken, "Target token not found");
|
|
17166
|
-
if (spokeProvider
|
|
17119
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
17167
17120
|
const result = await Erc20Service.approve(
|
|
17168
17121
|
targetToken,
|
|
17169
17122
|
params.amount,
|
|
@@ -17176,7 +17129,7 @@ var StakingService = class {
|
|
|
17176
17129
|
value: result
|
|
17177
17130
|
};
|
|
17178
17131
|
}
|
|
17179
|
-
if (spokeProvider
|
|
17132
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
17180
17133
|
const userRouter = await SonicSpokeService.getUserRouter(
|
|
17181
17134
|
walletAddress,
|
|
17182
17135
|
spokeProvider
|
|
@@ -17187,7 +17140,7 @@ var StakingService = class {
|
|
|
17187
17140
|
value: result
|
|
17188
17141
|
};
|
|
17189
17142
|
}
|
|
17190
|
-
if (spokeProvider
|
|
17143
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
17191
17144
|
const result = await StellarSpokeService.requestTrustline(targetToken, params.amount, spokeProvider, raw);
|
|
17192
17145
|
return {
|
|
17193
17146
|
ok: true,
|
|
@@ -18832,23 +18785,23 @@ var MigrationService = class {
|
|
|
18832
18785
|
isIcxMigrateParams(params) || isBalnMigrateParams(params) || isUnifiedBnUSDMigrateParams(params),
|
|
18833
18786
|
"Invalid params"
|
|
18834
18787
|
);
|
|
18835
|
-
if (spokeProvider
|
|
18788
|
+
if (isIconSpokeProviderType(spokeProvider) && (isIcxMigrateParams(params) || isBalnMigrateParams(params))) {
|
|
18836
18789
|
return {
|
|
18837
18790
|
ok: true,
|
|
18838
18791
|
value: true
|
|
18839
18792
|
};
|
|
18840
18793
|
}
|
|
18841
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18842
|
-
const
|
|
18794
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18795
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
18843
18796
|
return await Erc20Service.isAllowanceValid(
|
|
18844
18797
|
params.srcbnUSD,
|
|
18845
18798
|
params.amount,
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18799
|
+
walletAddress,
|
|
18800
|
+
isSonicSpokeProviderType(spokeProvider) ? spokeProvider.chainConfig.bnUSD : spokeProvider.chainConfig.addresses.assetManager,
|
|
18801
|
+
spokeProvider
|
|
18849
18802
|
);
|
|
18850
18803
|
}
|
|
18851
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18804
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18852
18805
|
return {
|
|
18853
18806
|
ok: true,
|
|
18854
18807
|
value: await StellarSpokeService.hasSufficientTrustline(params.srcbnUSD, params.amount, spokeProvider)
|
|
@@ -18863,49 +18816,37 @@ var MigrationService = class {
|
|
|
18863
18816
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18864
18817
|
invariant6(params.to.length > 0, "To address is required");
|
|
18865
18818
|
invariant6(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18866
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18867
|
-
const evmSpokeProvider = spokeProvider;
|
|
18819
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18868
18820
|
let spender;
|
|
18869
18821
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18870
|
-
if (spokeProvider
|
|
18871
|
-
spender = await SonicSpokeService.getUserRouter(
|
|
18822
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
18823
|
+
spender = await SonicSpokeService.getUserRouter(
|
|
18824
|
+
wallet,
|
|
18825
|
+
spokeProvider
|
|
18826
|
+
);
|
|
18872
18827
|
} else {
|
|
18873
|
-
spender =
|
|
18828
|
+
spender = spokeProvider.chainConfig.addresses.assetManager;
|
|
18874
18829
|
}
|
|
18875
18830
|
return await Erc20Service.isAllowanceValid(
|
|
18876
18831
|
params.srcbnUSD,
|
|
18877
18832
|
params.amount,
|
|
18878
18833
|
wallet,
|
|
18879
18834
|
spender,
|
|
18880
|
-
|
|
18881
|
-
);
|
|
18882
|
-
}
|
|
18883
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
|
|
18884
|
-
const evmSpokeProvider = spokeProvider;
|
|
18885
|
-
let spender;
|
|
18886
|
-
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18887
|
-
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
18888
|
-
spender = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
18889
|
-
} else {
|
|
18890
|
-
spender = evmSpokeProvider.chainConfig.addresses.assetManager;
|
|
18891
|
-
}
|
|
18892
|
-
return await Erc20Service.isAllowanceValid(
|
|
18893
|
-
params.srcbnUSD,
|
|
18894
|
-
params.amount,
|
|
18895
|
-
wallet,
|
|
18896
|
-
spender,
|
|
18897
|
-
evmSpokeProvider
|
|
18835
|
+
spokeProvider
|
|
18898
18836
|
);
|
|
18899
18837
|
}
|
|
18900
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18838
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18901
18839
|
return {
|
|
18902
18840
|
ok: true,
|
|
18903
18841
|
value: await StellarSpokeService.hasSufficientTrustline(params.srcbnUSD, params.amount, spokeProvider)
|
|
18904
18842
|
};
|
|
18905
18843
|
}
|
|
18906
|
-
if (spokeProvider
|
|
18844
|
+
if (isSonicSpokeProviderType(spokeProvider) && isIcxCreateRevertMigrationParams(params)) {
|
|
18907
18845
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18908
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18846
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18847
|
+
wallet,
|
|
18848
|
+
spokeProvider
|
|
18849
|
+
);
|
|
18909
18850
|
return await Erc20Service.isAllowanceValid(
|
|
18910
18851
|
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
18911
18852
|
params.amount,
|
|
@@ -18951,13 +18892,12 @@ var MigrationService = class {
|
|
|
18951
18892
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18952
18893
|
invariant6(params.to.length > 0, "To address is required");
|
|
18953
18894
|
invariant6(isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18954
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18955
|
-
const evmSpokeProvider = spokeProvider;
|
|
18895
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18956
18896
|
const result = await Erc20Service.approve(
|
|
18957
18897
|
params.srcbnUSD,
|
|
18958
18898
|
params.amount,
|
|
18959
|
-
|
|
18960
|
-
|
|
18899
|
+
isSonicSpokeProviderType(spokeProvider) ? spokeProvider.chainConfig.bnUSD : spokeProvider.chainConfig.addresses.assetManager,
|
|
18900
|
+
spokeProvider,
|
|
18961
18901
|
raw
|
|
18962
18902
|
);
|
|
18963
18903
|
return {
|
|
@@ -18965,7 +18905,7 @@ var MigrationService = class {
|
|
|
18965
18905
|
value: result
|
|
18966
18906
|
};
|
|
18967
18907
|
}
|
|
18968
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18908
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18969
18909
|
const result = await StellarSpokeService.requestTrustline(params.srcbnUSD, params.amount, spokeProvider, raw);
|
|
18970
18910
|
return {
|
|
18971
18911
|
ok: true,
|
|
@@ -18981,20 +18921,22 @@ var MigrationService = class {
|
|
|
18981
18921
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18982
18922
|
invariant6(params.to.length > 0, "To address is required");
|
|
18983
18923
|
invariant6(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18984
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18985
|
-
const evmSpokeProvider = spokeProvider;
|
|
18924
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18986
18925
|
let spender;
|
|
18987
18926
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18988
|
-
if (spokeProvider
|
|
18989
|
-
spender = await SonicSpokeService.getUserRouter(
|
|
18927
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
18928
|
+
spender = await SonicSpokeService.getUserRouter(
|
|
18929
|
+
wallet,
|
|
18930
|
+
spokeProvider
|
|
18931
|
+
);
|
|
18990
18932
|
} else {
|
|
18991
|
-
spender =
|
|
18933
|
+
spender = spokeProvider.chainConfig.addresses.assetManager;
|
|
18992
18934
|
}
|
|
18993
18935
|
const result = await Erc20Service.approve(
|
|
18994
18936
|
params.srcbnUSD,
|
|
18995
18937
|
params.amount,
|
|
18996
18938
|
spender,
|
|
18997
|
-
|
|
18939
|
+
spokeProvider,
|
|
18998
18940
|
raw
|
|
18999
18941
|
);
|
|
19000
18942
|
return {
|
|
@@ -19002,16 +18944,19 @@ var MigrationService = class {
|
|
|
19002
18944
|
value: result
|
|
19003
18945
|
};
|
|
19004
18946
|
}
|
|
19005
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18947
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
19006
18948
|
const result = await StellarSpokeService.requestTrustline(params.srcbnUSD, params.amount, spokeProvider, raw);
|
|
19007
18949
|
return {
|
|
19008
18950
|
ok: true,
|
|
19009
18951
|
value: result
|
|
19010
18952
|
};
|
|
19011
18953
|
}
|
|
19012
|
-
if (spokeProvider
|
|
18954
|
+
if (isSonicSpokeProviderType(spokeProvider) && isIcxCreateRevertMigrationParams(params)) {
|
|
19013
18955
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
19014
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18956
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18957
|
+
wallet,
|
|
18958
|
+
spokeProvider
|
|
18959
|
+
);
|
|
19015
18960
|
const result = await Erc20Service.approve(
|
|
19016
18961
|
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
19017
18962
|
params.amount,
|
|
@@ -19084,7 +19029,7 @@ var MigrationService = class {
|
|
|
19084
19029
|
*/
|
|
19085
19030
|
async migratebnUSD(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT, unchecked = false) {
|
|
19086
19031
|
try {
|
|
19087
|
-
const intentResult = await this.createMigratebnUSDIntent(params, spokeProvider, unchecked);
|
|
19032
|
+
const intentResult = await this.createMigratebnUSDIntent(params, spokeProvider, unchecked, false);
|
|
19088
19033
|
if (!intentResult.ok) {
|
|
19089
19034
|
return {
|
|
19090
19035
|
ok: false,
|
|
@@ -19171,7 +19116,7 @@ var MigrationService = class {
|
|
|
19171
19116
|
*/
|
|
19172
19117
|
async migrateIcxToSoda(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
19173
19118
|
try {
|
|
19174
|
-
const txResult = await this.createMigrateIcxToSodaIntent(params, spokeProvider);
|
|
19119
|
+
const txResult = await this.createMigrateIcxToSodaIntent(params, spokeProvider, false);
|
|
19175
19120
|
if (!txResult.ok) {
|
|
19176
19121
|
return {
|
|
19177
19122
|
ok: false,
|
|
@@ -19235,7 +19180,7 @@ var MigrationService = class {
|
|
|
19235
19180
|
*/
|
|
19236
19181
|
async revertMigrateSodaToIcx(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
19237
19182
|
try {
|
|
19238
|
-
const txResult = await this.createRevertSodaToIcxMigrationIntent(params, spokeProvider);
|
|
19183
|
+
const txResult = await this.createRevertSodaToIcxMigrationIntent(params, spokeProvider, false);
|
|
19239
19184
|
if (!txResult.ok) {
|
|
19240
19185
|
return txResult;
|
|
19241
19186
|
}
|
|
@@ -19298,7 +19243,7 @@ var MigrationService = class {
|
|
|
19298
19243
|
*/
|
|
19299
19244
|
async migrateBaln(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
19300
19245
|
try {
|
|
19301
|
-
const txResult = await this.createMigrateBalnIntent(params, spokeProvider);
|
|
19246
|
+
const txResult = await this.createMigrateBalnIntent(params, spokeProvider, false);
|
|
19302
19247
|
if (!txResult.ok) {
|
|
19303
19248
|
return {
|
|
19304
19249
|
ok: false,
|
|
@@ -19561,7 +19506,7 @@ var MigrationService = class {
|
|
|
19561
19506
|
params.address.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.address.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
19562
19507
|
"Token must be wICX or native ICX token"
|
|
19563
19508
|
);
|
|
19564
|
-
invariant6(spokeProvider
|
|
19509
|
+
invariant6(isIconSpokeProviderType(spokeProvider), "Spoke provider must be an IconSpokeProviderType");
|
|
19565
19510
|
const availableAmount = await this.icxMigration.getAvailableAmount();
|
|
19566
19511
|
if (availableAmount < params.amount) {
|
|
19567
19512
|
throw new Error(
|
|
@@ -19619,7 +19564,10 @@ var MigrationService = class {
|
|
|
19619
19564
|
async createRevertSodaToIcxMigrationIntent(params, spokeProvider, raw) {
|
|
19620
19565
|
try {
|
|
19621
19566
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
19622
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
19567
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
19568
|
+
wallet,
|
|
19569
|
+
spokeProvider
|
|
19570
|
+
);
|
|
19623
19571
|
const wICX = this.configService.spokeChainConfig[ICON_MAINNET_CHAIN_ID]?.addresses.wICX;
|
|
19624
19572
|
invariant6(wICX, "wICX token not found");
|
|
19625
19573
|
const data = this.icxMigration.revertMigration({
|
|
@@ -20020,6 +19968,6 @@ var BalnSwapService = class {
|
|
|
20020
19968
|
}
|
|
20021
19969
|
};
|
|
20022
19970
|
|
|
20023
|
-
export { BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, BridgeService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, Erc20Service, EvmAssetManagerService, EvmBaseSpokeProvider, EvmHubProvider, EvmRawSpokeProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, ICON_TX_RESULT_WAIT_MAX_RETRY, IconBaseSpokeProvider, IconRawSpokeProvider, IconSpokeProvider, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveBaseSpokeProvider, InjectiveRawSpokeProvider, InjectiveSpokeProvider, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataType, IntentFilledEventAbi, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaBaseSpokeProvider, SolanaRawSpokeProvider, SolanaSpokeProvider, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicBaseSpokeProvider, SonicRawSpokeProvider, SonicSpokeProvider, SonicSpokeService, SpokeService, StakingLogic, StakingService, StellarBaseSpokeProvider, StellarRawSpokeProvider, StellarSpokeProvider, StellarSpokeService, SuiBaseSpokeProvider, SuiRawSpokeProvider, SuiSpokeProvider, SuiSpokeService, SupportedMigrationTokens, SwapService, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, connectionAbi, convertTransactionInstructionToRaw, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubChainConfig, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, isBalnMigrateParams, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmRawSpokeProvider, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmSpokeProviderType, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconRawSpokeProvider, isIconSpokeProvider, isIconSpokeProviderType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveRawSpokeProvider, isInjectiveSpokeProvider, isInjectiveSpokeProviderType, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketWithdrawUnknownError, isNewbnUSDChainId, isNewbnUSDToken, isPartnerFeeAmount, isPartnerFeePercentage, isRawSpokeProvider, isResponseAddressType, isResponseSigningType, isSolanaNativeToken, isSolanaRawSpokeProvider, isSolanaSpokeProvider, isSolanaSpokeProviderType, isSonicRawSpokeProvider, isSonicSpokeProvider, isSonicSpokeProviderType, isStellarRawSpokeProvider, isStellarSpokeProvider, isStellarSpokeProviderType, isSuiRawSpokeProvider, isSuiSpokeProvider, isSuiSpokeProviderType, isUnifiedBnUSDMigrateParams, isWaitUntilIntentExecutedFailed, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, parseToStroops, parseTokenArrayFromJson, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sleep, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingRouterAbi, submitTransaction, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
19971
|
+
export { BackendApiService, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BnUSDMigrationService, BridgeService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, Erc20Service, EvmAssetManagerService, EvmBaseSpokeProvider, EvmHubProvider, EvmRawSpokeProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HALF_RAY, HALF_WAD, HubService, ICON_TX_RESULT_WAIT_MAX_RETRY, IconBaseSpokeProvider, IconRawSpokeProvider, IconSpokeProvider, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveBaseSpokeProvider, InjectiveRawSpokeProvider, InjectiveSpokeProvider, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataType, IntentFilledEventAbi, IntentsAbi, LTV_PRECISION, LendingPoolService, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketDataService, MoneyMarketService, RAY, RAY_DECIMALS, SECONDS_PER_YEAR, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaBaseSpokeProvider, SolanaRawSpokeProvider, SolanaSpokeProvider, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicBaseSpokeProvider, SonicRawSpokeProvider, SonicSpokeProvider, SonicSpokeService, SpokeService, StakingLogic, StakingService, StellarBaseSpokeProvider, StellarRawSpokeProvider, StellarSpokeProvider, StellarSpokeService, SuiBaseSpokeProvider, SuiRawSpokeProvider, SuiSpokeProvider, SuiSpokeService, SupportedMigrationTokens, SwapService, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, WalletAbstractionService, adjustAmountByFee, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bnUSDNewTokens, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, connectionAbi, convertTransactionInstructionToRaw, deriveUserWalletAddress, encodeAddress, encodeContractCalls, erc20Abi, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getCompoundedBalance, getEvmViemChain, getHubChainConfig, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, isBalnMigrateParams, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmRawSpokeProvider, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmSpokeProviderType, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isHubSpokeProvider, isIconAddress, isIconRawSpokeProvider, isIconSpokeProvider, isIconSpokeProviderType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveRawSpokeProvider, isInjectiveSpokeProvider, isInjectiveSpokeProviderType, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketWithdrawUnknownError, isNewbnUSDChainId, isNewbnUSDToken, isPartnerFeeAmount, isPartnerFeePercentage, isRawSpokeProvider, isResponseAddressType, isResponseSigningType, isSolanaNativeToken, isSolanaRawSpokeProvider, isSolanaSpokeProvider, isSolanaSpokeProviderType, isSonicRawSpokeProvider, isSonicSpokeProvider, isSonicSpokeProviderType, isStellarRawSpokeProvider, isStellarSpokeProvider, isStellarSpokeProviderType, isSuiRawSpokeProvider, isSuiSpokeProvider, isSuiSpokeProviderType, isUnifiedBnUSDMigrateParams, isWaitUntilIntentExecutedFailed, nativeToUSD, newbnUSDSpokeChainIds, normalize, normalizeBN, normalizedToUsd, parseToStroops, parseTokenArrayFromJson, poolAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sleep, sonicWalletFactoryAbi, spokeAssetManagerAbi, stakedSodaAbi, stakingRouterAbi, submitTransaction, uiPoolDataAbi, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, wadToRay, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
20024
19972
|
//# sourceMappingURL=index.mjs.map
|
|
20025
19973
|
//# sourceMappingURL=index.mjs.map
|