@sodax/sdk 0.0.1-rc.9 β 1.0.0-rc.1
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/LICENSE +1 -1
- package/README.md +228 -68
- package/dist/index.cjs +16324 -8317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8638 -4615
- package/dist/index.d.ts +8638 -4615
- package/dist/index.mjs +16214 -8286
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -29
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,27 +4,45 @@ The Sodax SDK provides a comprehensive interface for interacting with the Sodax
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
### Swaps (Solver / Intents)
|
|
8
|
-
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon) β
|
|
7
|
+
### Swaps (Solver / Intents) [π](./docs/SOLVER.md)
|
|
8
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVMβ, Lightlink) β
|
|
9
9
|
- Sui β
|
|
10
10
|
- Stellar β
|
|
11
11
|
- ICON β
|
|
12
|
-
- Solana
|
|
13
|
-
- Injective
|
|
14
|
-
- Havah β Coming soon
|
|
12
|
+
- Solana β
|
|
13
|
+
- Injective β
|
|
15
14
|
|
|
16
|
-
### Lend and Borrow (Money Market)
|
|
17
|
-
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon) β
|
|
15
|
+
### Lend and Borrow (Money Market) [π](./docs/MONEY_MARKET.md)
|
|
16
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVM, Lightlink) β
|
|
18
17
|
- Sui β
|
|
19
18
|
- Stellar β
|
|
20
19
|
- ICON β
|
|
21
|
-
- Solana
|
|
22
|
-
- Injective
|
|
23
|
-
- Havah β Coming soon
|
|
20
|
+
- Solana β
|
|
21
|
+
- Injective β
|
|
24
22
|
|
|
23
|
+
### Cross-chain bridging (Bridge) [π](./docs/BRIDGE.md)
|
|
24
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVM, Lightlink) β
|
|
25
|
+
- Sui β
|
|
26
|
+
- Stellar β
|
|
27
|
+
- ICON β
|
|
28
|
+
- Solana β
|
|
29
|
+
- Injective β
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
### Migration [π](./docs/MIGRATION.md)
|
|
32
|
+
- Legacy bnUSD <> New bnUSD:
|
|
33
|
+
- ICX <> SODA
|
|
34
|
+
- BALN <> SODA
|
|
35
|
+
|
|
36
|
+
### Staking SODA [π](./docs/STAKING.md)
|
|
37
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVMβ, Lightlink) β
|
|
38
|
+
- Sui β
|
|
39
|
+
- Stellar β
|
|
40
|
+
- ICON β
|
|
41
|
+
- Solana β
|
|
42
|
+
- Injective β
|
|
27
43
|
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
28
46
|
```bash
|
|
29
47
|
# Using npm
|
|
30
48
|
npm install @sodax/sdk
|
|
@@ -62,8 +80,8 @@ How to setup local development
|
|
|
62
80
|
## Intent Solver Endpoints
|
|
63
81
|
|
|
64
82
|
Current Intent Solver API endpoints:
|
|
65
|
-
- **Production (mainnet)**: "
|
|
66
|
-
- **Staging** (mainnet): "https://
|
|
83
|
+
- **Production (mainnet)**: "https://sodax-solver-staging.iconblockchain.xyz"
|
|
84
|
+
- **Staging** (mainnet): "https://sodax-solver-staging.iconblockchain.xyz"
|
|
67
85
|
|
|
68
86
|
**Note** Staging endpoint contains features to be potentially released and is subject to frequent change!
|
|
69
87
|
|
|
@@ -77,19 +95,31 @@ Current Relayer API endpoints:
|
|
|
77
95
|
|
|
78
96
|
## Usage
|
|
79
97
|
|
|
80
|
-
The Sodax SDK is initialized by creating a new `Sodax` instance with your desired configuration. The SDK supports both
|
|
98
|
+
The Sodax SDK is initialized by creating a new `Sodax` instance with your desired configuration. The SDK supports both Swaps (for intent-based solver swaps) and Money Market (for cross-chain lending and borrowing) services.
|
|
81
99
|
|
|
82
|
-
Both Solver and Money Market configuration and optional. You can always choose to use just a specific feature.
|
|
100
|
+
Both Swaps (Solver) and Money Market configuration and optional. You can always choose to use just a specific feature.
|
|
83
101
|
|
|
84
102
|
### Basic Configuration
|
|
85
103
|
|
|
86
104
|
```typescript
|
|
105
|
+
import { Sodax } from '@sodax/sdk';
|
|
106
|
+
|
|
87
107
|
// Initialize Sodax using default Sonic mainnet configurations (no fees)
|
|
88
108
|
const sodax = new Sodax();
|
|
89
109
|
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
// If you want dynamic (backend API based - contains latest tokens) configuration,
|
|
111
|
+
// make sure to initialize the instance before usage!
|
|
112
|
+
// By default, configuration from the specific SDK version you are using is used
|
|
113
|
+
await sodax.initialize();
|
|
114
|
+
|
|
115
|
+
// Use default config but put fee on swaps (solver intent swaps)
|
|
116
|
+
const partnerFeePercentage = {
|
|
117
|
+
address: '0x0000000000000000000000000000000000000000', // address to receive fee
|
|
118
|
+
percentage: 100, // 100 = 1%, 10000 = 100%
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const sodaxWithSwapFees = new Sodax({
|
|
122
|
+
swap: { partnerFee: partnerFeePercentage },
|
|
93
123
|
});
|
|
94
124
|
|
|
95
125
|
// Use default config with fee on money market (borrows)
|
|
@@ -97,137 +127,185 @@ const sodaxWithMoneyMarketFees = new Sodax({
|
|
|
97
127
|
moneyMarket: { partnerFee: partnerFeePercentage },
|
|
98
128
|
});
|
|
99
129
|
|
|
100
|
-
//
|
|
130
|
+
// Or use default config with fees on both swaps and money market
|
|
101
131
|
const sodaxWithFees = new Sodax({
|
|
102
|
-
|
|
132
|
+
swap: { partnerFee: partnerFeePercentage },
|
|
103
133
|
moneyMarket: { partnerFee: partnerFeePercentage },
|
|
104
134
|
});
|
|
105
135
|
```
|
|
106
136
|
|
|
107
137
|
### Custom Configuration
|
|
108
138
|
|
|
109
|
-
Sodax SDK can be customized for partner fee,
|
|
139
|
+
Sodax SDK can be customized for partner fee, swaps or money market configuration.
|
|
110
140
|
|
|
111
141
|
```typescript
|
|
112
142
|
import {
|
|
113
143
|
Sodax,
|
|
114
144
|
PartnerFee,
|
|
115
145
|
SolverConfigParams,
|
|
146
|
+
MoneyMarketConfigParams,
|
|
147
|
+
EvmHubProviderConfig,
|
|
116
148
|
getSolverConfig,
|
|
117
149
|
getMoneyMarketConfig,
|
|
150
|
+
getHubChainConfig,
|
|
151
|
+
SONIC_MAINNET_CHAIN_ID,
|
|
118
152
|
} from '@sodax/sdk';
|
|
119
153
|
|
|
120
154
|
// Partner fee can be defined as a percentage or a definite token amount.
|
|
121
155
|
// Fee is optional, you can leave it empty/undefined.
|
|
122
156
|
const partnerFeePercentage = {
|
|
123
|
-
address: '0x0000000000000000000000000000000000000000', // address to receive fee
|
|
157
|
+
address: '0x0000000000000000000000000000000000000000', // address to receive fee
|
|
124
158
|
percentage: 100, // 100 = 1%, 10000 = 100%
|
|
125
159
|
} satisfies PartnerFee;
|
|
126
160
|
|
|
127
161
|
const partnerFeeAmount = {
|
|
128
|
-
address: '0x0000000000000000000000000000000000000000', // address to receive fee
|
|
162
|
+
address: '0x0000000000000000000000000000000000000000', // address to receive fee
|
|
129
163
|
amount: 1000n, // definite amount denominated in token decimal precision
|
|
130
164
|
} satisfies PartnerFee;
|
|
131
165
|
|
|
132
166
|
// Solver config is optional and is required only if you want to use intent based swaps.
|
|
133
167
|
// You can either use custom solver config or the default one (based on hub chain id - defaults to Sonic chain as hub)
|
|
134
168
|
|
|
135
|
-
//
|
|
169
|
+
// Example of custom solver config
|
|
136
170
|
const customSolverConfig = {
|
|
137
171
|
intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
|
|
138
|
-
solverApiEndpoint: 'https://
|
|
172
|
+
solverApiEndpoint: 'https://sodax-solver-staging.iconblockchain.xyz',
|
|
139
173
|
partnerFee: partnerFeePercentage, // or partnerFeeAmount
|
|
140
174
|
} satisfies SolverConfigParams;
|
|
141
175
|
|
|
142
|
-
//
|
|
176
|
+
// Pre-defined default solver config per hub chain id (Sonic hub is the default)
|
|
143
177
|
const solverConfig: SolverConfigParams = getSolverConfig(SONIC_MAINNET_CHAIN_ID);
|
|
144
178
|
|
|
145
|
-
|
|
179
|
+
// Example of custom money market config
|
|
146
180
|
const customMoneyMarketConfig = {
|
|
147
181
|
lendingPool: '0x553434896D39F867761859D0FE7189d2Af70514E',
|
|
148
182
|
uiPoolDataProvider: '0xC04d746C38f1E51C8b3A3E2730250bbAC2F271bf',
|
|
149
183
|
poolAddressesProvider: '0x036aDe0aBAA4c82445Cb7597f2d6d6130C118c7b',
|
|
150
184
|
bnUSD: '0x94dC79ce9C515ba4AE4D195da8E6AB86c69BFc38',
|
|
151
185
|
bnUSDVault: '0xE801CA34E19aBCbFeA12025378D19c4FBE250131',
|
|
152
|
-
} satisfies
|
|
186
|
+
} satisfies MoneyMarketConfigParams;
|
|
153
187
|
|
|
154
|
-
//
|
|
188
|
+
// Pre-defined default money market config per hub chain id (Sonic hub is the default)
|
|
155
189
|
const moneyMarketConfig = getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID);
|
|
156
190
|
|
|
157
|
-
//
|
|
191
|
+
// Example of custom hub config
|
|
158
192
|
const hubConfig = {
|
|
159
193
|
hubRpcUrl: 'https://rpc.soniclabs.com',
|
|
160
194
|
chainConfig: getHubChainConfig(SONIC_MAINNET_CHAIN_ID),
|
|
161
195
|
} satisfies EvmHubProviderConfig;
|
|
162
196
|
|
|
163
|
-
|
|
164
197
|
// Initialize Sodax using custom/default configurations
|
|
165
198
|
const sodax = new Sodax({
|
|
166
|
-
|
|
199
|
+
swap: solverConfig,
|
|
167
200
|
moneyMarket: moneyMarketConfig,
|
|
168
201
|
hubProviderConfig: hubConfig,
|
|
169
202
|
});
|
|
203
|
+
|
|
204
|
+
// Initialize with dynamic configuration (recommended for latest tokens/chains)
|
|
205
|
+
await sodax.initialize();
|
|
170
206
|
```
|
|
171
207
|
|
|
172
208
|
### Using SDK Config and Constants
|
|
173
209
|
|
|
174
|
-
SDK includes predefined configurations of supported chains, tokens and other relevant information for the client to consume.
|
|
210
|
+
SDK includes predefined configurations of supported chains, tokens and other relevant information for the client to consume. All configurations are accessible through the `config` property of the Sodax instance (`sodax.config`), or through service-specific properties for convenience.
|
|
175
211
|
|
|
176
|
-
**NOTE
|
|
212
|
+
**NOTE**: You should generally only use spoke chains configuration to retrieve all supported chains and then invoke per spoke chain based configurations. If you are using hub configurations you should know what you are doing.
|
|
177
213
|
|
|
178
|
-
|
|
214
|
+
**IMPORTANT**: If you want dynamic (backend API based - contains latest tokens) configuration, make sure to initialize the instance before usage:
|
|
215
|
+
```typescript
|
|
216
|
+
await sodax.initialize();
|
|
217
|
+
```
|
|
218
|
+
By default, configuration from the specific SDK version you are using is used.
|
|
219
|
+
|
|
220
|
+
#### General Configuration (sodax.config)
|
|
179
221
|
|
|
180
222
|
```typescript
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
223
|
+
import { Sodax, type SpokeChainId, type HubChainId } from "@sodax/sdk";
|
|
224
|
+
|
|
225
|
+
const sodax = new Sodax();
|
|
226
|
+
await sodax.initialize(); // Initialize for dynamic config (optional but recommended)
|
|
227
|
+
|
|
228
|
+
// All supported hub chains (Sonic mainnet and testnet)
|
|
229
|
+
const hubChains: HubChainId[] = sodax.config.getSupportedHubChains();
|
|
230
|
+
|
|
231
|
+
// All supported spoke chains
|
|
232
|
+
const spokeChains: SpokeChainId[] = sodax.config.getSupportedSpokeChains();
|
|
233
|
+
|
|
234
|
+
// Get all chains configuration
|
|
235
|
+
const chains = sodax.config.getChains();
|
|
236
|
+
|
|
237
|
+
// Get hub assets configuration
|
|
238
|
+
const hubAssets = sodax.config.getHubAssets();
|
|
190
239
|
|
|
191
|
-
|
|
240
|
+
// Get hub vaults configuration
|
|
241
|
+
const hubVaults = sodax.config.getHubVaults();
|
|
192
242
|
|
|
193
|
-
//
|
|
194
|
-
|
|
243
|
+
// Get money market reserve assets
|
|
244
|
+
const moneyMarketReserves = sodax.config.getMoneyMarketReserveAssets();
|
|
195
245
|
|
|
196
|
-
//
|
|
197
|
-
|
|
246
|
+
// Check if a token is valid for a given chain
|
|
247
|
+
const isValid = sodax.config.isValidOriginalAssetAddress(chainId, tokenAddress);
|
|
198
248
|
|
|
199
|
-
//
|
|
200
|
-
|
|
249
|
+
// Get hub asset info for a given chain and original asset
|
|
250
|
+
const hubAssetInfo = sodax.config.getHubAssetInfo(chainId, tokenAddress);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Swap Configuration (sodax.swap)
|
|
201
254
|
|
|
202
|
-
|
|
203
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
import { Sodax, type SpokeChainId, type Token } from "@sodax/sdk";
|
|
204
257
|
|
|
205
|
-
|
|
206
|
-
|
|
258
|
+
const sodax = new Sodax();
|
|
259
|
+
await sodax.initialize(); // Initialize for dynamic config (optional but recommended)
|
|
207
260
|
|
|
208
|
-
//
|
|
209
|
-
const
|
|
261
|
+
// Get supported swap tokens for a specific chain
|
|
262
|
+
const supportedSwapTokens: readonly Token[] = sodax.swap.getSupportedSwapTokensByChainId(chainId);
|
|
210
263
|
|
|
211
|
-
//
|
|
212
|
-
const
|
|
264
|
+
// Get all supported swap tokens per chain
|
|
265
|
+
const allSwapTokens: Record<SpokeChainId, readonly Token[]> = sodax.swap.getSupportedSwapTokens();
|
|
213
266
|
|
|
214
|
-
//
|
|
267
|
+
// Alternative: Access through config service
|
|
268
|
+
const swapTokensFromConfig: readonly Token[] = sodax.config.getSupportedSwapTokensByChainId(chainId);
|
|
269
|
+
const allSwapTokensFromConfig = sodax.config.getSupportedSwapTokens();
|
|
215
270
|
```
|
|
216
271
|
|
|
272
|
+
#### Money Market Configuration (sodax.moneyMarket)
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import { Sodax, type SpokeChainId, type Token, type Address } from "@sodax/sdk";
|
|
276
|
+
|
|
277
|
+
const sodax = new Sodax();
|
|
278
|
+
await sodax.initialize(); // Initialize for dynamic config (optional but recommended)
|
|
279
|
+
|
|
280
|
+
// Get supported money market tokens for a specific chain
|
|
281
|
+
const supportedMoneyMarketTokens: readonly Token[] = sodax.moneyMarket.getSupportedTokensByChainId(chainId);
|
|
282
|
+
|
|
283
|
+
// Get all supported money market tokens
|
|
284
|
+
const allMoneyMarketTokens = sodax.moneyMarket.getSupportedTokens();
|
|
285
|
+
|
|
286
|
+
// Get supported money market reserves
|
|
287
|
+
const reserves: readonly Address[] = sodax.moneyMarket.getSupportedReserves();
|
|
288
|
+
|
|
289
|
+
// Alternative: Access through config service
|
|
290
|
+
const moneyMarketTokensFromConfig: readonly Token[] = sodax.config.getSupportedMoneyMarketTokensByChainId(chainId);
|
|
291
|
+
const allMoneyMarketTokensFromConfig = sodax.config.getSupportedMoneyMarketTokens();
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Please refer to [SDK constants.ts](https://github.com/icon-project/sodax-frontend/blob/main/packages/sdk/src/constants.ts) for additional static constants and configurations.
|
|
295
|
+
|
|
217
296
|
### Wallet Providers
|
|
218
297
|
|
|
219
298
|
Sodax SDK does not force the usage of a specific wallet or library, but requires client to provide implementation of `IWalletProvider` interfaces (e.g. for EVM chains `IEvmWalletProvider` has to be implemented).
|
|
220
299
|
|
|
221
|
-
As part of Sodax suite,
|
|
300
|
+
As part of Sodax suite, Wallet SDK is also going to be provided as one example wallet provider implementation. You are free to choose between using our Wallet SDK or implementing your own wallet connectivity for each chain.
|
|
222
301
|
|
|
223
302
|
- Supported Wallet Provider Interface (`IWalletProvider`)
|
|
224
303
|
- `IEvmWalletProvider`: EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon) β
|
|
225
304
|
- `ISuiWalletProvider`: Sui β
|
|
226
305
|
- `IIconWalletProvider`: ICON β
|
|
227
306
|
- `IStellarWalletProvider`: Stellar β
|
|
228
|
-
- Solana
|
|
229
|
-
- Injective
|
|
230
|
-
- Havah β Coming soon
|
|
307
|
+
- `ISolanaWalletProvider`: Solana β
|
|
308
|
+
- `IInjectiveWalletProvider`: Injective β
|
|
231
309
|
|
|
232
310
|
### Initialising Spoke Provider
|
|
233
311
|
|
|
@@ -242,20 +320,102 @@ EVM Provider example:
|
|
|
242
320
|
```typescript
|
|
243
321
|
import { EvmProvider, EvmHubProvider, EvmSpokeProvider, AVALANCHE_MAINNET_CHAIN_ID, SONIC_MAINNET_CHAIN_ID } from "@sodax/sdk"
|
|
244
322
|
|
|
245
|
-
const evmWalletProvider: IEvmWalletProvider = // injected by
|
|
323
|
+
const evmWalletProvider: IEvmWalletProvider = // injected by Wallet SDK or your own implementation
|
|
246
324
|
|
|
247
325
|
// spoke provider represents connection to a specific chain, should be instantiated for each supported chain when user connects wallet
|
|
248
326
|
const bscSpokeProvider: EvmSpokeProvider = new EvmSpokeProvider(
|
|
249
327
|
evmWalletProvider, // user connected wallet
|
|
250
|
-
spokeChainConfig[BSC_MAINNET_CHAIN_ID]
|
|
328
|
+
spokeChainConfig[BSC_MAINNET_CHAIN_ID], // connected chain config
|
|
251
329
|
);
|
|
252
330
|
```
|
|
253
331
|
|
|
332
|
+
### Estimate Gas for Raw Transactions
|
|
333
|
+
|
|
334
|
+
The `estimateGas` function allows you to estimate the gas cost for raw transactions before executing them. This is particularly useful for all Sodax operations (swaps, money market operations, approvals) to provide users with accurate gas estimates.
|
|
335
|
+
|
|
336
|
+
The function is available on all service classes:
|
|
337
|
+
- `SwapService.estimateGas()` - for solver/intent operations (reachable through `sodax.swap`)
|
|
338
|
+
- `MoneyMarketService.estimateGas()` - for money market operations (reachable through `sodax.moneyMarket`)
|
|
339
|
+
- `SpokeService.estimateGas()` - for general spoke chain operations
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
import {
|
|
343
|
+
SwapService,
|
|
344
|
+
MoneyMarketService,
|
|
345
|
+
SpokeService,
|
|
346
|
+
MoneyMarketSupplyParams
|
|
347
|
+
} from "@sodax/sdk";
|
|
348
|
+
|
|
349
|
+
// Example: Estimate gas for a solver swap transaction
|
|
350
|
+
const createIntentResult = await sodax.swap.createIntent(
|
|
351
|
+
createIntentParams,
|
|
352
|
+
bscSpokeProvider,
|
|
353
|
+
partnerFeeAmount,
|
|
354
|
+
true, // true = get raw transaction
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
if (createIntentResult.ok) {
|
|
358
|
+
const [rawTx, intent] = createIntentResult.value;
|
|
359
|
+
|
|
360
|
+
// Estimate gas for the raw transaction
|
|
361
|
+
const gasEstimate = await SwapService.estimateGas(rawTx, bscSpokeProvider);
|
|
362
|
+
|
|
363
|
+
if (gasEstimate.ok) {
|
|
364
|
+
console.log('Estimated gas for swap:', gasEstimate.value);
|
|
365
|
+
} else {
|
|
366
|
+
console.error('Failed to estimate gas for swap:', gasEstimate.error);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Example: Estimate gas for a money market supply transaction
|
|
371
|
+
const supplyResult = await sodax.moneyMarket.createSupplyIntent(
|
|
372
|
+
supplyParams,
|
|
373
|
+
bscSpokeProvider,
|
|
374
|
+
true, // true = get raw transaction
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
if (supplyResult.ok) {
|
|
378
|
+
const rawTx = supplyResult.value;
|
|
379
|
+
|
|
380
|
+
// Estimate gas for the raw transaction
|
|
381
|
+
const gasEstimate = await MoneyMarketService.estimateGas(rawTx, bscSpokeProvider);
|
|
382
|
+
|
|
383
|
+
if (gasEstimate.ok) {
|
|
384
|
+
console.log('Estimated gas for supply:', gasEstimate.value);
|
|
385
|
+
} else {
|
|
386
|
+
console.error('Failed to estimate gas for supply:', gasEstimate.error);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Example: Estimate gas for an approval transaction
|
|
391
|
+
const approveResult = await sodax.swap.approve(
|
|
392
|
+
tokenAddress,
|
|
393
|
+
amount,
|
|
394
|
+
bscSpokeProvider,
|
|
395
|
+
true // true = get raw transaction
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
if (approveResult.ok) {
|
|
399
|
+
const rawTx = approveResult.value;
|
|
400
|
+
|
|
401
|
+
// Estimate gas for the approval transaction
|
|
402
|
+
const gasEstimate = await SpokeService.estimateGas(rawTx, bscSpokeProvider);
|
|
403
|
+
|
|
404
|
+
if (gasEstimate.ok) {
|
|
405
|
+
console.log('Estimated gas for approval:', gasEstimate.value);
|
|
406
|
+
} else {
|
|
407
|
+
console.error('Failed to estimate gas for approval:', gasEstimate.error);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
254
412
|
### Accessing Sodax Features
|
|
255
413
|
|
|
256
414
|
Sodax feature set currently contain:
|
|
257
|
-
- Solver: used for intent based swaps. Please find documentation for
|
|
258
|
-
- Money Market: used for lending and borowing. Please find documentation for
|
|
415
|
+
- Swap (Solver): used for intent based swaps. Please find documentation for Swaps part of the SDK in [SWAPS.md](./docs/SWAPS.md)
|
|
416
|
+
- Money Market: used for lending and borowing. Please find documentation for Money Market part of the SDK in [MONEY_MARKET.md](./docs/MONEY_MARKET.md)
|
|
417
|
+
- Bridge: provides functionality to bridge tokens between different blockchain chains [BRIDGE.md](./docs/BRIDGE.md)
|
|
418
|
+
- Staking: provides functionality to stake SODA tokens from different blockchain chains [STAKING.md](./docs/STAKING.md)
|
|
259
419
|
|
|
260
420
|
## Intent Relay API
|
|
261
421
|
|