@sodax/sdk 0.0.1-rc.23 → 0.0.1-rc.25
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 +406 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -7
- package/dist/index.d.ts +67 -7
- package/dist/index.mjs +406 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6303,6 +6303,7 @@ var hubChainConfig = {
|
|
|
6303
6303
|
sodaToken: "0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
|
|
6304
6304
|
},
|
|
6305
6305
|
nativeToken: "0x0000000000000000000000000000000000000000",
|
|
6306
|
+
wrappedNativeToken: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
6306
6307
|
supportedTokens: []
|
|
6307
6308
|
}
|
|
6308
6309
|
};
|
|
@@ -6799,6 +6800,7 @@ var spokeChainConfig = {
|
|
|
6799
6800
|
[SUI_MAINNET_CHAIN_ID]: {
|
|
6800
6801
|
addresses: {
|
|
6801
6802
|
connection: "0xf3b1e696a66d02cb776dc15aae73c68bc8f03adcb6ba0ec7f6332d9d90a6a3d2::connectionv3::0x3ee76d13909ac58ae13baab4c9be5a5142818d9a387aed641825e5d4356969bf",
|
|
6803
|
+
assetManagerId: "0xa17a409164d1676db71b411ab50813ba2c7dd547d2df538c699049566f1ff922::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
|
|
6802
6804
|
assetManager: "0x897f911a4b7691870a1a2513af7e85fdee8de275615c77068fd8b90b8e78c678::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
|
|
6803
6805
|
xTokenManager: "",
|
|
6804
6806
|
rateLimit: "",
|
|
@@ -7162,7 +7164,7 @@ var getAllLegacybnUSDTokens = () => {
|
|
|
7162
7164
|
var hubAssets = {
|
|
7163
7165
|
[SONIC_MAINNET_CHAIN_ID]: {
|
|
7164
7166
|
[spokeChainConfig[SONIC_MAINNET_CHAIN_ID].nativeToken]: {
|
|
7165
|
-
asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.
|
|
7167
|
+
asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.S.address,
|
|
7166
7168
|
decimal: 18,
|
|
7167
7169
|
symbol: "S",
|
|
7168
7170
|
name: "Sonic",
|
|
@@ -9222,6 +9224,32 @@ var EvmSpokeService = class _EvmSpokeService {
|
|
|
9222
9224
|
args: [token]
|
|
9223
9225
|
});
|
|
9224
9226
|
}
|
|
9227
|
+
/**
|
|
9228
|
+
* Generate simulation parameters for deposit from EvmSpokeDepositParams.
|
|
9229
|
+
* @param {EvmSpokeDepositParams} params - The deposit parameters.
|
|
9230
|
+
* @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9231
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9232
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9233
|
+
*/
|
|
9234
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9235
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9236
|
+
spokeProvider.chainConfig.chain.id,
|
|
9237
|
+
params.from,
|
|
9238
|
+
hubProvider
|
|
9239
|
+
);
|
|
9240
|
+
return {
|
|
9241
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9242
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9243
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9244
|
+
to,
|
|
9245
|
+
amount: params.amount,
|
|
9246
|
+
data: params.data,
|
|
9247
|
+
srcAddress: encodeAddress(
|
|
9248
|
+
spokeProvider.chainConfig.chain.id,
|
|
9249
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9250
|
+
)
|
|
9251
|
+
};
|
|
9252
|
+
}
|
|
9225
9253
|
/**
|
|
9226
9254
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9227
9255
|
* @param {HubAddress} from - The address of the user on the hub chain.
|
|
@@ -9344,6 +9372,32 @@ var InjectiveSpokeService = class _InjectiveSpokeService {
|
|
|
9344
9372
|
raw
|
|
9345
9373
|
);
|
|
9346
9374
|
}
|
|
9375
|
+
/**
|
|
9376
|
+
* Generate simulation parameters for deposit from InjectiveSpokeDepositParams.
|
|
9377
|
+
* @param {InjectiveSpokeDepositParams} params - The deposit parameters.
|
|
9378
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9379
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9380
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9381
|
+
*/
|
|
9382
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9383
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9384
|
+
spokeProvider.chainConfig.chain.id,
|
|
9385
|
+
toHex(Buffer.from(params.from, "utf-8")),
|
|
9386
|
+
hubProvider
|
|
9387
|
+
);
|
|
9388
|
+
return {
|
|
9389
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9390
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9391
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9392
|
+
to,
|
|
9393
|
+
amount: params.amount,
|
|
9394
|
+
data: params.data,
|
|
9395
|
+
srcAddress: encodeAddress(
|
|
9396
|
+
spokeProvider.chainConfig.chain.id,
|
|
9397
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9398
|
+
)
|
|
9399
|
+
};
|
|
9400
|
+
}
|
|
9347
9401
|
/**
|
|
9348
9402
|
* Get the balance of the token that deposited in the spoke chain Asset Manager.
|
|
9349
9403
|
* @param {Address} token - The address of the token to get the balance of.
|
|
@@ -9481,6 +9535,32 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
9481
9535
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9482
9536
|
return _IconSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
9483
9537
|
}
|
|
9538
|
+
/**
|
|
9539
|
+
* Generate simulation parameters for deposit from IconSpokeDepositParams.
|
|
9540
|
+
* @param {IconSpokeDepositParams} params - The deposit parameters.
|
|
9541
|
+
* @param {IconSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9542
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9543
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9544
|
+
*/
|
|
9545
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9546
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9547
|
+
spokeProvider.chainConfig.chain.id,
|
|
9548
|
+
getIconAddressBytes(params.from),
|
|
9549
|
+
hubProvider
|
|
9550
|
+
);
|
|
9551
|
+
return {
|
|
9552
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9553
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9554
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9555
|
+
to,
|
|
9556
|
+
amount: params.amount,
|
|
9557
|
+
data: params.data,
|
|
9558
|
+
srcAddress: encodeAddress(
|
|
9559
|
+
spokeProvider.chainConfig.chain.id,
|
|
9560
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9561
|
+
)
|
|
9562
|
+
};
|
|
9563
|
+
}
|
|
9484
9564
|
/**
|
|
9485
9565
|
* Transfers tokens to the hub chain.
|
|
9486
9566
|
*/
|
|
@@ -9681,6 +9761,32 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9681
9761
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9682
9762
|
return _SolanaSpokeService.call(BigInt(relayId), from, keccak256(payload), spokeProvider, raw);
|
|
9683
9763
|
}
|
|
9764
|
+
/**
|
|
9765
|
+
* Generate simulation parameters for deposit from SolanaSpokeDepositParams.
|
|
9766
|
+
* @param {SolanaSpokeDepositParams} params - The deposit parameters.
|
|
9767
|
+
* @param {SolanaSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9768
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9769
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9770
|
+
*/
|
|
9771
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9772
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9773
|
+
spokeProvider.chainConfig.chain.id,
|
|
9774
|
+
encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9775
|
+
hubProvider
|
|
9776
|
+
);
|
|
9777
|
+
return {
|
|
9778
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9779
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9780
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9781
|
+
to,
|
|
9782
|
+
amount: params.amount,
|
|
9783
|
+
data: params.data,
|
|
9784
|
+
srcAddress: encodeAddress(
|
|
9785
|
+
spokeProvider.chainConfig.chain.id,
|
|
9786
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9787
|
+
)
|
|
9788
|
+
};
|
|
9789
|
+
}
|
|
9684
9790
|
static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
|
|
9685
9791
|
let depositInstruction;
|
|
9686
9792
|
const amountBN = new BN(amount);
|
|
@@ -9849,6 +9955,32 @@ var StellarSpokeService = class _StellarSpokeService {
|
|
|
9849
9955
|
static async getDeposit(token, spokeProvider) {
|
|
9850
9956
|
return BigInt(await spokeProvider.getBalance(token));
|
|
9851
9957
|
}
|
|
9958
|
+
/**
|
|
9959
|
+
* Generate simulation parameters for deposit from StellarSpokeDepositParams.
|
|
9960
|
+
* @param {StellarSpokeDepositParams} params - The deposit parameters.
|
|
9961
|
+
* @param {StellarSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9962
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9963
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9964
|
+
*/
|
|
9965
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9966
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9967
|
+
spokeProvider.chainConfig.chain.id,
|
|
9968
|
+
params.from,
|
|
9969
|
+
hubProvider
|
|
9970
|
+
);
|
|
9971
|
+
return {
|
|
9972
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9973
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9974
|
+
from: params.from,
|
|
9975
|
+
to,
|
|
9976
|
+
amount: params.amount,
|
|
9977
|
+
data: params.data,
|
|
9978
|
+
srcAddress: encodeAddress(
|
|
9979
|
+
spokeProvider.chainConfig.chain.id,
|
|
9980
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9981
|
+
)
|
|
9982
|
+
};
|
|
9983
|
+
}
|
|
9852
9984
|
/**
|
|
9853
9985
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9854
9986
|
* @param from - The address of the user on the hub chain.
|
|
@@ -9931,6 +10063,30 @@ var SuiSpokeService = class _SuiSpokeService {
|
|
|
9931
10063
|
static async getDeposit(token, spokeProvider) {
|
|
9932
10064
|
return spokeProvider.getBalance(token);
|
|
9933
10065
|
}
|
|
10066
|
+
/**
|
|
10067
|
+
* Generate simulation parameters for deposit from SuiSpokeDepositParams.
|
|
10068
|
+
* @param {SuiSpokeDepositParams} params - The deposit parameters.
|
|
10069
|
+
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
10070
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10071
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
10072
|
+
*/
|
|
10073
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
10074
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
10075
|
+
spokeProvider.chainConfig.chain.id,
|
|
10076
|
+
params.from,
|
|
10077
|
+
hubProvider
|
|
10078
|
+
);
|
|
10079
|
+
const encoder = new TextEncoder();
|
|
10080
|
+
return {
|
|
10081
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
10082
|
+
token: toHex(encoder.encode(params.token)),
|
|
10083
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
10084
|
+
to,
|
|
10085
|
+
amount: params.amount,
|
|
10086
|
+
data: params.data,
|
|
10087
|
+
srcAddress: toHex(encoder.encode(spokeProvider.chainConfig.addresses.assetManagerId))
|
|
10088
|
+
};
|
|
10089
|
+
}
|
|
9934
10090
|
/**
|
|
9935
10091
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9936
10092
|
* @param {HubAddress} from - The address of the user on the spoke chain.
|
|
@@ -10044,7 +10200,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10044
10200
|
params.data
|
|
10045
10201
|
)[0]
|
|
10046
10202
|
);
|
|
10047
|
-
if (params.token === spokeProvider.chainConfig.nativeToken) {
|
|
10203
|
+
if (params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10048
10204
|
const wrapCall = {
|
|
10049
10205
|
address: spokeProvider.chainConfig.addresses.wrappedSonic,
|
|
10050
10206
|
value: params.amount,
|
|
@@ -10078,7 +10234,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10078
10234
|
from: params.from,
|
|
10079
10235
|
to: spokeProvider.chainConfig.addresses.walletRouter,
|
|
10080
10236
|
data: txData,
|
|
10081
|
-
value: params.token === spokeProvider.chainConfig.nativeToken ? params.amount : 0n
|
|
10237
|
+
value: params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? params.amount : 0n
|
|
10082
10238
|
};
|
|
10083
10239
|
if (raw) {
|
|
10084
10240
|
return rawTx;
|
|
@@ -10293,12 +10449,16 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10293
10449
|
}
|
|
10294
10450
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
10295
10451
|
}
|
|
10296
|
-
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
|
|
10297
|
-
const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10452
|
+
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
|
|
10453
|
+
const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10454
|
+
let token = withdrawInfo.token;
|
|
10455
|
+
if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10456
|
+
token = spokeProvider.chainConfig.addresses.wrappedSonic;
|
|
10457
|
+
}
|
|
10298
10458
|
const withdrawCall = moneyMarketService.buildWithdrawData(
|
|
10299
10459
|
userRouter,
|
|
10300
10460
|
from,
|
|
10301
|
-
|
|
10461
|
+
token,
|
|
10302
10462
|
amount,
|
|
10303
10463
|
spokeProvider.chainConfig.chain.id
|
|
10304
10464
|
);
|
|
@@ -10316,17 +10476,6 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10316
10476
|
],
|
|
10317
10477
|
withdrawCall
|
|
10318
10478
|
)[0];
|
|
10319
|
-
const transferFromCall = Erc20Service.encodeTransferFrom(
|
|
10320
|
-
withdrawInfo.aTokenAddress,
|
|
10321
|
-
from,
|
|
10322
|
-
userRouter,
|
|
10323
|
-
withdrawInfo.aTokenAmount
|
|
10324
|
-
);
|
|
10325
|
-
calls.unshift({
|
|
10326
|
-
address: transferFromCall.address,
|
|
10327
|
-
value: transferFromCall.value,
|
|
10328
|
-
data: transferFromCall.data
|
|
10329
|
-
});
|
|
10330
10479
|
return encodeContractCalls(calls);
|
|
10331
10480
|
}
|
|
10332
10481
|
};
|
|
@@ -10453,9 +10602,7 @@ function isBalnMigrateParams(value) {
|
|
|
10453
10602
|
function isIcxCreateRevertMigrationParams(value) {
|
|
10454
10603
|
return typeof value === "object" && value !== null && "amount" in value && "to" in value;
|
|
10455
10604
|
}
|
|
10456
|
-
|
|
10457
|
-
// src/services/spoke/SpokeService.ts
|
|
10458
|
-
var SpokeService = class {
|
|
10605
|
+
var SpokeService = class _SpokeService {
|
|
10459
10606
|
constructor() {
|
|
10460
10607
|
}
|
|
10461
10608
|
/**
|
|
@@ -10509,14 +10656,99 @@ var SpokeService = class {
|
|
|
10509
10656
|
}
|
|
10510
10657
|
throw new Error("Invalid spoke provider");
|
|
10511
10658
|
}
|
|
10659
|
+
/**
|
|
10660
|
+
|
|
10661
|
+
* Encodes transfer data using RLP encoding to match Solidity Transfer struct.
|
|
10662
|
+
* @param {Hex} token - The token contract address.
|
|
10663
|
+
* @param {Hex} from - The sender address.
|
|
10664
|
+
* @param {Hex} to - The recipient address.
|
|
10665
|
+
* @param {bigint} amount - The transfer amount.
|
|
10666
|
+
* @param {Hex} data - The encoded data payload.
|
|
10667
|
+
* @returns {Promise<Hex>} A promise that resolves to the RLP encoded transfer data.
|
|
10668
|
+
*/
|
|
10669
|
+
static encodeTransfer(token, from, to, amount, data) {
|
|
10670
|
+
const rlpInput = [
|
|
10671
|
+
token,
|
|
10672
|
+
// token (bytes)
|
|
10673
|
+
from,
|
|
10674
|
+
// from (bytes)
|
|
10675
|
+
to,
|
|
10676
|
+
// to (bytes)
|
|
10677
|
+
amount,
|
|
10678
|
+
// amount (uint256)
|
|
10679
|
+
data
|
|
10680
|
+
// data (bytes)
|
|
10681
|
+
];
|
|
10682
|
+
const rlpEncodedData = rlp.encode(rlpInput);
|
|
10683
|
+
return `0x${Buffer.from(rlpEncodedData).toString("hex")}`;
|
|
10684
|
+
}
|
|
10685
|
+
static async simulateDeposit(params, hubProvider) {
|
|
10686
|
+
const chainId = getIntentRelayChainId(params.spokeChainID);
|
|
10687
|
+
const hubAssetManager = hubProvider.chainConfig.addresses.assetManager;
|
|
10688
|
+
const payload = _SpokeService.encodeTransfer(params.token, params.from, params.to, params.amount, params.data);
|
|
10689
|
+
return _SpokeService.simulateRecvMessage(
|
|
10690
|
+
{ target: hubAssetManager, srcChainId: chainId, srcAddress: params.srcAddress, payload },
|
|
10691
|
+
hubProvider
|
|
10692
|
+
);
|
|
10693
|
+
}
|
|
10694
|
+
/**
|
|
10695
|
+
* Simulates receiving a message without signature verification.
|
|
10696
|
+
* This function calls simulateRecvMessage which always reverts with 'Simulation completed'.
|
|
10697
|
+
* @param {bigint} srcChainId - The chain ID of the originating chain.
|
|
10698
|
+
* @param {Hex} srcAddress - The address of the sender on the originating chain.
|
|
10699
|
+
* @param {Hex} payload - The encoded payload containing call data (from encodeTransfer).
|
|
10700
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10701
|
+
* @returns {Promise<{ success: boolean; error?: string }>} Result of the simulation.
|
|
10702
|
+
*/
|
|
10703
|
+
static async simulateRecvMessage(params, hubProvider) {
|
|
10704
|
+
try {
|
|
10705
|
+
const result = await hubProvider.publicClient.call({
|
|
10706
|
+
to: params.target,
|
|
10707
|
+
data: encodeFunctionData({
|
|
10708
|
+
abi: [
|
|
10709
|
+
{
|
|
10710
|
+
name: "simulateRecvMessage",
|
|
10711
|
+
type: "function",
|
|
10712
|
+
stateMutability: "nonpayable",
|
|
10713
|
+
inputs: [
|
|
10714
|
+
{ name: "srcChainId", type: "uint256" },
|
|
10715
|
+
{ name: "srcAddress", type: "bytes" },
|
|
10716
|
+
{ name: "payload", type: "bytes" }
|
|
10717
|
+
],
|
|
10718
|
+
outputs: []
|
|
10719
|
+
}
|
|
10720
|
+
],
|
|
10721
|
+
functionName: "simulateRecvMessage",
|
|
10722
|
+
args: [params.srcChainId, params.srcAddress, params.payload]
|
|
10723
|
+
})
|
|
10724
|
+
});
|
|
10725
|
+
console.warn("simulateRecvMessage did not revert as expected", { result });
|
|
10726
|
+
return {
|
|
10727
|
+
success: false,
|
|
10728
|
+
error: 'Function should have reverted with "Simulation completed"'
|
|
10729
|
+
};
|
|
10730
|
+
} catch (error) {
|
|
10731
|
+
if (error instanceof Error && error.message?.includes("Simulation completed")) {
|
|
10732
|
+
console.warn("simulateRecvMessage completed successfully with expected revert");
|
|
10733
|
+
return { success: true };
|
|
10734
|
+
}
|
|
10735
|
+
console.error("simulateRecvMessage failed with unexpected error:", error);
|
|
10736
|
+
return {
|
|
10737
|
+
success: false,
|
|
10738
|
+
error: error instanceof Error ? error.message || "Unknown simulation error" : "Unknown simulation error"
|
|
10739
|
+
};
|
|
10740
|
+
}
|
|
10741
|
+
}
|
|
10512
10742
|
/**
|
|
10513
10743
|
* Deposit tokens to the spoke chain.
|
|
10514
10744
|
* @param {GetSpokeDepositParamsType<T extends SpokeProvider>} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
10515
10745
|
* @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
10516
10746
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10747
|
+
* @param {boolean} raw - Whether to return raw transaction data.
|
|
10748
|
+
* @param {boolean} skipSimulation - Whether to skip deposit simulation (optional, defaults to false).
|
|
10517
10749
|
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
10518
10750
|
*/
|
|
10519
|
-
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
10751
|
+
static async deposit(params, spokeProvider, hubProvider, raw, skipSimulation = false) {
|
|
10520
10752
|
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
10521
10753
|
return SonicSpokeService.deposit(
|
|
10522
10754
|
params,
|
|
@@ -10525,6 +10757,7 @@ var SpokeService = class {
|
|
|
10525
10757
|
);
|
|
10526
10758
|
}
|
|
10527
10759
|
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
10760
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10528
10761
|
return EvmSpokeService.deposit(
|
|
10529
10762
|
params,
|
|
10530
10763
|
spokeProvider,
|
|
@@ -10533,14 +10766,11 @@ var SpokeService = class {
|
|
|
10533
10766
|
);
|
|
10534
10767
|
}
|
|
10535
10768
|
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
spokeProvider,
|
|
10539
|
-
hubProvider,
|
|
10540
|
-
raw
|
|
10541
|
-
);
|
|
10769
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10770
|
+
return InjectiveSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
10542
10771
|
}
|
|
10543
10772
|
if (spokeProvider instanceof IconSpokeProvider) {
|
|
10773
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10544
10774
|
return IconSpokeService.deposit(
|
|
10545
10775
|
params,
|
|
10546
10776
|
spokeProvider,
|
|
@@ -10549,6 +10779,7 @@ var SpokeService = class {
|
|
|
10549
10779
|
);
|
|
10550
10780
|
}
|
|
10551
10781
|
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
10782
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10552
10783
|
return SuiSpokeService.deposit(
|
|
10553
10784
|
params,
|
|
10554
10785
|
spokeProvider,
|
|
@@ -10557,6 +10788,7 @@ var SpokeService = class {
|
|
|
10557
10788
|
);
|
|
10558
10789
|
}
|
|
10559
10790
|
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
10791
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10560
10792
|
return SolanaSpokeService.deposit(
|
|
10561
10793
|
params,
|
|
10562
10794
|
spokeProvider,
|
|
@@ -10565,6 +10797,7 @@ var SpokeService = class {
|
|
|
10565
10797
|
);
|
|
10566
10798
|
}
|
|
10567
10799
|
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
10800
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10568
10801
|
return StellarSpokeService.deposit(
|
|
10569
10802
|
params,
|
|
10570
10803
|
spokeProvider,
|
|
@@ -10574,6 +10807,60 @@ var SpokeService = class {
|
|
|
10574
10807
|
}
|
|
10575
10808
|
throw new Error("Invalid spoke provider");
|
|
10576
10809
|
}
|
|
10810
|
+
static getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
10811
|
+
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
10812
|
+
return EvmSpokeService.getSimulateDepositParams(
|
|
10813
|
+
params,
|
|
10814
|
+
spokeProvider,
|
|
10815
|
+
hubProvider
|
|
10816
|
+
);
|
|
10817
|
+
}
|
|
10818
|
+
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10819
|
+
return InjectiveSpokeService.getSimulateDepositParams(
|
|
10820
|
+
params,
|
|
10821
|
+
spokeProvider,
|
|
10822
|
+
hubProvider
|
|
10823
|
+
);
|
|
10824
|
+
}
|
|
10825
|
+
if (spokeProvider instanceof IconSpokeProvider) {
|
|
10826
|
+
return IconSpokeService.getSimulateDepositParams(
|
|
10827
|
+
params,
|
|
10828
|
+
spokeProvider,
|
|
10829
|
+
hubProvider
|
|
10830
|
+
);
|
|
10831
|
+
}
|
|
10832
|
+
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
10833
|
+
return SuiSpokeService.getSimulateDepositParams(
|
|
10834
|
+
params,
|
|
10835
|
+
spokeProvider,
|
|
10836
|
+
hubProvider
|
|
10837
|
+
);
|
|
10838
|
+
}
|
|
10839
|
+
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
10840
|
+
return SolanaSpokeService.getSimulateDepositParams(
|
|
10841
|
+
params,
|
|
10842
|
+
spokeProvider,
|
|
10843
|
+
hubProvider
|
|
10844
|
+
);
|
|
10845
|
+
}
|
|
10846
|
+
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
10847
|
+
return StellarSpokeService.getSimulateDepositParams(
|
|
10848
|
+
params,
|
|
10849
|
+
spokeProvider,
|
|
10850
|
+
hubProvider
|
|
10851
|
+
);
|
|
10852
|
+
}
|
|
10853
|
+
throw new Error("Invalid spoke provider");
|
|
10854
|
+
}
|
|
10855
|
+
static async verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation) {
|
|
10856
|
+
if (!skipSimulation) {
|
|
10857
|
+
const simulationParams = await _SpokeService.getSimulateDepositParams(params, spokeProvider, hubProvider);
|
|
10858
|
+
const result = await _SpokeService.simulateDeposit(simulationParams, hubProvider);
|
|
10859
|
+
if (!result.success) {
|
|
10860
|
+
throw new Error("Simulation failed", { cause: result });
|
|
10861
|
+
}
|
|
10862
|
+
}
|
|
10863
|
+
}
|
|
10577
10864
|
/**
|
|
10578
10865
|
* Get the balance of the token in the spoke chain.
|
|
10579
10866
|
* @param {Address} token - The address of the token to get the balance of.
|
|
@@ -10612,14 +10899,16 @@ var SpokeService = class {
|
|
|
10612
10899
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10613
10900
|
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
10614
10901
|
*/
|
|
10615
|
-
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
10902
|
+
static async callWallet(from, payload, spokeProvider, hubProvider, raw, skipSimulation = false) {
|
|
10616
10903
|
if (isSonicSpokeProvider(spokeProvider)) {
|
|
10617
10904
|
return await SonicSpokeService.callWallet(payload, spokeProvider, raw);
|
|
10618
10905
|
}
|
|
10619
10906
|
if (isEvmSpokeProvider(spokeProvider)) {
|
|
10907
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10620
10908
|
return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
10621
10909
|
}
|
|
10622
10910
|
if (isInjectiveSpokeProvider(spokeProvider)) {
|
|
10911
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10623
10912
|
return await InjectiveSpokeService.callWallet(
|
|
10624
10913
|
from,
|
|
10625
10914
|
payload,
|
|
@@ -10629,12 +10918,15 @@ var SpokeService = class {
|
|
|
10629
10918
|
);
|
|
10630
10919
|
}
|
|
10631
10920
|
if (isIconSpokeProvider(spokeProvider)) {
|
|
10921
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10632
10922
|
return await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
10633
10923
|
}
|
|
10634
10924
|
if (isSuiSpokeProvider(spokeProvider)) {
|
|
10925
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10635
10926
|
return await SuiSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
10636
10927
|
}
|
|
10637
10928
|
if (isSolanaSpokeProvider(spokeProvider)) {
|
|
10929
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10638
10930
|
return await SolanaSpokeService.callWallet(
|
|
10639
10931
|
from,
|
|
10640
10932
|
payload,
|
|
@@ -10644,10 +10936,27 @@ var SpokeService = class {
|
|
|
10644
10936
|
);
|
|
10645
10937
|
}
|
|
10646
10938
|
if (isStellarSpokeProvider(spokeProvider)) {
|
|
10939
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10647
10940
|
return await StellarSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
10648
10941
|
}
|
|
10649
10942
|
throw new Error("Invalid spoke provider");
|
|
10650
10943
|
}
|
|
10944
|
+
static async verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation) {
|
|
10945
|
+
if (!skipSimulation) {
|
|
10946
|
+
const result = await _SpokeService.simulateRecvMessage(
|
|
10947
|
+
{
|
|
10948
|
+
target: from,
|
|
10949
|
+
srcChainId: getIntentRelayChainId(spokeProvider.chainConfig.chain.id),
|
|
10950
|
+
srcAddress: await spokeProvider.walletProvider.getWalletAddressBytes(),
|
|
10951
|
+
payload
|
|
10952
|
+
},
|
|
10953
|
+
hubProvider
|
|
10954
|
+
);
|
|
10955
|
+
if (!result.success) {
|
|
10956
|
+
throw new Error("Simulation failed", { cause: result });
|
|
10957
|
+
}
|
|
10958
|
+
}
|
|
10959
|
+
}
|
|
10651
10960
|
};
|
|
10652
10961
|
async function postRequest(payload, apiUrl) {
|
|
10653
10962
|
const response = await retry(
|
|
@@ -10799,8 +11108,11 @@ var EvmSolverService = class _EvmSolverService {
|
|
|
10799
11108
|
* @param {PartnerFee} fee - The partner fee configuration
|
|
10800
11109
|
* @returns {Promise<[Hex, Intent, bigint]>} The encoded contract call, intent and fee amount
|
|
10801
11110
|
*/
|
|
10802
|
-
static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee) {
|
|
10803
|
-
|
|
11111
|
+
static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee, hubProvider) {
|
|
11112
|
+
let inputToken = getHubAssetInfo(createIntentParams.srcChain, createIntentParams.inputToken)?.asset;
|
|
11113
|
+
if (createIntentParams.srcChain === hubProvider.chainConfig.chain.id && createIntentParams.inputToken.toLowerCase() === hubProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
11114
|
+
inputToken = hubProvider.chainConfig.wrappedNativeToken;
|
|
11115
|
+
}
|
|
10804
11116
|
const outputToken = getHubAssetInfo(createIntentParams.dstChain, createIntentParams.outputToken)?.asset;
|
|
10805
11117
|
invariant10(
|
|
10806
11118
|
inputToken,
|
|
@@ -11352,13 +11664,15 @@ var SolverService = class {
|
|
|
11352
11664
|
intentParams: params,
|
|
11353
11665
|
spokeProvider,
|
|
11354
11666
|
fee = this.config.partnerFee,
|
|
11355
|
-
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
11667
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT,
|
|
11668
|
+
skipSimulation = false
|
|
11356
11669
|
}) {
|
|
11357
11670
|
return this.createAndSubmitIntent({
|
|
11358
11671
|
intentParams: params,
|
|
11359
11672
|
spokeProvider,
|
|
11360
11673
|
fee,
|
|
11361
|
-
timeout
|
|
11674
|
+
timeout,
|
|
11675
|
+
skipSimulation
|
|
11362
11676
|
});
|
|
11363
11677
|
}
|
|
11364
11678
|
/**
|
|
@@ -11407,14 +11721,16 @@ var SolverService = class {
|
|
|
11407
11721
|
intentParams: params,
|
|
11408
11722
|
spokeProvider,
|
|
11409
11723
|
fee = this.config.partnerFee,
|
|
11410
|
-
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
11724
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT,
|
|
11725
|
+
skipSimulation = false
|
|
11411
11726
|
}) {
|
|
11412
11727
|
try {
|
|
11413
11728
|
const createIntentResult = await this.createIntent({
|
|
11414
11729
|
intentParams: params,
|
|
11415
11730
|
spokeProvider,
|
|
11416
11731
|
fee,
|
|
11417
|
-
raw: false
|
|
11732
|
+
raw: false,
|
|
11733
|
+
skipSimulation
|
|
11418
11734
|
});
|
|
11419
11735
|
if (!createIntentResult.ok) {
|
|
11420
11736
|
return createIntentResult;
|
|
@@ -11702,7 +12018,8 @@ var SolverService = class {
|
|
|
11702
12018
|
},
|
|
11703
12019
|
creatorHubWalletAddress,
|
|
11704
12020
|
this.config,
|
|
11705
|
-
fee
|
|
12021
|
+
fee,
|
|
12022
|
+
this.hubProvider
|
|
11706
12023
|
);
|
|
11707
12024
|
const txResult = await SpokeService.deposit(
|
|
11708
12025
|
{
|
|
@@ -13832,7 +14149,7 @@ function calculateAllUserIncentives({
|
|
|
13832
14149
|
(reserve2) => reserve2.underlyingAsset === userIncentive.underlyingAsset
|
|
13833
14150
|
);
|
|
13834
14151
|
const userReserve = userReserves.find(
|
|
13835
|
-
(userReserve2) => userReserve2.reserve.underlyingAsset === userIncentive.underlyingAsset
|
|
14152
|
+
(userReserve2) => userReserve2.reserve.underlyingAsset.toLowerCase() === userIncentive.underlyingAsset.toLowerCase()
|
|
13836
14153
|
);
|
|
13837
14154
|
if (reserve) {
|
|
13838
14155
|
const reserveRewards = calculateUserReserveIncentives({
|
|
@@ -14847,7 +15164,11 @@ var MoneyMarketDataService = class {
|
|
|
14847
15164
|
*/
|
|
14848
15165
|
async getUserReservesData(spokeProvider) {
|
|
14849
15166
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14850
|
-
const hubWalletAddress =
|
|
15167
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
15168
|
+
walletAddress,
|
|
15169
|
+
spokeProvider,
|
|
15170
|
+
this.hubProvider
|
|
15171
|
+
);
|
|
14851
15172
|
return this.uiPoolDataProviderService.getUserReservesData(hubWalletAddress);
|
|
14852
15173
|
}
|
|
14853
15174
|
/**
|
|
@@ -14878,7 +15199,11 @@ var MoneyMarketDataService = class {
|
|
|
14878
15199
|
*/
|
|
14879
15200
|
async getUserReservesHumanized(spokeProvider) {
|
|
14880
15201
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14881
|
-
const hubWalletAddress =
|
|
15202
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
15203
|
+
walletAddress,
|
|
15204
|
+
spokeProvider,
|
|
15205
|
+
this.hubProvider
|
|
15206
|
+
);
|
|
14882
15207
|
return this.uiPoolDataProviderService.getUserReservesHumanized(hubWalletAddress);
|
|
14883
15208
|
}
|
|
14884
15209
|
/**
|
|
@@ -15616,13 +15941,31 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15616
15941
|
spokeProvider,
|
|
15617
15942
|
this.hubProvider
|
|
15618
15943
|
);
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15944
|
+
let data;
|
|
15945
|
+
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
15946
|
+
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
15947
|
+
params.token,
|
|
15948
|
+
params.amount,
|
|
15949
|
+
spokeProvider,
|
|
15950
|
+
this.data
|
|
15951
|
+
);
|
|
15952
|
+
data = await SonicSpokeService.buildWithdrawData(
|
|
15953
|
+
walletAddress,
|
|
15954
|
+
withdrawInfo,
|
|
15955
|
+
params.amount,
|
|
15956
|
+
spokeProvider,
|
|
15957
|
+
this,
|
|
15958
|
+
hubWallet
|
|
15959
|
+
);
|
|
15960
|
+
} else {
|
|
15961
|
+
data = this.buildWithdrawData(
|
|
15962
|
+
hubWallet,
|
|
15963
|
+
encodedAddress,
|
|
15964
|
+
params.token,
|
|
15965
|
+
params.amount,
|
|
15966
|
+
spokeProvider.chainConfig.chain.id
|
|
15967
|
+
);
|
|
15968
|
+
}
|
|
15626
15969
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
15627
15970
|
return {
|
|
15628
15971
|
ok: true,
|
|
@@ -15786,9 +16129,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15786
16129
|
const calls = [];
|
|
15787
16130
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15788
16131
|
invariant10(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15789
|
-
|
|
16132
|
+
let assetAddress = assetConfig.asset;
|
|
15790
16133
|
const vaultAddress = assetConfig.vault;
|
|
15791
16134
|
const lendingPool = this.config.lendingPool;
|
|
16135
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16136
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16137
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16138
|
+
}
|
|
16139
|
+
}
|
|
15792
16140
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15793
16141
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15794
16142
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|
|
@@ -15818,10 +16166,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15818
16166
|
);
|
|
15819
16167
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15820
16168
|
invariant10(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15821
|
-
|
|
16169
|
+
let assetAddress = assetConfig.asset;
|
|
15822
16170
|
const vaultAddress = assetConfig.vault;
|
|
15823
16171
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15824
16172
|
const bnUSD = this.config.bnUSD;
|
|
16173
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16174
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16175
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16176
|
+
}
|
|
16177
|
+
}
|
|
15825
16178
|
const feeAmount = calculateFeeAmount(amount, this.config.partnerFee);
|
|
15826
16179
|
const calls = [];
|
|
15827
16180
|
if (bnUSDVault && bnUSD && bnUSDVault.toLowerCase() === vaultAddress.toLowerCase()) {
|
|
@@ -15942,10 +16295,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15942
16295
|
if (!assetConfig) {
|
|
15943
16296
|
throw new Error("[buildRepayData] Hub asset not found");
|
|
15944
16297
|
}
|
|
15945
|
-
|
|
16298
|
+
let assetAddress = assetConfig.asset;
|
|
15946
16299
|
const vaultAddress = assetConfig.vault;
|
|
15947
16300
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15948
16301
|
const bnUSD = this.config.bnUSD;
|
|
16302
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16303
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16304
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16305
|
+
}
|
|
16306
|
+
}
|
|
15949
16307
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15950
16308
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15951
16309
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|