@gearbox-protocol/sdk 14.11.13 → 14.11.15

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.
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var liquidationCompressor_exports = {};
20
+ __export(liquidationCompressor_exports, {
21
+ liquidationCompressorAbi: () => liquidationCompressorAbi
22
+ });
23
+ module.exports = __toCommonJS(liquidationCompressor_exports);
24
+ const liquidationCompressorAbi = [
25
+ {
26
+ type: "constructor",
27
+ inputs: [
28
+ { name: "_owner", type: "address", internalType: "address" },
29
+ { name: "addressProvider_", type: "address", internalType: "address" }
30
+ ],
31
+ stateMutability: "nonpayable"
32
+ },
33
+ {
34
+ type: "function",
35
+ name: "addressProvider",
36
+ inputs: [],
37
+ outputs: [{ name: "", type: "address", internalType: "address" }],
38
+ stateMutability: "view"
39
+ },
40
+ {
41
+ type: "function",
42
+ name: "compressorTypeToCompressor",
43
+ inputs: [
44
+ { name: "", type: "bytes32", internalType: "bytes32" },
45
+ { name: "", type: "uint256", internalType: "uint256" }
46
+ ],
47
+ outputs: [{ name: "", type: "address", internalType: "address" }],
48
+ stateMutability: "view"
49
+ },
50
+ {
51
+ type: "function",
52
+ name: "contractType",
53
+ inputs: [],
54
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
55
+ stateMutability: "view"
56
+ },
57
+ {
58
+ type: "function",
59
+ name: "getLiquidationData",
60
+ inputs: [
61
+ { name: "liquidator", type: "address", internalType: "address" },
62
+ { name: "creditAccount", type: "address", internalType: "address" },
63
+ {
64
+ name: "priceUpdates",
65
+ type: "tuple[]",
66
+ internalType: "struct PriceUpdate[]",
67
+ components: [
68
+ { name: "priceFeed", type: "address", internalType: "address" },
69
+ { name: "data", type: "bytes", internalType: "bytes" }
70
+ ]
71
+ }
72
+ ],
73
+ outputs: [
74
+ {
75
+ name: "",
76
+ type: "tuple",
77
+ internalType: "struct LiquidationData",
78
+ components: [
79
+ {
80
+ name: "requiredUnderlyingAmount",
81
+ type: "uint256",
82
+ internalType: "uint256"
83
+ },
84
+ {
85
+ name: "expectedOutputs",
86
+ type: "tuple[]",
87
+ internalType: "struct LiquidationOutput[]",
88
+ components: [
89
+ { name: "token", type: "address", internalType: "address" },
90
+ { name: "amount", type: "uint256", internalType: "uint256" },
91
+ { name: "delayed", type: "bool", internalType: "bool" },
92
+ {
93
+ name: "redeemerAddress",
94
+ type: "address",
95
+ internalType: "address"
96
+ },
97
+ { name: "claimableAt", type: "uint256", internalType: "uint256" }
98
+ ]
99
+ },
100
+ {
101
+ name: "liquidationCall",
102
+ type: "tuple",
103
+ internalType: "struct MultiCall",
104
+ components: [
105
+ { name: "target", type: "address", internalType: "address" },
106
+ { name: "callData", type: "bytes", internalType: "bytes" }
107
+ ]
108
+ },
109
+ { name: "isLiquidatorEligible", type: "bool", internalType: "bool" },
110
+ { name: "kycProtocol", type: "string", internalType: "string" },
111
+ { name: "kycToken", type: "address", internalType: "address" }
112
+ ]
113
+ }
114
+ ],
115
+ stateMutability: "nonpayable"
116
+ },
117
+ {
118
+ type: "function",
119
+ name: "liquidatableTypeToCompressorType",
120
+ inputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
121
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
122
+ stateMutability: "view"
123
+ },
124
+ {
125
+ type: "function",
126
+ name: "liquidatableTypeToSpecificCompressorVersion",
127
+ inputs: [
128
+ { name: "", type: "bytes32", internalType: "bytes32" },
129
+ { name: "", type: "uint256", internalType: "uint256" }
130
+ ],
131
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
132
+ stateMutability: "view"
133
+ },
134
+ {
135
+ type: "function",
136
+ name: "owner",
137
+ inputs: [],
138
+ outputs: [{ name: "", type: "address", internalType: "address" }],
139
+ stateMutability: "view"
140
+ },
141
+ {
142
+ type: "function",
143
+ name: "renounceOwnership",
144
+ inputs: [],
145
+ outputs: [],
146
+ stateMutability: "nonpayable"
147
+ },
148
+ {
149
+ type: "function",
150
+ name: "setLiquidatableTypeToCompressorType",
151
+ inputs: [
152
+ { name: "liquidatableType", type: "bytes32", internalType: "bytes32" },
153
+ { name: "compressorType", type: "bytes32", internalType: "bytes32" }
154
+ ],
155
+ outputs: [],
156
+ stateMutability: "nonpayable"
157
+ },
158
+ {
159
+ type: "function",
160
+ name: "setLiquidatableVersionToSpecificCompressorVersion",
161
+ inputs: [
162
+ { name: "liquidatableType", type: "bytes32", internalType: "bytes32" },
163
+ { name: "liquidatableVersion", type: "uint256", internalType: "uint256" },
164
+ { name: "compressorVersion", type: "uint256", internalType: "uint256" }
165
+ ],
166
+ outputs: [],
167
+ stateMutability: "nonpayable"
168
+ },
169
+ {
170
+ type: "function",
171
+ name: "setSubcompressor",
172
+ inputs: [
173
+ { name: "subcompressor", type: "address", internalType: "address" }
174
+ ],
175
+ outputs: [],
176
+ stateMutability: "nonpayable"
177
+ },
178
+ {
179
+ type: "function",
180
+ name: "transferOwnership",
181
+ inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
182
+ outputs: [],
183
+ stateMutability: "nonpayable"
184
+ },
185
+ {
186
+ type: "function",
187
+ name: "version",
188
+ inputs: [],
189
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
190
+ stateMutability: "view"
191
+ },
192
+ {
193
+ type: "event",
194
+ name: "OwnershipTransferred",
195
+ inputs: [
196
+ {
197
+ name: "previousOwner",
198
+ type: "address",
199
+ indexed: true,
200
+ internalType: "address"
201
+ },
202
+ {
203
+ name: "newOwner",
204
+ type: "address",
205
+ indexed: true,
206
+ internalType: "address"
207
+ }
208
+ ],
209
+ anonymous: false
210
+ }
211
+ ];
212
+ // Annotate the CommonJS export names for ESM import in node:
213
+ 0 && (module.exports = {
214
+ liquidationCompressorAbi
215
+ });
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var midasLiquidationSubcompressor_exports = {};
20
+ __export(midasLiquidationSubcompressor_exports, {
21
+ midasLiquidationSubcompressorAbi: () => midasLiquidationSubcompressorAbi
22
+ });
23
+ module.exports = __toCommonJS(midasLiquidationSubcompressor_exports);
24
+ const midasLiquidationSubcompressorAbi = [
25
+ {
26
+ type: "function",
27
+ name: "contractType",
28
+ inputs: [],
29
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
30
+ stateMutability: "view"
31
+ },
32
+ {
33
+ type: "function",
34
+ name: "getLiquidationData",
35
+ inputs: [
36
+ { name: "liquidator", type: "address", internalType: "address" },
37
+ { name: "creditAccount", type: "address", internalType: "address" },
38
+ { name: "phantomToken", type: "address", internalType: "address" },
39
+ {
40
+ name: "priceUpdates",
41
+ type: "tuple[]",
42
+ internalType: "struct PriceUpdate[]",
43
+ components: [
44
+ { name: "priceFeed", type: "address", internalType: "address" },
45
+ { name: "data", type: "bytes", internalType: "bytes" }
46
+ ]
47
+ }
48
+ ],
49
+ outputs: [
50
+ {
51
+ name: "data",
52
+ type: "tuple",
53
+ internalType: "struct LiquidationData",
54
+ components: [
55
+ {
56
+ name: "requiredUnderlyingAmount",
57
+ type: "uint256",
58
+ internalType: "uint256"
59
+ },
60
+ {
61
+ name: "expectedOutputs",
62
+ type: "tuple[]",
63
+ internalType: "struct LiquidationOutput[]",
64
+ components: [
65
+ { name: "token", type: "address", internalType: "address" },
66
+ { name: "amount", type: "uint256", internalType: "uint256" },
67
+ { name: "delayed", type: "bool", internalType: "bool" },
68
+ {
69
+ name: "redeemerAddress",
70
+ type: "address",
71
+ internalType: "address"
72
+ },
73
+ { name: "claimableAt", type: "uint256", internalType: "uint256" }
74
+ ]
75
+ },
76
+ {
77
+ name: "liquidationCall",
78
+ type: "tuple",
79
+ internalType: "struct MultiCall",
80
+ components: [
81
+ { name: "target", type: "address", internalType: "address" },
82
+ { name: "callData", type: "bytes", internalType: "bytes" }
83
+ ]
84
+ },
85
+ { name: "isLiquidatorEligible", type: "bool", internalType: "bool" },
86
+ { name: "kycProtocol", type: "string", internalType: "string" },
87
+ { name: "kycToken", type: "address", internalType: "address" }
88
+ ]
89
+ }
90
+ ],
91
+ stateMutability: "nonpayable"
92
+ },
93
+ {
94
+ type: "function",
95
+ name: "version",
96
+ inputs: [],
97
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
98
+ stateMutability: "view"
99
+ }
100
+ ];
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ midasLiquidationSubcompressorAbi
104
+ });
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var securitizeLiquidationSubcompressor_exports = {};
20
+ __export(securitizeLiquidationSubcompressor_exports, {
21
+ securitizeLiquidationSubcompressorAbi: () => securitizeLiquidationSubcompressorAbi
22
+ });
23
+ module.exports = __toCommonJS(securitizeLiquidationSubcompressor_exports);
24
+ const securitizeLiquidationSubcompressorAbi = [
25
+ {
26
+ type: "function",
27
+ name: "contractType",
28
+ inputs: [],
29
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
30
+ stateMutability: "view"
31
+ },
32
+ {
33
+ type: "function",
34
+ name: "getLiquidationData",
35
+ inputs: [
36
+ { name: "liquidator", type: "address", internalType: "address" },
37
+ { name: "creditAccount", type: "address", internalType: "address" },
38
+ { name: "phantomToken", type: "address", internalType: "address" },
39
+ {
40
+ name: "priceUpdates",
41
+ type: "tuple[]",
42
+ internalType: "struct PriceUpdate[]",
43
+ components: [
44
+ { name: "priceFeed", type: "address", internalType: "address" },
45
+ { name: "data", type: "bytes", internalType: "bytes" }
46
+ ]
47
+ }
48
+ ],
49
+ outputs: [
50
+ {
51
+ name: "data",
52
+ type: "tuple",
53
+ internalType: "struct LiquidationData",
54
+ components: [
55
+ {
56
+ name: "requiredUnderlyingAmount",
57
+ type: "uint256",
58
+ internalType: "uint256"
59
+ },
60
+ {
61
+ name: "expectedOutputs",
62
+ type: "tuple[]",
63
+ internalType: "struct LiquidationOutput[]",
64
+ components: [
65
+ { name: "token", type: "address", internalType: "address" },
66
+ { name: "amount", type: "uint256", internalType: "uint256" },
67
+ { name: "delayed", type: "bool", internalType: "bool" },
68
+ {
69
+ name: "redeemerAddress",
70
+ type: "address",
71
+ internalType: "address"
72
+ },
73
+ { name: "claimableAt", type: "uint256", internalType: "uint256" }
74
+ ]
75
+ },
76
+ {
77
+ name: "liquidationCall",
78
+ type: "tuple",
79
+ internalType: "struct MultiCall",
80
+ components: [
81
+ { name: "target", type: "address", internalType: "address" },
82
+ { name: "callData", type: "bytes", internalType: "bytes" }
83
+ ]
84
+ },
85
+ { name: "isLiquidatorEligible", type: "bool", internalType: "bool" },
86
+ { name: "kycProtocol", type: "string", internalType: "string" },
87
+ { name: "kycToken", type: "address", internalType: "address" }
88
+ ]
89
+ }
90
+ ],
91
+ stateMutability: "nonpayable"
92
+ },
93
+ {
94
+ type: "function",
95
+ name: "version",
96
+ inputs: [],
97
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
98
+ stateMutability: "view"
99
+ }
100
+ ];
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ securitizeLiquidationSubcompressorAbi
104
+ });
@@ -64,10 +64,12 @@ const adapterActionSignatures = {
64
64
  310: "function setVaultStatusBatch((address,bool)[])"
65
65
  },
66
66
  [import_types.AdapterType.MIDAS_ISSUANCE_VAULT]: {
67
- 310: "function setTokenAllowedStatusBatch(address[],bool[])"
67
+ 310: "function setTokenAllowedStatusBatch(address[],bool[])",
68
+ 311: "function setInputTokenStatusBatch(address[],bool[])"
68
69
  },
69
70
  [import_types.AdapterType.MIDAS_REDEMPTION_VAULT]: {
70
- 310: "function setTokenAllowedStatusBatch((address,address,bool)[])"
71
+ 310: "function setTokenAllowedStatusBatch((address,address,bool)[])",
72
+ 311: "function setOutputTokenStatusBatch(address[],bool[])"
71
73
  },
72
74
  [import_types.AdapterType.PENDLE_ROUTER]: {
73
75
  310: "function setPairStatusBatch((address,address,address,uint8)[])",
@@ -63,7 +63,8 @@ const adapterConstructorAbi = {
63
63
  310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI
64
64
  },
65
65
  [import_types.AdapterType.MIDAS_REDEMPTION_VAULT]: {
66
- 310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI
66
+ 310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI,
67
+ 311: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI
67
68
  },
68
69
  [import_types.AdapterType.PENDLE_ROUTER]: {
69
70
  310: import_conctructorAbiPatterns.BASIC_ADAPTER_ABI,
@@ -193,7 +194,8 @@ const adapterConstructorAbi = {
193
194
  312: import_conctructorAbiPatterns.STAKING_REWARDS_ADAPTER_ABI
194
195
  },
195
196
  [import_types.AdapterType.MIDAS_ISSUANCE_VAULT]: {
196
- 310: import_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI
197
+ 310: import_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI,
198
+ 311: import_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI
197
199
  },
198
200
  [import_types.AdapterType.MIDAS_GATEWAY]: {
199
201
  311: import_conctructorAbiPatterns.REFERER_ID_ADAPTER_ABI
@@ -28,32 +28,51 @@ var import_AbstractAdapter = require("./AbstractAdapter.js");
28
28
  const abi = import_integrations_v3.iMidasRedemptionVaultAdapterAbi;
29
29
  const protocolAbi = import_integrations_v3.iMidasRedemptionVaultGatewayAbi;
30
30
  class MidasRedemptionVaultAdapterContract extends import_AbstractAdapter.AbstractAdapterContract {
31
+ #version;
31
32
  #gateway;
32
33
  #mToken;
33
34
  #allowedTokens;
34
35
  constructor(options, args) {
35
36
  super(options, { ...args, abi, protocolAbi });
36
37
  if (args.baseParams.serializedParams) {
37
- const decoded = (0, import_viem.decodeAbiParameters)(
38
- [
39
- { type: "address", name: "creditManager" },
40
- { type: "address", name: "targetContract" },
41
- { type: "address", name: "gateway" },
42
- { type: "address", name: "mToken" },
43
- { type: "address[]", name: "allowedTokens" },
44
- { type: "address[]", name: "allowedPhantomTokens" }
45
- ],
46
- args.baseParams.serializedParams
47
- );
48
- this.#gateway = decoded[2];
49
- this.#mToken = decoded[3];
50
- this.#allowedTokens = decoded[4].map((token, index) => ({
51
- token,
52
- phantomToken: decoded[5][index]
53
- }));
38
+ const version = Number(args.baseParams.version);
39
+ this.#version = version;
40
+ if (version <= 310) {
41
+ const decoded = (0, import_viem.decodeAbiParameters)(
42
+ [
43
+ { type: "address", name: "creditManager" },
44
+ { type: "address", name: "targetContract" },
45
+ { type: "address", name: "gateway" },
46
+ { type: "address", name: "mToken" },
47
+ { type: "address[]", name: "allowedTokens" },
48
+ { type: "address[]", name: "allowedPhantomTokens" }
49
+ ],
50
+ args.baseParams.serializedParams
51
+ );
52
+ this.#gateway = decoded[2];
53
+ this.#mToken = decoded[3];
54
+ this.#allowedTokens = decoded[4].map((token, index) => ({
55
+ token,
56
+ phantomToken: decoded[5][index]
57
+ }));
58
+ } else {
59
+ const decoded = (0, import_viem.decodeAbiParameters)(
60
+ [
61
+ { type: "address", name: "creditManager" },
62
+ { type: "address", name: "targetContract" },
63
+ { type: "address", name: "mToken" },
64
+ { type: "address[]", name: "supportedInputTokens" }
65
+ ],
66
+ args.baseParams.serializedParams
67
+ );
68
+ this.#mToken = decoded[2];
69
+ this.#allowedTokens = [...decoded[3]];
70
+ }
54
71
  }
55
72
  }
56
73
  get gateway() {
74
+ if (!this.#version) throw new import_sdk.MissingSerializedParamsError("version");
75
+ if (this.#version > 310) return void 0;
57
76
  if (!this.#gateway) throw new import_sdk.MissingSerializedParamsError("gateway");
58
77
  return this.#gateway;
59
78
  }
@@ -71,10 +90,17 @@ class MidasRedemptionVaultAdapterContract extends import_AbstractAdapter.Abstrac
71
90
  ...super.stateHuman(raw),
72
91
  gateway: this.#gateway ? this.labelAddress(this.#gateway) : void 0,
73
92
  mToken: this.#mToken ? this.labelAddress(this.#mToken) : void 0,
74
- allowedTokens: this.#allowedTokens?.map((t) => ({
75
- token: this.labelAddress(t.token),
76
- phantomToken: this.labelAddress(t.phantomToken)
77
- }))
93
+ allowedTokens: this.#allowedTokens?.map((t) => {
94
+ if (typeof t === "object") {
95
+ return {
96
+ token: this.labelAddress(t.token),
97
+ phantomToken: this.labelAddress(t.phantomToken)
98
+ };
99
+ }
100
+ return {
101
+ token: this.labelAddress(t)
102
+ };
103
+ })
78
104
  };
79
105
  }
80
106
  }