@sodax/sdk 1.5.7-beta → 2.0.0-rc.2
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/README.md +91 -7
- package/ai-exported/AGENTS.md +99 -0
- package/ai-exported/integration/README.md +41 -0
- package/ai-exported/integration/ai-rules.md +75 -0
- package/ai-exported/integration/architecture.md +519 -0
- package/ai-exported/integration/chain-specifics.md +189 -0
- package/ai-exported/integration/features/README.md +19 -0
- package/ai-exported/integration/features/auxiliary-services.md +189 -0
- package/ai-exported/integration/features/bridge.md +136 -0
- package/ai-exported/integration/features/dex.md +182 -0
- package/ai-exported/integration/features/icx-bnusd-baln.md +181 -0
- package/ai-exported/integration/features/money-market.md +198 -0
- package/ai-exported/integration/features/staking.md +166 -0
- package/ai-exported/integration/features/swap.md +207 -0
- package/ai-exported/integration/quickstart.md +213 -0
- package/ai-exported/integration/recipes/README.md +21 -0
- package/ai-exported/integration/recipes/backend-server-init.md +69 -0
- package/ai-exported/integration/recipes/chain-key-narrowing.md +65 -0
- package/ai-exported/integration/recipes/gas-estimation.md +33 -0
- package/ai-exported/integration/recipes/initialize-sodax.md +53 -0
- package/ai-exported/integration/recipes/raw-tx-flow.md +71 -0
- package/ai-exported/integration/recipes/result-and-errors.md +104 -0
- package/ai-exported/integration/recipes/signed-tx-flow.md +46 -0
- package/ai-exported/integration/recipes/testing.md +101 -0
- package/ai-exported/integration/reference/README.md +18 -0
- package/ai-exported/integration/reference/chain-keys.md +67 -0
- package/ai-exported/integration/reference/error-codes.md +165 -0
- package/ai-exported/integration/reference/glossary.md +32 -0
- package/ai-exported/integration/reference/public-api.md +138 -0
- package/ai-exported/integration/reference/wallet-providers.md +62 -0
- package/ai-exported/migration/README.md +58 -0
- package/ai-exported/migration/ai-rules.md +80 -0
- package/ai-exported/migration/breaking-changes/architecture.md +342 -0
- package/ai-exported/migration/breaking-changes/result-and-errors.md +363 -0
- package/ai-exported/migration/breaking-changes/type-system.md +321 -0
- package/ai-exported/migration/checklist.md +61 -0
- package/ai-exported/migration/features/README.md +35 -0
- package/ai-exported/migration/features/auxiliary-services.md +156 -0
- package/ai-exported/migration/features/bridge.md +125 -0
- package/ai-exported/migration/features/dex.md +143 -0
- package/ai-exported/migration/features/icx-bnusd-baln.md +151 -0
- package/ai-exported/migration/features/money-market.md +214 -0
- package/ai-exported/migration/features/staking.md +138 -0
- package/ai-exported/migration/features/swap.md +198 -0
- package/ai-exported/migration/recipes.md +288 -0
- package/ai-exported/migration/reference/README.md +18 -0
- package/ai-exported/migration/reference/deleted-exports.md +126 -0
- package/ai-exported/migration/reference/error-code-crosswalk.md +104 -0
- package/ai-exported/migration/reference/return-shapes.md +49 -0
- package/ai-exported/migration/reference/sodax-config.md +52 -0
- package/dist/index.cjs +32076 -31544
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8604 -7136
- package/dist/index.d.ts +8604 -7136
- package/dist/index.mjs +31893 -31402
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -12
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# v1 ↔ v2 code crosswalk
|
|
2
|
+
|
|
3
|
+
The widest-impact migration table in this file. v1 had per-module `*ErrorCode` unions; v2 reuses the 13 unified codes plus `feature` discrimination. **Match by intent, not by name** — the v1 `CREATE_SUPPLY_INTENT_FAILED` code is now `INTENT_CREATION_FAILED` with `feature: 'moneyMarket'` and `context.action: 'supply'`.
|
|
4
|
+
|
|
5
|
+
### Money Market (`MoneyMarketErrorCode` → `feature: 'moneyMarket'`)
|
|
6
|
+
|
|
7
|
+
| v1 code | v2 code | v2 context |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `CREATE_SUPPLY_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'supply'` |
|
|
10
|
+
| `CREATE_BORROW_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'borrow'` |
|
|
11
|
+
| `CREATE_WITHDRAW_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'withdraw'` |
|
|
12
|
+
| `CREATE_REPAY_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'repay'` |
|
|
13
|
+
| `SUPPLY_FAILED` | `EXECUTION_FAILED` | `action: 'supply'` |
|
|
14
|
+
| `BORROW_FAILED` | `EXECUTION_FAILED` | `action: 'borrow'` |
|
|
15
|
+
| `WITHDRAW_FAILED` | `EXECUTION_FAILED` | `action: 'withdraw'` |
|
|
16
|
+
| `REPAY_FAILED` | `EXECUTION_FAILED` | `action: 'repay'` |
|
|
17
|
+
| `ALLOWANCE_CHECK_FAILED` | `ALLOWANCE_CHECK_FAILED` | (unchanged) |
|
|
18
|
+
| `APPROVE_FAILED` | `APPROVE_FAILED` | (unchanged) |
|
|
19
|
+
| `GAS_ESTIMATION_FAILED` | `GAS_ESTIMATION_FAILED` | (unchanged) |
|
|
20
|
+
|
|
21
|
+
### Swap (`IntentErrorCode` → `feature: 'swap'`)
|
|
22
|
+
|
|
23
|
+
| v1 code | v2 code | v2 context |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `CREATE_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'createIntent'` |
|
|
26
|
+
| `CREATE_LIMIT_ORDER_FAILED` | `INTENT_CREATION_FAILED` | `action: 'createLimitOrder'` |
|
|
27
|
+
| `POST_EXECUTION_FAILED` | `EXECUTION_FAILED` | `action: 'swap'`, `phase: 'postExecution'` |
|
|
28
|
+
| `SOLVER_API_ERROR` | `EXTERNAL_API_ERROR` | `api: 'solver'`, `solverCode`/`solverDetail` on context |
|
|
29
|
+
| `SIMULATION_FAILED` | `EXECUTION_FAILED` | `phase: 'execution'` |
|
|
30
|
+
|
|
31
|
+
### Staking (`StakingErrorCode` → `feature: 'staking'`)
|
|
32
|
+
|
|
33
|
+
| v1 code | v2 code | v2 context |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `STAKE_FAILED` | `EXECUTION_FAILED` | `action: 'stake'` |
|
|
36
|
+
| `UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'unstake'` |
|
|
37
|
+
| `INSTANT_UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'instantUnstake'` |
|
|
38
|
+
| `CLAIM_FAILED` | `EXECUTION_FAILED` | `action: 'claim'` |
|
|
39
|
+
| `CANCEL_UNSTAKE_FAILED` | `EXECUTION_FAILED` | `action: 'cancelUnstake'` |
|
|
40
|
+
| `GET_STAKING_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getStakingInfo'` |
|
|
41
|
+
| `GET_UNSTAKING_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getUnstakingInfo'` |
|
|
42
|
+
| `GET_STAKING_CONFIG_FAILED` | `LOOKUP_FAILED` | `method: 'getStakingConfig'` |
|
|
43
|
+
| `GET_STAKE_RATIO_FAILED` | `LOOKUP_FAILED` | `method: 'getStakeRatio'` |
|
|
44
|
+
|
|
45
|
+
### Bridge (`BridgeErrorCode` → `feature: 'bridge'`)
|
|
46
|
+
|
|
47
|
+
| v1 code | v2 code | v2 context |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `BRIDGE_FAILED` | `EXECUTION_FAILED` | `action: 'bridge'` |
|
|
50
|
+
| `CREATE_BRIDGE_INTENT_FAILED` | `INTENT_CREATION_FAILED` | `action: 'bridge'` |
|
|
51
|
+
| `GET_BRIDGEABLE_AMOUNT_FAILED` | `LOOKUP_FAILED` | `method: 'getBridgeableAmount'` |
|
|
52
|
+
| `GET_BRIDGEABLE_TOKENS_FAILED` | `LOOKUP_FAILED` | `method: 'getBridgeableTokens'` |
|
|
53
|
+
|
|
54
|
+
### Migration (`MigrationErrorCode` → `feature: 'migration'`)
|
|
55
|
+
|
|
56
|
+
| v1 code | v2 code | v2 context |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `MIGRATE_BNUSD_FORWARD_FAILED` | `EXECUTION_FAILED` | `action: 'migratebnUSD'`, `direction: 'forward'` |
|
|
59
|
+
| `MIGRATE_BNUSD_REVERSE_FAILED` | `EXECUTION_FAILED` | `action: 'migratebnUSD'`, `direction: 'reverse'` |
|
|
60
|
+
| `MIGRATE_ICX_TO_SODA_FAILED` | `EXECUTION_FAILED` | `action: 'migrateIcxToSoda'` |
|
|
61
|
+
| `REVERT_MIGRATE_SODA_TO_ICX_FAILED` | `EXECUTION_FAILED` | `action: 'revertMigrateSodaToIcx'` |
|
|
62
|
+
| `MIGRATE_BALN_FAILED` | `EXECUTION_FAILED` | `action: 'migrateBaln'` |
|
|
63
|
+
| `GET_AVAILABLE_AMOUNT_FAILED` | `LOOKUP_FAILED` | `method: 'getAvailableAmount'` |
|
|
64
|
+
|
|
65
|
+
### DEX (`AssetServiceErrorCode` + `ConcentratedLiquidityErrorCode` → `feature: 'dex'`)
|
|
66
|
+
|
|
67
|
+
| v1 code | v2 code | v2 context |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `DEPOSIT_FAILED` | `EXECUTION_FAILED` | `action: 'deposit'` |
|
|
70
|
+
| `WITHDRAW_FAILED` | `EXECUTION_FAILED` | `action: 'withdraw'` |
|
|
71
|
+
| `SUPPLY_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'supplyLiquidity'` |
|
|
72
|
+
| `INCREASE_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'increaseLiquidity'` |
|
|
73
|
+
| `DECREASE_LIQUIDITY_FAILED` | `EXECUTION_FAILED` | `action: 'decreaseLiquidity'` |
|
|
74
|
+
| `CLAIM_REWARDS_FAILED` | `EXECUTION_FAILED` | `action: 'claimRewards'` |
|
|
75
|
+
| `GET_POOL_DATA_FAILED` | `LOOKUP_FAILED` | `method: 'getPoolData'` |
|
|
76
|
+
| `GET_POSITION_INFO_FAILED` | `LOOKUP_FAILED` | `method: 'getPositionInfo'` |
|
|
77
|
+
|
|
78
|
+
### Relay (`RelayErrorCode` → typically still on `context.relayCode`)
|
|
79
|
+
|
|
80
|
+
The relay-layer code strings are kept on `context.relayCode` of the surfaced `SodaxError`. They are also a stable public contract used by lower-level relay code:
|
|
81
|
+
|
|
82
|
+
| v1 code | v2 code on `error.code` | v2 `context.relayCode` |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `SUBMIT_TX_FAILED` | `TX_SUBMIT_FAILED` | `'SUBMIT_TX_FAILED'` |
|
|
85
|
+
| `RELAY_TIMEOUT` | `RELAY_TIMEOUT` | `'RELAY_TIMEOUT'` |
|
|
86
|
+
| `RELAY_POLLING_FAILED` | `RELAY_FAILED` | `'RELAY_POLLING_FAILED'` |
|
|
87
|
+
| (any unrecognised) | `RELAY_FAILED` | `'UNKNOWN'` |
|
|
88
|
+
|
|
89
|
+
### Partner (5 typed errors → `feature: 'partner'`)
|
|
90
|
+
|
|
91
|
+
All partner typed errors collapse to `EXECUTION_FAILED` with `action` discriminating between the 5 v1 operations.
|
|
92
|
+
|
|
93
|
+
### Recovery (no v1 typed errors — module is v2-new) → `feature: 'recovery'`
|
|
94
|
+
|
|
95
|
+
`EXECUTION_FAILED` for the recovery action; `LOOKUP_FAILED` for read methods.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## Cross-references
|
|
101
|
+
|
|
102
|
+
- [`README.md`](README.md) — migration reference index.
|
|
103
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
104
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Return-shape diffs per method
|
|
2
|
+
|
|
3
|
+
### `SwapService.createIntent`
|
|
4
|
+
|
|
5
|
+
```diff
|
|
6
|
+
- const [spokeTxHash, intent, relayData] = result;
|
|
7
|
+
+ const { tx, intent, relayData } = result.value;
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
v1 returned a tuple. v2 returns an object: `{ tx, intent, relayData }` where:
|
|
11
|
+
- `tx` is `TxReturnType<K, false>` (the spoke tx hash for `raw: false`, or the raw tx payload for `raw: true`).
|
|
12
|
+
- `intent` is the intent struct.
|
|
13
|
+
- `relayData` is `RelayExtraData` (`{ payload: string; ... }`).
|
|
14
|
+
|
|
15
|
+
If you use the backend submit-swap-tx API, the v1 `relayData` field on the request expects the **string**, not the object — pass `relayData.payload`.
|
|
16
|
+
|
|
17
|
+
### `BridgeService.bridge` and similar full-execution methods
|
|
18
|
+
|
|
19
|
+
```diff
|
|
20
|
+
- const txHash: string = await sodax.bridge.bridge(...);
|
|
21
|
+
+ const result = await sodax.bridge.bridge({ params, raw: false, walletProvider });
|
|
22
|
+
+ if (!result.ok) return;
|
|
23
|
+
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
v2 cross-chain mutation methods return `TxHashPair = { srcChainTxHash, dstChainTxHash }` so the consumer has both legs of the relay. The same shape applies to `staking.stake`, `staking.unstake`, `staking.instantUnstake`, `staking.claim`, `staking.cancelUnstake`, `dex.assetService.deposit/withdraw`, `dex.clService.supplyLiquidity/increaseLiquidity/decreaseLiquidity/claimRewards`, and the 4 `migration.*` orchestrators (`migratebnUSD`, `migrateIcxToSoda`, `revertMigrateSodaToIcx`, `migrateBaln`). Consumers on the hub chain still get both fields populated (with the same hash) for shape consistency.
|
|
27
|
+
|
|
28
|
+
### `MoneyMarketService.{supply, borrow, withdraw, repay}`
|
|
29
|
+
|
|
30
|
+
```diff
|
|
31
|
+
- const txHash = await sodax.moneyMarket.supply(...);
|
|
32
|
+
+ const result = await sodax.moneyMarket.supply({ params, raw: false, walletProvider });
|
|
33
|
+
+ const { srcChainTxHash, dstChainTxHash } = result.value;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Same `TxHashPair` shape as every other cross-chain mutation in v2.
|
|
37
|
+
|
|
38
|
+
### Everything else
|
|
39
|
+
|
|
40
|
+
If a v1 method returned a single `string` tx hash, the v2 return is `Result<TxReturnType<K, false>>` — destructure as `result.value` (which is the hash for `raw: false`, or the chain-specific raw tx payload for `raw: true`).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Cross-references
|
|
46
|
+
|
|
47
|
+
- [`README.md`](README.md) — migration reference index.
|
|
48
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
49
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# `SodaxConfig` constructor reshape
|
|
2
|
+
|
|
3
|
+
The v2 `Sodax` constructor accepts a `DeepPartial<SodaxConfig>`. Several config fields renamed or moved between v1 and v2; if your project passed a custom config, check these:
|
|
4
|
+
|
|
5
|
+
| v1 location | v2 location |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `SodaxConfig.swaps` (held solver endpoints AND supported tokens) | Split into two: `SodaxConfig.swaps` (now `SwapsConfig` — supported tokens per chain) and `SodaxConfig.solver` (`{ intentsContract, solverApiEndpoint, protocolIntentsContract }`). |
|
|
8
|
+
| `SodaxConfig.rpcConfig` (flat object: one URL per chain field) | `SodaxConfig.rpcConfig` (mapped type keyed by `ChainKey` values; chain-family-specific shapes — see [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 5). |
|
|
9
|
+
| `SodaxConfig.hubProviderConfig` | Renamed: `SodaxConfig.hubConfig`. |
|
|
10
|
+
| `SodaxConfig.configService` (raw `IConfigApi` instance you injected) | Pass via `new Sodax({ configService: <your impl> })` is gone — `ConfigService` is constructed internally. To inject a custom `IConfigApi`, override via `SodaxConfig.backendApi`. |
|
|
11
|
+
|
|
12
|
+
Migration:
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
const sodax = new Sodax({
|
|
16
|
+
- swaps: {
|
|
17
|
+
- intentsContract: '0x…',
|
|
18
|
+
- solverApiEndpoint: 'https://…',
|
|
19
|
+
- supportedTokens: { /* … */ },
|
|
20
|
+
- },
|
|
21
|
+
+ solver: {
|
|
22
|
+
+ intentsContract: '0x…',
|
|
23
|
+
+ solverApiEndpoint: 'https://…',
|
|
24
|
+
+ },
|
|
25
|
+
+ swaps: {
|
|
26
|
+
+ supportedTokens: { /* per-chain table */ },
|
|
27
|
+
+ },
|
|
28
|
+
- rpcConfig: { sonic: 'https://…', arbitrum: 'https://…' },
|
|
29
|
+
+ rpcConfig: {
|
|
30
|
+
+ [ChainKeys.SONIC_MAINNET]: 'https://…',
|
|
31
|
+
+ [ChainKeys.ARBITRUM_MAINNET]: 'https://…',
|
|
32
|
+
+ [ChainKeys.BITCOIN_MAINNET]: { /* BitcoinRpcConfig shape */ },
|
|
33
|
+
+ // …
|
|
34
|
+
+ },
|
|
35
|
+
- hubProviderConfig: { /* … */ },
|
|
36
|
+
+ hubConfig: { /* … */ },
|
|
37
|
+
});
|
|
38
|
+
await sodax.config.initialize();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Pitfall
|
|
42
|
+
|
|
43
|
+
If you previously injected a custom `ConfigService` for testing (a v1 escape hatch), v2 doesn't accept one at the top level. Inject a custom `IConfigApi` via `SodaxConfig.backendApi.api` instead — `ConfigService` consumes it internally on `initialize()`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Cross-references
|
|
49
|
+
|
|
50
|
+
- [`README.md`](README.md) — migration reference index.
|
|
51
|
+
- [`../README.md`](../README.md) — migration overview.
|
|
52
|
+
- [`../checklist.md`](../checklist.md) — top-level migration checklist.
|