@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.cjs
CHANGED
|
@@ -6331,6 +6331,7 @@ var hubChainConfig = {
|
|
|
6331
6331
|
sodaToken: "0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
|
|
6332
6332
|
},
|
|
6333
6333
|
nativeToken: "0x0000000000000000000000000000000000000000",
|
|
6334
|
+
wrappedNativeToken: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
|
|
6334
6335
|
supportedTokens: []
|
|
6335
6336
|
}
|
|
6336
6337
|
};
|
|
@@ -6827,6 +6828,7 @@ var spokeChainConfig = {
|
|
|
6827
6828
|
[types.SUI_MAINNET_CHAIN_ID]: {
|
|
6828
6829
|
addresses: {
|
|
6829
6830
|
connection: "0xf3b1e696a66d02cb776dc15aae73c68bc8f03adcb6ba0ec7f6332d9d90a6a3d2::connectionv3::0x3ee76d13909ac58ae13baab4c9be5a5142818d9a387aed641825e5d4356969bf",
|
|
6831
|
+
assetManagerId: "0xa17a409164d1676db71b411ab50813ba2c7dd547d2df538c699049566f1ff922::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
|
|
6830
6832
|
assetManager: "0x897f911a4b7691870a1a2513af7e85fdee8de275615c77068fd8b90b8e78c678::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
|
|
6831
6833
|
xTokenManager: "",
|
|
6832
6834
|
rateLimit: "",
|
|
@@ -7190,7 +7192,7 @@ var getAllLegacybnUSDTokens = () => {
|
|
|
7190
7192
|
var hubAssets = {
|
|
7191
7193
|
[types.SONIC_MAINNET_CHAIN_ID]: {
|
|
7192
7194
|
[spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].nativeToken]: {
|
|
7193
|
-
asset: spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.
|
|
7195
|
+
asset: spokeChainConfig[types.SONIC_MAINNET_CHAIN_ID].supportedTokens.S.address,
|
|
7194
7196
|
decimal: 18,
|
|
7195
7197
|
symbol: "S",
|
|
7196
7198
|
name: "Sonic",
|
|
@@ -9250,6 +9252,32 @@ var EvmSpokeService = class _EvmSpokeService {
|
|
|
9250
9252
|
args: [token]
|
|
9251
9253
|
});
|
|
9252
9254
|
}
|
|
9255
|
+
/**
|
|
9256
|
+
* Generate simulation parameters for deposit from EvmSpokeDepositParams.
|
|
9257
|
+
* @param {EvmSpokeDepositParams} params - The deposit parameters.
|
|
9258
|
+
* @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9259
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9260
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9261
|
+
*/
|
|
9262
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9263
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9264
|
+
spokeProvider.chainConfig.chain.id,
|
|
9265
|
+
params.from,
|
|
9266
|
+
hubProvider
|
|
9267
|
+
);
|
|
9268
|
+
return {
|
|
9269
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9270
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9271
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9272
|
+
to,
|
|
9273
|
+
amount: params.amount,
|
|
9274
|
+
data: params.data,
|
|
9275
|
+
srcAddress: encodeAddress(
|
|
9276
|
+
spokeProvider.chainConfig.chain.id,
|
|
9277
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9278
|
+
)
|
|
9279
|
+
};
|
|
9280
|
+
}
|
|
9253
9281
|
/**
|
|
9254
9282
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9255
9283
|
* @param {HubAddress} from - The address of the user on the hub chain.
|
|
@@ -9372,6 +9400,32 @@ var InjectiveSpokeService = class _InjectiveSpokeService {
|
|
|
9372
9400
|
raw
|
|
9373
9401
|
);
|
|
9374
9402
|
}
|
|
9403
|
+
/**
|
|
9404
|
+
* Generate simulation parameters for deposit from InjectiveSpokeDepositParams.
|
|
9405
|
+
* @param {InjectiveSpokeDepositParams} params - The deposit parameters.
|
|
9406
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9407
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9408
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9409
|
+
*/
|
|
9410
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9411
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9412
|
+
spokeProvider.chainConfig.chain.id,
|
|
9413
|
+
viem.toHex(Buffer.from(params.from, "utf-8")),
|
|
9414
|
+
hubProvider
|
|
9415
|
+
);
|
|
9416
|
+
return {
|
|
9417
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9418
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9419
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9420
|
+
to,
|
|
9421
|
+
amount: params.amount,
|
|
9422
|
+
data: params.data,
|
|
9423
|
+
srcAddress: encodeAddress(
|
|
9424
|
+
spokeProvider.chainConfig.chain.id,
|
|
9425
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9426
|
+
)
|
|
9427
|
+
};
|
|
9428
|
+
}
|
|
9375
9429
|
/**
|
|
9376
9430
|
* Get the balance of the token that deposited in the spoke chain Asset Manager.
|
|
9377
9431
|
* @param {Address} token - The address of the token to get the balance of.
|
|
@@ -9509,6 +9563,32 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
9509
9563
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9510
9564
|
return _IconSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
9511
9565
|
}
|
|
9566
|
+
/**
|
|
9567
|
+
* Generate simulation parameters for deposit from IconSpokeDepositParams.
|
|
9568
|
+
* @param {IconSpokeDepositParams} params - The deposit parameters.
|
|
9569
|
+
* @param {IconSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9570
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9571
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9572
|
+
*/
|
|
9573
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9574
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9575
|
+
spokeProvider.chainConfig.chain.id,
|
|
9576
|
+
getIconAddressBytes(params.from),
|
|
9577
|
+
hubProvider
|
|
9578
|
+
);
|
|
9579
|
+
return {
|
|
9580
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9581
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9582
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9583
|
+
to,
|
|
9584
|
+
amount: params.amount,
|
|
9585
|
+
data: params.data,
|
|
9586
|
+
srcAddress: encodeAddress(
|
|
9587
|
+
spokeProvider.chainConfig.chain.id,
|
|
9588
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9589
|
+
)
|
|
9590
|
+
};
|
|
9591
|
+
}
|
|
9512
9592
|
/**
|
|
9513
9593
|
* Transfers tokens to the hub chain.
|
|
9514
9594
|
*/
|
|
@@ -9709,6 +9789,32 @@ var SolanaSpokeService = class _SolanaSpokeService {
|
|
|
9709
9789
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9710
9790
|
return _SolanaSpokeService.call(BigInt(relayId), from, viem.keccak256(payload), spokeProvider, raw);
|
|
9711
9791
|
}
|
|
9792
|
+
/**
|
|
9793
|
+
* Generate simulation parameters for deposit from SolanaSpokeDepositParams.
|
|
9794
|
+
* @param {SolanaSpokeDepositParams} params - The deposit parameters.
|
|
9795
|
+
* @param {SolanaSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9796
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9797
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9798
|
+
*/
|
|
9799
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9800
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9801
|
+
spokeProvider.chainConfig.chain.id,
|
|
9802
|
+
encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9803
|
+
hubProvider
|
|
9804
|
+
);
|
|
9805
|
+
return {
|
|
9806
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
9807
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
9808
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
9809
|
+
to,
|
|
9810
|
+
amount: params.amount,
|
|
9811
|
+
data: params.data,
|
|
9812
|
+
srcAddress: encodeAddress(
|
|
9813
|
+
spokeProvider.chainConfig.chain.id,
|
|
9814
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
9815
|
+
)
|
|
9816
|
+
};
|
|
9817
|
+
}
|
|
9712
9818
|
static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
|
|
9713
9819
|
let depositInstruction;
|
|
9714
9820
|
const amountBN = new BN__default.default(amount);
|
|
@@ -9877,6 +9983,32 @@ var StellarSpokeService = class _StellarSpokeService {
|
|
|
9877
9983
|
static async getDeposit(token, spokeProvider) {
|
|
9878
9984
|
return BigInt(await spokeProvider.getBalance(token));
|
|
9879
9985
|
}
|
|
9986
|
+
/**
|
|
9987
|
+
* Generate simulation parameters for deposit from StellarSpokeDepositParams.
|
|
9988
|
+
* @param {StellarSpokeDepositParams} params - The deposit parameters.
|
|
9989
|
+
* @param {StellarSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9990
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9991
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
9992
|
+
*/
|
|
9993
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
9994
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
9995
|
+
spokeProvider.chainConfig.chain.id,
|
|
9996
|
+
params.from,
|
|
9997
|
+
hubProvider
|
|
9998
|
+
);
|
|
9999
|
+
return {
|
|
10000
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
10001
|
+
token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
|
|
10002
|
+
from: params.from,
|
|
10003
|
+
to,
|
|
10004
|
+
amount: params.amount,
|
|
10005
|
+
data: params.data,
|
|
10006
|
+
srcAddress: encodeAddress(
|
|
10007
|
+
spokeProvider.chainConfig.chain.id,
|
|
10008
|
+
spokeProvider.chainConfig.addresses.assetManager
|
|
10009
|
+
)
|
|
10010
|
+
};
|
|
10011
|
+
}
|
|
9880
10012
|
/**
|
|
9881
10013
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9882
10014
|
* @param from - The address of the user on the hub chain.
|
|
@@ -9959,6 +10091,30 @@ var SuiSpokeService = class _SuiSpokeService {
|
|
|
9959
10091
|
static async getDeposit(token, spokeProvider) {
|
|
9960
10092
|
return spokeProvider.getBalance(token);
|
|
9961
10093
|
}
|
|
10094
|
+
/**
|
|
10095
|
+
* Generate simulation parameters for deposit from SuiSpokeDepositParams.
|
|
10096
|
+
* @param {SuiSpokeDepositParams} params - The deposit parameters.
|
|
10097
|
+
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
10098
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10099
|
+
* @returns {Promise<DepositSimulationParams>} The simulation parameters.
|
|
10100
|
+
*/
|
|
10101
|
+
static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
10102
|
+
const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
10103
|
+
spokeProvider.chainConfig.chain.id,
|
|
10104
|
+
params.from,
|
|
10105
|
+
hubProvider
|
|
10106
|
+
);
|
|
10107
|
+
const encoder = new TextEncoder();
|
|
10108
|
+
return {
|
|
10109
|
+
spokeChainID: spokeProvider.chainConfig.chain.id,
|
|
10110
|
+
token: viem.toHex(encoder.encode(params.token)),
|
|
10111
|
+
from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
|
|
10112
|
+
to,
|
|
10113
|
+
amount: params.amount,
|
|
10114
|
+
data: params.data,
|
|
10115
|
+
srcAddress: viem.toHex(encoder.encode(spokeProvider.chainConfig.addresses.assetManagerId))
|
|
10116
|
+
};
|
|
10117
|
+
}
|
|
9962
10118
|
/**
|
|
9963
10119
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9964
10120
|
* @param {HubAddress} from - The address of the user on the spoke chain.
|
|
@@ -10072,7 +10228,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10072
10228
|
params.data
|
|
10073
10229
|
)[0]
|
|
10074
10230
|
);
|
|
10075
|
-
if (params.token === spokeProvider.chainConfig.nativeToken) {
|
|
10231
|
+
if (params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10076
10232
|
const wrapCall = {
|
|
10077
10233
|
address: spokeProvider.chainConfig.addresses.wrappedSonic,
|
|
10078
10234
|
value: params.amount,
|
|
@@ -10106,7 +10262,7 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10106
10262
|
from: params.from,
|
|
10107
10263
|
to: spokeProvider.chainConfig.addresses.walletRouter,
|
|
10108
10264
|
data: txData,
|
|
10109
|
-
value: params.token === spokeProvider.chainConfig.nativeToken ? params.amount : 0n
|
|
10265
|
+
value: params.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase() ? params.amount : 0n
|
|
10110
10266
|
};
|
|
10111
10267
|
if (raw) {
|
|
10112
10268
|
return rawTx;
|
|
@@ -10321,12 +10477,16 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10321
10477
|
}
|
|
10322
10478
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
10323
10479
|
}
|
|
10324
|
-
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService) {
|
|
10325
|
-
const userRouter = await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10480
|
+
static async buildWithdrawData(from, withdrawInfo, amount, spokeProvider, moneyMarketService, userRouterAddress) {
|
|
10481
|
+
const userRouter = userRouterAddress ?? await _SonicSpokeService.getUserRouter(from, spokeProvider);
|
|
10482
|
+
let token = withdrawInfo.token;
|
|
10483
|
+
if (withdrawInfo.token.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
10484
|
+
token = spokeProvider.chainConfig.addresses.wrappedSonic;
|
|
10485
|
+
}
|
|
10326
10486
|
const withdrawCall = moneyMarketService.buildWithdrawData(
|
|
10327
10487
|
userRouter,
|
|
10328
10488
|
from,
|
|
10329
|
-
|
|
10489
|
+
token,
|
|
10330
10490
|
amount,
|
|
10331
10491
|
spokeProvider.chainConfig.chain.id
|
|
10332
10492
|
);
|
|
@@ -10344,17 +10504,6 @@ var SonicSpokeService = class _SonicSpokeService {
|
|
|
10344
10504
|
],
|
|
10345
10505
|
withdrawCall
|
|
10346
10506
|
)[0];
|
|
10347
|
-
const transferFromCall = Erc20Service.encodeTransferFrom(
|
|
10348
|
-
withdrawInfo.aTokenAddress,
|
|
10349
|
-
from,
|
|
10350
|
-
userRouter,
|
|
10351
|
-
withdrawInfo.aTokenAmount
|
|
10352
|
-
);
|
|
10353
|
-
calls.unshift({
|
|
10354
|
-
address: transferFromCall.address,
|
|
10355
|
-
value: transferFromCall.value,
|
|
10356
|
-
data: transferFromCall.data
|
|
10357
|
-
});
|
|
10358
10507
|
return encodeContractCalls(calls);
|
|
10359
10508
|
}
|
|
10360
10509
|
};
|
|
@@ -10481,9 +10630,7 @@ function isBalnMigrateParams(value) {
|
|
|
10481
10630
|
function isIcxCreateRevertMigrationParams(value) {
|
|
10482
10631
|
return typeof value === "object" && value !== null && "amount" in value && "to" in value;
|
|
10483
10632
|
}
|
|
10484
|
-
|
|
10485
|
-
// src/services/spoke/SpokeService.ts
|
|
10486
|
-
var SpokeService = class {
|
|
10633
|
+
var SpokeService = class _SpokeService {
|
|
10487
10634
|
constructor() {
|
|
10488
10635
|
}
|
|
10489
10636
|
/**
|
|
@@ -10537,14 +10684,99 @@ var SpokeService = class {
|
|
|
10537
10684
|
}
|
|
10538
10685
|
throw new Error("Invalid spoke provider");
|
|
10539
10686
|
}
|
|
10687
|
+
/**
|
|
10688
|
+
|
|
10689
|
+
* Encodes transfer data using RLP encoding to match Solidity Transfer struct.
|
|
10690
|
+
* @param {Hex} token - The token contract address.
|
|
10691
|
+
* @param {Hex} from - The sender address.
|
|
10692
|
+
* @param {Hex} to - The recipient address.
|
|
10693
|
+
* @param {bigint} amount - The transfer amount.
|
|
10694
|
+
* @param {Hex} data - The encoded data payload.
|
|
10695
|
+
* @returns {Promise<Hex>} A promise that resolves to the RLP encoded transfer data.
|
|
10696
|
+
*/
|
|
10697
|
+
static encodeTransfer(token, from, to, amount, data) {
|
|
10698
|
+
const rlpInput = [
|
|
10699
|
+
token,
|
|
10700
|
+
// token (bytes)
|
|
10701
|
+
from,
|
|
10702
|
+
// from (bytes)
|
|
10703
|
+
to,
|
|
10704
|
+
// to (bytes)
|
|
10705
|
+
amount,
|
|
10706
|
+
// amount (uint256)
|
|
10707
|
+
data
|
|
10708
|
+
// data (bytes)
|
|
10709
|
+
];
|
|
10710
|
+
const rlpEncodedData = rlp__namespace.encode(rlpInput);
|
|
10711
|
+
return `0x${Buffer.from(rlpEncodedData).toString("hex")}`;
|
|
10712
|
+
}
|
|
10713
|
+
static async simulateDeposit(params, hubProvider) {
|
|
10714
|
+
const chainId = getIntentRelayChainId(params.spokeChainID);
|
|
10715
|
+
const hubAssetManager = hubProvider.chainConfig.addresses.assetManager;
|
|
10716
|
+
const payload = _SpokeService.encodeTransfer(params.token, params.from, params.to, params.amount, params.data);
|
|
10717
|
+
return _SpokeService.simulateRecvMessage(
|
|
10718
|
+
{ target: hubAssetManager, srcChainId: chainId, srcAddress: params.srcAddress, payload },
|
|
10719
|
+
hubProvider
|
|
10720
|
+
);
|
|
10721
|
+
}
|
|
10722
|
+
/**
|
|
10723
|
+
* Simulates receiving a message without signature verification.
|
|
10724
|
+
* This function calls simulateRecvMessage which always reverts with 'Simulation completed'.
|
|
10725
|
+
* @param {bigint} srcChainId - The chain ID of the originating chain.
|
|
10726
|
+
* @param {Hex} srcAddress - The address of the sender on the originating chain.
|
|
10727
|
+
* @param {Hex} payload - The encoded payload containing call data (from encodeTransfer).
|
|
10728
|
+
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10729
|
+
* @returns {Promise<{ success: boolean; error?: string }>} Result of the simulation.
|
|
10730
|
+
*/
|
|
10731
|
+
static async simulateRecvMessage(params, hubProvider) {
|
|
10732
|
+
try {
|
|
10733
|
+
const result = await hubProvider.publicClient.call({
|
|
10734
|
+
to: params.target,
|
|
10735
|
+
data: viem.encodeFunctionData({
|
|
10736
|
+
abi: [
|
|
10737
|
+
{
|
|
10738
|
+
name: "simulateRecvMessage",
|
|
10739
|
+
type: "function",
|
|
10740
|
+
stateMutability: "nonpayable",
|
|
10741
|
+
inputs: [
|
|
10742
|
+
{ name: "srcChainId", type: "uint256" },
|
|
10743
|
+
{ name: "srcAddress", type: "bytes" },
|
|
10744
|
+
{ name: "payload", type: "bytes" }
|
|
10745
|
+
],
|
|
10746
|
+
outputs: []
|
|
10747
|
+
}
|
|
10748
|
+
],
|
|
10749
|
+
functionName: "simulateRecvMessage",
|
|
10750
|
+
args: [params.srcChainId, params.srcAddress, params.payload]
|
|
10751
|
+
})
|
|
10752
|
+
});
|
|
10753
|
+
console.warn("simulateRecvMessage did not revert as expected", { result });
|
|
10754
|
+
return {
|
|
10755
|
+
success: false,
|
|
10756
|
+
error: 'Function should have reverted with "Simulation completed"'
|
|
10757
|
+
};
|
|
10758
|
+
} catch (error) {
|
|
10759
|
+
if (error instanceof Error && error.message?.includes("Simulation completed")) {
|
|
10760
|
+
console.warn("simulateRecvMessage completed successfully with expected revert");
|
|
10761
|
+
return { success: true };
|
|
10762
|
+
}
|
|
10763
|
+
console.error("simulateRecvMessage failed with unexpected error:", error);
|
|
10764
|
+
return {
|
|
10765
|
+
success: false,
|
|
10766
|
+
error: error instanceof Error ? error.message || "Unknown simulation error" : "Unknown simulation error"
|
|
10767
|
+
};
|
|
10768
|
+
}
|
|
10769
|
+
}
|
|
10540
10770
|
/**
|
|
10541
10771
|
* Deposit tokens to the spoke chain.
|
|
10542
10772
|
* @param {GetSpokeDepositParamsType<T extends SpokeProvider>} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
10543
10773
|
* @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
10544
10774
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10775
|
+
* @param {boolean} raw - Whether to return raw transaction data.
|
|
10776
|
+
* @param {boolean} skipSimulation - Whether to skip deposit simulation (optional, defaults to false).
|
|
10545
10777
|
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
10546
10778
|
*/
|
|
10547
|
-
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
10779
|
+
static async deposit(params, spokeProvider, hubProvider, raw, skipSimulation = false) {
|
|
10548
10780
|
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
10549
10781
|
return SonicSpokeService.deposit(
|
|
10550
10782
|
params,
|
|
@@ -10553,6 +10785,7 @@ var SpokeService = class {
|
|
|
10553
10785
|
);
|
|
10554
10786
|
}
|
|
10555
10787
|
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
10788
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10556
10789
|
return EvmSpokeService.deposit(
|
|
10557
10790
|
params,
|
|
10558
10791
|
spokeProvider,
|
|
@@ -10561,14 +10794,11 @@ var SpokeService = class {
|
|
|
10561
10794
|
);
|
|
10562
10795
|
}
|
|
10563
10796
|
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
spokeProvider,
|
|
10567
|
-
hubProvider,
|
|
10568
|
-
raw
|
|
10569
|
-
);
|
|
10797
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10798
|
+
return InjectiveSpokeService.deposit(params, spokeProvider, hubProvider, raw);
|
|
10570
10799
|
}
|
|
10571
10800
|
if (spokeProvider instanceof IconSpokeProvider) {
|
|
10801
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10572
10802
|
return IconSpokeService.deposit(
|
|
10573
10803
|
params,
|
|
10574
10804
|
spokeProvider,
|
|
@@ -10577,6 +10807,7 @@ var SpokeService = class {
|
|
|
10577
10807
|
);
|
|
10578
10808
|
}
|
|
10579
10809
|
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
10810
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10580
10811
|
return SuiSpokeService.deposit(
|
|
10581
10812
|
params,
|
|
10582
10813
|
spokeProvider,
|
|
@@ -10585,6 +10816,7 @@ var SpokeService = class {
|
|
|
10585
10816
|
);
|
|
10586
10817
|
}
|
|
10587
10818
|
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
10819
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10588
10820
|
return SolanaSpokeService.deposit(
|
|
10589
10821
|
params,
|
|
10590
10822
|
spokeProvider,
|
|
@@ -10593,6 +10825,7 @@ var SpokeService = class {
|
|
|
10593
10825
|
);
|
|
10594
10826
|
}
|
|
10595
10827
|
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
10828
|
+
await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
|
|
10596
10829
|
return StellarSpokeService.deposit(
|
|
10597
10830
|
params,
|
|
10598
10831
|
spokeProvider,
|
|
@@ -10602,6 +10835,60 @@ var SpokeService = class {
|
|
|
10602
10835
|
}
|
|
10603
10836
|
throw new Error("Invalid spoke provider");
|
|
10604
10837
|
}
|
|
10838
|
+
static getSimulateDepositParams(params, spokeProvider, hubProvider) {
|
|
10839
|
+
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
10840
|
+
return EvmSpokeService.getSimulateDepositParams(
|
|
10841
|
+
params,
|
|
10842
|
+
spokeProvider,
|
|
10843
|
+
hubProvider
|
|
10844
|
+
);
|
|
10845
|
+
}
|
|
10846
|
+
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10847
|
+
return InjectiveSpokeService.getSimulateDepositParams(
|
|
10848
|
+
params,
|
|
10849
|
+
spokeProvider,
|
|
10850
|
+
hubProvider
|
|
10851
|
+
);
|
|
10852
|
+
}
|
|
10853
|
+
if (spokeProvider instanceof IconSpokeProvider) {
|
|
10854
|
+
return IconSpokeService.getSimulateDepositParams(
|
|
10855
|
+
params,
|
|
10856
|
+
spokeProvider,
|
|
10857
|
+
hubProvider
|
|
10858
|
+
);
|
|
10859
|
+
}
|
|
10860
|
+
if (spokeProvider instanceof SuiSpokeProvider) {
|
|
10861
|
+
return SuiSpokeService.getSimulateDepositParams(
|
|
10862
|
+
params,
|
|
10863
|
+
spokeProvider,
|
|
10864
|
+
hubProvider
|
|
10865
|
+
);
|
|
10866
|
+
}
|
|
10867
|
+
if (spokeProvider instanceof SolanaSpokeProvider) {
|
|
10868
|
+
return SolanaSpokeService.getSimulateDepositParams(
|
|
10869
|
+
params,
|
|
10870
|
+
spokeProvider,
|
|
10871
|
+
hubProvider
|
|
10872
|
+
);
|
|
10873
|
+
}
|
|
10874
|
+
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
10875
|
+
return StellarSpokeService.getSimulateDepositParams(
|
|
10876
|
+
params,
|
|
10877
|
+
spokeProvider,
|
|
10878
|
+
hubProvider
|
|
10879
|
+
);
|
|
10880
|
+
}
|
|
10881
|
+
throw new Error("Invalid spoke provider");
|
|
10882
|
+
}
|
|
10883
|
+
static async verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation) {
|
|
10884
|
+
if (!skipSimulation) {
|
|
10885
|
+
const simulationParams = await _SpokeService.getSimulateDepositParams(params, spokeProvider, hubProvider);
|
|
10886
|
+
const result = await _SpokeService.simulateDeposit(simulationParams, hubProvider);
|
|
10887
|
+
if (!result.success) {
|
|
10888
|
+
throw new Error("Simulation failed", { cause: result });
|
|
10889
|
+
}
|
|
10890
|
+
}
|
|
10891
|
+
}
|
|
10605
10892
|
/**
|
|
10606
10893
|
* Get the balance of the token in the spoke chain.
|
|
10607
10894
|
* @param {Address} token - The address of the token to get the balance of.
|
|
@@ -10640,14 +10927,16 @@ var SpokeService = class {
|
|
|
10640
10927
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
10641
10928
|
* @returns {Promise<Hash>} A promise that resolves to the transaction hash.
|
|
10642
10929
|
*/
|
|
10643
|
-
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
10930
|
+
static async callWallet(from, payload, spokeProvider, hubProvider, raw, skipSimulation = false) {
|
|
10644
10931
|
if (isSonicSpokeProvider(spokeProvider)) {
|
|
10645
10932
|
return await SonicSpokeService.callWallet(payload, spokeProvider, raw);
|
|
10646
10933
|
}
|
|
10647
10934
|
if (isEvmSpokeProvider(spokeProvider)) {
|
|
10935
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10648
10936
|
return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
10649
10937
|
}
|
|
10650
10938
|
if (isInjectiveSpokeProvider(spokeProvider)) {
|
|
10939
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10651
10940
|
return await InjectiveSpokeService.callWallet(
|
|
10652
10941
|
from,
|
|
10653
10942
|
payload,
|
|
@@ -10657,12 +10946,15 @@ var SpokeService = class {
|
|
|
10657
10946
|
);
|
|
10658
10947
|
}
|
|
10659
10948
|
if (isIconSpokeProvider(spokeProvider)) {
|
|
10949
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10660
10950
|
return await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
10661
10951
|
}
|
|
10662
10952
|
if (isSuiSpokeProvider(spokeProvider)) {
|
|
10953
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10663
10954
|
return await SuiSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
10664
10955
|
}
|
|
10665
10956
|
if (isSolanaSpokeProvider(spokeProvider)) {
|
|
10957
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10666
10958
|
return await SolanaSpokeService.callWallet(
|
|
10667
10959
|
from,
|
|
10668
10960
|
payload,
|
|
@@ -10672,10 +10964,27 @@ var SpokeService = class {
|
|
|
10672
10964
|
);
|
|
10673
10965
|
}
|
|
10674
10966
|
if (isStellarSpokeProvider(spokeProvider)) {
|
|
10967
|
+
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
10675
10968
|
return await StellarSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
10676
10969
|
}
|
|
10677
10970
|
throw new Error("Invalid spoke provider");
|
|
10678
10971
|
}
|
|
10972
|
+
static async verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation) {
|
|
10973
|
+
if (!skipSimulation) {
|
|
10974
|
+
const result = await _SpokeService.simulateRecvMessage(
|
|
10975
|
+
{
|
|
10976
|
+
target: from,
|
|
10977
|
+
srcChainId: getIntentRelayChainId(spokeProvider.chainConfig.chain.id),
|
|
10978
|
+
srcAddress: await spokeProvider.walletProvider.getWalletAddressBytes(),
|
|
10979
|
+
payload
|
|
10980
|
+
},
|
|
10981
|
+
hubProvider
|
|
10982
|
+
);
|
|
10983
|
+
if (!result.success) {
|
|
10984
|
+
throw new Error("Simulation failed", { cause: result });
|
|
10985
|
+
}
|
|
10986
|
+
}
|
|
10987
|
+
}
|
|
10679
10988
|
};
|
|
10680
10989
|
async function postRequest(payload, apiUrl) {
|
|
10681
10990
|
const response = await retry(
|
|
@@ -10827,8 +11136,11 @@ var EvmSolverService = class _EvmSolverService {
|
|
|
10827
11136
|
* @param {PartnerFee} fee - The partner fee configuration
|
|
10828
11137
|
* @returns {Promise<[Hex, Intent, bigint]>} The encoded contract call, intent and fee amount
|
|
10829
11138
|
*/
|
|
10830
|
-
static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee) {
|
|
10831
|
-
|
|
11139
|
+
static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee, hubProvider) {
|
|
11140
|
+
let inputToken = getHubAssetInfo(createIntentParams.srcChain, createIntentParams.inputToken)?.asset;
|
|
11141
|
+
if (createIntentParams.srcChain === hubProvider.chainConfig.chain.id && createIntentParams.inputToken.toLowerCase() === hubProvider.chainConfig.nativeToken.toLowerCase()) {
|
|
11142
|
+
inputToken = hubProvider.chainConfig.wrappedNativeToken;
|
|
11143
|
+
}
|
|
10832
11144
|
const outputToken = getHubAssetInfo(createIntentParams.dstChain, createIntentParams.outputToken)?.asset;
|
|
10833
11145
|
invariant10__default.default(
|
|
10834
11146
|
inputToken,
|
|
@@ -11380,13 +11692,15 @@ var SolverService = class {
|
|
|
11380
11692
|
intentParams: params,
|
|
11381
11693
|
spokeProvider,
|
|
11382
11694
|
fee = this.config.partnerFee,
|
|
11383
|
-
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
11695
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT,
|
|
11696
|
+
skipSimulation = false
|
|
11384
11697
|
}) {
|
|
11385
11698
|
return this.createAndSubmitIntent({
|
|
11386
11699
|
intentParams: params,
|
|
11387
11700
|
spokeProvider,
|
|
11388
11701
|
fee,
|
|
11389
|
-
timeout
|
|
11702
|
+
timeout,
|
|
11703
|
+
skipSimulation
|
|
11390
11704
|
});
|
|
11391
11705
|
}
|
|
11392
11706
|
/**
|
|
@@ -11435,14 +11749,16 @@ var SolverService = class {
|
|
|
11435
11749
|
intentParams: params,
|
|
11436
11750
|
spokeProvider,
|
|
11437
11751
|
fee = this.config.partnerFee,
|
|
11438
|
-
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
11752
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT,
|
|
11753
|
+
skipSimulation = false
|
|
11439
11754
|
}) {
|
|
11440
11755
|
try {
|
|
11441
11756
|
const createIntentResult = await this.createIntent({
|
|
11442
11757
|
intentParams: params,
|
|
11443
11758
|
spokeProvider,
|
|
11444
11759
|
fee,
|
|
11445
|
-
raw: false
|
|
11760
|
+
raw: false,
|
|
11761
|
+
skipSimulation
|
|
11446
11762
|
});
|
|
11447
11763
|
if (!createIntentResult.ok) {
|
|
11448
11764
|
return createIntentResult;
|
|
@@ -11730,7 +12046,8 @@ var SolverService = class {
|
|
|
11730
12046
|
},
|
|
11731
12047
|
creatorHubWalletAddress,
|
|
11732
12048
|
this.config,
|
|
11733
|
-
fee
|
|
12049
|
+
fee,
|
|
12050
|
+
this.hubProvider
|
|
11734
12051
|
);
|
|
11735
12052
|
const txResult = await SpokeService.deposit(
|
|
11736
12053
|
{
|
|
@@ -13860,7 +14177,7 @@ function calculateAllUserIncentives({
|
|
|
13860
14177
|
(reserve2) => reserve2.underlyingAsset === userIncentive.underlyingAsset
|
|
13861
14178
|
);
|
|
13862
14179
|
const userReserve = userReserves.find(
|
|
13863
|
-
(userReserve2) => userReserve2.reserve.underlyingAsset === userIncentive.underlyingAsset
|
|
14180
|
+
(userReserve2) => userReserve2.reserve.underlyingAsset.toLowerCase() === userIncentive.underlyingAsset.toLowerCase()
|
|
13864
14181
|
);
|
|
13865
14182
|
if (reserve) {
|
|
13866
14183
|
const reserveRewards = calculateUserReserveIncentives({
|
|
@@ -14875,7 +15192,11 @@ var MoneyMarketDataService = class {
|
|
|
14875
15192
|
*/
|
|
14876
15193
|
async getUserReservesData(spokeProvider) {
|
|
14877
15194
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14878
|
-
const hubWalletAddress =
|
|
15195
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
15196
|
+
walletAddress,
|
|
15197
|
+
spokeProvider,
|
|
15198
|
+
this.hubProvider
|
|
15199
|
+
);
|
|
14879
15200
|
return this.uiPoolDataProviderService.getUserReservesData(hubWalletAddress);
|
|
14880
15201
|
}
|
|
14881
15202
|
/**
|
|
@@ -14906,7 +15227,11 @@ var MoneyMarketDataService = class {
|
|
|
14906
15227
|
*/
|
|
14907
15228
|
async getUserReservesHumanized(spokeProvider) {
|
|
14908
15229
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14909
|
-
const hubWalletAddress =
|
|
15230
|
+
const hubWalletAddress = await WalletAbstractionService.getUserHubWalletAddress(
|
|
15231
|
+
walletAddress,
|
|
15232
|
+
spokeProvider,
|
|
15233
|
+
this.hubProvider
|
|
15234
|
+
);
|
|
14910
15235
|
return this.uiPoolDataProviderService.getUserReservesHumanized(hubWalletAddress);
|
|
14911
15236
|
}
|
|
14912
15237
|
/**
|
|
@@ -15644,13 +15969,31 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15644
15969
|
spokeProvider,
|
|
15645
15970
|
this.hubProvider
|
|
15646
15971
|
);
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15972
|
+
let data;
|
|
15973
|
+
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
15974
|
+
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
15975
|
+
params.token,
|
|
15976
|
+
params.amount,
|
|
15977
|
+
spokeProvider,
|
|
15978
|
+
this.data
|
|
15979
|
+
);
|
|
15980
|
+
data = await SonicSpokeService.buildWithdrawData(
|
|
15981
|
+
walletAddress,
|
|
15982
|
+
withdrawInfo,
|
|
15983
|
+
params.amount,
|
|
15984
|
+
spokeProvider,
|
|
15985
|
+
this,
|
|
15986
|
+
hubWallet
|
|
15987
|
+
);
|
|
15988
|
+
} else {
|
|
15989
|
+
data = this.buildWithdrawData(
|
|
15990
|
+
hubWallet,
|
|
15991
|
+
encodedAddress,
|
|
15992
|
+
params.token,
|
|
15993
|
+
params.amount,
|
|
15994
|
+
spokeProvider.chainConfig.chain.id
|
|
15995
|
+
);
|
|
15996
|
+
}
|
|
15654
15997
|
const txResult = await SpokeService.callWallet(hubWallet, data, spokeProvider, this.hubProvider, raw);
|
|
15655
15998
|
return {
|
|
15656
15999
|
ok: true,
|
|
@@ -15814,9 +16157,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15814
16157
|
const calls = [];
|
|
15815
16158
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15816
16159
|
invariant10__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15817
|
-
|
|
16160
|
+
let assetAddress = assetConfig.asset;
|
|
15818
16161
|
const vaultAddress = assetConfig.vault;
|
|
15819
16162
|
const lendingPool = this.config.lendingPool;
|
|
16163
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16164
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16165
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16166
|
+
}
|
|
16167
|
+
}
|
|
15820
16168
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15821
16169
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15822
16170
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|
|
@@ -15846,10 +16194,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15846
16194
|
);
|
|
15847
16195
|
const assetConfig = getHubAssetInfo(spokeChainId, token);
|
|
15848
16196
|
invariant10__default.default(assetConfig, `hub asset not found for spoke chain token (token): ${token}`);
|
|
15849
|
-
|
|
16197
|
+
let assetAddress = assetConfig.asset;
|
|
15850
16198
|
const vaultAddress = assetConfig.vault;
|
|
15851
16199
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15852
16200
|
const bnUSD = this.config.bnUSD;
|
|
16201
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16202
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16203
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16204
|
+
}
|
|
16205
|
+
}
|
|
15853
16206
|
const feeAmount = calculateFeeAmount(amount, this.config.partnerFee);
|
|
15854
16207
|
const calls = [];
|
|
15855
16208
|
if (bnUSDVault && bnUSD && bnUSDVault.toLowerCase() === vaultAddress.toLowerCase()) {
|
|
@@ -15970,10 +16323,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
15970
16323
|
if (!assetConfig) {
|
|
15971
16324
|
throw new Error("[buildRepayData] Hub asset not found");
|
|
15972
16325
|
}
|
|
15973
|
-
|
|
16326
|
+
let assetAddress = assetConfig.asset;
|
|
15974
16327
|
const vaultAddress = assetConfig.vault;
|
|
15975
16328
|
const bnUSDVault = this.config.bnUSDVault;
|
|
15976
16329
|
const bnUSD = this.config.bnUSD;
|
|
16330
|
+
if (spokeChainId === this.hubProvider.chainConfig.chain.id) {
|
|
16331
|
+
if (token.toLowerCase() === spokeChainConfig[this.hubProvider.chainConfig.chain.id].nativeToken.toLowerCase()) {
|
|
16332
|
+
assetAddress = spokeChainConfig[this.hubProvider.chainConfig.chain.id].supportedTokens.wS.address;
|
|
16333
|
+
}
|
|
16334
|
+
}
|
|
15977
16335
|
calls.push(Erc20Service.encodeApprove(assetAddress, vaultAddress, amount));
|
|
15978
16336
|
calls.push(EvmVaultTokenService.encodeDeposit(vaultAddress, assetAddress, amount));
|
|
15979
16337
|
const translatedAmount = EvmVaultTokenService.translateIncomingDecimals(assetConfig.decimal, amount);
|