@curvefi/llamalend-api 1.0.41 → 1.1.0
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/.github/workflows/publish.yml +7 -14
- package/README.md +451 -1
- package/lib/constants/aliases.js +15 -0
- package/lib/interfaces.d.ts +11 -0
- package/lib/lendMarkets/LendMarketTemplate.d.ts +6 -3
- package/lib/lendMarkets/LendMarketTemplate.js +40 -1
- package/lib/lendMarkets/interfaces/leverageZapV2.d.ts +223 -0
- package/lib/lendMarkets/interfaces/leverageZapV2.js +1 -0
- package/lib/lendMarkets/modules/index.d.ts +1 -0
- package/lib/lendMarkets/modules/index.js +1 -0
- package/lib/lendMarkets/modules/leverageZapV2.d.ts +253 -0
- package/lib/lendMarkets/modules/leverageZapV2.js +681 -0
- package/lib/llamalend.js +1 -0
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +5 -0
- package/package.json +2 -1
- package/src/cache/index.ts +1 -1
- package/src/constants/aliases.ts +15 -0
- package/src/external-api.ts +4 -4
- package/src/interfaces.ts +19 -0
- package/src/lendMarkets/LendMarketTemplate.ts +81 -32
- package/src/lendMarkets/interfaces/leverageZapV2.ts +282 -0
- package/src/lendMarkets/modules/index.ts +1 -0
- package/src/lendMarkets/modules/leverageZapV2.ts +991 -0
- package/src/llamalend.ts +1 -0
- package/src/utils.ts +12 -1
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {GetExpectedFn, IDict, ILeverageMetrics, IQuote, TAmount, TGas} from "../../interfaces.js";
|
|
2
|
+
|
|
3
|
+
export interface ILeverageZapV2 {
|
|
4
|
+
hasLeverage: () => boolean,
|
|
5
|
+
|
|
6
|
+
maxLeverage: (N: number) => Promise<string>,
|
|
7
|
+
|
|
8
|
+
createLoanMaxRecv: ({
|
|
9
|
+
userCollateral,
|
|
10
|
+
userBorrowed,
|
|
11
|
+
range,
|
|
12
|
+
getExpected,
|
|
13
|
+
}: {
|
|
14
|
+
userCollateral: TAmount,
|
|
15
|
+
userBorrowed: TAmount,
|
|
16
|
+
range: number,
|
|
17
|
+
getExpected: GetExpectedFn
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
maxDebt: string,
|
|
20
|
+
maxTotalCollateral: string,
|
|
21
|
+
userCollateral: string,
|
|
22
|
+
collateralFromUserBorrowed: string,
|
|
23
|
+
collateralFromMaxDebt: string,
|
|
24
|
+
maxLeverage: string,
|
|
25
|
+
avgPrice: string,
|
|
26
|
+
}>,
|
|
27
|
+
createLoanMaxRecvAllRanges: ({
|
|
28
|
+
userCollateral,
|
|
29
|
+
userBorrowed,
|
|
30
|
+
getExpected,
|
|
31
|
+
}: {
|
|
32
|
+
userCollateral: TAmount,
|
|
33
|
+
userBorrowed: TAmount,
|
|
34
|
+
getExpected: GetExpectedFn
|
|
35
|
+
}) => Promise<IDict<{
|
|
36
|
+
maxDebt: string,
|
|
37
|
+
maxTotalCollateral: string,
|
|
38
|
+
userCollateral: string,
|
|
39
|
+
collateralFromUserBorrowed: string,
|
|
40
|
+
collateralFromMaxDebt: string,
|
|
41
|
+
maxLeverage: string,
|
|
42
|
+
avgPrice: string,
|
|
43
|
+
}>>,
|
|
44
|
+
createLoanExpectedCollateral: ({
|
|
45
|
+
userCollateral,
|
|
46
|
+
userBorrowed,
|
|
47
|
+
debt,
|
|
48
|
+
quote,
|
|
49
|
+
}: {
|
|
50
|
+
userCollateral: TAmount,
|
|
51
|
+
userBorrowed: TAmount,
|
|
52
|
+
debt: TAmount,
|
|
53
|
+
quote: IQuote
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
totalCollateral: string,
|
|
56
|
+
userCollateral: string,
|
|
57
|
+
collateralFromUserBorrowed: string,
|
|
58
|
+
collateralFromDebt: string,
|
|
59
|
+
leverage: string,
|
|
60
|
+
avgPrice: string
|
|
61
|
+
}>,
|
|
62
|
+
createLoanExpectedMetrics: ({
|
|
63
|
+
userCollateral,
|
|
64
|
+
userBorrowed,
|
|
65
|
+
debt,
|
|
66
|
+
range,
|
|
67
|
+
quote,
|
|
68
|
+
healthIsFull,
|
|
69
|
+
}: {
|
|
70
|
+
userCollateral: TAmount,
|
|
71
|
+
userBorrowed: TAmount,
|
|
72
|
+
debt: TAmount,
|
|
73
|
+
range: number,
|
|
74
|
+
quote: IQuote,
|
|
75
|
+
healthIsFull?: boolean
|
|
76
|
+
}) => Promise<ILeverageMetrics>,
|
|
77
|
+
createLoanMaxRange: ({
|
|
78
|
+
userCollateral,
|
|
79
|
+
userBorrowed,
|
|
80
|
+
debt,
|
|
81
|
+
getExpected,
|
|
82
|
+
}: {
|
|
83
|
+
userCollateral: TAmount,
|
|
84
|
+
userBorrowed: TAmount,
|
|
85
|
+
debt: TAmount,
|
|
86
|
+
getExpected: GetExpectedFn
|
|
87
|
+
}) => Promise<number>,
|
|
88
|
+
createLoanBandsAllRanges: ({
|
|
89
|
+
userCollateral,
|
|
90
|
+
userBorrowed,
|
|
91
|
+
debt,
|
|
92
|
+
getExpected,
|
|
93
|
+
quote,
|
|
94
|
+
}: {
|
|
95
|
+
userCollateral: TAmount,
|
|
96
|
+
userBorrowed: TAmount,
|
|
97
|
+
debt: TAmount,
|
|
98
|
+
getExpected: GetExpectedFn,
|
|
99
|
+
quote: IQuote
|
|
100
|
+
}) => Promise<IDict<[number, number] | null>>,
|
|
101
|
+
createLoanPricesAllRanges: ({
|
|
102
|
+
userCollateral,
|
|
103
|
+
userBorrowed,
|
|
104
|
+
debt,
|
|
105
|
+
getExpected,
|
|
106
|
+
quote,
|
|
107
|
+
}: {
|
|
108
|
+
userCollateral: TAmount,
|
|
109
|
+
userBorrowed: TAmount,
|
|
110
|
+
debt: TAmount,
|
|
111
|
+
getExpected: GetExpectedFn,
|
|
112
|
+
quote: IQuote
|
|
113
|
+
}) => Promise<IDict<[string, string] | null>>,
|
|
114
|
+
createLoanIsApproved: ({
|
|
115
|
+
userCollateral,
|
|
116
|
+
userBorrowed,
|
|
117
|
+
}: {
|
|
118
|
+
userCollateral: TAmount,
|
|
119
|
+
userBorrowed: TAmount
|
|
120
|
+
}) => Promise<boolean>,
|
|
121
|
+
createLoanApprove: ({
|
|
122
|
+
userCollateral,
|
|
123
|
+
userBorrowed,
|
|
124
|
+
}: {
|
|
125
|
+
userCollateral: TAmount,
|
|
126
|
+
userBorrowed: TAmount
|
|
127
|
+
}) => Promise<string[]>,
|
|
128
|
+
createLoan: ({
|
|
129
|
+
userCollateral,
|
|
130
|
+
userBorrowed,
|
|
131
|
+
debt,
|
|
132
|
+
range,
|
|
133
|
+
router,
|
|
134
|
+
calldata,
|
|
135
|
+
}: {
|
|
136
|
+
userCollateral: TAmount,
|
|
137
|
+
userBorrowed: TAmount,
|
|
138
|
+
debt: TAmount,
|
|
139
|
+
range: number,
|
|
140
|
+
router: string,
|
|
141
|
+
calldata: string
|
|
142
|
+
}) => Promise<string>,
|
|
143
|
+
|
|
144
|
+
borrowMoreMaxRecv: ({ userCollateral, userBorrowed, getExpected, address }: {
|
|
145
|
+
userCollateral: TAmount,
|
|
146
|
+
userBorrowed: TAmount,
|
|
147
|
+
getExpected: GetExpectedFn,
|
|
148
|
+
address?: string
|
|
149
|
+
}) => Promise<{
|
|
150
|
+
maxDebt: string,
|
|
151
|
+
maxTotalCollateral: string,
|
|
152
|
+
userCollateral: string,
|
|
153
|
+
collateralFromUserBorrowed: string,
|
|
154
|
+
collateralFromMaxDebt: string,
|
|
155
|
+
avgPrice: string,
|
|
156
|
+
}>,
|
|
157
|
+
borrowMoreExpectedCollateral: ({ userCollateral, userBorrowed, dDebt, quote, address }: {
|
|
158
|
+
userCollateral: TAmount,
|
|
159
|
+
userBorrowed: TAmount,
|
|
160
|
+
dDebt: TAmount,
|
|
161
|
+
quote: IQuote,
|
|
162
|
+
address?: string
|
|
163
|
+
}) => Promise<{
|
|
164
|
+
totalCollateral: string,
|
|
165
|
+
userCollateral: string,
|
|
166
|
+
collateralFromUserBorrowed: string,
|
|
167
|
+
collateralFromDebt: string,
|
|
168
|
+
avgPrice: string
|
|
169
|
+
}>,
|
|
170
|
+
borrowMoreExpectedMetrics: ({ userCollateral, userBorrowed, debt, quote, healthIsFull, address }: {
|
|
171
|
+
userCollateral: TAmount,
|
|
172
|
+
userBorrowed: TAmount,
|
|
173
|
+
debt: TAmount,
|
|
174
|
+
quote: IQuote,
|
|
175
|
+
healthIsFull?: boolean,
|
|
176
|
+
address?: string
|
|
177
|
+
}) => Promise<ILeverageMetrics>,
|
|
178
|
+
borrowMoreIsApproved: ({ userCollateral, userBorrowed }: {
|
|
179
|
+
userCollateral: TAmount,
|
|
180
|
+
userBorrowed: TAmount
|
|
181
|
+
}) => Promise<boolean>,
|
|
182
|
+
borrowMoreApprove: ({ userCollateral, userBorrowed }: {
|
|
183
|
+
userCollateral: TAmount,
|
|
184
|
+
userBorrowed: TAmount
|
|
185
|
+
}) => Promise<string[]>,
|
|
186
|
+
borrowMore: ({ userCollateral, userBorrowed, debt, router, calldata }: {
|
|
187
|
+
userCollateral: TAmount,
|
|
188
|
+
userBorrowed: TAmount,
|
|
189
|
+
debt: TAmount,
|
|
190
|
+
router: string,
|
|
191
|
+
calldata: string
|
|
192
|
+
}) => Promise<string>,
|
|
193
|
+
|
|
194
|
+
repayExpectedBorrowed: ({ stateCollateral, userCollateral, userBorrowed, quote }: {
|
|
195
|
+
stateCollateral: TAmount,
|
|
196
|
+
userCollateral: TAmount,
|
|
197
|
+
userBorrowed: TAmount,
|
|
198
|
+
quote: IQuote
|
|
199
|
+
}) => Promise<{
|
|
200
|
+
totalBorrowed: string,
|
|
201
|
+
borrowedFromStateCollateral: string,
|
|
202
|
+
borrowedFromUserCollateral: string,
|
|
203
|
+
userBorrowed: string,
|
|
204
|
+
avgPrice: string
|
|
205
|
+
}>,
|
|
206
|
+
repayIsFull: ({ stateCollateral, userCollateral, userBorrowed, quote, address }: {
|
|
207
|
+
stateCollateral: TAmount,
|
|
208
|
+
userCollateral: TAmount,
|
|
209
|
+
userBorrowed: TAmount,
|
|
210
|
+
quote: IQuote,
|
|
211
|
+
address?: string
|
|
212
|
+
}) => Promise<boolean>,
|
|
213
|
+
repayIsAvailable: ({ stateCollateral, userCollateral, userBorrowed, quote, address }: {
|
|
214
|
+
stateCollateral: TAmount,
|
|
215
|
+
userCollateral: TAmount,
|
|
216
|
+
userBorrowed: TAmount,
|
|
217
|
+
quote: IQuote,
|
|
218
|
+
address?: string
|
|
219
|
+
}) => Promise<boolean>,
|
|
220
|
+
repayExpectedMetrics: ({ stateCollateral, userCollateral, userBorrowed, healthIsFull, quote, address }: {
|
|
221
|
+
stateCollateral: TAmount,
|
|
222
|
+
userCollateral: TAmount,
|
|
223
|
+
userBorrowed: TAmount,
|
|
224
|
+
healthIsFull: boolean,
|
|
225
|
+
quote: IQuote,
|
|
226
|
+
address: string
|
|
227
|
+
}) => Promise<ILeverageMetrics>,
|
|
228
|
+
repayIsApproved: ({ userCollateral, userBorrowed }: {
|
|
229
|
+
userCollateral: TAmount,
|
|
230
|
+
userBorrowed: TAmount
|
|
231
|
+
}) => Promise<boolean>,
|
|
232
|
+
repayApprove: ({ userCollateral, userBorrowed }: {
|
|
233
|
+
userCollateral: TAmount,
|
|
234
|
+
userBorrowed: TAmount
|
|
235
|
+
}) => Promise<string[]>,
|
|
236
|
+
repay: ({ stateCollateral, userCollateral, userBorrowed, router, calldata }: {
|
|
237
|
+
stateCollateral: TAmount,
|
|
238
|
+
userCollateral: TAmount,
|
|
239
|
+
userBorrowed: TAmount,
|
|
240
|
+
router: string,
|
|
241
|
+
calldata: string
|
|
242
|
+
}) => Promise<string>,
|
|
243
|
+
|
|
244
|
+
estimateGas: {
|
|
245
|
+
createLoanApprove: ({ userCollateral, userBorrowed }: {
|
|
246
|
+
userCollateral: TAmount,
|
|
247
|
+
userBorrowed: TAmount
|
|
248
|
+
}) => Promise<TGas>,
|
|
249
|
+
createLoan: ({ userCollateral, userBorrowed, debt, range, router, calldata }: {
|
|
250
|
+
userCollateral: TAmount,
|
|
251
|
+
userBorrowed: TAmount,
|
|
252
|
+
debt: TAmount,
|
|
253
|
+
range: number,
|
|
254
|
+
router: string,
|
|
255
|
+
calldata: string
|
|
256
|
+
}) => Promise<number>,
|
|
257
|
+
|
|
258
|
+
borrowMoreApprove: ({ userCollateral, userBorrowed }: {
|
|
259
|
+
userCollateral: TAmount,
|
|
260
|
+
userBorrowed: TAmount
|
|
261
|
+
}) => Promise<TGas>,
|
|
262
|
+
borrowMore: ({ userCollateral, userBorrowed, debt, router, calldata }: {
|
|
263
|
+
userCollateral: TAmount,
|
|
264
|
+
userBorrowed: TAmount,
|
|
265
|
+
debt: TAmount,
|
|
266
|
+
router: string,
|
|
267
|
+
calldata: string
|
|
268
|
+
}) => Promise<number>,
|
|
269
|
+
|
|
270
|
+
repayApprove: ({ userCollateral, userBorrowed }: {
|
|
271
|
+
userCollateral: TAmount,
|
|
272
|
+
userBorrowed: TAmount
|
|
273
|
+
}) => Promise<TGas>,
|
|
274
|
+
repay: ({ stateCollateral, userCollateral, userBorrowed, router, calldata }: {
|
|
275
|
+
stateCollateral: TAmount,
|
|
276
|
+
userCollateral: TAmount,
|
|
277
|
+
userBorrowed: TAmount,
|
|
278
|
+
router: string,
|
|
279
|
+
calldata: string
|
|
280
|
+
}) => Promise<number>,
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LeverageZapV2Module } from './leverageZapV2.js';
|