@sodax/sdk 1.0.1-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 +469 -226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +277 -40
- package/dist/index.d.ts +277 -40
- package/dist/index.mjs +468 -227
- 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
|
/**
|
|
@@ -12907,7 +12933,8 @@ var SwapService = class {
|
|
|
12907
12933
|
intentParams: params,
|
|
12908
12934
|
spokeProvider,
|
|
12909
12935
|
fee = this.config.partnerFee,
|
|
12910
|
-
raw
|
|
12936
|
+
raw,
|
|
12937
|
+
skipSimulation = false
|
|
12911
12938
|
}) {
|
|
12912
12939
|
invariant6(
|
|
12913
12940
|
this.configService.isValidOriginalAssetAddress(params.srcChain, params.inputToken),
|
|
@@ -12976,7 +13003,8 @@ var SwapService = class {
|
|
|
12976
13003
|
},
|
|
12977
13004
|
spokeProvider,
|
|
12978
13005
|
this.hubProvider,
|
|
12979
|
-
raw
|
|
13006
|
+
raw,
|
|
13007
|
+
skipSimulation
|
|
12980
13008
|
);
|
|
12981
13009
|
return {
|
|
12982
13010
|
ok: true,
|
|
@@ -12996,6 +13024,179 @@ var SwapService = class {
|
|
|
12996
13024
|
};
|
|
12997
13025
|
}
|
|
12998
13026
|
}
|
|
13027
|
+
/**
|
|
13028
|
+
* Creates a limit order intent (no deadline, must be cancelled manually by user).
|
|
13029
|
+
* Similar to swap but enforces deadline=0n (no deadline).
|
|
13030
|
+
* Limit orders remain active until manually cancelled by the user.
|
|
13031
|
+
*
|
|
13032
|
+
* @param {Prettify<LimitOrderParams<S> & OptionalTimeout>} params - Object containing:
|
|
13033
|
+
* - intentParams: The parameters for creating the limit order (deadline is automatically set to 0n, deadline field should be omitted).
|
|
13034
|
+
* - spokeProvider: The spoke provider instance.
|
|
13035
|
+
* - fee: (Optional) Partner fee configuration.
|
|
13036
|
+
* - timeout: (Optional) Timeout in milliseconds for the transaction (default: 60 seconds).
|
|
13037
|
+
* - skipSimulation: (Optional) Whether to skip transaction simulation (default: false).
|
|
13038
|
+
* @returns {Promise<Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>>} A promise resolving to a Result containing a tuple of SolverExecutionResponse, Intent, and intent delivery info, or an IntentError if the operation fails.
|
|
13039
|
+
*
|
|
13040
|
+
* @example
|
|
13041
|
+
* const payload = {
|
|
13042
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
13043
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
13044
|
+
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
13045
|
+
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
13046
|
+
* // deadline is omitted - will be automatically set to 0n
|
|
13047
|
+
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
13048
|
+
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
13049
|
+
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
13050
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
13051
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
13052
|
+
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
13053
|
+
* "data": "0x..", // Additional arbitrary data
|
|
13054
|
+
* } satisfies CreateLimitOrderParams;
|
|
13055
|
+
*
|
|
13056
|
+
* const createLimitOrderResult = await swapService.createLimitOrder({
|
|
13057
|
+
* intentParams: payload,
|
|
13058
|
+
* spokeProvider,
|
|
13059
|
+
* fee, // optional
|
|
13060
|
+
* timeout, // optional
|
|
13061
|
+
* });
|
|
13062
|
+
*
|
|
13063
|
+
* if (createLimitOrderResult.ok) {
|
|
13064
|
+
* const [solverExecutionResponse, intent, intentDeliveryInfo] = createLimitOrderResult.value;
|
|
13065
|
+
* console.log('Intent execution response:', solverExecutionResponse);
|
|
13066
|
+
* console.log('Intent:', intent);
|
|
13067
|
+
* console.log('Intent delivery info:', intentDeliveryInfo);
|
|
13068
|
+
* // Limit order is now active and will remain until cancelled manually
|
|
13069
|
+
* } else {
|
|
13070
|
+
* // handle error
|
|
13071
|
+
* }
|
|
13072
|
+
*/
|
|
13073
|
+
async createLimitOrder({
|
|
13074
|
+
intentParams: params,
|
|
13075
|
+
spokeProvider,
|
|
13076
|
+
fee = this.config.partnerFee,
|
|
13077
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT,
|
|
13078
|
+
skipSimulation = false
|
|
13079
|
+
}) {
|
|
13080
|
+
const limitOrderParams = {
|
|
13081
|
+
...params,
|
|
13082
|
+
deadline: 0n
|
|
13083
|
+
};
|
|
13084
|
+
return this.createAndSubmitIntent({
|
|
13085
|
+
intentParams: limitOrderParams,
|
|
13086
|
+
spokeProvider,
|
|
13087
|
+
fee,
|
|
13088
|
+
timeout,
|
|
13089
|
+
skipSimulation
|
|
13090
|
+
});
|
|
13091
|
+
}
|
|
13092
|
+
/**
|
|
13093
|
+
* Creates a limit order intent (no deadline, must be cancelled manually by user).
|
|
13094
|
+
* Similar to createIntent but enforces deadline=0n (no deadline) and uses LimitOrderParams.
|
|
13095
|
+
* Limit orders remain active until manually cancelled by the user.
|
|
13096
|
+
* NOTE: This method does not submit the intent to the Solver API
|
|
13097
|
+
*
|
|
13098
|
+
* @param {Prettify<LimitOrderParams<S> & OptionalRaw<R>>} params - Object containing:
|
|
13099
|
+
* - intentParams: The parameters for creating the limit order (deadline is automatically set to 0n, deadline field should be omitted).
|
|
13100
|
+
* - spokeProvider: The spoke provider instance.
|
|
13101
|
+
* - fee: (Optional) Partner fee configuration.
|
|
13102
|
+
* - raw: (Optional) Whether to return the raw transaction data instead of executing it
|
|
13103
|
+
* - skipSimulation: (Optional) Whether to skip transaction simulation (default: false).
|
|
13104
|
+
* @returns {Promise<Result<[TxReturnType<S, R>, Intent & FeeAmount, Hex], IntentError<'CREATION_FAILED'>>>} The encoded contract call or raw transaction data, Intent and intent data as hex
|
|
13105
|
+
*
|
|
13106
|
+
* @example
|
|
13107
|
+
* const payload = {
|
|
13108
|
+
* "inputToken": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8", // BSC ETH token address
|
|
13109
|
+
* "outputToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // ARB WBTC token address
|
|
13110
|
+
* "inputAmount": 1000000000000000n, // The amount of input tokens
|
|
13111
|
+
* "minOutputAmount": 900000000000000n, // min amount you are expecting to receive
|
|
13112
|
+
* // deadline is omitted - will be automatically set to 0n
|
|
13113
|
+
* "allowPartialFill": false, // Whether the intent can be partially filled
|
|
13114
|
+
* "srcChain": "0x38.bsc", // Chain ID where input tokens originate
|
|
13115
|
+
* "dstChain": "0xa4b1.arbitrum", // Chain ID where output tokens should be delivered
|
|
13116
|
+
* "srcAddress": "0x..", // Source address (original address on spoke chain)
|
|
13117
|
+
* "dstAddress": "0x...", // Destination address (original address on spoke chain)
|
|
13118
|
+
* "solver": "0x..", // Optional specific solver address (address(0) = any solver)
|
|
13119
|
+
* "data": "0x..", // Additional arbitrary data
|
|
13120
|
+
* } satisfies CreateLimitOrderParams;
|
|
13121
|
+
*
|
|
13122
|
+
* const createLimitOrderIntentResult = await swapService.createLimitOrderIntent({
|
|
13123
|
+
* intentParams: payload,
|
|
13124
|
+
* spokeProvider,
|
|
13125
|
+
* fee, // optional
|
|
13126
|
+
* raw, // optional
|
|
13127
|
+
* });
|
|
13128
|
+
*
|
|
13129
|
+
* if (createLimitOrderIntentResult.ok) {
|
|
13130
|
+
* const [txResult, intent, intentData] = createLimitOrderIntentResult.value;
|
|
13131
|
+
* console.log('Transaction result:', txResult);
|
|
13132
|
+
* console.log('Intent:', intent);
|
|
13133
|
+
* console.log('Intent data:', intentData);
|
|
13134
|
+
* } else {
|
|
13135
|
+
* // handle error
|
|
13136
|
+
* }
|
|
13137
|
+
*/
|
|
13138
|
+
async createLimitOrderIntent({
|
|
13139
|
+
intentParams: params,
|
|
13140
|
+
spokeProvider,
|
|
13141
|
+
fee = this.config.partnerFee,
|
|
13142
|
+
raw,
|
|
13143
|
+
skipSimulation = false
|
|
13144
|
+
}) {
|
|
13145
|
+
const limitOrderParams = {
|
|
13146
|
+
...params,
|
|
13147
|
+
deadline: 0n
|
|
13148
|
+
};
|
|
13149
|
+
return this.createIntent({
|
|
13150
|
+
intentParams: limitOrderParams,
|
|
13151
|
+
spokeProvider,
|
|
13152
|
+
fee,
|
|
13153
|
+
raw,
|
|
13154
|
+
skipSimulation
|
|
13155
|
+
});
|
|
13156
|
+
}
|
|
13157
|
+
/**
|
|
13158
|
+
* Syntactic sugar for cancelAndSubmitIntent: cancels a limit order intent and submits it to the Relayer API.
|
|
13159
|
+
* Similar to swap function that wraps createAndSubmitIntent.
|
|
13160
|
+
*
|
|
13161
|
+
* @param params - Object containing:
|
|
13162
|
+
* @param params.intent - The limit order intent to cancel.
|
|
13163
|
+
* @param params.spokeProvider - The spoke provider instance.
|
|
13164
|
+
* @param params.timeout - (Optional) Timeout in milliseconds for the transaction (default: 60 seconds).
|
|
13165
|
+
* @returns
|
|
13166
|
+
* A promise resolving to a Result containing a tuple of cancel transaction hash and destination transaction hash,
|
|
13167
|
+
* or an IntentError if the operation fails.
|
|
13168
|
+
*
|
|
13169
|
+
* @example
|
|
13170
|
+
* // Get intent first (or use intent from createLimitOrder response)
|
|
13171
|
+
* const intent: Intent = await swapService.getIntent(txHash);
|
|
13172
|
+
*
|
|
13173
|
+
* // Cancel the limit order
|
|
13174
|
+
* const result = await swapService.cancelLimitOrder({
|
|
13175
|
+
* intent,
|
|
13176
|
+
* spokeProvider,
|
|
13177
|
+
* timeout, // optional
|
|
13178
|
+
* });
|
|
13179
|
+
*
|
|
13180
|
+
* if (result.ok) {
|
|
13181
|
+
* const [cancelTxHash, dstTxHash] = result.value;
|
|
13182
|
+
* console.log('Cancel transaction hash:', cancelTxHash);
|
|
13183
|
+
* console.log('Destination transaction hash:', dstTxHash);
|
|
13184
|
+
* } else {
|
|
13185
|
+
* // handle error
|
|
13186
|
+
* console.error('[cancelLimitOrder] error:', result.error);
|
|
13187
|
+
* }
|
|
13188
|
+
*/
|
|
13189
|
+
async cancelLimitOrder({
|
|
13190
|
+
intent,
|
|
13191
|
+
spokeProvider,
|
|
13192
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
13193
|
+
}) {
|
|
13194
|
+
return this.cancelAndSubmitIntent({
|
|
13195
|
+
intent,
|
|
13196
|
+
spokeProvider,
|
|
13197
|
+
timeout
|
|
13198
|
+
});
|
|
13199
|
+
}
|
|
12999
13200
|
/**
|
|
13000
13201
|
* Cancels an intent
|
|
13001
13202
|
* @param {Intent} intent - The intent to cancel
|
|
@@ -13037,7 +13238,97 @@ var SwapService = class {
|
|
|
13037
13238
|
} catch (error) {
|
|
13038
13239
|
return {
|
|
13039
13240
|
ok: false,
|
|
13040
|
-
error
|
|
13241
|
+
error: {
|
|
13242
|
+
code: "CANCEL_FAILED",
|
|
13243
|
+
data: {
|
|
13244
|
+
payload: intent,
|
|
13245
|
+
error
|
|
13246
|
+
}
|
|
13247
|
+
}
|
|
13248
|
+
};
|
|
13249
|
+
}
|
|
13250
|
+
}
|
|
13251
|
+
/**
|
|
13252
|
+
* Cancels an intent on the spoke chain, submits the cancel intent to the relayer API,
|
|
13253
|
+
* and waits until the intent cancel is executed (on the destination/hub chain).
|
|
13254
|
+
* Follows a similar workflow to createAndSubmitIntent, but for cancelling.
|
|
13255
|
+
*
|
|
13256
|
+
* @param params - The parameters for canceling and submitting the intent.
|
|
13257
|
+
* @param params.intent - The intent to be canceled.
|
|
13258
|
+
* @param params.spokeProvider - The provider for the spoke chain.
|
|
13259
|
+
* @param params.timeout - Optional timeout in milliseconds (default: 60 seconds).
|
|
13260
|
+
* @returns
|
|
13261
|
+
* A Result containing the SolverExecutionResponse (cancel tx), intent, and relay info,
|
|
13262
|
+
* or an IntentError on failure.
|
|
13263
|
+
*/
|
|
13264
|
+
async cancelAndSubmitIntent({
|
|
13265
|
+
intent,
|
|
13266
|
+
spokeProvider,
|
|
13267
|
+
timeout = DEFAULT_RELAY_TX_TIMEOUT
|
|
13268
|
+
}) {
|
|
13269
|
+
try {
|
|
13270
|
+
const cancelResult = await this.cancelIntent(intent, spokeProvider, false);
|
|
13271
|
+
if (!cancelResult.ok) {
|
|
13272
|
+
return cancelResult;
|
|
13273
|
+
}
|
|
13274
|
+
const cancelTxHash = cancelResult.value;
|
|
13275
|
+
const verifyTxHashResult = await SpokeService.verifyTxHash(cancelTxHash, spokeProvider);
|
|
13276
|
+
if (!verifyTxHashResult.ok) {
|
|
13277
|
+
return {
|
|
13278
|
+
ok: false,
|
|
13279
|
+
error: {
|
|
13280
|
+
code: "CANCEL_FAILED",
|
|
13281
|
+
data: {
|
|
13282
|
+
payload: intent,
|
|
13283
|
+
error: verifyTxHashResult.error
|
|
13284
|
+
}
|
|
13285
|
+
}
|
|
13286
|
+
};
|
|
13287
|
+
}
|
|
13288
|
+
let dstIntentTxHash;
|
|
13289
|
+
if (spokeProvider.chainConfig.chain.id !== this.hubProvider.chainConfig.chain.id) {
|
|
13290
|
+
const intentRelayChainId = intent.srcChain.toString();
|
|
13291
|
+
const submitPayload = {
|
|
13292
|
+
action: "submit",
|
|
13293
|
+
params: {
|
|
13294
|
+
chain_id: intentRelayChainId,
|
|
13295
|
+
tx_hash: cancelTxHash
|
|
13296
|
+
}
|
|
13297
|
+
};
|
|
13298
|
+
const submitResult = await this.submitIntent(submitPayload);
|
|
13299
|
+
if (!submitResult.ok) {
|
|
13300
|
+
return submitResult;
|
|
13301
|
+
}
|
|
13302
|
+
const packet = await waitUntilIntentExecuted({
|
|
13303
|
+
intentRelayChainId,
|
|
13304
|
+
spokeTxHash: cancelTxHash,
|
|
13305
|
+
timeout,
|
|
13306
|
+
apiUrl: this.config.relayerApiEndpoint
|
|
13307
|
+
});
|
|
13308
|
+
if (!packet.ok) {
|
|
13309
|
+
return {
|
|
13310
|
+
ok: false,
|
|
13311
|
+
error: packet.error
|
|
13312
|
+
};
|
|
13313
|
+
}
|
|
13314
|
+
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
13315
|
+
} else {
|
|
13316
|
+
dstIntentTxHash = cancelTxHash;
|
|
13317
|
+
}
|
|
13318
|
+
return {
|
|
13319
|
+
ok: true,
|
|
13320
|
+
value: [cancelTxHash, dstIntentTxHash]
|
|
13321
|
+
};
|
|
13322
|
+
} catch (error) {
|
|
13323
|
+
return {
|
|
13324
|
+
ok: false,
|
|
13325
|
+
error: {
|
|
13326
|
+
code: "CANCEL_FAILED",
|
|
13327
|
+
data: {
|
|
13328
|
+
payload: intent,
|
|
13329
|
+
error
|
|
13330
|
+
}
|
|
13331
|
+
}
|
|
13041
13332
|
};
|
|
13042
13333
|
}
|
|
13043
13334
|
}
|
|
@@ -13600,65 +13891,25 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13600
13891
|
);
|
|
13601
13892
|
}
|
|
13602
13893
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
13603
|
-
if (spokeProvider
|
|
13894
|
+
if (isStellarSpokeProviderType(spokeProvider) && (params.action === "supply" || params.action === "repay")) {
|
|
13604
13895
|
return {
|
|
13605
13896
|
ok: true,
|
|
13606
13897
|
value: await StellarSpokeService.hasSufficientTrustline(params.token, params.amount, spokeProvider)
|
|
13607
13898
|
};
|
|
13608
13899
|
}
|
|
13609
|
-
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;
|
|
13610
13905
|
return await Erc20Service.isAllowanceValid(
|
|
13611
13906
|
params.token,
|
|
13612
13907
|
params.amount,
|
|
13613
13908
|
walletAddress,
|
|
13614
|
-
|
|
13909
|
+
spender,
|
|
13615
13910
|
spokeProvider
|
|
13616
13911
|
);
|
|
13617
13912
|
}
|
|
13618
|
-
if (spokeProvider instanceof SonicSpokeProvider && spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
13619
|
-
if (params.action === "withdraw") {
|
|
13620
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
13621
|
-
params.token,
|
|
13622
|
-
params.amount,
|
|
13623
|
-
params.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13624
|
-
this.data,
|
|
13625
|
-
this.configService
|
|
13626
|
-
);
|
|
13627
|
-
return await SonicSpokeService.isWithdrawApproved(
|
|
13628
|
-
walletAddress,
|
|
13629
|
-
withdrawInfo,
|
|
13630
|
-
spokeProvider
|
|
13631
|
-
);
|
|
13632
|
-
}
|
|
13633
|
-
if (params.action === "borrow") {
|
|
13634
|
-
const borrowInfo = await SonicSpokeService.getBorrowInfo(
|
|
13635
|
-
params.token,
|
|
13636
|
-
params.amount,
|
|
13637
|
-
params.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13638
|
-
this.data,
|
|
13639
|
-
this.configService,
|
|
13640
|
-
this.config
|
|
13641
|
-
);
|
|
13642
|
-
return await SonicSpokeService.isBorrowApproved(
|
|
13643
|
-
walletAddress,
|
|
13644
|
-
borrowInfo,
|
|
13645
|
-
spokeProvider
|
|
13646
|
-
);
|
|
13647
|
-
}
|
|
13648
|
-
if (params.action === "supply" || params.action === "repay") {
|
|
13649
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
13650
|
-
walletAddress,
|
|
13651
|
-
spokeProvider
|
|
13652
|
-
);
|
|
13653
|
-
return await Erc20Service.isAllowanceValid(
|
|
13654
|
-
params.token,
|
|
13655
|
-
params.amount,
|
|
13656
|
-
walletAddress,
|
|
13657
|
-
userRouter,
|
|
13658
|
-
spokeProvider
|
|
13659
|
-
);
|
|
13660
|
-
}
|
|
13661
|
-
}
|
|
13662
13913
|
return {
|
|
13663
13914
|
ok: true,
|
|
13664
13915
|
value: true
|
|
@@ -13714,7 +13965,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13714
13965
|
);
|
|
13715
13966
|
}
|
|
13716
13967
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
13717
|
-
if (spokeProvider
|
|
13968
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
13718
13969
|
invariant6(
|
|
13719
13970
|
params.action === "supply" || params.action === "repay",
|
|
13720
13971
|
"Invalid action (only supply and repay are supported on stellar)"
|
|
@@ -13725,16 +13976,20 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13725
13976
|
value: result
|
|
13726
13977
|
};
|
|
13727
13978
|
}
|
|
13728
|
-
if (spokeProvider
|
|
13979
|
+
if (isEvmSpokeProviderType(spokeProvider) || isSonicSpokeProviderType(spokeProvider)) {
|
|
13729
13980
|
invariant6(
|
|
13730
13981
|
params.action === "supply" || params.action === "repay",
|
|
13731
13982
|
"Invalid action (only supply and repay are supported on evm)"
|
|
13732
13983
|
);
|
|
13733
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;
|
|
13734
13989
|
const result = await Erc20Service.approve(
|
|
13735
13990
|
params.token,
|
|
13736
13991
|
params.amount,
|
|
13737
|
-
|
|
13992
|
+
spender,
|
|
13738
13993
|
spokeProvider,
|
|
13739
13994
|
raw
|
|
13740
13995
|
);
|
|
@@ -13743,69 +13998,6 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13743
13998
|
value: result
|
|
13744
13999
|
};
|
|
13745
14000
|
}
|
|
13746
|
-
if (spokeProvider instanceof SonicSpokeProvider && spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
13747
|
-
invariant6(
|
|
13748
|
-
params.action === "withdraw" || params.action === "borrow" || params.action === "supply" || params.action === "repay",
|
|
13749
|
-
"Invalid action (only withdraw, borrow, supply and repay are supported on sonic)"
|
|
13750
|
-
);
|
|
13751
|
-
invariant6(isAddress(params.token), "Invalid token address");
|
|
13752
|
-
if (params.action === "withdraw") {
|
|
13753
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
13754
|
-
params.token,
|
|
13755
|
-
params.amount,
|
|
13756
|
-
params?.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13757
|
-
this.data,
|
|
13758
|
-
this.configService
|
|
13759
|
-
);
|
|
13760
|
-
const result = await SonicSpokeService.approveWithdraw(
|
|
13761
|
-
walletAddress,
|
|
13762
|
-
withdrawInfo,
|
|
13763
|
-
spokeProvider,
|
|
13764
|
-
raw
|
|
13765
|
-
);
|
|
13766
|
-
return {
|
|
13767
|
-
ok: true,
|
|
13768
|
-
value: result
|
|
13769
|
-
};
|
|
13770
|
-
}
|
|
13771
|
-
if (params.action === "borrow") {
|
|
13772
|
-
const borrowInfo = await SonicSpokeService.getBorrowInfo(
|
|
13773
|
-
params.token,
|
|
13774
|
-
params.amount,
|
|
13775
|
-
params?.toChainId ?? spokeProvider.chainConfig.chain.id,
|
|
13776
|
-
this.data,
|
|
13777
|
-
this.configService,
|
|
13778
|
-
this.config
|
|
13779
|
-
);
|
|
13780
|
-
const result = await SonicSpokeService.approveBorrow(
|
|
13781
|
-
walletAddress,
|
|
13782
|
-
borrowInfo,
|
|
13783
|
-
spokeProvider,
|
|
13784
|
-
raw
|
|
13785
|
-
);
|
|
13786
|
-
return {
|
|
13787
|
-
ok: true,
|
|
13788
|
-
value: result
|
|
13789
|
-
};
|
|
13790
|
-
}
|
|
13791
|
-
if (params.action === "supply" || params.action === "repay") {
|
|
13792
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
13793
|
-
walletAddress,
|
|
13794
|
-
spokeProvider
|
|
13795
|
-
);
|
|
13796
|
-
const result = await Erc20Service.approve(
|
|
13797
|
-
params.token,
|
|
13798
|
-
params.amount,
|
|
13799
|
-
userRouter,
|
|
13800
|
-
spokeProvider,
|
|
13801
|
-
raw
|
|
13802
|
-
);
|
|
13803
|
-
return {
|
|
13804
|
-
ok: true,
|
|
13805
|
-
value: result
|
|
13806
|
-
};
|
|
13807
|
-
}
|
|
13808
|
-
}
|
|
13809
14001
|
return {
|
|
13810
14002
|
ok: false,
|
|
13811
14003
|
error: new Error("Approve only supported for EVM spoke chains")
|
|
@@ -13864,7 +14056,9 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13864
14056
|
};
|
|
13865
14057
|
}
|
|
13866
14058
|
let intentTxHash = null;
|
|
13867
|
-
if (spokeProvider.chainConfig.chain.id
|
|
14059
|
+
if (spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id) {
|
|
14060
|
+
intentTxHash = txResult.value;
|
|
14061
|
+
} else {
|
|
13868
14062
|
const packetResult = await relayTxAndWaitPacket(
|
|
13869
14063
|
txResult.value,
|
|
13870
14064
|
spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
|
|
@@ -13885,8 +14079,6 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13885
14079
|
};
|
|
13886
14080
|
}
|
|
13887
14081
|
intentTxHash = packetResult.value.dst_tx_hash;
|
|
13888
|
-
} else {
|
|
13889
|
-
intentTxHash = txResult.value;
|
|
13890
14082
|
}
|
|
13891
14083
|
return { ok: true, value: [txResult.value, intentTxHash] };
|
|
13892
14084
|
} catch (error) {
|
|
@@ -13947,13 +14139,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
13947
14139
|
this.configService.isMoneyMarketSupportedToken(fromChainId, params.token),
|
|
13948
14140
|
`Unsupported spoke chain (${fromChainId}) token: ${params.token}`
|
|
13949
14141
|
);
|
|
13950
|
-
const fromHubWallet = await
|
|
13951
|
-
|
|
14142
|
+
const [fromHubWallet, toHubWallet] = await Promise.all([
|
|
14143
|
+
HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider),
|
|
14144
|
+
HubService.getUserHubWalletAddress(toAddress, toChainId, this.hubProvider)
|
|
14145
|
+
]);
|
|
13952
14146
|
const data = this.buildSupplyData(fromChainId, params.token, params.amount, toHubWallet);
|
|
13953
14147
|
const txResult = await SpokeService.deposit(
|
|
13954
14148
|
{
|
|
13955
14149
|
from: fromAddress,
|
|
13956
|
-
to:
|
|
14150
|
+
to: fromHubWallet,
|
|
13957
14151
|
token: params.token,
|
|
13958
14152
|
amount: params.amount,
|
|
13959
14153
|
data
|
|
@@ -14033,7 +14227,7 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14033
14227
|
if (spokeProvider.chainConfig.chain.id !== this.hubProvider.chainConfig.chain.id || params.toChainId && params.toAddress && params.toChainId !== this.hubProvider.chainConfig.chain.id) {
|
|
14034
14228
|
const packetResult = await relayTxAndWaitPacket(
|
|
14035
14229
|
txResult.value,
|
|
14036
|
-
spokeProvider
|
|
14230
|
+
isSolanaSpokeProviderType(spokeProvider) ? txResult.data : void 0,
|
|
14037
14231
|
spokeProvider,
|
|
14038
14232
|
this.config.relayerApiEndpoint,
|
|
14039
14233
|
timeout
|
|
@@ -14102,14 +14296,14 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14102
14296
|
invariant6(params.action === "borrow", "Invalid action");
|
|
14103
14297
|
invariant6(params.token.length > 0, "Token is required");
|
|
14104
14298
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
14105
|
-
const fromChainId = spokeProvider.chainConfig.chain.id;
|
|
14106
|
-
const fromAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
14299
|
+
const fromChainId = params.fromChainId ?? spokeProvider.chainConfig.chain.id;
|
|
14300
|
+
const fromAddress = params.fromAddress ?? await spokeProvider.walletProvider.getWalletAddress();
|
|
14107
14301
|
const toChainId = params.toChainId ?? fromChainId;
|
|
14108
14302
|
const toAddress = params.toAddress ?? fromAddress;
|
|
14109
14303
|
const dstToken = this.configService.getMoneyMarketToken(toChainId, params.token);
|
|
14110
14304
|
invariant6(dstToken, `Money market token not found for spoke chain (${toChainId}) token: ${params.token}`);
|
|
14111
14305
|
const encodedToAddress = encodeAddress(toChainId, toAddress);
|
|
14112
|
-
const fromHubWallet = await
|
|
14306
|
+
const fromHubWallet = await HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider);
|
|
14113
14307
|
const data = this.buildBorrowData(fromHubWallet, encodedToAddress, dstToken.address, params.amount, toChainId);
|
|
14114
14308
|
let txResult;
|
|
14115
14309
|
if (fromChainId === this.hubProvider.chainConfig.chain.id && isSonicSpokeProviderType(spokeProvider)) {
|
|
@@ -14255,29 +14449,9 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14255
14449
|
`Unsupported spoke chain (${toChainId}) token: ${params.token}`
|
|
14256
14450
|
);
|
|
14257
14451
|
const encodedToAddress = encodeAddress(toChainId, toAddress);
|
|
14258
|
-
const fromHubWallet = await
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
const withdrawInfo = await SonicSpokeService.getWithdrawInfo(
|
|
14262
|
-
params.token,
|
|
14263
|
-
params.amount,
|
|
14264
|
-
toChainId,
|
|
14265
|
-
this.data,
|
|
14266
|
-
this.configService
|
|
14267
|
-
);
|
|
14268
|
-
data = await SonicSpokeService.buildWithdrawData(
|
|
14269
|
-
fromAddress,
|
|
14270
|
-
withdrawInfo,
|
|
14271
|
-
params.amount,
|
|
14272
|
-
encodedToAddress,
|
|
14273
|
-
toChainId,
|
|
14274
|
-
spokeProvider,
|
|
14275
|
-
this
|
|
14276
|
-
);
|
|
14277
|
-
} else {
|
|
14278
|
-
data = this.buildWithdrawData(fromHubWallet, encodedToAddress, params.token, params.amount, toChainId);
|
|
14279
|
-
}
|
|
14280
|
-
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);
|
|
14281
14455
|
return {
|
|
14282
14456
|
ok: true,
|
|
14283
14457
|
value: txResult,
|
|
@@ -14417,13 +14591,15 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
14417
14591
|
this.configService.isMoneyMarketSupportedToken(fromChainId, params.token),
|
|
14418
14592
|
`Unsupported spoke chain (${fromChainId}) token: ${params.token}`
|
|
14419
14593
|
);
|
|
14420
|
-
const toHubWallet = await
|
|
14421
|
-
|
|
14594
|
+
const [fromHubWallet, toHubWallet] = await Promise.all([
|
|
14595
|
+
HubService.getUserHubWalletAddress(fromAddress, fromChainId, this.hubProvider),
|
|
14596
|
+
HubService.getUserHubWalletAddress(toAddress, toChainId, this.hubProvider)
|
|
14597
|
+
]);
|
|
14422
14598
|
const data = this.buildRepayData(fromChainId, params.token, params.amount, toHubWallet);
|
|
14423
14599
|
const txResult = await SpokeService.deposit(
|
|
14424
14600
|
{
|
|
14425
14601
|
from: fromAddress,
|
|
14426
|
-
to:
|
|
14602
|
+
to: fromHubWallet,
|
|
14427
14603
|
token: params.token,
|
|
14428
14604
|
amount: params.amount,
|
|
14429
14605
|
data
|
|
@@ -14902,6 +15078,8 @@ var Sodax = class {
|
|
|
14902
15078
|
|
|
14903
15079
|
// src/shared/services/hub/WalletAbstractionService.ts
|
|
14904
15080
|
var WalletAbstractionService = class {
|
|
15081
|
+
constructor() {
|
|
15082
|
+
}
|
|
14905
15083
|
/**
|
|
14906
15084
|
* Gets the hub wallet address for a user based on their spoke chain address.
|
|
14907
15085
|
* @param address - The user's address on the spoke chain
|
|
@@ -14926,6 +15104,40 @@ var WalletAbstractionService = class {
|
|
|
14926
15104
|
);
|
|
14927
15105
|
}
|
|
14928
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
|
+
};
|
|
14929
15141
|
var SuiSpokeService = class _SuiSpokeService {
|
|
14930
15142
|
constructor() {
|
|
14931
15143
|
}
|
|
@@ -15566,6 +15778,9 @@ function parseToStroops(amount) {
|
|
|
15566
15778
|
function sleep(ms) {
|
|
15567
15779
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15568
15780
|
}
|
|
15781
|
+
function isHubSpokeProvider(spokeProvider, hubProvider) {
|
|
15782
|
+
return spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id;
|
|
15783
|
+
}
|
|
15569
15784
|
|
|
15570
15785
|
// src/shared/types.ts
|
|
15571
15786
|
var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
|
|
@@ -15678,6 +15893,29 @@ var BackendApiService = class {
|
|
|
15678
15893
|
const endpoint = `/solver/orderbook?${queryString}`;
|
|
15679
15894
|
return this.makeRequest(endpoint, { method: "GET" });
|
|
15680
15895
|
}
|
|
15896
|
+
/**
|
|
15897
|
+
* Get all intents created by a specific user address with optional filters.
|
|
15898
|
+
*
|
|
15899
|
+
* @param params - Options to filter the user intents.
|
|
15900
|
+
* @param params.userAddress - The user's wallet address on the hub chain (required).
|
|
15901
|
+
* @param params.startDate - Optional. Start timestamp in milliseconds (number, required if filtering by date).
|
|
15902
|
+
* @param params.endDate - Optional. End timestamp in milliseconds (number, required if filtering by date).
|
|
15903
|
+
* @param params.limit - Optional. Max number of results (string).
|
|
15904
|
+
* @param params.offset - Optional. Pagination offset (string).
|
|
15905
|
+
*
|
|
15906
|
+
* @returns {Promise<UserIntentsResponse>} Promise resolving to an array of intent responses for the user.
|
|
15907
|
+
*/
|
|
15908
|
+
async getUserIntents(params) {
|
|
15909
|
+
const { userAddress, startDate, endDate, limit, offset } = params;
|
|
15910
|
+
const queryParams = new URLSearchParams();
|
|
15911
|
+
if (startDate) queryParams.append("startDate", new Date(startDate).toISOString());
|
|
15912
|
+
if (endDate) queryParams.append("endDate", new Date(endDate).toISOString());
|
|
15913
|
+
if (limit) queryParams.append("limit", limit);
|
|
15914
|
+
if (offset) queryParams.append("offset", offset);
|
|
15915
|
+
const queryString = queryParams.toString();
|
|
15916
|
+
const endpoint = queryString.length > 0 ? `/intent/user/${userAddress}?${queryString}` : `/intent/user/${userAddress}`;
|
|
15917
|
+
return this.makeRequest(endpoint, { method: "GET" });
|
|
15918
|
+
}
|
|
15681
15919
|
// Money Market endpoints
|
|
15682
15920
|
/**
|
|
15683
15921
|
* Get money market position for a specific user
|
|
@@ -15884,7 +16122,7 @@ var BridgeService = class {
|
|
|
15884
16122
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
15885
16123
|
invariant6(params.srcAsset.length > 0, "Source asset is required");
|
|
15886
16124
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
15887
|
-
if (spokeProvider
|
|
16125
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
15888
16126
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
|
|
15889
16127
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
15890
16128
|
params.srcAsset,
|
|
@@ -15907,7 +16145,7 @@ var BridgeService = class {
|
|
|
15907
16145
|
value: allowanceResult.value
|
|
15908
16146
|
};
|
|
15909
16147
|
}
|
|
15910
|
-
if (spokeProvider
|
|
16148
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
15911
16149
|
const allowanceResult = await StellarSpokeService.hasSufficientTrustline(
|
|
15912
16150
|
params.srcAsset,
|
|
15913
16151
|
params.amount,
|
|
@@ -15927,9 +16165,12 @@ var BridgeService = class {
|
|
|
15927
16165
|
value: allowanceResult
|
|
15928
16166
|
};
|
|
15929
16167
|
}
|
|
15930
|
-
if (spokeProvider
|
|
16168
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
15931
16169
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
|
|
15932
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16170
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16171
|
+
walletAddress,
|
|
16172
|
+
spokeProvider
|
|
16173
|
+
);
|
|
15933
16174
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
15934
16175
|
params.srcAsset,
|
|
15935
16176
|
params.amount,
|
|
@@ -15981,7 +16222,7 @@ var BridgeService = class {
|
|
|
15981
16222
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
15982
16223
|
invariant6(params.srcAsset.length > 0, "Source asset is required");
|
|
15983
16224
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
15984
|
-
if (spokeProvider
|
|
16225
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
15985
16226
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for EVM chain");
|
|
15986
16227
|
const result = await Erc20Service.approve(
|
|
15987
16228
|
params.srcAsset,
|
|
@@ -15995,14 +16236,14 @@ var BridgeService = class {
|
|
|
15995
16236
|
value: result
|
|
15996
16237
|
};
|
|
15997
16238
|
}
|
|
15998
|
-
if (spokeProvider
|
|
16239
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
15999
16240
|
const result = await StellarSpokeService.requestTrustline(params.srcAsset, params.amount, spokeProvider, raw);
|
|
16000
16241
|
return {
|
|
16001
16242
|
ok: true,
|
|
16002
16243
|
value: result
|
|
16003
16244
|
};
|
|
16004
16245
|
}
|
|
16005
|
-
if (spokeProvider
|
|
16246
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
16006
16247
|
invariant6(isAddress(params.srcAsset), "Invalid source asset address for Sonic chain");
|
|
16007
16248
|
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16008
16249
|
walletAddress,
|
|
@@ -16784,7 +17025,7 @@ var StakingService = class {
|
|
|
16784
17025
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
16785
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;
|
|
16786
17027
|
invariant6(targetToken, "Target token not found");
|
|
16787
|
-
if (spokeProvider
|
|
17028
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
16788
17029
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
16789
17030
|
targetToken,
|
|
16790
17031
|
params.amount,
|
|
@@ -16806,7 +17047,7 @@ var StakingService = class {
|
|
|
16806
17047
|
value: allowanceResult.value
|
|
16807
17048
|
};
|
|
16808
17049
|
}
|
|
16809
|
-
if (spokeProvider
|
|
17050
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
16810
17051
|
const userRouter = await SonicSpokeService.getUserRouter(walletAddress, spokeProvider);
|
|
16811
17052
|
const allowanceResult = await Erc20Service.isAllowanceValid(
|
|
16812
17053
|
targetToken,
|
|
@@ -16829,7 +17070,7 @@ var StakingService = class {
|
|
|
16829
17070
|
value: allowanceResult.value
|
|
16830
17071
|
};
|
|
16831
17072
|
}
|
|
16832
|
-
if (spokeProvider
|
|
17073
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
16833
17074
|
return {
|
|
16834
17075
|
ok: true,
|
|
16835
17076
|
value: await StellarSpokeService.hasSufficientTrustline(targetToken, params.amount, spokeProvider)
|
|
@@ -16875,7 +17116,7 @@ var StakingService = class {
|
|
|
16875
17116
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
16876
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;
|
|
16877
17118
|
invariant6(targetToken, "Target token not found");
|
|
16878
|
-
if (spokeProvider
|
|
17119
|
+
if (isEvmSpokeProviderType(spokeProvider)) {
|
|
16879
17120
|
const result = await Erc20Service.approve(
|
|
16880
17121
|
targetToken,
|
|
16881
17122
|
params.amount,
|
|
@@ -16888,7 +17129,7 @@ var StakingService = class {
|
|
|
16888
17129
|
value: result
|
|
16889
17130
|
};
|
|
16890
17131
|
}
|
|
16891
|
-
if (spokeProvider
|
|
17132
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
16892
17133
|
const userRouter = await SonicSpokeService.getUserRouter(
|
|
16893
17134
|
walletAddress,
|
|
16894
17135
|
spokeProvider
|
|
@@ -16899,7 +17140,7 @@ var StakingService = class {
|
|
|
16899
17140
|
value: result
|
|
16900
17141
|
};
|
|
16901
17142
|
}
|
|
16902
|
-
if (spokeProvider
|
|
17143
|
+
if (isStellarSpokeProviderType(spokeProvider)) {
|
|
16903
17144
|
const result = await StellarSpokeService.requestTrustline(targetToken, params.amount, spokeProvider, raw);
|
|
16904
17145
|
return {
|
|
16905
17146
|
ok: true,
|
|
@@ -17154,7 +17395,13 @@ var StakingService = class {
|
|
|
17154
17395
|
spokeProvider,
|
|
17155
17396
|
this.hubProvider
|
|
17156
17397
|
);
|
|
17157
|
-
const
|
|
17398
|
+
const xSoda = this.hubProvider.chainConfig.addresses.xSoda;
|
|
17399
|
+
const underlyingSodaAmount = await StakingLogic.convertXSodaSharesToSoda(
|
|
17400
|
+
xSoda,
|
|
17401
|
+
params.amount,
|
|
17402
|
+
this.hubProvider.publicClient
|
|
17403
|
+
);
|
|
17404
|
+
const data = this.buildUnstakeData(hubWallet, params, xSoda, underlyingSodaAmount);
|
|
17158
17405
|
let txResult;
|
|
17159
17406
|
if (isHub) {
|
|
17160
17407
|
txResult = await SpokeService.deposit(
|
|
@@ -17197,13 +17444,12 @@ var StakingService = class {
|
|
|
17197
17444
|
* @param params - The unstake parameters
|
|
17198
17445
|
* @returns The encoded contract call data
|
|
17199
17446
|
*/
|
|
17200
|
-
buildUnstakeData(hubWallet, params) {
|
|
17447
|
+
buildUnstakeData(hubWallet, params, xSoda, underlyingSodaAmount) {
|
|
17201
17448
|
const hubConfig = getHubChainConfig();
|
|
17202
17449
|
const stakedSoda = hubConfig.addresses.stakedSoda;
|
|
17203
|
-
const xSoda = hubConfig.addresses.xSoda;
|
|
17204
17450
|
const calls = [];
|
|
17205
17451
|
calls.push(StakingLogic.encodeXSodaRedeem(xSoda, params.amount, hubWallet, hubWallet));
|
|
17206
|
-
calls.push(StakingLogic.encodeUnstake(stakedSoda, hubWallet,
|
|
17452
|
+
calls.push(StakingLogic.encodeUnstake(stakedSoda, hubWallet, underlyingSodaAmount));
|
|
17207
17453
|
return encodeContractCalls(calls);
|
|
17208
17454
|
}
|
|
17209
17455
|
/**
|
|
@@ -18539,23 +18785,23 @@ var MigrationService = class {
|
|
|
18539
18785
|
isIcxMigrateParams(params) || isBalnMigrateParams(params) || isUnifiedBnUSDMigrateParams(params),
|
|
18540
18786
|
"Invalid params"
|
|
18541
18787
|
);
|
|
18542
|
-
if (spokeProvider
|
|
18788
|
+
if (isIconSpokeProviderType(spokeProvider) && (isIcxMigrateParams(params) || isBalnMigrateParams(params))) {
|
|
18543
18789
|
return {
|
|
18544
18790
|
ok: true,
|
|
18545
18791
|
value: true
|
|
18546
18792
|
};
|
|
18547
18793
|
}
|
|
18548
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18549
|
-
const
|
|
18794
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18795
|
+
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
18550
18796
|
return await Erc20Service.isAllowanceValid(
|
|
18551
18797
|
params.srcbnUSD,
|
|
18552
18798
|
params.amount,
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
|
|
18799
|
+
walletAddress,
|
|
18800
|
+
isSonicSpokeProviderType(spokeProvider) ? spokeProvider.chainConfig.bnUSD : spokeProvider.chainConfig.addresses.assetManager,
|
|
18801
|
+
spokeProvider
|
|
18556
18802
|
);
|
|
18557
18803
|
}
|
|
18558
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18804
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18559
18805
|
return {
|
|
18560
18806
|
ok: true,
|
|
18561
18807
|
value: await StellarSpokeService.hasSufficientTrustline(params.srcbnUSD, params.amount, spokeProvider)
|
|
@@ -18570,49 +18816,37 @@ var MigrationService = class {
|
|
|
18570
18816
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18571
18817
|
invariant6(params.to.length > 0, "To address is required");
|
|
18572
18818
|
invariant6(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18573
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18574
|
-
const evmSpokeProvider = spokeProvider;
|
|
18819
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18575
18820
|
let spender;
|
|
18576
18821
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18577
|
-
if (spokeProvider
|
|
18578
|
-
spender = await SonicSpokeService.getUserRouter(
|
|
18822
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
18823
|
+
spender = await SonicSpokeService.getUserRouter(
|
|
18824
|
+
wallet,
|
|
18825
|
+
spokeProvider
|
|
18826
|
+
);
|
|
18579
18827
|
} else {
|
|
18580
|
-
spender =
|
|
18828
|
+
spender = spokeProvider.chainConfig.addresses.assetManager;
|
|
18581
18829
|
}
|
|
18582
18830
|
return await Erc20Service.isAllowanceValid(
|
|
18583
18831
|
params.srcbnUSD,
|
|
18584
18832
|
params.amount,
|
|
18585
18833
|
wallet,
|
|
18586
18834
|
spender,
|
|
18587
|
-
|
|
18588
|
-
);
|
|
18589
|
-
}
|
|
18590
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider.chainConfig.chain.type === "EVM") {
|
|
18591
|
-
const evmSpokeProvider = spokeProvider;
|
|
18592
|
-
let spender;
|
|
18593
|
-
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18594
|
-
if (spokeProvider instanceof SonicSpokeProvider) {
|
|
18595
|
-
spender = await SonicSpokeService.getUserRouter(wallet, spokeProvider);
|
|
18596
|
-
} else {
|
|
18597
|
-
spender = evmSpokeProvider.chainConfig.addresses.assetManager;
|
|
18598
|
-
}
|
|
18599
|
-
return await Erc20Service.isAllowanceValid(
|
|
18600
|
-
params.srcbnUSD,
|
|
18601
|
-
params.amount,
|
|
18602
|
-
wallet,
|
|
18603
|
-
spender,
|
|
18604
|
-
evmSpokeProvider
|
|
18835
|
+
spokeProvider
|
|
18605
18836
|
);
|
|
18606
18837
|
}
|
|
18607
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18838
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18608
18839
|
return {
|
|
18609
18840
|
ok: true,
|
|
18610
18841
|
value: await StellarSpokeService.hasSufficientTrustline(params.srcbnUSD, params.amount, spokeProvider)
|
|
18611
18842
|
};
|
|
18612
18843
|
}
|
|
18613
|
-
if (spokeProvider
|
|
18844
|
+
if (isSonicSpokeProviderType(spokeProvider) && isIcxCreateRevertMigrationParams(params)) {
|
|
18614
18845
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18615
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18846
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18847
|
+
wallet,
|
|
18848
|
+
spokeProvider
|
|
18849
|
+
);
|
|
18616
18850
|
return await Erc20Service.isAllowanceValid(
|
|
18617
18851
|
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
18618
18852
|
params.amount,
|
|
@@ -18658,13 +18892,12 @@ var MigrationService = class {
|
|
|
18658
18892
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18659
18893
|
invariant6(params.to.length > 0, "To address is required");
|
|
18660
18894
|
invariant6(isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18661
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18662
|
-
const evmSpokeProvider = spokeProvider;
|
|
18895
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18663
18896
|
const result = await Erc20Service.approve(
|
|
18664
18897
|
params.srcbnUSD,
|
|
18665
18898
|
params.amount,
|
|
18666
|
-
|
|
18667
|
-
|
|
18899
|
+
isSonicSpokeProviderType(spokeProvider) ? spokeProvider.chainConfig.bnUSD : spokeProvider.chainConfig.addresses.assetManager,
|
|
18900
|
+
spokeProvider,
|
|
18668
18901
|
raw
|
|
18669
18902
|
);
|
|
18670
18903
|
return {
|
|
@@ -18672,7 +18905,7 @@ var MigrationService = class {
|
|
|
18672
18905
|
value: result
|
|
18673
18906
|
};
|
|
18674
18907
|
}
|
|
18675
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18908
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18676
18909
|
const result = await StellarSpokeService.requestTrustline(params.srcbnUSD, params.amount, spokeProvider, raw);
|
|
18677
18910
|
return {
|
|
18678
18911
|
ok: true,
|
|
@@ -18688,20 +18921,22 @@ var MigrationService = class {
|
|
|
18688
18921
|
invariant6(params.amount > 0n, "Amount must be greater than 0");
|
|
18689
18922
|
invariant6(params.to.length > 0, "To address is required");
|
|
18690
18923
|
invariant6(isIcxCreateRevertMigrationParams(params) || isUnifiedBnUSDMigrateParams(params), "Invalid params");
|
|
18691
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18692
|
-
const evmSpokeProvider = spokeProvider;
|
|
18924
|
+
if (isUnifiedBnUSDMigrateParams(params) && isEvmSpokeProviderType(spokeProvider)) {
|
|
18693
18925
|
let spender;
|
|
18694
18926
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18695
|
-
if (spokeProvider
|
|
18696
|
-
spender = await SonicSpokeService.getUserRouter(
|
|
18927
|
+
if (isSonicSpokeProviderType(spokeProvider)) {
|
|
18928
|
+
spender = await SonicSpokeService.getUserRouter(
|
|
18929
|
+
wallet,
|
|
18930
|
+
spokeProvider
|
|
18931
|
+
);
|
|
18697
18932
|
} else {
|
|
18698
|
-
spender =
|
|
18933
|
+
spender = spokeProvider.chainConfig.addresses.assetManager;
|
|
18699
18934
|
}
|
|
18700
18935
|
const result = await Erc20Service.approve(
|
|
18701
18936
|
params.srcbnUSD,
|
|
18702
18937
|
params.amount,
|
|
18703
18938
|
spender,
|
|
18704
|
-
|
|
18939
|
+
spokeProvider,
|
|
18705
18940
|
raw
|
|
18706
18941
|
);
|
|
18707
18942
|
return {
|
|
@@ -18709,16 +18944,19 @@ var MigrationService = class {
|
|
|
18709
18944
|
value: result
|
|
18710
18945
|
};
|
|
18711
18946
|
}
|
|
18712
|
-
if (isUnifiedBnUSDMigrateParams(params) && spokeProvider
|
|
18947
|
+
if (isUnifiedBnUSDMigrateParams(params) && isStellarSpokeProviderType(spokeProvider)) {
|
|
18713
18948
|
const result = await StellarSpokeService.requestTrustline(params.srcbnUSD, params.amount, spokeProvider, raw);
|
|
18714
18949
|
return {
|
|
18715
18950
|
ok: true,
|
|
18716
18951
|
value: result
|
|
18717
18952
|
};
|
|
18718
18953
|
}
|
|
18719
|
-
if (spokeProvider
|
|
18954
|
+
if (isSonicSpokeProviderType(spokeProvider) && isIcxCreateRevertMigrationParams(params)) {
|
|
18720
18955
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
18721
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18956
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
18957
|
+
wallet,
|
|
18958
|
+
spokeProvider
|
|
18959
|
+
);
|
|
18722
18960
|
const result = await Erc20Service.approve(
|
|
18723
18961
|
this.hubProvider.chainConfig.addresses.sodaToken,
|
|
18724
18962
|
params.amount,
|
|
@@ -18791,7 +19029,7 @@ var MigrationService = class {
|
|
|
18791
19029
|
*/
|
|
18792
19030
|
async migratebnUSD(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT, unchecked = false) {
|
|
18793
19031
|
try {
|
|
18794
|
-
const intentResult = await this.createMigratebnUSDIntent(params, spokeProvider, unchecked);
|
|
19032
|
+
const intentResult = await this.createMigratebnUSDIntent(params, spokeProvider, unchecked, false);
|
|
18795
19033
|
if (!intentResult.ok) {
|
|
18796
19034
|
return {
|
|
18797
19035
|
ok: false,
|
|
@@ -18878,7 +19116,7 @@ var MigrationService = class {
|
|
|
18878
19116
|
*/
|
|
18879
19117
|
async migrateIcxToSoda(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
18880
19118
|
try {
|
|
18881
|
-
const txResult = await this.createMigrateIcxToSodaIntent(params, spokeProvider);
|
|
19119
|
+
const txResult = await this.createMigrateIcxToSodaIntent(params, spokeProvider, false);
|
|
18882
19120
|
if (!txResult.ok) {
|
|
18883
19121
|
return {
|
|
18884
19122
|
ok: false,
|
|
@@ -18942,7 +19180,7 @@ var MigrationService = class {
|
|
|
18942
19180
|
*/
|
|
18943
19181
|
async revertMigrateSodaToIcx(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
18944
19182
|
try {
|
|
18945
|
-
const txResult = await this.createRevertSodaToIcxMigrationIntent(params, spokeProvider);
|
|
19183
|
+
const txResult = await this.createRevertSodaToIcxMigrationIntent(params, spokeProvider, false);
|
|
18946
19184
|
if (!txResult.ok) {
|
|
18947
19185
|
return txResult;
|
|
18948
19186
|
}
|
|
@@ -19005,7 +19243,7 @@ var MigrationService = class {
|
|
|
19005
19243
|
*/
|
|
19006
19244
|
async migrateBaln(params, spokeProvider, timeout = DEFAULT_RELAY_TX_TIMEOUT) {
|
|
19007
19245
|
try {
|
|
19008
|
-
const txResult = await this.createMigrateBalnIntent(params, spokeProvider);
|
|
19246
|
+
const txResult = await this.createMigrateBalnIntent(params, spokeProvider, false);
|
|
19009
19247
|
if (!txResult.ok) {
|
|
19010
19248
|
return {
|
|
19011
19249
|
ok: false,
|
|
@@ -19268,7 +19506,7 @@ var MigrationService = class {
|
|
|
19268
19506
|
params.address.toLowerCase() === spokeProvider.chainConfig.addresses.wICX.toLowerCase() || params.address.toLowerCase() === spokeProvider.chainConfig.nativeToken.toLowerCase(),
|
|
19269
19507
|
"Token must be wICX or native ICX token"
|
|
19270
19508
|
);
|
|
19271
|
-
invariant6(spokeProvider
|
|
19509
|
+
invariant6(isIconSpokeProviderType(spokeProvider), "Spoke provider must be an IconSpokeProviderType");
|
|
19272
19510
|
const availableAmount = await this.icxMigration.getAvailableAmount();
|
|
19273
19511
|
if (availableAmount < params.amount) {
|
|
19274
19512
|
throw new Error(
|
|
@@ -19326,7 +19564,10 @@ var MigrationService = class {
|
|
|
19326
19564
|
async createRevertSodaToIcxMigrationIntent(params, spokeProvider, raw) {
|
|
19327
19565
|
try {
|
|
19328
19566
|
const wallet = await spokeProvider.walletProvider.getWalletAddress();
|
|
19329
|
-
const userRouter = await SonicSpokeService.getUserRouter(
|
|
19567
|
+
const userRouter = await SonicSpokeService.getUserRouter(
|
|
19568
|
+
wallet,
|
|
19569
|
+
spokeProvider
|
|
19570
|
+
);
|
|
19330
19571
|
const wICX = this.configService.spokeChainConfig[ICON_MAINNET_CHAIN_ID]?.addresses.wICX;
|
|
19331
19572
|
invariant6(wICX, "wICX token not found");
|
|
19332
19573
|
const data = this.icxMigration.revertMigration({
|
|
@@ -19727,6 +19968,6 @@ var BalnSwapService = class {
|
|
|
19727
19968
|
}
|
|
19728
19969
|
};
|
|
19729
19970
|
|
|
19730
|
-
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 };
|
|
19731
19972
|
//# sourceMappingURL=index.mjs.map
|
|
19732
19973
|
//# sourceMappingURL=index.mjs.map
|