@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
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var iSecuritizeOnRampAdapterV310_exports = {};
|
|
20
|
+
__export(iSecuritizeOnRampAdapterV310_exports, {
|
|
21
|
+
iSecuritizeOnRampAdapterV310Abi: () => iSecuritizeOnRampAdapterV310Abi
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
23
|
+
module.exports = __toCommonJS(iSecuritizeOnRampAdapterV310_exports);
|
|
24
|
+
const iSecuritizeOnRampAdapterV310Abi = [
|
|
25
25
|
{
|
|
26
26
|
type: "function",
|
|
27
27
|
name: "contractType",
|
|
@@ -94,5 +94,5 @@ const iSecuritizeOnRampAdapterAbi = [
|
|
|
94
94
|
];
|
|
95
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
96
|
0 && (module.exports = {
|
|
97
|
-
|
|
97
|
+
iSecuritizeOnRampAdapterV310Abi
|
|
98
98
|
});
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var iSecuritizeRedemptionGatewayAdapterV311_exports = {};
|
|
20
|
+
__export(iSecuritizeRedemptionGatewayAdapterV311_exports, {
|
|
21
|
+
iSecuritizeRedemptionGatewayAdapterV311Abi: () => iSecuritizeRedemptionGatewayAdapterV311Abi
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
23
|
+
module.exports = __toCommonJS(iSecuritizeRedemptionGatewayAdapterV311_exports);
|
|
24
|
+
const iSecuritizeRedemptionGatewayAdapterV311Abi = [
|
|
25
25
|
{
|
|
26
26
|
type: "function",
|
|
27
27
|
name: "claim",
|
|
@@ -71,6 +71,26 @@ const iSecuritizeRedemptionGatewayAdapterAbi = [
|
|
|
71
71
|
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
72
72
|
stateMutability: "nonpayable"
|
|
73
73
|
},
|
|
74
|
+
{
|
|
75
|
+
type: "function",
|
|
76
|
+
name: "redeem",
|
|
77
|
+
inputs: [
|
|
78
|
+
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" },
|
|
79
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
80
|
+
],
|
|
81
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
82
|
+
stateMutability: "nonpayable"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "function",
|
|
86
|
+
name: "redeemDiff",
|
|
87
|
+
inputs: [
|
|
88
|
+
{ name: "leftoverAmount", type: "uint256", internalType: "uint256" },
|
|
89
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
90
|
+
],
|
|
91
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
92
|
+
stateMutability: "nonpayable"
|
|
93
|
+
},
|
|
74
94
|
{
|
|
75
95
|
type: "function",
|
|
76
96
|
name: "redeemDiff",
|
|
@@ -140,5 +160,5 @@ const iSecuritizeRedemptionGatewayAdapterAbi = [
|
|
|
140
160
|
];
|
|
141
161
|
// Annotate the CommonJS export names for ESM import in node:
|
|
142
162
|
0 && (module.exports = {
|
|
143
|
-
|
|
163
|
+
iSecuritizeRedemptionGatewayAdapterV311Abi
|
|
144
164
|
});
|
|
@@ -39,6 +39,8 @@ __reExport(adapters_exports, require("./iMidasGatewayAdapterV311.js"), module.ex
|
|
|
39
39
|
__reExport(adapters_exports, require("./iMidasIssuanceVaultAdapterV310.js"), module.exports);
|
|
40
40
|
__reExport(adapters_exports, require("./iMidasRedemptionVaultAdapterV310.js"), module.exports);
|
|
41
41
|
__reExport(adapters_exports, require("./iPendleRouterAdapter.js"), module.exports);
|
|
42
|
+
__reExport(adapters_exports, require("./iSecuritizeOnRampAdapterV310.js"), module.exports);
|
|
43
|
+
__reExport(adapters_exports, require("./iSecuritizeRedemptionGatewayAdapterV311.js"), module.exports);
|
|
42
44
|
__reExport(adapters_exports, require("./iStakingRewardsAdapter.js"), module.exports);
|
|
43
45
|
__reExport(adapters_exports, require("./iTraderJoeRouterAdapter.js"), module.exports);
|
|
44
46
|
__reExport(adapters_exports, require("./iUniswapV2Adapter.js"), module.exports);
|
|
@@ -74,6 +76,8 @@ __reExport(adapters_exports, require("./mellowDvvAdapter.js"), module.exports);
|
|
|
74
76
|
...require("./iMidasIssuanceVaultAdapterV310.js"),
|
|
75
77
|
...require("./iMidasRedemptionVaultAdapterV310.js"),
|
|
76
78
|
...require("./iPendleRouterAdapter.js"),
|
|
79
|
+
...require("./iSecuritizeOnRampAdapterV310.js"),
|
|
80
|
+
...require("./iSecuritizeRedemptionGatewayAdapterV311.js"),
|
|
77
81
|
...require("./iStakingRewardsAdapter.js"),
|
|
78
82
|
...require("./iTraderJoeRouterAdapter.js"),
|
|
79
83
|
...require("./iUniswapV2Adapter.js"),
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var iSecuritizeRedemptionGatewayV311_exports = {};
|
|
20
|
+
__export(iSecuritizeRedemptionGatewayV311_exports, {
|
|
21
|
+
iSecuritizeRedemptionGatewayV311Abi: () => iSecuritizeRedemptionGatewayV311Abi
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
23
|
+
module.exports = __toCommonJS(iSecuritizeRedemptionGatewayV311_exports);
|
|
24
|
+
const iSecuritizeRedemptionGatewayV311Abi = [
|
|
25
25
|
{
|
|
26
26
|
type: "function",
|
|
27
27
|
name: "claim",
|
|
@@ -84,7 +84,8 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
84
84
|
type: "function",
|
|
85
85
|
name: "redeem",
|
|
86
86
|
inputs: [
|
|
87
|
-
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" }
|
|
87
|
+
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" },
|
|
88
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
88
89
|
],
|
|
89
90
|
outputs: [],
|
|
90
91
|
stateMutability: "nonpayable"
|
|
@@ -96,6 +97,13 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
96
97
|
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
97
98
|
stateMutability: "view"
|
|
98
99
|
},
|
|
100
|
+
{
|
|
101
|
+
type: "function",
|
|
102
|
+
name: "redemptionLogger",
|
|
103
|
+
inputs: [],
|
|
104
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
105
|
+
stateMutability: "view"
|
|
106
|
+
},
|
|
99
107
|
{
|
|
100
108
|
type: "function",
|
|
101
109
|
name: "securitizeWhitelister",
|
|
@@ -145,5 +153,5 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
145
153
|
];
|
|
146
154
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
155
|
0 && (module.exports = {
|
|
148
|
-
|
|
156
|
+
iSecuritizeRedemptionGatewayV311Abi
|
|
149
157
|
});
|
|
@@ -17,14 +17,10 @@ var securitize_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(securitize_exports);
|
|
18
18
|
__reExport(securitize_exports, require("./iBaseOnRamp.js"), module.exports);
|
|
19
19
|
__reExport(securitize_exports, require("./iSecuritizeOnRamp.js"), module.exports);
|
|
20
|
-
__reExport(securitize_exports, require("./
|
|
21
|
-
__reExport(securitize_exports, require("./iSecuritizeRedemptionGateway.js"), module.exports);
|
|
22
|
-
__reExport(securitize_exports, require("./iSecuritizeRedemptionGatewayAdapter.js"), module.exports);
|
|
20
|
+
__reExport(securitize_exports, require("./iSecuritizeRedemptionGatewayV311.js"), module.exports);
|
|
23
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
22
|
0 && (module.exports = {
|
|
25
23
|
...require("./iBaseOnRamp.js"),
|
|
26
24
|
...require("./iSecuritizeOnRamp.js"),
|
|
27
|
-
...require("./
|
|
28
|
-
...require("./iSecuritizeRedemptionGateway.js"),
|
|
29
|
-
...require("./iSecuritizeRedemptionGatewayAdapter.js")
|
|
25
|
+
...require("./iSecuritizeRedemptionGatewayV311.js")
|
|
30
26
|
});
|
|
@@ -23,11 +23,11 @@ __export(SecuritizeOnRampAdapterContract_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(SecuritizeOnRampAdapterContract_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_sdk = require("../../../sdk/index.js");
|
|
26
|
+
var import_iSecuritizeOnRampAdapterV310 = require("../abi/adapters/iSecuritizeOnRampAdapterV310.js");
|
|
26
27
|
var import_iBaseOnRamp = require("../abi/securitize/iBaseOnRamp.js");
|
|
27
28
|
var import_iSecuritizeOnRamp = require("../abi/securitize/iSecuritizeOnRamp.js");
|
|
28
|
-
var import_iSecuritizeOnRampAdapter = require("../abi/securitize/iSecuritizeOnRampAdapter.js");
|
|
29
29
|
var import_AbstractAdapter = require("./AbstractAdapter.js");
|
|
30
|
-
const abi =
|
|
30
|
+
const abi = import_iSecuritizeOnRampAdapterV310.iSecuritizeOnRampAdapterV310Abi;
|
|
31
31
|
const protocolAbi = [...import_iSecuritizeOnRamp.iSecuritizeOnRampAbi, ...import_iBaseOnRamp.iBaseOnRampAbi];
|
|
32
32
|
class SecuritizeOnRampAdapterContract extends import_AbstractAdapter.AbstractAdapterContract {
|
|
33
33
|
#dsToken;
|
|
@@ -23,11 +23,11 @@ __export(SecuritizeRedemptionGatewayAdapterContract_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(SecuritizeRedemptionGatewayAdapterContract_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_sdk = require("../../../sdk/index.js");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var import_iSecuritizeRedemptionGatewayAdapterV311 = require("../abi/adapters/iSecuritizeRedemptionGatewayAdapterV311.js");
|
|
27
|
+
var import_iSecuritizeRedemptionGatewayV311 = require("../abi/securitize/iSecuritizeRedemptionGatewayV311.js");
|
|
28
28
|
var import_AbstractAdapter = require("./AbstractAdapter.js");
|
|
29
|
-
const abi =
|
|
30
|
-
const protocolAbi =
|
|
29
|
+
const abi = import_iSecuritizeRedemptionGatewayAdapterV311.iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
30
|
+
const protocolAbi = import_iSecuritizeRedemptionGatewayV311.iSecuritizeRedemptionGatewayV311Abi;
|
|
31
31
|
class SecuritizeRedemptionGatewayAdapterContract extends import_AbstractAdapter.AbstractAdapterContract {
|
|
32
32
|
#dsToken;
|
|
33
33
|
#stableCoinToken;
|
|
@@ -72,6 +72,30 @@ class SecuritizeRedemptionGatewayAdapterContract extends import_AbstractAdapter.
|
|
|
72
72
|
redemptionPhantomToken: this.#redemptionPhantomToken ? this.labelAddress(this.#redemptionPhantomToken) : void 0
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
decodeDiffLeftovers(decoded, balances) {
|
|
76
|
+
switch (decoded.functionName) {
|
|
77
|
+
// exact-input redemption: burns dsTokenAmount of the DS token in
|
|
78
|
+
// exchange for the redemption phantom token (which is credited by the
|
|
79
|
+
// storeExpectedBalances bracket delta, not here)
|
|
80
|
+
case "redeem": {
|
|
81
|
+
const [dsTokenAmount] = decoded.args;
|
|
82
|
+
const balance = balances.get(this.dsToken) ?? 0n;
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
tokenIn: this.dsToken,
|
|
86
|
+
leftoverAmount: balance > dsTokenAmount ? balance - dsTokenAmount : 0n
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
// diff-style redemption: spends the DS token down to the leftover
|
|
91
|
+
case "redeemDiff": {
|
|
92
|
+
const [leftoverAmount] = decoded.args;
|
|
93
|
+
return [{ tokenIn: this.dsToken, leftoverAmount }];
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
return super.decodeDiffLeftovers(decoded, balances);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
75
99
|
}
|
|
76
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
77
101
|
0 && (module.exports = {
|
|
@@ -23,7 +23,7 @@ __export(AbstractWithdrawalCompressorContract_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(AbstractWithdrawalCompressorContract_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_base = require("../../base/index.js");
|
|
26
|
-
var
|
|
26
|
+
var import_intent_codec = require("./intent-codec.js");
|
|
27
27
|
const iCreditAccountAbi = [
|
|
28
28
|
{
|
|
29
29
|
type: "function",
|
|
@@ -156,7 +156,7 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
|
|
|
156
156
|
amount
|
|
157
157
|
]);
|
|
158
158
|
}
|
|
159
|
-
const extraData = (0,
|
|
159
|
+
const extraData = (0, import_intent_codec.encodeDelayedIntent)(intent);
|
|
160
160
|
const creditManager = await this.client.readContract({
|
|
161
161
|
address: creditAccount,
|
|
162
162
|
abi: iCreditAccountAbi,
|
|
@@ -199,7 +199,7 @@ function toWithdrawableAsset(a, creditManager) {
|
|
|
199
199
|
function toClaimableWithdrawal(w, creditManager, decodeIntent) {
|
|
200
200
|
let intent;
|
|
201
201
|
if (decodeIntent && w.extraData && w.extraData !== "0x") {
|
|
202
|
-
intent = { ...(0,
|
|
202
|
+
intent = { ...(0, import_intent_codec.decodeDelayedIntent)(w.extraData), creditManager };
|
|
203
203
|
}
|
|
204
204
|
return {
|
|
205
205
|
token: w.token,
|
|
@@ -18,7 +18,7 @@ module.exports = __toCommonJS(withdrawal_compressor_exports);
|
|
|
18
18
|
__reExport(withdrawal_compressor_exports, require("./AbstractWithdrawalCompressorContract.js"), module.exports);
|
|
19
19
|
__reExport(withdrawal_compressor_exports, require("./addresses.js"), module.exports);
|
|
20
20
|
__reExport(withdrawal_compressor_exports, require("./createWithdrawalCompressor.js"), module.exports);
|
|
21
|
-
__reExport(withdrawal_compressor_exports, require("./intent.js"), module.exports);
|
|
21
|
+
__reExport(withdrawal_compressor_exports, require("./intent-codec.js"), module.exports);
|
|
22
22
|
__reExport(withdrawal_compressor_exports, require("./types.js"), module.exports);
|
|
23
23
|
__reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV310Contract.js"), module.exports);
|
|
24
24
|
__reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV311Contract.js"), module.exports);
|
|
@@ -28,7 +28,7 @@ __reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV313Con
|
|
|
28
28
|
...require("./AbstractWithdrawalCompressorContract.js"),
|
|
29
29
|
...require("./addresses.js"),
|
|
30
30
|
...require("./createWithdrawalCompressor.js"),
|
|
31
|
-
...require("./intent.js"),
|
|
31
|
+
...require("./intent-codec.js"),
|
|
32
32
|
...require("./types.js"),
|
|
33
33
|
...require("./WithdrawalCompressorV310Contract.js"),
|
|
34
34
|
...require("./WithdrawalCompressorV311Contract.js"),
|
|
@@ -16,60 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var intent_codec_exports = {};
|
|
20
|
+
__export(intent_codec_exports, {
|
|
21
21
|
DELAYED_INTENT_TYPES: () => DELAYED_INTENT_TYPES,
|
|
22
22
|
DELAYED_INTENT_VERSION: () => DELAYED_INTENT_VERSION,
|
|
23
23
|
decodeDelayedIntent: () => decodeDelayedIntent,
|
|
24
|
-
delayedAddCollateralIntentSchema: () => delayedAddCollateralIntentSchema,
|
|
25
|
-
delayedCloseAccountIntentSchema: () => delayedCloseAccountIntentSchema,
|
|
26
|
-
delayedDecreaseLeverageIntentSchema: () => delayedDecreaseLeverageIntentSchema,
|
|
27
|
-
delayedDepositAndIncreaseLeverageIntentSchema: () => delayedDepositAndIncreaseLeverageIntentSchema,
|
|
28
|
-
delayedDepositIntentSchema: () => delayedDepositIntentSchema,
|
|
29
|
-
delayedIncreaseLeverageIntentSchema: () => delayedIncreaseLeverageIntentSchema,
|
|
30
|
-
delayedIntentSchema: () => delayedIntentSchema,
|
|
31
|
-
delayedWithdrawCollateralIntentSchema: () => delayedWithdrawCollateralIntentSchema,
|
|
32
24
|
encodeDelayedIntent: () => encodeDelayedIntent
|
|
33
25
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(intent_codec_exports);
|
|
35
27
|
var import_viem = require("viem");
|
|
36
|
-
var import_v4 = require("zod/v4");
|
|
37
|
-
var import_utils = require("../../utils/index.js");
|
|
38
|
-
const delayedIncreaseLeverageIntentSchema = import_v4.z.object({
|
|
39
|
-
type: import_v4.z.literal("INCREASE_LEVERAGE"),
|
|
40
|
-
to: (0, import_utils.ZodAddress)()
|
|
41
|
-
});
|
|
42
|
-
const delayedDepositIntentSchema = import_v4.z.object({
|
|
43
|
-
type: import_v4.z.literal("DEPOSIT")
|
|
44
|
-
});
|
|
45
|
-
const delayedDepositAndIncreaseLeverageIntentSchema = import_v4.z.object({
|
|
46
|
-
type: import_v4.z.literal("DEPOSIT_AND_INCREASE_LEVERAGE")
|
|
47
|
-
});
|
|
48
|
-
const delayedWithdrawCollateralIntentSchema = import_v4.z.object({
|
|
49
|
-
type: import_v4.z.literal("WITHDRAW_COLLATERAL"),
|
|
50
|
-
to: (0, import_utils.ZodAddress)(),
|
|
51
|
-
withdrawToken: (0, import_utils.ZodAddress)(),
|
|
52
|
-
withdrawAmount: import_v4.z.bigint()
|
|
53
|
-
});
|
|
54
|
-
const delayedCloseAccountIntentSchema = import_v4.z.object({
|
|
55
|
-
type: import_v4.z.literal("CLOSE_ACCOUNT"),
|
|
56
|
-
to: (0, import_utils.ZodAddress)()
|
|
57
|
-
});
|
|
58
|
-
const delayedAddCollateralIntentSchema = import_v4.z.object({
|
|
59
|
-
type: import_v4.z.literal("ADD_COLLATERAL")
|
|
60
|
-
});
|
|
61
|
-
const delayedDecreaseLeverageIntentSchema = import_v4.z.object({
|
|
62
|
-
type: import_v4.z.literal("DECREASE_LEVERAGE")
|
|
63
|
-
});
|
|
64
|
-
const delayedIntentSchema = import_v4.z.discriminatedUnion("type", [
|
|
65
|
-
delayedIncreaseLeverageIntentSchema,
|
|
66
|
-
delayedDepositIntentSchema,
|
|
67
|
-
delayedDepositAndIncreaseLeverageIntentSchema,
|
|
68
|
-
delayedWithdrawCollateralIntentSchema,
|
|
69
|
-
delayedCloseAccountIntentSchema,
|
|
70
|
-
delayedAddCollateralIntentSchema,
|
|
71
|
-
delayedDecreaseLeverageIntentSchema
|
|
72
|
-
]);
|
|
73
28
|
const DELAYED_INTENT_VERSION = 1;
|
|
74
29
|
const DELAYED_INTENT_TYPES = {
|
|
75
30
|
INCREASE_LEVERAGE: 1,
|
|
@@ -91,20 +46,19 @@ const WITHDRAW_COLLATERAL_PARAMS = [
|
|
|
91
46
|
{ type: "uint256", name: "withdrawAmount" }
|
|
92
47
|
];
|
|
93
48
|
function encodeDelayedIntent(intent) {
|
|
94
|
-
const parsed = delayedIntentSchema.parse(intent);
|
|
95
49
|
const version = DELAYED_INTENT_VERSION;
|
|
96
|
-
const intentType = DELAYED_INTENT_TYPES[
|
|
97
|
-
switch (
|
|
50
|
+
const intentType = DELAYED_INTENT_TYPES[intent.type];
|
|
51
|
+
switch (intent.type) {
|
|
98
52
|
case "INCREASE_LEVERAGE":
|
|
99
53
|
case "CLOSE_ACCOUNT":
|
|
100
|
-
return (0, import_viem.encodeAbiParameters)(TO_PARAMS, [version, intentType,
|
|
54
|
+
return (0, import_viem.encodeAbiParameters)(TO_PARAMS, [version, intentType, intent.to]);
|
|
101
55
|
case "WITHDRAW_COLLATERAL":
|
|
102
56
|
return (0, import_viem.encodeAbiParameters)(WITHDRAW_COLLATERAL_PARAMS, [
|
|
103
57
|
version,
|
|
104
58
|
intentType,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
59
|
+
intent.to,
|
|
60
|
+
intent.withdrawToken,
|
|
61
|
+
intent.withdrawAmount
|
|
108
62
|
]);
|
|
109
63
|
case "DEPOSIT":
|
|
110
64
|
case "DEPOSIT_AND_INCREASE_LEVERAGE":
|
|
@@ -112,7 +66,7 @@ function encodeDelayedIntent(intent) {
|
|
|
112
66
|
case "DECREASE_LEVERAGE":
|
|
113
67
|
return (0, import_viem.encodeAbiParameters)(HEADER_PARAMS, [version, intentType]);
|
|
114
68
|
default: {
|
|
115
|
-
const t =
|
|
69
|
+
const t = intent;
|
|
116
70
|
throw new Error(`unknown delayed intent: ${JSON.stringify(t)}`);
|
|
117
71
|
}
|
|
118
72
|
}
|
|
@@ -125,7 +79,7 @@ function decodeDelayedIntent(data) {
|
|
|
125
79
|
switch (intentType) {
|
|
126
80
|
case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE: {
|
|
127
81
|
const [, , to] = (0, import_viem.decodeAbiParameters)(TO_PARAMS, data);
|
|
128
|
-
return
|
|
82
|
+
return { type: "INCREASE_LEVERAGE", to };
|
|
129
83
|
}
|
|
130
84
|
case DELAYED_INTENT_TYPES.DEPOSIT:
|
|
131
85
|
return { type: "DEPOSIT" };
|
|
@@ -136,16 +90,16 @@ function decodeDelayedIntent(data) {
|
|
|
136
90
|
WITHDRAW_COLLATERAL_PARAMS,
|
|
137
91
|
data
|
|
138
92
|
);
|
|
139
|
-
return
|
|
93
|
+
return {
|
|
140
94
|
type: "WITHDRAW_COLLATERAL",
|
|
141
95
|
to,
|
|
142
96
|
withdrawToken,
|
|
143
97
|
withdrawAmount
|
|
144
|
-
}
|
|
98
|
+
};
|
|
145
99
|
}
|
|
146
100
|
case DELAYED_INTENT_TYPES.CLOSE_ACCOUNT: {
|
|
147
101
|
const [, , to] = (0, import_viem.decodeAbiParameters)(TO_PARAMS, data);
|
|
148
|
-
return
|
|
102
|
+
return { type: "CLOSE_ACCOUNT", to };
|
|
149
103
|
}
|
|
150
104
|
case DELAYED_INTENT_TYPES.ADD_COLLATERAL:
|
|
151
105
|
return { type: "ADD_COLLATERAL" };
|
|
@@ -160,13 +114,5 @@ function decodeDelayedIntent(data) {
|
|
|
160
114
|
DELAYED_INTENT_TYPES,
|
|
161
115
|
DELAYED_INTENT_VERSION,
|
|
162
116
|
decodeDelayedIntent,
|
|
163
|
-
delayedAddCollateralIntentSchema,
|
|
164
|
-
delayedCloseAccountIntentSchema,
|
|
165
|
-
delayedDecreaseLeverageIntentSchema,
|
|
166
|
-
delayedDepositAndIncreaseLeverageIntentSchema,
|
|
167
|
-
delayedDepositIntentSchema,
|
|
168
|
-
delayedIncreaseLeverageIntentSchema,
|
|
169
|
-
delayedIntentSchema,
|
|
170
|
-
delayedWithdrawCollateralIntentSchema,
|
|
171
117
|
encodeDelayedIntent
|
|
172
118
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const iSecuritizeOnRampAdapterV310Abi = [
|
|
2
2
|
{
|
|
3
3
|
type: "function",
|
|
4
4
|
name: "contractType",
|
|
@@ -70,5 +70,5 @@ const iSecuritizeOnRampAdapterAbi = [
|
|
|
70
70
|
}
|
|
71
71
|
];
|
|
72
72
|
export {
|
|
73
|
-
|
|
73
|
+
iSecuritizeOnRampAdapterV310Abi
|
|
74
74
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const iSecuritizeRedemptionGatewayAdapterV311Abi = [
|
|
2
2
|
{
|
|
3
3
|
type: "function",
|
|
4
4
|
name: "claim",
|
|
@@ -48,6 +48,26 @@ const iSecuritizeRedemptionGatewayAdapterAbi = [
|
|
|
48
48
|
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
49
49
|
stateMutability: "nonpayable"
|
|
50
50
|
},
|
|
51
|
+
{
|
|
52
|
+
type: "function",
|
|
53
|
+
name: "redeem",
|
|
54
|
+
inputs: [
|
|
55
|
+
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" },
|
|
56
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
57
|
+
],
|
|
58
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
59
|
+
stateMutability: "nonpayable"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "function",
|
|
63
|
+
name: "redeemDiff",
|
|
64
|
+
inputs: [
|
|
65
|
+
{ name: "leftoverAmount", type: "uint256", internalType: "uint256" },
|
|
66
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
67
|
+
],
|
|
68
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
69
|
+
stateMutability: "nonpayable"
|
|
70
|
+
},
|
|
51
71
|
{
|
|
52
72
|
type: "function",
|
|
53
73
|
name: "redeemDiff",
|
|
@@ -116,5 +136,5 @@ const iSecuritizeRedemptionGatewayAdapterAbi = [
|
|
|
116
136
|
{ type: "error", name: "InvalidRedemptionGatewayException", inputs: [] }
|
|
117
137
|
];
|
|
118
138
|
export {
|
|
119
|
-
|
|
139
|
+
iSecuritizeRedemptionGatewayAdapterV311Abi
|
|
120
140
|
};
|
|
@@ -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
|
-
const
|
|
1
|
+
const iSecuritizeRedemptionGatewayV311Abi = [
|
|
2
2
|
{
|
|
3
3
|
type: "function",
|
|
4
4
|
name: "claim",
|
|
@@ -61,7 +61,8 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
61
61
|
type: "function",
|
|
62
62
|
name: "redeem",
|
|
63
63
|
inputs: [
|
|
64
|
-
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" }
|
|
64
|
+
{ name: "dsTokenAmount", type: "uint256", internalType: "uint256" },
|
|
65
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
65
66
|
],
|
|
66
67
|
outputs: [],
|
|
67
68
|
stateMutability: "nonpayable"
|
|
@@ -73,6 +74,13 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
73
74
|
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
74
75
|
stateMutability: "view"
|
|
75
76
|
},
|
|
77
|
+
{
|
|
78
|
+
type: "function",
|
|
79
|
+
name: "redemptionLogger",
|
|
80
|
+
inputs: [],
|
|
81
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
82
|
+
stateMutability: "view"
|
|
83
|
+
},
|
|
76
84
|
{
|
|
77
85
|
type: "function",
|
|
78
86
|
name: "securitizeWhitelister",
|
|
@@ -121,5 +129,5 @@ const iSecuritizeRedemptionGatewayAbi = [
|
|
|
121
129
|
{ type: "error", name: "RedeemerTransferNotAllowedException", inputs: [] }
|
|
122
130
|
];
|
|
123
131
|
export {
|
|
124
|
-
|
|
132
|
+
iSecuritizeRedemptionGatewayV311Abi
|
|
125
133
|
};
|
|
@@ -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";
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
MissingSerializedParamsError
|
|
6
6
|
} from "../../../sdk/index.js";
|
|
7
|
+
import { iSecuritizeOnRampAdapterV310Abi } from "../abi/adapters/iSecuritizeOnRampAdapterV310.js";
|
|
7
8
|
import { iBaseOnRampAbi } from "../abi/securitize/iBaseOnRamp.js";
|
|
8
9
|
import { iSecuritizeOnRampAbi } from "../abi/securitize/iSecuritizeOnRamp.js";
|
|
9
|
-
import { iSecuritizeOnRampAdapterAbi } from "../abi/securitize/iSecuritizeOnRampAdapter.js";
|
|
10
10
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
11
|
-
const abi =
|
|
11
|
+
const abi = iSecuritizeOnRampAdapterV310Abi;
|
|
12
12
|
const protocolAbi = [...iSecuritizeOnRampAbi, ...iBaseOnRampAbi];
|
|
13
13
|
class SecuritizeOnRampAdapterContract extends AbstractAdapterContract {
|
|
14
14
|
#dsToken;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
decodeAbiParameters
|
|
3
|
+
} from "viem";
|
|
2
4
|
import {
|
|
3
5
|
MissingSerializedParamsError
|
|
4
6
|
} from "../../../sdk/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { iSecuritizeRedemptionGatewayAdapterV311Abi } from "../abi/adapters/iSecuritizeRedemptionGatewayAdapterV311.js";
|
|
8
|
+
import { iSecuritizeRedemptionGatewayV311Abi } from "../abi/securitize/iSecuritizeRedemptionGatewayV311.js";
|
|
7
9
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
8
|
-
const abi =
|
|
9
|
-
const protocolAbi =
|
|
10
|
+
const abi = iSecuritizeRedemptionGatewayAdapterV311Abi;
|
|
11
|
+
const protocolAbi = iSecuritizeRedemptionGatewayV311Abi;
|
|
10
12
|
class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract {
|
|
11
13
|
#dsToken;
|
|
12
14
|
#stableCoinToken;
|
|
@@ -51,6 +53,30 @@ class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract
|
|
|
51
53
|
redemptionPhantomToken: this.#redemptionPhantomToken ? this.labelAddress(this.#redemptionPhantomToken) : void 0
|
|
52
54
|
};
|
|
53
55
|
}
|
|
56
|
+
decodeDiffLeftovers(decoded, balances) {
|
|
57
|
+
switch (decoded.functionName) {
|
|
58
|
+
// exact-input redemption: burns dsTokenAmount of the DS token in
|
|
59
|
+
// exchange for the redemption phantom token (which is credited by the
|
|
60
|
+
// storeExpectedBalances bracket delta, not here)
|
|
61
|
+
case "redeem": {
|
|
62
|
+
const [dsTokenAmount] = decoded.args;
|
|
63
|
+
const balance = balances.get(this.dsToken) ?? 0n;
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
tokenIn: this.dsToken,
|
|
67
|
+
leftoverAmount: balance > dsTokenAmount ? balance - dsTokenAmount : 0n
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
// diff-style redemption: spends the DS token down to the leftover
|
|
72
|
+
case "redeemDiff": {
|
|
73
|
+
const [leftoverAmount] = decoded.args;
|
|
74
|
+
return [{ tokenIn: this.dsToken, leftoverAmount }];
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
return super.decodeDiffLeftovers(decoded, balances);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
54
80
|
}
|
|
55
81
|
export {
|
|
56
82
|
SecuritizeRedemptionGatewayAdapterContract
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isAddressEqual } from "viem";
|
|
2
2
|
import { BaseContract } from "../../base/index.js";
|
|
3
|
-
import { decodeDelayedIntent, encodeDelayedIntent } from "./intent.js";
|
|
3
|
+
import { decodeDelayedIntent, encodeDelayedIntent } from "./intent-codec.js";
|
|
4
4
|
const iCreditAccountAbi = [
|
|
5
5
|
{
|
|
6
6
|
type: "function",
|
|
@@ -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";
|