@gearbox-protocol/sdk 14.12.0-next.19 → 14.12.0-next.20
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/plugins/adapters/abi/{securitize/iSecuritizeOnRampAdapter.js → adapters/iSecuritizeOnRampAdapterV310.js} +6 -6
- package/dist/cjs/plugins/adapters/abi/{securitize/iSecuritizeRedemptionGatewayAdapter.js → adapters/iSecuritizeRedemptionGatewayAdapterV311.js} +26 -6
- package/dist/cjs/plugins/adapters/abi/adapters/index.js +4 -0
- package/dist/cjs/plugins/adapters/abi/securitize/{iSecuritizeRedemptionGateway.js → iSecuritizeRedemptionGatewayV311.js} +15 -7
- package/dist/cjs/plugins/adapters/abi/securitize/index.js +2 -6
- package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +28 -4
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +3 -3
- package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +2 -2
- package/dist/cjs/sdk/accounts/withdrawal-compressor/{intent.js → intent-codec.js} +14 -68
- package/dist/esm/plugins/adapters/abi/{securitize/iSecuritizeOnRampAdapter.js → adapters/iSecuritizeOnRampAdapterV310.js} +2 -2
- package/dist/esm/plugins/adapters/abi/{securitize/iSecuritizeRedemptionGatewayAdapter.js → adapters/iSecuritizeRedemptionGatewayAdapterV311.js} +22 -2
- package/dist/esm/plugins/adapters/abi/adapters/index.js +2 -0
- package/dist/esm/plugins/adapters/abi/securitize/{iSecuritizeRedemptionGateway.js → iSecuritizeRedemptionGatewayV311.js} +11 -3
- package/dist/esm/plugins/adapters/abi/securitize/index.js +1 -3
- package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +2 -2
- package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +31 -5
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/{intent.js → intent-codec.js} +11 -57
- package/dist/types/plugins/adapters/abi/{securitize/iSecuritizeOnRampAdapter.d.ts → adapters/iSecuritizeOnRampAdapterV310.d.ts} +1 -1
- package/dist/types/plugins/adapters/abi/{securitize/iSecuritizeRedemptionGatewayAdapter.d.ts → adapters/iSecuritizeRedemptionGatewayAdapterV311.d.ts} +37 -1
- package/dist/types/plugins/adapters/abi/adapters/index.d.ts +2 -0
- package/dist/types/plugins/adapters/abi/securitize/{iSecuritizeRedemptionGateway.d.ts → iSecuritizeRedemptionGatewayV311.d.ts} +15 -1
- package/dist/types/plugins/adapters/abi/securitize/index.d.ts +1 -3
- package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +54 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +1 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +1 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/intent-codec.d.ts +26 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +167 -6
- package/package.json +1 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/intent.d.ts +0 -106
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
import { decodeAbiParameters, encodeAbiParameters } from "viem";
|
|
2
|
-
import { z } from "zod/v4";
|
|
3
|
-
import { ZodAddress } from "../../utils/index.js";
|
|
4
|
-
const delayedIncreaseLeverageIntentSchema = z.object({
|
|
5
|
-
type: z.literal("INCREASE_LEVERAGE"),
|
|
6
|
-
to: ZodAddress()
|
|
7
|
-
});
|
|
8
|
-
const delayedDepositIntentSchema = z.object({
|
|
9
|
-
type: z.literal("DEPOSIT")
|
|
10
|
-
});
|
|
11
|
-
const delayedDepositAndIncreaseLeverageIntentSchema = z.object({
|
|
12
|
-
type: z.literal("DEPOSIT_AND_INCREASE_LEVERAGE")
|
|
13
|
-
});
|
|
14
|
-
const delayedWithdrawCollateralIntentSchema = z.object({
|
|
15
|
-
type: z.literal("WITHDRAW_COLLATERAL"),
|
|
16
|
-
to: ZodAddress(),
|
|
17
|
-
withdrawToken: ZodAddress(),
|
|
18
|
-
withdrawAmount: z.bigint()
|
|
19
|
-
});
|
|
20
|
-
const delayedCloseAccountIntentSchema = z.object({
|
|
21
|
-
type: z.literal("CLOSE_ACCOUNT"),
|
|
22
|
-
to: ZodAddress()
|
|
23
|
-
});
|
|
24
|
-
const delayedAddCollateralIntentSchema = z.object({
|
|
25
|
-
type: z.literal("ADD_COLLATERAL")
|
|
26
|
-
});
|
|
27
|
-
const delayedDecreaseLeverageIntentSchema = z.object({
|
|
28
|
-
type: z.literal("DECREASE_LEVERAGE")
|
|
29
|
-
});
|
|
30
|
-
const delayedIntentSchema = z.discriminatedUnion("type", [
|
|
31
|
-
delayedIncreaseLeverageIntentSchema,
|
|
32
|
-
delayedDepositIntentSchema,
|
|
33
|
-
delayedDepositAndIncreaseLeverageIntentSchema,
|
|
34
|
-
delayedWithdrawCollateralIntentSchema,
|
|
35
|
-
delayedCloseAccountIntentSchema,
|
|
36
|
-
delayedAddCollateralIntentSchema,
|
|
37
|
-
delayedDecreaseLeverageIntentSchema
|
|
38
|
-
]);
|
|
39
2
|
const DELAYED_INTENT_VERSION = 1;
|
|
40
3
|
const DELAYED_INTENT_TYPES = {
|
|
41
4
|
INCREASE_LEVERAGE: 1,
|
|
@@ -57,20 +20,19 @@ const WITHDRAW_COLLATERAL_PARAMS = [
|
|
|
57
20
|
{ type: "uint256", name: "withdrawAmount" }
|
|
58
21
|
];
|
|
59
22
|
function encodeDelayedIntent(intent) {
|
|
60
|
-
const parsed = delayedIntentSchema.parse(intent);
|
|
61
23
|
const version = DELAYED_INTENT_VERSION;
|
|
62
|
-
const intentType = DELAYED_INTENT_TYPES[
|
|
63
|
-
switch (
|
|
24
|
+
const intentType = DELAYED_INTENT_TYPES[intent.type];
|
|
25
|
+
switch (intent.type) {
|
|
64
26
|
case "INCREASE_LEVERAGE":
|
|
65
27
|
case "CLOSE_ACCOUNT":
|
|
66
|
-
return encodeAbiParameters(TO_PARAMS, [version, intentType,
|
|
28
|
+
return encodeAbiParameters(TO_PARAMS, [version, intentType, intent.to]);
|
|
67
29
|
case "WITHDRAW_COLLATERAL":
|
|
68
30
|
return encodeAbiParameters(WITHDRAW_COLLATERAL_PARAMS, [
|
|
69
31
|
version,
|
|
70
32
|
intentType,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
33
|
+
intent.to,
|
|
34
|
+
intent.withdrawToken,
|
|
35
|
+
intent.withdrawAmount
|
|
74
36
|
]);
|
|
75
37
|
case "DEPOSIT":
|
|
76
38
|
case "DEPOSIT_AND_INCREASE_LEVERAGE":
|
|
@@ -78,7 +40,7 @@ function encodeDelayedIntent(intent) {
|
|
|
78
40
|
case "DECREASE_LEVERAGE":
|
|
79
41
|
return encodeAbiParameters(HEADER_PARAMS, [version, intentType]);
|
|
80
42
|
default: {
|
|
81
|
-
const t =
|
|
43
|
+
const t = intent;
|
|
82
44
|
throw new Error(`unknown delayed intent: ${JSON.stringify(t)}`);
|
|
83
45
|
}
|
|
84
46
|
}
|
|
@@ -91,7 +53,7 @@ function decodeDelayedIntent(data) {
|
|
|
91
53
|
switch (intentType) {
|
|
92
54
|
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE: {
|
|
93
55
|
const [, , to] = decodeAbiParameters(TO_PARAMS, data);
|
|
94
|
-
return
|
|
56
|
+
return { type: "INCREASE_LEVERAGE", to };
|
|
95
57
|
}
|
|
96
58
|
case DELAYED_INTENT_TYPES.DEPOSIT:
|
|
97
59
|
return { type: "DEPOSIT" };
|
|
@@ -102,16 +64,16 @@ function decodeDelayedIntent(data) {
|
|
|
102
64
|
WITHDRAW_COLLATERAL_PARAMS,
|
|
103
65
|
data
|
|
104
66
|
);
|
|
105
|
-
return
|
|
67
|
+
return {
|
|
106
68
|
type: "WITHDRAW_COLLATERAL",
|
|
107
69
|
to,
|
|
108
70
|
withdrawToken,
|
|
109
71
|
withdrawAmount
|
|
110
|
-
}
|
|
72
|
+
};
|
|
111
73
|
}
|
|
112
74
|
case DELAYED_INTENT_TYPES.CLOSE_ACCOUNT: {
|
|
113
75
|
const [, , to] = decodeAbiParameters(TO_PARAMS, data);
|
|
114
|
-
return
|
|
76
|
+
return { type: "CLOSE_ACCOUNT", to };
|
|
115
77
|
}
|
|
116
78
|
case DELAYED_INTENT_TYPES.ADD_COLLATERAL:
|
|
117
79
|
return { type: "ADD_COLLATERAL" };
|
|
@@ -125,13 +87,5 @@ export {
|
|
|
125
87
|
DELAYED_INTENT_TYPES,
|
|
126
88
|
DELAYED_INTENT_VERSION,
|
|
127
89
|
decodeDelayedIntent,
|
|
128
|
-
delayedAddCollateralIntentSchema,
|
|
129
|
-
delayedCloseAccountIntentSchema,
|
|
130
|
-
delayedDecreaseLeverageIntentSchema,
|
|
131
|
-
delayedDepositAndIncreaseLeverageIntentSchema,
|
|
132
|
-
delayedDepositIntentSchema,
|
|
133
|
-
delayedIncreaseLeverageIntentSchema,
|
|
134
|
-
delayedIntentSchema,
|
|
135
|
-
delayedWithdrawCollateralIntentSchema,
|
|
136
90
|
encodeDelayedIntent
|
|
137
91
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const iSecuritizeRedemptionGatewayAdapterV311Abi: readonly [{
|
|
2
2
|
readonly type: "function";
|
|
3
3
|
readonly name: "claim";
|
|
4
4
|
readonly inputs: readonly [{
|
|
@@ -74,6 +74,42 @@ export declare const iSecuritizeRedemptionGatewayAdapterAbi: readonly [{
|
|
|
74
74
|
readonly internalType: "bool";
|
|
75
75
|
}];
|
|
76
76
|
readonly stateMutability: "nonpayable";
|
|
77
|
+
}, {
|
|
78
|
+
readonly type: "function";
|
|
79
|
+
readonly name: "redeem";
|
|
80
|
+
readonly inputs: readonly [{
|
|
81
|
+
readonly name: "dsTokenAmount";
|
|
82
|
+
readonly type: "uint256";
|
|
83
|
+
readonly internalType: "uint256";
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "extraData";
|
|
86
|
+
readonly type: "bytes";
|
|
87
|
+
readonly internalType: "bytes";
|
|
88
|
+
}];
|
|
89
|
+
readonly outputs: readonly [{
|
|
90
|
+
readonly name: "";
|
|
91
|
+
readonly type: "bool";
|
|
92
|
+
readonly internalType: "bool";
|
|
93
|
+
}];
|
|
94
|
+
readonly stateMutability: "nonpayable";
|
|
95
|
+
}, {
|
|
96
|
+
readonly type: "function";
|
|
97
|
+
readonly name: "redeemDiff";
|
|
98
|
+
readonly inputs: readonly [{
|
|
99
|
+
readonly name: "leftoverAmount";
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
readonly internalType: "uint256";
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "extraData";
|
|
104
|
+
readonly type: "bytes";
|
|
105
|
+
readonly internalType: "bytes";
|
|
106
|
+
}];
|
|
107
|
+
readonly outputs: readonly [{
|
|
108
|
+
readonly name: "";
|
|
109
|
+
readonly type: "bool";
|
|
110
|
+
readonly internalType: "bool";
|
|
111
|
+
}];
|
|
112
|
+
readonly stateMutability: "nonpayable";
|
|
77
113
|
}, {
|
|
78
114
|
readonly type: "function";
|
|
79
115
|
readonly name: "redeemDiff";
|
|
@@ -22,6 +22,8 @@ export * from "./iMidasGatewayAdapterV311.js";
|
|
|
22
22
|
export * from "./iMidasIssuanceVaultAdapterV310.js";
|
|
23
23
|
export * from "./iMidasRedemptionVaultAdapterV310.js";
|
|
24
24
|
export * from "./iPendleRouterAdapter.js";
|
|
25
|
+
export * from "./iSecuritizeOnRampAdapterV310.js";
|
|
26
|
+
export * from "./iSecuritizeRedemptionGatewayAdapterV311.js";
|
|
25
27
|
export * from "./iStakingRewardsAdapter.js";
|
|
26
28
|
export * from "./iTraderJoeRouterAdapter.js";
|
|
27
29
|
export * from "./iUniswapV2Adapter.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const iSecuritizeRedemptionGatewayV311Abi: readonly [{
|
|
2
2
|
readonly type: "function";
|
|
3
3
|
readonly name: "claim";
|
|
4
4
|
readonly inputs: readonly [{
|
|
@@ -97,6 +97,10 @@ export declare const iSecuritizeRedemptionGatewayAbi: readonly [{
|
|
|
97
97
|
readonly name: "dsTokenAmount";
|
|
98
98
|
readonly type: "uint256";
|
|
99
99
|
readonly internalType: "uint256";
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "extraData";
|
|
102
|
+
readonly type: "bytes";
|
|
103
|
+
readonly internalType: "bytes";
|
|
100
104
|
}];
|
|
101
105
|
readonly outputs: readonly [];
|
|
102
106
|
readonly stateMutability: "nonpayable";
|
|
@@ -110,6 +114,16 @@ export declare const iSecuritizeRedemptionGatewayAbi: readonly [{
|
|
|
110
114
|
readonly internalType: "address";
|
|
111
115
|
}];
|
|
112
116
|
readonly stateMutability: "view";
|
|
117
|
+
}, {
|
|
118
|
+
readonly type: "function";
|
|
119
|
+
readonly name: "redemptionLogger";
|
|
120
|
+
readonly inputs: readonly [];
|
|
121
|
+
readonly outputs: readonly [{
|
|
122
|
+
readonly name: "";
|
|
123
|
+
readonly type: "address";
|
|
124
|
+
readonly internalType: "address";
|
|
125
|
+
}];
|
|
126
|
+
readonly stateMutability: "view";
|
|
113
127
|
}, {
|
|
114
128
|
readonly type: "function";
|
|
115
129
|
readonly name: "securitizeWhitelister";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export * from "./iBaseOnRamp.js";
|
|
2
2
|
export * from "./iSecuritizeOnRamp.js";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./iSecuritizeRedemptionGateway.js";
|
|
5
|
-
export * from "./iSecuritizeRedemptionGatewayAdapter.js";
|
|
3
|
+
export * from "./iSecuritizeRedemptionGatewayV311.js";
|
package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import { type ConstructOptions } from "../../../sdk/index.js";
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
|
+
import { type AddressMap, type ConstructOptions } from "../../../sdk/index.js";
|
|
3
|
+
import type { DiffLeftover } from "../types.js";
|
|
3
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
4
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
5
6
|
declare const abi: readonly [{
|
|
@@ -78,6 +79,42 @@ declare const abi: readonly [{
|
|
|
78
79
|
readonly internalType: "bool";
|
|
79
80
|
}];
|
|
80
81
|
readonly stateMutability: "nonpayable";
|
|
82
|
+
}, {
|
|
83
|
+
readonly type: "function";
|
|
84
|
+
readonly name: "redeem";
|
|
85
|
+
readonly inputs: readonly [{
|
|
86
|
+
readonly name: "dsTokenAmount";
|
|
87
|
+
readonly type: "uint256";
|
|
88
|
+
readonly internalType: "uint256";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "extraData";
|
|
91
|
+
readonly type: "bytes";
|
|
92
|
+
readonly internalType: "bytes";
|
|
93
|
+
}];
|
|
94
|
+
readonly outputs: readonly [{
|
|
95
|
+
readonly name: "";
|
|
96
|
+
readonly type: "bool";
|
|
97
|
+
readonly internalType: "bool";
|
|
98
|
+
}];
|
|
99
|
+
readonly stateMutability: "nonpayable";
|
|
100
|
+
}, {
|
|
101
|
+
readonly type: "function";
|
|
102
|
+
readonly name: "redeemDiff";
|
|
103
|
+
readonly inputs: readonly [{
|
|
104
|
+
readonly name: "leftoverAmount";
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
readonly internalType: "uint256";
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "extraData";
|
|
109
|
+
readonly type: "bytes";
|
|
110
|
+
readonly internalType: "bytes";
|
|
111
|
+
}];
|
|
112
|
+
readonly outputs: readonly [{
|
|
113
|
+
readonly name: "";
|
|
114
|
+
readonly type: "bool";
|
|
115
|
+
readonly internalType: "bool";
|
|
116
|
+
}];
|
|
117
|
+
readonly stateMutability: "nonpayable";
|
|
81
118
|
}, {
|
|
82
119
|
readonly type: "function";
|
|
83
120
|
readonly name: "redeemDiff";
|
|
@@ -287,6 +324,10 @@ declare const protocolAbi: readonly [{
|
|
|
287
324
|
readonly name: "dsTokenAmount";
|
|
288
325
|
readonly type: "uint256";
|
|
289
326
|
readonly internalType: "uint256";
|
|
327
|
+
}, {
|
|
328
|
+
readonly name: "extraData";
|
|
329
|
+
readonly type: "bytes";
|
|
330
|
+
readonly internalType: "bytes";
|
|
290
331
|
}];
|
|
291
332
|
readonly outputs: readonly [];
|
|
292
333
|
readonly stateMutability: "nonpayable";
|
|
@@ -300,6 +341,16 @@ declare const protocolAbi: readonly [{
|
|
|
300
341
|
readonly internalType: "address";
|
|
301
342
|
}];
|
|
302
343
|
readonly stateMutability: "view";
|
|
344
|
+
}, {
|
|
345
|
+
readonly type: "function";
|
|
346
|
+
readonly name: "redemptionLogger";
|
|
347
|
+
readonly inputs: readonly [];
|
|
348
|
+
readonly outputs: readonly [{
|
|
349
|
+
readonly name: "";
|
|
350
|
+
readonly type: "address";
|
|
351
|
+
readonly internalType: "address";
|
|
352
|
+
}];
|
|
353
|
+
readonly stateMutability: "view";
|
|
303
354
|
}, {
|
|
304
355
|
readonly type: "function";
|
|
305
356
|
readonly name: "securitizeWhitelister";
|
|
@@ -388,5 +439,6 @@ export declare class SecuritizeRedemptionGatewayAdapterContract extends Abstract
|
|
|
388
439
|
stableCoinToken: string | undefined;
|
|
389
440
|
redemptionPhantomToken: string | undefined;
|
|
390
441
|
};
|
|
442
|
+
protected decodeDiffLeftovers(decoded: DecodeFunctionDataReturnType<abi>, balances: AddressMap<bigint>): DiffLeftover[];
|
|
391
443
|
}
|
|
392
444
|
export {};
|
package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import type { Abi, Address } from "viem";
|
|
|
2
2
|
import type { BaseContractArgs } from "../../base/index.js";
|
|
3
3
|
import { BaseContract } from "../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
|
-
import type { DelayedIntent } from "./
|
|
6
|
-
import type { CurrentWithdrawals, IWithdrawalCompressorContract, RequestableWithdrawal, WithdrawableAsset } from "./types.js";
|
|
5
|
+
import type { CurrentWithdrawals, DelayedIntent, IWithdrawalCompressorContract, RequestableWithdrawal, WithdrawableAsset } from "./types.js";
|
|
7
6
|
/**
|
|
8
7
|
* Base class for WithdrawalCompressor contracts of different versions.
|
|
9
8
|
* Implements version-agnostic reads, normalizing results to common types.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./AbstractWithdrawalCompressorContract.js";
|
|
2
2
|
export * from "./addresses.js";
|
|
3
3
|
export * from "./createWithdrawalCompressor.js";
|
|
4
|
-
export * from "./intent.js";
|
|
4
|
+
export * from "./intent-codec.js";
|
|
5
5
|
export * from "./types.js";
|
|
6
6
|
export * from "./WithdrawalCompressorV310Contract.js";
|
|
7
7
|
export * from "./WithdrawalCompressorV311Contract.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import type { DelayedIntent } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Current version of the delayed intent encoding schema.
|
|
5
|
+
* Bump when the layout of any intent type changes.
|
|
6
|
+
**/
|
|
7
|
+
export declare const DELAYED_INTENT_VERSION = 1;
|
|
8
|
+
/**
|
|
9
|
+
* Stable uint8 discriminants for intent types.
|
|
10
|
+
* Starts at 1 so that all-zero data cannot decode as a valid intent.
|
|
11
|
+
* Never reuse or renumber existing values.
|
|
12
|
+
**/
|
|
13
|
+
export declare const DELAYED_INTENT_TYPES: Record<DelayedIntent["type"], number>;
|
|
14
|
+
/**
|
|
15
|
+
* ABI-encodes a delayed intent as
|
|
16
|
+
* `(uint8 version, uint8 intentType, ...intent-specific fields)`.
|
|
17
|
+
* @throws if the intent has an unknown type or fields that cannot be
|
|
18
|
+
* abi-encoded (e.g. an invalid address)
|
|
19
|
+
**/
|
|
20
|
+
export declare function encodeDelayedIntent(intent: DelayedIntent): Hex;
|
|
21
|
+
/**
|
|
22
|
+
* Decodes a delayed intent from abi-encoded `extraData`.
|
|
23
|
+
* @throws if data is empty, malformed, has an unsupported version,
|
|
24
|
+
* or an unknown intent type
|
|
25
|
+
**/
|
|
26
|
+
export declare function decodeDelayedIntent(data: Hex): DelayedIntent;
|
|
@@ -1,7 +1,91 @@
|
|
|
1
1
|
import type { Address } 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 TVL.
|
|
6
|
+
* Borrow `underlying` -> swap `underlying` into `targetToken` -> [withdraw to wallet].
|
|
7
|
+
**/
|
|
8
|
+
export interface DelayedIncreaseLeverageIntent {
|
|
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
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* App: 1.2 Deposit — `amount > 0`, leverage = current (grow net value at same L).
|
|
18
|
+
* Add collateral -> borrow `underlying` -> swap collateral and `underlying`
|
|
19
|
+
* into the target token.
|
|
20
|
+
**/
|
|
21
|
+
export interface DelayedDepositIntent {
|
|
22
|
+
type: "DEPOSIT";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* App: 1.3 Deposit and Adjust leverage — `amount > 0`, leverage > current.
|
|
26
|
+
* Add collateral -> borrow `underlying` -> swap collateral and `underlying`
|
|
27
|
+
* into the target token.
|
|
28
|
+
**/
|
|
29
|
+
export interface DelayedDepositAndIncreaseLeverageIntent {
|
|
30
|
+
type: "DEPOSIT_AND_INCREASE_LEVERAGE";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* App: 2.1 Withdraw — withdraw selected token at fixed leverage.
|
|
34
|
+
* Swap token into `underlying` -> [decrease debt with `underlying` ->
|
|
35
|
+
* withdraw token to wallet].
|
|
36
|
+
**/
|
|
37
|
+
export interface DelayedWithdrawCollateralIntent {
|
|
38
|
+
type: "WITHDRAW_COLLATERAL";
|
|
39
|
+
/**
|
|
40
|
+
* Wallet address that receives the withdrawn token
|
|
41
|
+
* when the flow is resumed after the claim
|
|
42
|
+
**/
|
|
43
|
+
to: Address;
|
|
44
|
+
/**
|
|
45
|
+
* Token to withdraw from the credit account to the wallet after the claim
|
|
46
|
+
**/
|
|
47
|
+
withdrawToken: Address;
|
|
48
|
+
/**
|
|
49
|
+
* Amount of `withdrawToken` to withdraw to the wallet after the claim
|
|
50
|
+
**/
|
|
51
|
+
withdrawAmount: bigint;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* App: 2.2 Withdraw — close account (receive leftover to wallet).
|
|
55
|
+
**/
|
|
56
|
+
export interface DelayedCloseAccountIntent {
|
|
57
|
+
type: "CLOSE_ACCOUNT";
|
|
58
|
+
/**
|
|
59
|
+
* Wallet address that receives leftover tokens when the account is closed
|
|
60
|
+
* after the claim
|
|
61
|
+
**/
|
|
62
|
+
to: Address;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* App: 3.1 Add collateral — fixed debt.
|
|
66
|
+
* Add collateral -> swap collateral into the target token.
|
|
67
|
+
**/
|
|
68
|
+
export interface DelayedAddCollateralIntent {
|
|
69
|
+
type: "ADD_COLLATERAL";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* App: 4.2 Adjust leverage — lower leverage at fixed TVL.
|
|
73
|
+
* Swap collateral into `underlying` -> [decrease debt with `underlying`].
|
|
74
|
+
**/
|
|
75
|
+
export interface DelayedDecreaseLeverageIntent {
|
|
76
|
+
type: "DECREASE_LEVERAGE";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Lean intent that is abi-encoded into `extraData` of a delayed withdrawal
|
|
80
|
+
* request and decoded back when reading claimable withdrawals.
|
|
81
|
+
*
|
|
82
|
+
* It allows the app to resume a multi-step operation that was interrupted by
|
|
83
|
+
* a delayed withdrawal: the intent records which operation was in progress
|
|
84
|
+
* (and the minimal set of parameters that cannot be re-derived at claim time),
|
|
85
|
+
* so that after the withdrawal is claimed, the remaining steps can be
|
|
86
|
+
* previewed and executed.
|
|
87
|
+
**/
|
|
88
|
+
export type DelayedIntent = DelayedIncreaseLeverageIntent | DelayedDepositIntent | DelayedDepositAndIncreaseLeverageIntent | DelayedWithdrawCollateralIntent | DelayedCloseAccountIntent | DelayedAddCollateralIntent | DelayedDecreaseLeverageIntent;
|
|
5
89
|
/**
|
|
6
90
|
* Delayed intent decoded from `extraData`, enriched with data known at read time.
|
|
7
91
|
**/
|
|
@@ -12,11 +96,27 @@ export type DelayedIntentExtended = DelayedIntent & {
|
|
|
12
96
|
creditManager: Address;
|
|
13
97
|
};
|
|
14
98
|
/**
|
|
15
|
-
* A single output of a (delayed) withdrawal
|
|
99
|
+
* A single output of a (delayed) withdrawal: one token amount produced by
|
|
100
|
+
* requesting or claiming a withdrawal.
|
|
16
101
|
**/
|
|
17
102
|
export interface WithdrawalOutput {
|
|
103
|
+
/**
|
|
104
|
+
* Output token. For a delayed output, this is the withdrawal phantom token;
|
|
105
|
+
* otherwise the actual token received (usually the withdrawable asset's
|
|
106
|
+
* `underlying`)
|
|
107
|
+
**/
|
|
18
108
|
token: Address;
|
|
109
|
+
/**
|
|
110
|
+
* When `false`, the amount lands on the credit account immediately.
|
|
111
|
+
* When `true`, the amount is only represented by the withdrawal phantom
|
|
112
|
+
* token and becomes claimable after the withdrawal delay. A request can
|
|
113
|
+
* produce both kinds at once, e.g. Mellow serves the liquid part of a
|
|
114
|
+
* withdrawal instantly and queues the remainder
|
|
115
|
+
**/
|
|
19
116
|
isDelayed: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Amount of `token` produced (or expected to be produced) by the withdrawal
|
|
119
|
+
**/
|
|
20
120
|
amount: bigint;
|
|
21
121
|
}
|
|
22
122
|
/**
|
|
@@ -28,19 +128,29 @@ export interface WithdrawableAsset {
|
|
|
28
128
|
**/
|
|
29
129
|
creditManager: Address;
|
|
30
130
|
/**
|
|
31
|
-
* Source token
|
|
131
|
+
* Source token: the collateral that is spent when the
|
|
132
|
+
* withdrawal is requested, e.g. a Mellow multivault share, a Securitize
|
|
133
|
+
* dsToken or a Midas mToken
|
|
32
134
|
**/
|
|
33
135
|
token: Address;
|
|
34
136
|
/**
|
|
35
|
-
* Withdrawal phantom token
|
|
137
|
+
* Withdrawal phantom token: a non-transferable collateral
|
|
138
|
+
* token that represents the in-flight withdrawal position on the credit
|
|
139
|
+
* account while the withdrawal is pending
|
|
36
140
|
**/
|
|
37
141
|
withdrawalPhantomToken: Address;
|
|
38
142
|
/**
|
|
39
|
-
* Target token
|
|
143
|
+
* Target token: the token ultimately received when the
|
|
144
|
+
* withdrawal is claimed
|
|
40
145
|
**/
|
|
41
146
|
underlying: Address;
|
|
147
|
+
/**
|
|
148
|
+
* Expected delay between requesting and claiming a withdrawal, in seconds
|
|
149
|
+
**/
|
|
42
150
|
withdrawalLength: bigint;
|
|
43
151
|
/**
|
|
152
|
+
* Maximum number of simultaneously open withdrawal requests per credit
|
|
153
|
+
* account.
|
|
44
154
|
* Not available on v310 compressors
|
|
45
155
|
**/
|
|
46
156
|
maxWithdrawals?: bigint;
|
|
@@ -49,10 +159,26 @@ export interface WithdrawableAsset {
|
|
|
49
159
|
* A single delayed withdrawal that is ready to be claimed.
|
|
50
160
|
**/
|
|
51
161
|
export interface ClaimableWithdrawal {
|
|
162
|
+
/**
|
|
163
|
+
* Source token the withdrawal was requested from
|
|
164
|
+
**/
|
|
52
165
|
token: Address;
|
|
166
|
+
/**
|
|
167
|
+
* Withdrawal phantom token that represents this withdrawal position
|
|
168
|
+
**/
|
|
53
169
|
withdrawalPhantomToken: Address;
|
|
170
|
+
/**
|
|
171
|
+
* Amount of the withdrawal phantom token that will be burned when the
|
|
172
|
+
* withdrawal is claimed
|
|
173
|
+
**/
|
|
54
174
|
withdrawalTokenSpent: bigint;
|
|
175
|
+
/**
|
|
176
|
+
* Tokens received by the credit account upon claiming
|
|
177
|
+
**/
|
|
55
178
|
outputs: WithdrawalOutput[];
|
|
179
|
+
/**
|
|
180
|
+
* Credit facade multicall (adapter calls) that executes the claim
|
|
181
|
+
**/
|
|
56
182
|
claimCalls: MultiCall[];
|
|
57
183
|
/**
|
|
58
184
|
* Delayed intent decoded from the withdrawal's `extraData`, enriched with
|
|
@@ -66,19 +192,51 @@ export interface ClaimableWithdrawal {
|
|
|
66
192
|
* A single pending delayed withdrawal that is not yet claimable.
|
|
67
193
|
**/
|
|
68
194
|
export interface PendingWithdrawal {
|
|
195
|
+
/**
|
|
196
|
+
* Source token the withdrawal was requested from
|
|
197
|
+
**/
|
|
69
198
|
token: Address;
|
|
199
|
+
/**
|
|
200
|
+
* Withdrawal phantom token that represents this withdrawal position
|
|
201
|
+
**/
|
|
70
202
|
withdrawalPhantomToken: Address;
|
|
203
|
+
/**
|
|
204
|
+
* Estimated tokens the credit account will receive once the withdrawal
|
|
205
|
+
* matures and is claimed
|
|
206
|
+
**/
|
|
71
207
|
expectedOutputs: WithdrawalOutput[];
|
|
208
|
+
/**
|
|
209
|
+
* Unix timestamp (in seconds) when the withdrawal becomes claimable
|
|
210
|
+
**/
|
|
72
211
|
claimableAt: bigint;
|
|
73
212
|
}
|
|
74
213
|
/**
|
|
75
214
|
* Result of previewing a delayed withdrawal request.
|
|
76
215
|
**/
|
|
77
216
|
export interface RequestableWithdrawal {
|
|
217
|
+
/**
|
|
218
|
+
* Source token that will be spent by the request
|
|
219
|
+
**/
|
|
78
220
|
token: Address;
|
|
221
|
+
/**
|
|
222
|
+
* Amount of `token` that will actually be spent; the contract caps the
|
|
223
|
+
* requested amount at the credit account's balance
|
|
224
|
+
**/
|
|
79
225
|
amountIn: bigint;
|
|
226
|
+
/**
|
|
227
|
+
* Expected outputs of the request: instant outputs land on the credit
|
|
228
|
+
* account in the same transaction, delayed outputs become claimable
|
|
229
|
+
* at `claimableAt`
|
|
230
|
+
**/
|
|
80
231
|
outputs: WithdrawalOutput[];
|
|
232
|
+
/**
|
|
233
|
+
* Credit facade multicall (adapter calls) that submits the withdrawal request
|
|
234
|
+
**/
|
|
81
235
|
requestCalls: MultiCall[];
|
|
236
|
+
/**
|
|
237
|
+
* Estimated unix timestamp (in seconds) when the delayed outputs become
|
|
238
|
+
* claimable
|
|
239
|
+
**/
|
|
82
240
|
claimableAt: bigint;
|
|
83
241
|
}
|
|
84
242
|
/**
|
|
@@ -86,9 +244,12 @@ export interface RequestableWithdrawal {
|
|
|
86
244
|
* and still-pending entries.
|
|
87
245
|
**/
|
|
88
246
|
export interface CurrentWithdrawals {
|
|
247
|
+
/**
|
|
248
|
+
* Withdrawals that have matured and can be claimed now
|
|
249
|
+
**/
|
|
89
250
|
claimable: ClaimableWithdrawal[];
|
|
90
251
|
/**
|
|
91
|
-
*
|
|
252
|
+
* Withdrawals that are still maturing
|
|
92
253
|
**/
|
|
93
254
|
pending: PendingWithdrawal[];
|
|
94
255
|
}
|