@gearbox-protocol/sdk 13.1.0 → 13.2.0-next.1

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.
Files changed (96) hide show
  1. package/dist/cjs/abi/310/iSecuritizeDegenNFT.js +263 -0
  2. package/dist/cjs/abi/310/iSecuritizeKYCFactory.js +278 -0
  3. package/dist/cjs/{sdk/pools/PoolServiceV310.js → abi/iStateSerializer.js} +14 -8
  4. package/dist/cjs/dev/AccountOpener.js +45 -5
  5. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +462 -104
  6. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +16 -5
  7. package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -1
  8. package/dist/cjs/sdk/base/TokensMeta.js +255 -32
  9. package/dist/cjs/sdk/base/index.js +2 -0
  10. package/dist/cjs/sdk/{constants/phantom-tokens.js → base/token-types.js} +9 -3
  11. package/dist/cjs/sdk/chain/chains.js +2 -1
  12. package/dist/cjs/sdk/constants/index.js +0 -2
  13. package/dist/cjs/sdk/market/MarketRegister.js +2 -2
  14. package/dist/cjs/sdk/market/MarketSuite.js +6 -0
  15. package/dist/cjs/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +110 -6
  16. package/dist/cjs/sdk/market/index.js +3 -1
  17. package/dist/cjs/sdk/market/pool/PoolSuite.js +3 -0
  18. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +17 -2
  19. package/dist/cjs/sdk/market/pool/SecuritizeKYCFactory.js +97 -0
  20. package/dist/cjs/sdk/market/pool/index.js +4 -0
  21. package/dist/cjs/sdk/pools/PoolService.js +391 -0
  22. package/dist/cjs/sdk/pools/index.js +2 -4
  23. package/dist/cjs/sdk/utils/AddressMap.js +1 -1
  24. package/dist/cjs/sdk/utils/viem/sendRawTx.js +16 -0
  25. package/dist/esm/abi/310/iSecuritizeDegenNFT.js +239 -0
  26. package/dist/esm/abi/310/iSecuritizeKYCFactory.js +254 -0
  27. package/dist/esm/abi/iStateSerializer.js +12 -0
  28. package/dist/esm/dev/AccountOpener.js +47 -6
  29. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +462 -104
  30. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +16 -5
  31. package/dist/esm/sdk/base/ChainContractsRegister.js +1 -1
  32. package/dist/esm/sdk/base/TokensMeta.js +261 -32
  33. package/dist/esm/sdk/base/index.js +1 -0
  34. package/dist/esm/sdk/{constants/phantom-tokens.js → base/token-types.js} +4 -0
  35. package/dist/esm/sdk/chain/chains.js +2 -1
  36. package/dist/esm/sdk/constants/index.js +0 -1
  37. package/dist/esm/sdk/market/MarketRegister.js +2 -2
  38. package/dist/esm/sdk/market/MarketSuite.js +6 -0
  39. package/dist/esm/{plugins/zappers/extraZappers.js → sdk/market/ZapperRegister.js} +109 -2
  40. package/dist/esm/sdk/market/index.js +1 -0
  41. package/dist/esm/sdk/market/pool/PoolSuite.js +3 -0
  42. package/dist/esm/sdk/market/pool/PoolV310Contract.js +17 -2
  43. package/dist/esm/sdk/market/pool/SecuritizeKYCFactory.js +73 -0
  44. package/dist/esm/sdk/market/pool/index.js +2 -0
  45. package/dist/esm/sdk/pools/PoolService.js +371 -0
  46. package/dist/esm/sdk/pools/index.js +1 -2
  47. package/dist/esm/sdk/utils/AddressMap.js +1 -1
  48. package/dist/esm/sdk/utils/viem/sendRawTx.js +19 -1
  49. package/dist/types/abi/310/iSecuritizeDegenNFT.d.ts +324 -0
  50. package/dist/types/abi/310/iSecuritizeKYCFactory.d.ts +322 -0
  51. package/dist/types/abi/iStateSerializer.d.ts +11 -0
  52. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +123 -27
  53. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  54. package/dist/types/sdk/accounts/types.d.ts +108 -8
  55. package/dist/types/sdk/base/TokensMeta.d.ts +34 -18
  56. package/dist/types/sdk/base/index.d.ts +1 -0
  57. package/dist/types/sdk/base/token-types.d.ts +33 -0
  58. package/dist/types/sdk/base/types.d.ts +0 -1
  59. package/dist/types/sdk/chain/chains.d.ts +1 -1
  60. package/dist/types/sdk/constants/index.d.ts +0 -1
  61. package/dist/types/sdk/market/MarketRegister.d.ts +2 -2
  62. package/dist/types/sdk/market/MarketSuite.d.ts +3 -0
  63. package/dist/types/sdk/market/ZapperRegister.d.ts +17 -0
  64. package/dist/types/sdk/market/index.d.ts +1 -0
  65. package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -0
  66. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +6 -2
  67. package/dist/types/sdk/market/pool/SecuritizeKYCFactory.d.ts +345 -0
  68. package/dist/types/sdk/market/pool/index.d.ts +2 -0
  69. package/dist/types/sdk/market/types.d.ts +10 -0
  70. package/dist/types/sdk/pools/PoolService.d.ts +14 -0
  71. package/dist/types/sdk/pools/index.d.ts +1 -2
  72. package/dist/types/sdk/pools/types.d.ts +84 -63
  73. package/dist/types/sdk/utils/AddressMap.d.ts +1 -1
  74. package/dist/types/sdk/utils/viem/sendRawTx.d.ts +5 -1
  75. package/package.json +1 -1
  76. package/dist/cjs/plugins/zappers/ZappersPlugin.js +0 -144
  77. package/dist/cjs/plugins/zappers/index.js +0 -26
  78. package/dist/cjs/plugins/zappers/package.json +0 -1
  79. package/dist/cjs/sdk/pools/AbstractPoolService.js +0 -137
  80. package/dist/cjs/sdk/pools/createPoolService.js +0 -35
  81. package/dist/esm/plugins/zappers/ZappersPlugin.js +0 -126
  82. package/dist/esm/plugins/zappers/index.js +0 -3
  83. package/dist/esm/plugins/zappers/package.json +0 -1
  84. package/dist/esm/sdk/pools/AbstractPoolService.js +0 -113
  85. package/dist/esm/sdk/pools/PoolServiceV310.js +0 -6
  86. package/dist/esm/sdk/pools/createPoolService.js +0 -11
  87. package/dist/types/plugins/zappers/ZappersPlugin.d.ts +0 -18
  88. package/dist/types/plugins/zappers/extraZappers.d.ts +0 -6
  89. package/dist/types/plugins/zappers/index.d.ts +0 -3
  90. package/dist/types/plugins/zappers/types.d.ts +0 -12
  91. package/dist/types/sdk/constants/phantom-tokens.d.ts +0 -2
  92. package/dist/types/sdk/pools/AbstractPoolService.d.ts +0 -9
  93. package/dist/types/sdk/pools/PoolServiceV310.d.ts +0 -4
  94. package/dist/types/sdk/pools/createPoolService.d.ts +0 -3
  95. /package/dist/cjs/{plugins/zappers → sdk/market}/types.js +0 -0
  96. /package/dist/esm/{plugins/zappers → sdk/market}/types.js +0 -0
@@ -0,0 +1,239 @@
1
+ const iSecuritizeDegenNFTAbi = [
2
+ {
3
+ type: "function",
4
+ name: "addRegistrar",
5
+ inputs: [{ name: "registrar", type: "address", internalType: "address" }],
6
+ outputs: [],
7
+ stateMutability: "nonpayable"
8
+ },
9
+ {
10
+ type: "function",
11
+ name: "burn",
12
+ inputs: [
13
+ { name: "wallet", type: "address", internalType: "address" },
14
+ { name: "", type: "uint256", internalType: "uint256" }
15
+ ],
16
+ outputs: [],
17
+ stateMutability: "nonpayable"
18
+ },
19
+ {
20
+ type: "function",
21
+ name: "contractType",
22
+ inputs: [],
23
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
24
+ stateMutability: "view"
25
+ },
26
+ {
27
+ type: "function",
28
+ name: "getDSTokens",
29
+ inputs: [],
30
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
31
+ stateMutability: "view"
32
+ },
33
+ {
34
+ type: "function",
35
+ name: "getFactory",
36
+ inputs: [],
37
+ outputs: [{ name: "", type: "address", internalType: "address" }],
38
+ stateMutability: "view"
39
+ },
40
+ {
41
+ type: "function",
42
+ name: "getOperators",
43
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
44
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
45
+ stateMutability: "view"
46
+ },
47
+ {
48
+ type: "function",
49
+ name: "getRegisteredTokens",
50
+ inputs: [
51
+ { name: "creditAccount", type: "address", internalType: "address" }
52
+ ],
53
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
54
+ stateMutability: "view"
55
+ },
56
+ {
57
+ type: "function",
58
+ name: "getRegistrar",
59
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
60
+ outputs: [{ name: "", type: "address", internalType: "address" }],
61
+ stateMutability: "view"
62
+ },
63
+ {
64
+ type: "function",
65
+ name: "isDSToken",
66
+ inputs: [{ name: "token", type: "address", internalType: "address" }],
67
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
68
+ stateMutability: "view"
69
+ },
70
+ {
71
+ type: "function",
72
+ name: "isOperator",
73
+ inputs: [
74
+ { name: "token", type: "address", internalType: "address" },
75
+ { name: "operator", type: "address", internalType: "address" }
76
+ ],
77
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
78
+ stateMutability: "view"
79
+ },
80
+ {
81
+ type: "function",
82
+ name: "mint",
83
+ inputs: [{ name: "wallet", type: "address", internalType: "address" }],
84
+ outputs: [],
85
+ stateMutability: "nonpayable"
86
+ },
87
+ {
88
+ type: "function",
89
+ name: "registerCreditAccount",
90
+ inputs: [
91
+ { name: "creditAccount", type: "address", internalType: "address" },
92
+ { name: "tokens", type: "address[]", internalType: "address[]" }
93
+ ],
94
+ outputs: [],
95
+ stateMutability: "nonpayable"
96
+ },
97
+ {
98
+ type: "function",
99
+ name: "registerHelperAccount",
100
+ inputs: [
101
+ { name: "creditAccount", type: "address", internalType: "address" },
102
+ { name: "helperAccount", type: "address", internalType: "address" },
103
+ { name: "token", type: "address", internalType: "address" }
104
+ ],
105
+ outputs: [],
106
+ stateMutability: "nonpayable"
107
+ },
108
+ {
109
+ type: "function",
110
+ name: "serialize",
111
+ inputs: [],
112
+ outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
113
+ stateMutability: "view"
114
+ },
115
+ {
116
+ type: "function",
117
+ name: "setOperatorStatus",
118
+ inputs: [
119
+ { name: "token", type: "address", internalType: "address" },
120
+ { name: "operator", type: "address", internalType: "address" },
121
+ { name: "approved", type: "bool", internalType: "bool" }
122
+ ],
123
+ outputs: [],
124
+ stateMutability: "nonpayable"
125
+ },
126
+ {
127
+ type: "function",
128
+ name: "version",
129
+ inputs: [],
130
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
131
+ stateMutability: "view"
132
+ },
133
+ {
134
+ type: "event",
135
+ name: "Burn",
136
+ inputs: [
137
+ {
138
+ name: "wallet",
139
+ type: "address",
140
+ indexed: true,
141
+ internalType: "address"
142
+ }
143
+ ],
144
+ anonymous: false
145
+ },
146
+ {
147
+ type: "event",
148
+ name: "Mint",
149
+ inputs: [
150
+ {
151
+ name: "wallet",
152
+ type: "address",
153
+ indexed: true,
154
+ internalType: "address"
155
+ }
156
+ ],
157
+ anonymous: false
158
+ },
159
+ {
160
+ type: "event",
161
+ name: "SetOperatorStatus",
162
+ inputs: [
163
+ {
164
+ name: "token",
165
+ type: "address",
166
+ indexed: true,
167
+ internalType: "address"
168
+ },
169
+ {
170
+ name: "operator",
171
+ type: "address",
172
+ indexed: true,
173
+ internalType: "address"
174
+ },
175
+ { name: "approved", type: "bool", indexed: false, internalType: "bool" }
176
+ ],
177
+ anonymous: false
178
+ },
179
+ {
180
+ type: "event",
181
+ name: "SetRegistrar",
182
+ inputs: [
183
+ {
184
+ name: "token",
185
+ type: "address",
186
+ indexed: true,
187
+ internalType: "address"
188
+ },
189
+ {
190
+ name: "registrar",
191
+ type: "address",
192
+ indexed: true,
193
+ internalType: "address"
194
+ }
195
+ ],
196
+ anonymous: false
197
+ },
198
+ {
199
+ type: "error",
200
+ name: "CallerIsNotCreditFacadeException",
201
+ inputs: [{ name: "caller", type: "address", internalType: "address" }]
202
+ },
203
+ {
204
+ type: "error",
205
+ name: "CallerIsNotFactoryException",
206
+ inputs: [{ name: "caller", type: "address", internalType: "address" }]
207
+ },
208
+ {
209
+ type: "error",
210
+ name: "CallerIsNotInstanceOwnerException",
211
+ inputs: [{ name: "caller", type: "address", internalType: "address" }]
212
+ },
213
+ {
214
+ type: "error",
215
+ name: "CallerIsNotOperatorException",
216
+ inputs: [
217
+ { name: "token", type: "address", internalType: "address" },
218
+ { name: "caller", type: "address", internalType: "address" }
219
+ ]
220
+ },
221
+ {
222
+ type: "error",
223
+ name: "RegistrarNotSetForTokenException",
224
+ inputs: [{ name: "token", type: "address", internalType: "address" }]
225
+ },
226
+ {
227
+ type: "error",
228
+ name: "UnknownTokenException",
229
+ inputs: [{ name: "token", type: "address", internalType: "address" }]
230
+ },
231
+ {
232
+ type: "error",
233
+ name: "UnknownWalletException",
234
+ inputs: [{ name: "wallet", type: "address", internalType: "address" }]
235
+ }
236
+ ];
237
+ export {
238
+ iSecuritizeDegenNFTAbi
239
+ };
@@ -0,0 +1,254 @@
1
+ const iSecuritizeKYCFactoryAbi = [
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: "getCreditAccounts",
12
+ inputs: [{ name: "investor", type: "address", internalType: "address" }],
13
+ outputs: [{ name: "", type: "address[]", internalType: "address[]" }],
14
+ stateMutability: "view"
15
+ },
16
+ {
17
+ type: "function",
18
+ name: "getDegenNFT",
19
+ inputs: [],
20
+ outputs: [{ name: "", type: "address", internalType: "address" }],
21
+ stateMutability: "view"
22
+ },
23
+ {
24
+ type: "function",
25
+ name: "getInvestor",
26
+ inputs: [
27
+ { name: "creditAccount", type: "address", internalType: "address" }
28
+ ],
29
+ outputs: [{ name: "", type: "address", internalType: "address" }],
30
+ stateMutability: "view"
31
+ },
32
+ {
33
+ type: "function",
34
+ name: "getWallet",
35
+ inputs: [
36
+ { name: "creditAccount", type: "address", internalType: "address" }
37
+ ],
38
+ outputs: [{ name: "", type: "address", internalType: "address" }],
39
+ stateMutability: "view"
40
+ },
41
+ {
42
+ type: "function",
43
+ name: "isCreditAccount",
44
+ inputs: [
45
+ { name: "creditAccount", type: "address", internalType: "address" }
46
+ ],
47
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
48
+ stateMutability: "view"
49
+ },
50
+ {
51
+ type: "function",
52
+ name: "isFrozen",
53
+ inputs: [
54
+ { name: "creditAccount", type: "address", internalType: "address" }
55
+ ],
56
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
57
+ stateMutability: "view"
58
+ },
59
+ {
60
+ type: "function",
61
+ name: "multicall",
62
+ inputs: [
63
+ { name: "creditAccount", type: "address", internalType: "address" },
64
+ {
65
+ name: "calls",
66
+ type: "tuple[]",
67
+ internalType: "struct MultiCall[]",
68
+ components: [
69
+ { name: "target", type: "address", internalType: "address" },
70
+ { name: "callData", type: "bytes", internalType: "bytes" }
71
+ ]
72
+ },
73
+ {
74
+ name: "tokensToRegister",
75
+ type: "address[]",
76
+ internalType: "address[]"
77
+ }
78
+ ],
79
+ outputs: [],
80
+ stateMutability: "nonpayable"
81
+ },
82
+ {
83
+ type: "function",
84
+ name: "openCreditAccount",
85
+ inputs: [
86
+ { name: "creditManager", type: "address", internalType: "address" },
87
+ {
88
+ name: "calls",
89
+ type: "tuple[]",
90
+ internalType: "struct MultiCall[]",
91
+ components: [
92
+ { name: "target", type: "address", internalType: "address" },
93
+ { name: "callData", type: "bytes", internalType: "bytes" }
94
+ ]
95
+ },
96
+ {
97
+ name: "tokensToRegister",
98
+ type: "address[]",
99
+ internalType: "address[]"
100
+ }
101
+ ],
102
+ outputs: [
103
+ { name: "creditAccount", type: "address", internalType: "address" },
104
+ { name: "wallet", type: "address", internalType: "address" }
105
+ ],
106
+ stateMutability: "nonpayable"
107
+ },
108
+ {
109
+ type: "function",
110
+ name: "precomputeWalletAddress",
111
+ inputs: [
112
+ { name: "creditManager", type: "address", internalType: "address" },
113
+ { name: "investor", type: "address", internalType: "address" }
114
+ ],
115
+ outputs: [{ name: "", type: "address", internalType: "address" }],
116
+ stateMutability: "view"
117
+ },
118
+ {
119
+ type: "function",
120
+ name: "serialize",
121
+ inputs: [],
122
+ outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
123
+ stateMutability: "view"
124
+ },
125
+ {
126
+ type: "function",
127
+ name: "setFrozenStatus",
128
+ inputs: [
129
+ { name: "creditAccount", type: "address", internalType: "address" },
130
+ { name: "frozen", type: "bool", internalType: "bool" }
131
+ ],
132
+ outputs: [],
133
+ stateMutability: "nonpayable"
134
+ },
135
+ {
136
+ type: "function",
137
+ name: "setInvestor",
138
+ inputs: [
139
+ { name: "creditAccount", type: "address", internalType: "address" },
140
+ { name: "investor", type: "address", internalType: "address" }
141
+ ],
142
+ outputs: [],
143
+ stateMutability: "nonpayable"
144
+ },
145
+ {
146
+ type: "function",
147
+ name: "version",
148
+ inputs: [],
149
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
150
+ stateMutability: "view"
151
+ },
152
+ {
153
+ type: "event",
154
+ name: "CreateWallet",
155
+ inputs: [
156
+ {
157
+ name: "creditAccount",
158
+ type: "address",
159
+ indexed: true,
160
+ internalType: "address"
161
+ },
162
+ {
163
+ name: "wallet",
164
+ type: "address",
165
+ indexed: true,
166
+ internalType: "address"
167
+ },
168
+ {
169
+ name: "investor",
170
+ type: "address",
171
+ indexed: true,
172
+ internalType: "address"
173
+ }
174
+ ],
175
+ anonymous: false
176
+ },
177
+ {
178
+ type: "event",
179
+ name: "SetFrozenStatus",
180
+ inputs: [
181
+ {
182
+ name: "creditAccount",
183
+ type: "address",
184
+ indexed: true,
185
+ internalType: "address"
186
+ },
187
+ { name: "frozen", type: "bool", indexed: false, internalType: "bool" }
188
+ ],
189
+ anonymous: false
190
+ },
191
+ {
192
+ type: "event",
193
+ name: "SetInvestor",
194
+ inputs: [
195
+ {
196
+ name: "creditAccount",
197
+ type: "address",
198
+ indexed: true,
199
+ internalType: "address"
200
+ },
201
+ {
202
+ name: "oldInvestor",
203
+ type: "address",
204
+ indexed: true,
205
+ internalType: "address"
206
+ },
207
+ {
208
+ name: "newInvestor",
209
+ type: "address",
210
+ indexed: true,
211
+ internalType: "address"
212
+ }
213
+ ],
214
+ anonymous: false
215
+ },
216
+ {
217
+ type: "error",
218
+ name: "CallerIsNotInvestorException",
219
+ inputs: [
220
+ { name: "caller", type: "address", internalType: "address" },
221
+ { name: "creditAccount", type: "address", internalType: "address" }
222
+ ]
223
+ },
224
+ {
225
+ type: "error",
226
+ name: "FrozenCreditAccountException",
227
+ inputs: [
228
+ { name: "creditAccount", type: "address", internalType: "address" }
229
+ ]
230
+ },
231
+ {
232
+ type: "error",
233
+ name: "InvalidCreditManagerException",
234
+ inputs: [
235
+ { name: "creditManager", type: "address", internalType: "address" }
236
+ ]
237
+ },
238
+ {
239
+ type: "error",
240
+ name: "InvalidUnderlyingTokenException",
241
+ inputs: [{ name: "underlying", type: "address", internalType: "address" }]
242
+ },
243
+ {
244
+ type: "error",
245
+ name: "UnknownCreditAccountException",
246
+ inputs: [
247
+ { name: "creditAccount", type: "address", internalType: "address" }
248
+ ]
249
+ },
250
+ { type: "error", name: "ZeroAddressException", inputs: [] }
251
+ ];
252
+ export {
253
+ iSecuritizeKYCFactoryAbi
254
+ };
@@ -0,0 +1,12 @@
1
+ const iStateSerializerAbi = [
2
+ {
3
+ type: "function",
4
+ inputs: [],
5
+ name: "serialize",
6
+ outputs: [{ name: "serializedData", internalType: "bytes", type: "bytes" }],
7
+ stateMutability: "view"
8
+ }
9
+ ];
10
+ export {
11
+ iStateSerializerAbi
12
+ };
@@ -6,7 +6,7 @@ import {
6
6
  parseEventLogs
7
7
  } from "viem";
8
8
  import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
9
- import { iCreditFacadeV310Abi, iPoolV310Abi } from "../abi/310/generated.js";
9
+ import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
10
10
  import { ierc20Abi } from "../abi/iERC20.js";
11
11
  import {
12
12
  ADDRESS_0X0,
@@ -15,6 +15,7 @@ import {
15
15
  childLogger,
16
16
  MAX_UINT256,
17
17
  PERCENTAGE_FACTOR,
18
+ PoolService,
18
19
  SDKConstruct,
19
20
  sendRawTx
20
21
  } from "../sdk/index.js";
@@ -43,6 +44,7 @@ class AccountOpener extends SDKConstruct {
43
44
  #minDebtMultiplier;
44
45
  #allowMint;
45
46
  #leverageDelta;
47
+ #poolService;
46
48
  constructor(service, options_ = {}) {
47
49
  super(service.sdk);
48
50
  const {
@@ -68,6 +70,7 @@ class AccountOpener extends SDKConstruct {
68
70
  this.#poolDepositMultiplier = BigInt(poolDepositMultiplier);
69
71
  this.#minDebtMultiplier = BigInt(minDebtMultiplier);
70
72
  this.#leverageDelta = BigInt(leverageDelta);
73
+ this.#poolService = new PoolService(service.sdk);
71
74
  this.#logger?.info(
72
75
  {
73
76
  borrower: privateKeyToAccount(this.borrowerKey).address,
@@ -105,6 +108,10 @@ class AccountOpener extends SDKConstruct {
105
108
  },
106
109
  "opening credit accounts"
107
110
  );
111
+ await Promise.all([
112
+ this.sdk.tokensMeta.loadTokenData(),
113
+ this.sdk.marketRegister.loadZappers()
114
+ ]);
108
115
  let deposits = [];
109
116
  if (depositIntoPools) {
110
117
  try {
@@ -456,9 +463,34 @@ class AccountOpener extends SDKConstruct {
456
463
  this.#logger?.debug(
457
464
  `depositor balance in underlying: ${this.sdk.tokensMeta.formatBN(pool.underlying, allowance, { symbol: true })}`
458
465
  );
466
+ const tokensOut = this.#poolService.getDepositTokensOut(
467
+ address,
468
+ underlying
469
+ );
470
+ this.#logger?.debug(
471
+ { tokensOut: tokensOut.map((t) => this.labelAddress(t)) },
472
+ "deposit tokens out"
473
+ );
474
+ if (tokensOut.length === 0) {
475
+ throw new Error(`no tokens out found for pool ${poolName}`);
476
+ }
477
+ const tokenOut = tokensOut[0];
478
+ const metadata = this.#poolService.getDepositMetadata(
479
+ address,
480
+ underlying,
481
+ tokenOut
482
+ );
483
+ this.logger?.debug(
484
+ {
485
+ underlying: this.labelAddress(underlying),
486
+ tokenOut: this.labelAddress(tokenOut),
487
+ ...metadata
488
+ },
489
+ "pool deposit metadata"
490
+ );
459
491
  txHash = await this.#anvil.writeContract({
460
492
  account: depositor,
461
- address: underlying,
493
+ address: metadata.approveTarget,
462
494
  abi: ierc20Abi,
463
495
  functionName: "approve",
464
496
  args: [address, allowance],
@@ -475,12 +507,21 @@ class AccountOpener extends SDKConstruct {
475
507
  this.#logger?.debug(
476
508
  `depositor approved underlying for pool ${poolName}: ${txHash}`
477
509
  );
510
+ const depositCall = this.#poolService.addLiquidity({
511
+ collateral: { token: underlying, balance: amount },
512
+ pool: address,
513
+ wallet: depositor.address,
514
+ meta: metadata
515
+ });
516
+ if (!depositCall) {
517
+ throw new Error(`no deposit call could be created for ${poolName}`);
518
+ }
478
519
  txHash = await this.#anvil.writeContract({
479
520
  account: depositor,
480
- address,
481
- abi: iPoolV310Abi,
482
- functionName: "deposit",
483
- args: [amount, depositor.address],
521
+ address: depositCall.target,
522
+ abi: depositCall.abi,
523
+ functionName: depositCall.functionName,
524
+ args: depositCall.args,
484
525
  chain: this.#anvil.chain
485
526
  });
486
527
  receipt = await this.#anvil.waitForTransactionReceipt({ hash: txHash });