@gearbox-protocol/sdk 14.12.0-next.42 → 14.12.0-next.43
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/cjs/sdk/accounts/withdrawal-compressor/intent-codec.js +5 -10
- package/dist/cjs/sdk/chain/chains.js +3 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/intent-codec.js +5 -10
- package/dist/esm/sdk/chain/chains.js +3 -1
- package/dist/types/sdk/accounts/types.d.ts +11 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/intent-codec.d.ts +1 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +4 -9
- package/dist/types/sdk/base/types.d.ts +8 -4
- package/dist/types/sdk/chain/chains.d.ts +1 -1
- package/dist/types/sdk/router/types.d.ts +24 -3
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ __export(intent_codec_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(intent_codec_exports);
|
|
27
27
|
var import_viem = require("viem");
|
|
28
|
-
const DELAYED_INTENT_VERSION =
|
|
28
|
+
const DELAYED_INTENT_VERSION = 1;
|
|
29
29
|
const DELAYED_INTENT_TYPES = {
|
|
30
30
|
INCREASE_LEVERAGE: 1,
|
|
31
31
|
DEPOSIT: 2,
|
|
@@ -51,7 +51,6 @@ function encodeDelayedIntent(intent) {
|
|
|
51
51
|
const version = DELAYED_INTENT_VERSION;
|
|
52
52
|
const intentType = DELAYED_INTENT_TYPES[intent.type];
|
|
53
53
|
switch (intent.type) {
|
|
54
|
-
case "INCREASE_LEVERAGE":
|
|
55
54
|
case "CLOSE_ACCOUNT":
|
|
56
55
|
return (0, import_viem.encodeAbiParameters)(TO_PARAMS, [version, intentType, intent.to]);
|
|
57
56
|
case "WITHDRAW_COLLATERAL":
|
|
@@ -64,6 +63,7 @@ function encodeDelayedIntent(intent) {
|
|
|
64
63
|
intent.sourceToken,
|
|
65
64
|
intent.debtRepaid
|
|
66
65
|
]);
|
|
66
|
+
case "INCREASE_LEVERAGE":
|
|
67
67
|
case "DEPOSIT":
|
|
68
68
|
case "DEPOSIT_AND_INCREASE_LEVERAGE":
|
|
69
69
|
case "ADD_COLLATERAL":
|
|
@@ -76,15 +76,10 @@ function encodeDelayedIntent(intent) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
function decodeDelayedIntent(data) {
|
|
79
|
-
const [
|
|
80
|
-
if (version !== DELAYED_INTENT_VERSION) {
|
|
81
|
-
throw new Error(`unsupported delayed intent version: ${version}`);
|
|
82
|
-
}
|
|
79
|
+
const [_version, intentType] = (0, import_viem.decodeAbiParameters)(HEADER_PARAMS, data);
|
|
83
80
|
switch (intentType) {
|
|
84
|
-
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE:
|
|
85
|
-
|
|
86
|
-
return { type: "INCREASE_LEVERAGE", to };
|
|
87
|
-
}
|
|
81
|
+
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE:
|
|
82
|
+
return { type: "INCREASE_LEVERAGE" };
|
|
88
83
|
case DELAYED_INTENT_TYPES.DEPOSIT:
|
|
89
84
|
return { type: "DEPOSIT" };
|
|
90
85
|
case DELAYED_INTENT_TYPES.DEPOSIT_AND_INCREASE_LEVERAGE:
|
|
@@ -80,7 +80,9 @@ const chains = {
|
|
|
80
80
|
},
|
|
81
81
|
testMarketConfigurators: {
|
|
82
82
|
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
|
|
83
|
-
"0x610627d8d01a413bdd9b0a0b60070da7dd1e54ad": "Securitize"
|
|
83
|
+
"0x610627d8d01a413bdd9b0a0b60070da7dd1e54ad": "Securitize",
|
|
84
|
+
"0xa770ce584adb6491a2138da6eaec33243bdcd248": "Testnet Curator"
|
|
85
|
+
// without governor, for midas
|
|
84
86
|
},
|
|
85
87
|
rwaFactories: [],
|
|
86
88
|
isPublic: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeAbiParameters, encodeAbiParameters } from "viem";
|
|
2
|
-
const DELAYED_INTENT_VERSION =
|
|
2
|
+
const DELAYED_INTENT_VERSION = 1;
|
|
3
3
|
const DELAYED_INTENT_TYPES = {
|
|
4
4
|
INCREASE_LEVERAGE: 1,
|
|
5
5
|
DEPOSIT: 2,
|
|
@@ -25,7 +25,6 @@ function encodeDelayedIntent(intent) {
|
|
|
25
25
|
const version = DELAYED_INTENT_VERSION;
|
|
26
26
|
const intentType = DELAYED_INTENT_TYPES[intent.type];
|
|
27
27
|
switch (intent.type) {
|
|
28
|
-
case "INCREASE_LEVERAGE":
|
|
29
28
|
case "CLOSE_ACCOUNT":
|
|
30
29
|
return encodeAbiParameters(TO_PARAMS, [version, intentType, intent.to]);
|
|
31
30
|
case "WITHDRAW_COLLATERAL":
|
|
@@ -38,6 +37,7 @@ function encodeDelayedIntent(intent) {
|
|
|
38
37
|
intent.sourceToken,
|
|
39
38
|
intent.debtRepaid
|
|
40
39
|
]);
|
|
40
|
+
case "INCREASE_LEVERAGE":
|
|
41
41
|
case "DEPOSIT":
|
|
42
42
|
case "DEPOSIT_AND_INCREASE_LEVERAGE":
|
|
43
43
|
case "ADD_COLLATERAL":
|
|
@@ -50,15 +50,10 @@ function encodeDelayedIntent(intent) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
function decodeDelayedIntent(data) {
|
|
53
|
-
const [
|
|
54
|
-
if (version !== DELAYED_INTENT_VERSION) {
|
|
55
|
-
throw new Error(`unsupported delayed intent version: ${version}`);
|
|
56
|
-
}
|
|
53
|
+
const [_version, intentType] = decodeAbiParameters(HEADER_PARAMS, data);
|
|
57
54
|
switch (intentType) {
|
|
58
|
-
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE:
|
|
59
|
-
|
|
60
|
-
return { type: "INCREASE_LEVERAGE", to };
|
|
61
|
-
}
|
|
55
|
+
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE:
|
|
56
|
+
return { type: "INCREASE_LEVERAGE" };
|
|
62
57
|
case DELAYED_INTENT_TYPES.DEPOSIT:
|
|
63
58
|
return { type: "DEPOSIT" };
|
|
64
59
|
case DELAYED_INTENT_TYPES.DEPOSIT_AND_INCREASE_LEVERAGE:
|
|
@@ -66,7 +66,9 @@ const chains = {
|
|
|
66
66
|
},
|
|
67
67
|
testMarketConfigurators: {
|
|
68
68
|
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
|
|
69
|
-
"0x610627d8d01a413bdd9b0a0b60070da7dd1e54ad": "Securitize"
|
|
69
|
+
"0x610627d8d01a413bdd9b0a0b60070da7dd1e54ad": "Securitize",
|
|
70
|
+
"0xa770ce584adb6491a2138da6eaec33243bdcd248": "Testnet Curator"
|
|
71
|
+
// without governor, for midas
|
|
70
72
|
},
|
|
71
73
|
rwaFactories: [],
|
|
72
74
|
isPublic: true,
|
|
@@ -256,13 +256,22 @@ export interface RepayCreditAccountProps extends RepayAndLiquidateCreditAccountP
|
|
|
256
256
|
*/
|
|
257
257
|
operation: CloseOptions;
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Quota `Asset.balance` values are denominated in **pool underlying token
|
|
261
|
+
* units**, not in the quoted token's own units.
|
|
262
|
+
**/
|
|
259
263
|
export interface PrepareUpdateQuotasProps {
|
|
260
264
|
/**
|
|
261
|
-
*
|
|
265
|
+
* Average quota for desired token, in pool underlying units
|
|
266
|
+
* (see {@link PrepareUpdateQuotasProps})
|
|
262
267
|
*/
|
|
263
268
|
averageQuota: Array<Asset>;
|
|
264
269
|
/**
|
|
265
|
-
*
|
|
270
|
+
* Minimum quota for desired token, in pool underlying units.
|
|
271
|
+
* The credit facade rounds quota changes down to a multiple of
|
|
272
|
+
* `PERCENTAGE_FACTOR`; the min quota bound must not exceed the rounded
|
|
273
|
+
* value, otherwise the quota keeper reverts with
|
|
274
|
+
* `QuotaIsOutOfBoundsException`.
|
|
266
275
|
*/
|
|
267
276
|
minQuota: Array<Asset>;
|
|
268
277
|
}
|
|
@@ -4,7 +4,7 @@ import type { DelayedIntent } from "./types.js";
|
|
|
4
4
|
* Current version of the delayed intent encoding schema.
|
|
5
5
|
* Bump when the layout of any intent type changes.
|
|
6
6
|
**/
|
|
7
|
-
export declare const DELAYED_INTENT_VERSION =
|
|
7
|
+
export declare const DELAYED_INTENT_VERSION = 1;
|
|
8
8
|
/**
|
|
9
9
|
* Stable uint8 discriminants for intent types.
|
|
10
10
|
* Starts at 1 so that all-zero data cannot decode as a valid intent.
|
|
@@ -2,16 +2,11 @@ import type { Address, Hex } from "viem";
|
|
|
2
2
|
import type { IBaseContract } from "../../base/index.js";
|
|
3
3
|
import type { MultiCall } from "../../types/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* App: 1.1 Deposit and 4.1 Adjust leverage — raise leverage at fixed
|
|
6
|
-
* Borrow `underlying` -> swap `underlying` into `targetToken`
|
|
5
|
+
* App: 1.1 Deposit and 4.1 Adjust leverage — raise leverage at fixed collateral.
|
|
6
|
+
* Borrow `underlying` -> swap `underlying` into `targetToken` (kept on CA).
|
|
7
7
|
**/
|
|
8
8
|
export interface DelayedIncreaseLeverageIntent {
|
|
9
9
|
type: "INCREASE_LEVERAGE";
|
|
10
|
-
/**
|
|
11
|
-
* Wallet address that receives tokens withdrawn from the credit account
|
|
12
|
-
* when the flow is resumed after the claim
|
|
13
|
-
**/
|
|
14
|
-
to: Address;
|
|
15
10
|
}
|
|
16
11
|
/**
|
|
17
12
|
* App: 1.2 Deposit — `amount > 0`, leverage = current (grow net value at same L).
|
|
@@ -79,8 +74,8 @@ export interface DelayedAddCollateralIntent {
|
|
|
79
74
|
type: "ADD_COLLATERAL";
|
|
80
75
|
}
|
|
81
76
|
/**
|
|
82
|
-
* App: 4.2 Adjust leverage — lower leverage at fixed
|
|
83
|
-
* Swap
|
|
77
|
+
* App: 4.2 Adjust leverage — lower leverage at fixed collateral.
|
|
78
|
+
* Swap source token into `underlying` -> decrease debt.
|
|
84
79
|
**/
|
|
85
80
|
export interface DelayedDecreaseLeverageIntent {
|
|
86
81
|
type: "DECREASE_LEVERAGE";
|
|
@@ -136,8 +136,9 @@ export interface CreditAccountDataPayload {
|
|
|
136
136
|
**/
|
|
137
137
|
underlying: Address;
|
|
138
138
|
/**
|
|
139
|
-
* Credit account's owner
|
|
140
|
-
*
|
|
139
|
+
* Credit account's owner: for RWA accounts, the per-account vault proxy
|
|
140
|
+
* created by the RWA factory (use `investor` for the EOA); EOA for
|
|
141
|
+
* normal accounts.
|
|
141
142
|
**/
|
|
142
143
|
owner: Address;
|
|
143
144
|
/**
|
|
@@ -187,6 +188,7 @@ export interface CreditAccountDataPayload {
|
|
|
187
188
|
success: boolean;
|
|
188
189
|
/**
|
|
189
190
|
* Info on credit account's enabled tokens and tokens with non-zero balance.
|
|
191
|
+
* Nothing else is present.
|
|
190
192
|
**/
|
|
191
193
|
tokens: readonly TokenInfo[];
|
|
192
194
|
}
|
|
@@ -198,8 +200,10 @@ export interface CreditAccountDataPayload {
|
|
|
198
200
|
**/
|
|
199
201
|
export type CreditAccountData<WithInvestor extends boolean = false> = WithInvestor extends true ? CreditAccountDataPayload & {
|
|
200
202
|
/**
|
|
201
|
-
* Investor EOA address (the real person behind the account)
|
|
202
|
-
*
|
|
203
|
+
* Investor EOA address (the real person behind the account) —
|
|
204
|
+
* the tx sender and delayed-intent recipient.
|
|
205
|
+
* - RWA accounts: resolved from RWA factory, always defined
|
|
206
|
+
* (`owner` is the per-account vault proxy, not the EOA).
|
|
203
207
|
* - Normal accounts: `undefined` (owner IS the investor).
|
|
204
208
|
**/
|
|
205
209
|
investor: Address | undefined;
|
|
@@ -4,7 +4,7 @@ import { z } from "zod/v4";
|
|
|
4
4
|
* Known curator names that manage Gearbox markets.
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
|
-
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7" | "Invariant Group" | "Tulipa" | "M11 Credit" | "KPK" | "Hyperithm" | "UltraYield" | "TelosC" | "Gami Labs" | "Securitize";
|
|
7
|
+
export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7" | "Invariant Group" | "Tulipa" | "M11 Credit" | "KPK" | "Hyperithm" | "UltraYield" | "TelosC" | "Gami Labs" | "Securitize" | "Testnet Curator";
|
|
8
8
|
/**
|
|
9
9
|
* Extended viem {@link Chain} with Gearbox-specific metadata.
|
|
10
10
|
*
|
|
@@ -168,8 +168,10 @@ export interface FindBestClosePathProps {
|
|
|
168
168
|
export interface ClosePathBalances {
|
|
169
169
|
/**
|
|
170
170
|
* List of all credit account balances nominated in their respective tokens.
|
|
171
|
-
* Current balances or expected balances after some actions (add/withdraw collateral
|
|
172
|
-
* if these actions are before router calls
|
|
171
|
+
* Current balances or expected balances after some actions (e.g. add/withdraw collateral),
|
|
172
|
+
* if these actions are before router calls — including balances of tokens
|
|
173
|
+
* not yet on the account (e.g. a claim token about to be received), which
|
|
174
|
+
* are absent from `creditAccount.tokens` and must be added here explicitly.
|
|
173
175
|
*/
|
|
174
176
|
expectedBalances: Array<Asset>;
|
|
175
177
|
/**
|
|
@@ -187,10 +189,27 @@ export interface ClosePathBalances {
|
|
|
187
189
|
* On-chain router contract that finds optimal multi-hop swap paths
|
|
188
190
|
* for credit-account operations: single-token swaps, open-strategy
|
|
189
191
|
* collateral conversion, reward claiming, and full account closure.
|
|
192
|
+
*
|
|
193
|
+
* Which finder to use:
|
|
194
|
+
*
|
|
195
|
+
* - {@link findOneTokenPath} — full spend of a single token. The on-chain
|
|
196
|
+
* `routeOneToOne` reads leftovers from the **live** account balances:
|
|
197
|
+
* a full spend emits `leftover=1` diff encodings, while pre-existing dust
|
|
198
|
+
* of intermediate tokens is preserved as leftover.
|
|
199
|
+
* - {@link findOpenStrategyPath} — partial spend: swap a token while keeping
|
|
200
|
+
* an exact remainder on the account. `expectedBalances` is the total amount
|
|
201
|
+
* available at execution time (may differ from the live balance, e.g. when
|
|
202
|
+
* the input token arrives in the same multicall from a delayed-withdrawal
|
|
203
|
+
* claim), `leftoverBalances` is the amount to keep; the router swaps the
|
|
204
|
+
* difference.
|
|
205
|
+
* - {@link findBestClosePath} account closure: converts all remaining assets
|
|
206
|
+
* (including dust) into underlying.
|
|
190
207
|
**/
|
|
191
208
|
export interface IRouterContract extends IBaseContract {
|
|
192
209
|
/**
|
|
193
210
|
* Find the best path to swap one token into another.
|
|
211
|
+
* Use for full spends of a single token; to keep an exact remainder
|
|
212
|
+
* on the account, use {@link findOpenStrategyPath} instead.
|
|
194
213
|
*
|
|
195
214
|
* @param props - {@link FindOneTokenPathProps}
|
|
196
215
|
* @returns The optimal swap result including amount, slippage-adjusted
|
|
@@ -200,6 +219,8 @@ export interface IRouterContract extends IBaseContract {
|
|
|
200
219
|
/**
|
|
201
220
|
* Find the best path for opening a credit account by converting all
|
|
202
221
|
* collateral (except leftovers) into a single target token.
|
|
222
|
+
* Also the right choice for any partial spend that must keep an exact
|
|
223
|
+
* remainder on the account (see {@link IRouterContract}).
|
|
203
224
|
*
|
|
204
225
|
* @param props - {@link FindOpenStrategyPathProps}
|
|
205
226
|
* @returns Swap result with projected post-open balances.
|
|
@@ -215,7 +236,7 @@ export interface IRouterContract extends IBaseContract {
|
|
|
215
236
|
findClaimAllRewards: (props: FindClaimAllRewardsProps) => Promise<RouterRewardsResult>;
|
|
216
237
|
/**
|
|
217
238
|
* Find the best path to swap all credit-account assets into the
|
|
218
|
-
* underlying token. Used for account closure and liquidation
|
|
239
|
+
* underlying token. Used for account closure and liquidation
|
|
219
240
|
*
|
|
220
241
|
* @param props - {@link FindBestClosePathProps}
|
|
221
242
|
* @returns Swap result including the total underlying balance
|