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