@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.
@@ -199,8 +199,6 @@ export type StellarRpcConfig = {
199
199
  };
200
200
  export type BitcoinRpcConfig = {
201
201
  rpcUrl?: string;
202
- radfiApiUrl?: string;
203
- radfiUmsUrl?: string;
204
202
  };
205
203
  export type InjectiveRpcConfig = {
206
204
  indexer?: string;
package/dist/index.d.ts CHANGED
@@ -19,4 +19,40 @@ export * from './sui/index.js';
19
19
  export * from './swap/index.js';
20
20
  export * from './utils/index.js';
21
21
  export * from './wallet/index.js';
22
- export declare const CONFIG_VERSION = 234;
22
+ /**
23
+ * Identifies the SDK release a SODAX config belongs to. Derived from this package's version by
24
+ * `scripts/bump-versions.sh` — never hand-edit it. The backend serves this same constant from the SDK
25
+ * release it has installed, so comparing it against `GetAllConfigResponseV2.version` answers "do the
26
+ * SDK and the API run the same release?".
27
+ *
28
+ * Encoding: `major * 1e6 + minor * 1e4 + patch * 100 + (rc ?? 99)`, where the 99 rc slot is the
29
+ * sentinel for a stable release. Use {@link configVersionFor} and {@link formatConfigVersion} rather
30
+ * than unpacking it by hand.
31
+ */
32
+ export declare const CONFIG_VERSION = 2020006;
33
+ /** A version decoded from a config version number. `rc` is `null` for a stable release. */
34
+ export type ParsedConfigVersion = {
35
+ major: number;
36
+ minor: number;
37
+ patch: number;
38
+ rc: number | null;
39
+ };
40
+ /**
41
+ * Encodes an `X.Y.Z` / `X.Y.Z-rc.N` version as its config version number, or `null` when the version
42
+ * is outside the grammar (`2.3.0-beta.1`) or the domain (major outside 1..99, minor or patch above
43
+ * 99, rc above 98). Total by design: the release tooling throws on these, application code should not.
44
+ */
45
+ export declare function configVersionFor(version: string): number | null;
46
+ /**
47
+ * Decodes a config version number, or `null` when it is not one — which includes the small counter
48
+ * values an API running an older SDK still serves, and any non-integer or out-of-range input.
49
+ */
50
+ export declare function parseConfigVersion(value: number): ParsedConfigVersion | null;
51
+ /** Renders a config version number as its version string, or `null` when it is not one. */
52
+ export declare function formatConfigVersion(value: number): string | null;
53
+ /**
54
+ * This package's version, projected from {@link CONFIG_VERSION} rather than written separately, so the
55
+ * two cannot disagree. Always a version string: `scripts/bump-versions.sh` derives the constant, and
56
+ * `config-version.test.ts` asserts it against the manifest.
57
+ */
58
+ export declare const SDK_VERSION: string;
package/dist/index.js CHANGED
@@ -19,4 +19,70 @@ export * from './sui/index.js';
19
19
  export * from './swap/index.js';
20
20
  export * from './utils/index.js';
21
21
  export * from './wallet/index.js';
22
- export const CONFIG_VERSION = 234; // bumped once per release by scripts/bump-versions.sh, on the release branch
22
+ /**
23
+ * Identifies the SDK release a SODAX config belongs to. Derived from this package's version by
24
+ * `scripts/bump-versions.sh` — never hand-edit it. The backend serves this same constant from the SDK
25
+ * release it has installed, so comparing it against `GetAllConfigResponseV2.version` answers "do the
26
+ * SDK and the API run the same release?".
27
+ *
28
+ * Encoding: `major * 1e6 + minor * 1e4 + patch * 100 + (rc ?? 99)`, where the 99 rc slot is the
29
+ * sentinel for a stable release. Use {@link configVersionFor} and {@link formatConfigVersion} rather
30
+ * than unpacking it by hand.
31
+ */
32
+ export const CONFIG_VERSION = 2020006; // 2.2.0-rc.6
33
+ /** Highest rc slot, reserved for a stable release so it outranks every rc of the same triple. */
34
+ const RC_STABLE = 99;
35
+ const MIN_CONFIG_VERSION = 1_000_000;
36
+ const MAX_CONFIG_VERSION = 99_999_999;
37
+ const VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-rc\.(0|[1-9]\d*))?$/;
38
+ /**
39
+ * Encodes an `X.Y.Z` / `X.Y.Z-rc.N` version as its config version number, or `null` when the version
40
+ * is outside the grammar (`2.3.0-beta.1`) or the domain (major outside 1..99, minor or patch above
41
+ * 99, rc above 98). Total by design: the release tooling throws on these, application code should not.
42
+ */
43
+ export function configVersionFor(version) {
44
+ const match = typeof version === 'string' ? version.match(VERSION_PATTERN) : null;
45
+ if (!match)
46
+ return null;
47
+ const major = Number(match[1]);
48
+ const minor = Number(match[2]);
49
+ const patch = Number(match[3]);
50
+ const rc = match[4] === undefined ? null : Number(match[4]);
51
+ if (major < 1 || major > 99 || minor > 99 || patch > 99)
52
+ return null;
53
+ if (rc !== null && rc > 98)
54
+ return null;
55
+ return major * 1_000_000 + minor * 10_000 + patch * 100 + (rc === null ? RC_STABLE : rc);
56
+ }
57
+ // Total on purpose: the domain check lives in parseConfigVersion, so SDK_VERSION can project the
58
+ // committed constant without routing through a nullable step it would then have to narrow.
59
+ const unpack = (value) => {
60
+ const slot = value % 100;
61
+ return {
62
+ major: Math.floor(value / 1_000_000),
63
+ minor: Math.floor(value / 10_000) % 100,
64
+ patch: Math.floor(value / 100) % 100,
65
+ rc: slot === RC_STABLE ? null : slot,
66
+ };
67
+ };
68
+ const render = ({ major, minor, patch, rc }) => `${major}.${minor}.${patch}${rc === null ? '' : `-rc.${rc}`}`;
69
+ /**
70
+ * Decodes a config version number, or `null` when it is not one — which includes the small counter
71
+ * values an API running an older SDK still serves, and any non-integer or out-of-range input.
72
+ */
73
+ export function parseConfigVersion(value) {
74
+ if (!Number.isInteger(value) || value < MIN_CONFIG_VERSION || value > MAX_CONFIG_VERSION)
75
+ return null;
76
+ return unpack(value);
77
+ }
78
+ /** Renders a config version number as its version string, or `null` when it is not one. */
79
+ export function formatConfigVersion(value) {
80
+ const parsed = parseConfigVersion(value);
81
+ return parsed === null ? null : render(parsed);
82
+ }
83
+ /**
84
+ * This package's version, projected from {@link CONFIG_VERSION} rather than written separately, so the
85
+ * two cannot disagree. Always a version string: `scripts/bump-versions.sh` derives the constant, and
86
+ * `config-version.test.ts` asserts it against the manifest.
87
+ */
88
+ export const SDK_VERSION = render(unpack(CONFIG_VERSION));
@@ -120,8 +120,100 @@ export declare const leverageYieldVaults: readonly [{
120
120
  readonly label: "Sky (sUSDS)";
121
121
  };
122
122
  }];
123
+ /**
124
+ * A leverage position's operation slot.
125
+ *
126
+ * `kind` mirrors the contract's `PendingKind`: 0 none, 1 leverage, 2 deleverage, 3 debt-side open.
127
+ * The pair matters because they can disagree — see `needsSettle`.
128
+ */
129
+ export type LeveragePositionPendingState = {
130
+ kind: number;
131
+ /** The intent is still registered on `Intents`, so no second operation is permitted. */
132
+ isLive: boolean;
133
+ /**
134
+ * An operation is recorded but its intent is gone, so the position still holds an open grant and
135
+ * any debt-side contribution. Cleared by `buildSettlePosition`, which anyone may call.
136
+ */
137
+ needsSettle: boolean;
138
+ };
139
+ /**
140
+ * Static descriptor of a single leverage position — one owner-controlled AAVE account
141
+ * deployed as a clone by `LeveragePositionFactory`.
142
+ *
143
+ * Positions are the unpooled counterpart to {@link LeverageYieldVault}: instead of many
144
+ * depositors sharing one ERC-4626 vault at a single target LTV, each position is its own
145
+ * AAVE account with its own eMode category, health factor and liquidation risk. That is
146
+ * what lets one owner hold several positions at different leverage tiers at once, which a
147
+ * pooled vault cannot express because AAVE allows one eMode category per address.
148
+ *
149
+ * Unlike vaults there is no registry of these: positions are created per user at runtime
150
+ * and discovered through `LeverageYieldService.listPositions(owner)`.
151
+ */
152
+ export type LeveragePosition = {
153
+ /** Deployed `LeveragePosition` clone address on the Sonic hub. */
154
+ address: Address;
155
+ /** Address permitted to operate the position — a hub EOA, the solver, or a hub Wallet. */
156
+ owner: Address;
157
+ /** Hub-side collateral supplied to AAVE, a Sodax vault token (e.g. sodaSUSDS). */
158
+ collateral: Address;
159
+ /** Hub-side asset borrowed against the collateral, a Sodax vault token (e.g. sodaUSSD). */
160
+ borrowToken: Address;
161
+ /** AAVE eMode category, fixed at creation. `0` means no eMode. */
162
+ eModeCategory: number;
163
+ /**
164
+ * The position's own partner fee in basis points, FIXED AT CREATION.
165
+ *
166
+ * Read from the position, not from config: config can change and an open can pass a per-call
167
+ * override, so what a new position would carry is not what this one does. The fee is borrowed on
168
+ * top of what the solver is paid, so any projection of an adjust or exit has to charge it.
169
+ */
170
+ feeBps: number;
171
+ /** Who that fee is paid to. Zero address when none is charged. */
172
+ feeReceiver: Address;
173
+ };
174
+ /**
175
+ * Live AAVE account snapshot for a leverage position. Read from the pool rather than the
176
+ * position contract, which holds no accounting of its own.
177
+ *
178
+ * All base-currency figures use the pool's oracle base unit (8 decimals on the Sodax fork).
179
+ */
180
+ export type LeveragePositionAccount = {
181
+ /** Total collateral in the pool's base currency. */
182
+ totalCollateralBase: bigint;
183
+ /** Total debt in the pool's base currency. */
184
+ totalDebtBase: bigint;
185
+ /** Remaining borrowing power in the pool's base currency. */
186
+ availableBorrowsBase: bigint;
187
+ /** Liquidation threshold in basis points, reflecting the position's eMode category. */
188
+ currentLiquidationThreshold: bigint;
189
+ /** Current loan-to-value in basis points. */
190
+ ltv: bigint;
191
+ /** Health factor in WAD (1e18). Below 1e18 the position is liquidatable. */
192
+ healthFactor: bigint;
193
+ };
194
+ /**
195
+ * A position's collateral holding, read straight off the aToken.
196
+ *
197
+ * The counterpart to {@link LeveragePositionAccount}'s `totalCollateralBase`, which is an oracle
198
+ * base-currency figure at 8 decimals — right for display, useless for sizing a full exit, because
199
+ * converting it back through a price lands near the balance rather than on it.
200
+ */
201
+ export type LeveragePositionCollateral = {
202
+ /** The reserve's aToken. Holding this *is* the collateral position. */
203
+ aToken: Address;
204
+ /** Exact aToken balance, in the collateral reserve's own decimals. */
205
+ balance: bigint;
206
+ };
123
207
  export type LeverageYieldOptions = {
124
208
  partnerFee?: PartnerFee;
209
+ /**
210
+ * Overrides the deployed `LeveragePositionFactory` in {@link leverageYieldConfig}.
211
+ *
212
+ * Only needed to point at a different deployment — a fork, a staging factory, or a new
213
+ * one before the default catches up. Omitting it (or passing `undefined`) keeps the
214
+ * default: config merging skips `undefined`, so an absent override cannot blank it.
215
+ */
216
+ positionFactory?: Address;
125
217
  /**
126
218
  * Route `vaultSwap()` (and so `deposit`/`withdraw`) through the backend submit-tx flow. Default
127
219
  * `false` — the backend leverage-yield submit-tx path is opt-in while it beds in, unlike the
@@ -133,6 +225,14 @@ export type LeverageYieldOptions = {
133
225
  export type LeverageYieldConfig = Prettify<LeverageYieldDefaultConfig & LeverageYieldOptions>;
134
226
  export type LeverageYieldDefaultConfig = {
135
227
  vaults: readonly LeverageYieldVault[];
228
+ /**
229
+ * Deployed `LeveragePositionFactory` on the Sonic hub.
230
+ *
231
+ * Defaulted so the position methods work out of the box: they fail closed on a missing
232
+ * factory rather than guessing an address, which previously meant every integrator had
233
+ * to supply this before a single position call would run.
234
+ */
235
+ positionFactory: Address;
136
236
  };
137
237
  export declare const leverageYieldConfig: {
138
238
  readonly vaults: readonly [{
@@ -176,4 +276,5 @@ export declare const leverageYieldConfig: {
176
276
  readonly label: "Sky (sUSDS)";
177
277
  };
178
278
  }];
279
+ readonly positionFactory: "0xF8fB7F200B6545295e1729Cf254482d7c116031C";
179
280
  };
@@ -61,4 +61,5 @@ export const leverageYieldVaults = [
61
61
  ];
62
62
  export const leverageYieldConfig = {
63
63
  vaults: leverageYieldVaults,
64
+ positionFactory: '0xF8fB7F200B6545295e1729Cf254482d7c116031C',
64
65
  };