@sodax/types 2.2.0-rc.4 → 2.2.0-rc.6
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 +49 -1
- package/dist/backend/backendApiV2.js +4 -3
- package/dist/chains/chains.d.ts +215 -93
- package/dist/chains/chains.js +20 -1
- package/dist/chains/tokens.d.ts +340 -138
- package/dist/chains/tokens.js +150 -46
- package/dist/common/common.d.ts +0 -2
- package/dist/index.d.ts +37 -1
- package/dist/index.js +67 -1
- package/dist/leverageYield/leverageYield.d.ts +101 -0
- package/dist/leverageYield/leverageYield.js +1 -0
- package/dist/moneyMarket/moneyMarket.d.ts +140 -92
- package/dist/moneyMarket/moneyMarket.js +3 -0
- package/dist/sodax-config/sodax-config.d.ts +434 -182
- package/dist/swap/swap.d.ts +321 -93
- package/dist/swap/swap.js +11 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,18 @@ pnpm add @sodax/types
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
+
> SDK consumers should import these from `@sodax/sdk` (`import { ... } from '@sodax/sdk'`), which re-exports `@sodax/types`; reserve a direct `@sodax/types` install for standalone or type-only use.
|
|
16
|
+
|
|
15
17
|
Import shared types, constants, configuration, and helpers from the root package:
|
|
16
18
|
|
|
17
19
|
```typescript
|
|
18
20
|
import {
|
|
19
21
|
ChainKeys,
|
|
20
22
|
CONFIG_VERSION,
|
|
23
|
+
SDK_VERSION,
|
|
24
|
+
configVersionFor,
|
|
25
|
+
formatConfigVersion,
|
|
26
|
+
parseConfigVersion,
|
|
21
27
|
getEvmChainKeyByChainId,
|
|
22
28
|
sodaxConfig,
|
|
23
29
|
supportedTokensByChain,
|
|
@@ -54,8 +60,10 @@ The package currently exposes only the root export (`@sodax/types`) and the DEX
|
|
|
54
60
|
| Chains and tokens | `ChainKeys`, `SpokeChainKey`, `ChainType`, `baseChainInfo`, `spokeChainConfig` [^cfg], `supportedTokensByChain` |
|
|
55
61
|
| Wallet providers | `WalletAddressProvider`, `ICoreWallet`, `IWalletProvider`, `GetWalletProviderType` |
|
|
56
62
|
| Chain transaction types | `EvmRawTransaction`, `BitcoinRawTransaction`, `SolanaRawTransaction`, `StellarRawTransaction`, `SuiRawTransaction`, `IconRawTransaction`, `InjectiveRawTransaction`, `NearRawTransaction`, `StacksRawTransaction` |
|
|
57
|
-
| Backend API contracts | `
|
|
63
|
+
| Backend API contracts | `IConfigApiV1`, `IConfigApiV2`, `GetAllConfigApiResponse`, `SubmitTxRequestV2`, `SubmitTxResponseV2`, `SubmitTxStatusResponseV2`, `SubmitIntentRequestV2`, `SubmitIntentResponseV2` |
|
|
58
64
|
| Product configuration | `sodaxConfig` [^cfg], `bridgeConfig`, `swapsConfig`, `moneyMarketConfig`, `dexConfig`, `concentratedLiquidityConfig` |
|
|
65
|
+
| Leverage yield | leverage-yield param and response types (`leverageYield`) |
|
|
66
|
+
| Hooks | shared hook types (`hooks`) |
|
|
59
67
|
| Utilities | `DeepPartial`, `getChainType`, `getEvmChainKeyByChainId`, chain guard helpers, bnUSD token helpers |
|
|
60
68
|
|
|
61
69
|
[^cfg]: `spokeChainConfig` and `sodaxConfig` (and the related `hubConfig`, etc.) are **packaged-default snapshots** frozen at SDK release time. They are safe to import at module scope, but **direct imports do NOT reflect overrides passed to `new Sodax(config)` or dynamic config loaded by `sodax.config.initialize()`** — those flow into the `ConfigService` only. Once a `Sodax` instance exists, prefer the instance-scope readers: `sodax.config.spokeChainConfig`, `sodax.config.getChainConfig(chainKey)`, `sodax.config.sodaxConfig`, `sodax.config.getHubChainConfig()`, etc. Mixing a static import with a custom-configured `Sodax` instance will silently fall back to defaults for any chain you customized.
|
|
@@ -122,3 +130,43 @@ type AddressForChain<C extends SpokeChainKey> = GetAddressType<C>;
|
|
|
122
130
|
```
|
|
123
131
|
|
|
124
132
|
`GetTokenAddressType<C>` is the token-address counterpart: `Address` for EVM chains, `string` everywhere else.
|
|
133
|
+
|
|
134
|
+
## Config version
|
|
135
|
+
|
|
136
|
+
`CONFIG_VERSION` identifies the SDK release a SODAX config belongs to. The backend does not maintain
|
|
137
|
+
its own number — it serves this constant from the `@sodax/sdk` release it has installed — so comparing
|
|
138
|
+
it against `GetAllConfigResponseV2.version` answers *do the SDK and the API run the same release?*
|
|
139
|
+
|
|
140
|
+
It is **derived from this package's version**, never hand-edited:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
CONFIG_VERSION = major * 1_000_000 + minor * 10_000 + patch * 100 + (rc ?? 99)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The `99` rc slot is the sentinel for a stable release, so it outranks every rc of the same triple.
|
|
147
|
+
Each field is capped — major `1..99`, minor and patch `0..99`, rc `0..98` — because one past any
|
|
148
|
+
boundary the packing would carry into the next field and collide with a different release.
|
|
149
|
+
|
|
150
|
+
| version | `CONFIG_VERSION` |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `2.2.0-rc.6` | `2_020_006` |
|
|
153
|
+
| `2.2.0` | `2_020_099` |
|
|
154
|
+
| `2.2.1` | `2_020_199` |
|
|
155
|
+
| `2.10.0` | `2_100_099` |
|
|
156
|
+
|
|
157
|
+
Read it back rather than unpacking it by hand. All three helpers are total — they return `null` for
|
|
158
|
+
anything outside the encoding, including the small counter values an API on an older SDK still serves:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { CONFIG_VERSION, SDK_VERSION, configVersionFor, formatConfigVersion, parseConfigVersion } from '@sodax/types';
|
|
162
|
+
|
|
163
|
+
SDK_VERSION; // '2.2.0-rc.6' — computed from CONFIG_VERSION, never written
|
|
164
|
+
formatConfigVersion(2_020_099); // '2.2.0'
|
|
165
|
+
parseConfigVersion(2_020_006); // { major: 2, minor: 2, patch: 0, rc: 6 }
|
|
166
|
+
configVersionFor('2.2.0'); // 2_020_099
|
|
167
|
+
configVersionFor('2.3.0-beta.1'); // null — outside the grammar
|
|
168
|
+
parseConfigVersion(235); // null — a legacy counter value, not a config version
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`rc` is `null` for a stable release; `rc: 0` is legal, so test it against `null` rather than for
|
|
172
|
+
truthiness.
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
// - `Hex` / `Address` / `Hash` / `SpokeChainKey` are plain `string` everywhere.
|
|
21
21
|
// - The unsigned `tx` is typed as the SDK domain union `RawTxReturnType`. It
|
|
22
22
|
// travels as pure JSON (bigints stringified; Injective byte arrays as
|
|
23
|
-
// `{ "0": N, … }` index objects), and the
|
|
24
|
-
// (
|
|
25
|
-
// `Uint8Array`) on parse — the inverse
|
|
23
|
+
// `{ "0": N, … }` index objects), and the wire clients' response schemas
|
|
24
|
+
// (the `rawTxSchemas` module in `@sodax/swaps-api` / `@sodax/bridge-api`)
|
|
25
|
+
// rebuild the domain shape (`bigint`, `Uint8Array`) on parse — the inverse
|
|
26
|
+
// of the backend's `stringifyBigInts`.
|
|
26
27
|
// - The remaining chain-specific opaque payloads (gas estimate, raw relay
|
|
27
28
|
// `result`) stay `unknown` because their shape varies by chain family.
|
|
28
29
|
//
|