@curvefi/llamalend-api 2.1.2 → 2.2.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/lib/constants/aliases.js +2 -2
- package/lib/external-api.js +2 -2
- package/lib/mintMarkets/fetch/fetchMintMarkets.js +2 -2
- package/lib/mintMarkets/modules/leverageV2.js +16 -16
- package/package.json +1 -1
- package/src/constants/aliases.ts +2 -2
- package/src/external-api.ts +3 -3
- package/src/mintMarkets/fetch/fetchMintMarkets.ts +2 -2
- package/src/mintMarkets/modules/leverageV2.ts +17 -17
package/lib/constants/aliases.js
CHANGED
|
@@ -25,14 +25,14 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
25
25
|
export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
26
26
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
27
27
|
"one_way_factory": "0x5EA8f3D674C70b020586933A0a5b250734798BeF",
|
|
28
|
-
"one_way_factory_v2": "
|
|
28
|
+
"one_way_factory_v2": "0xdB70c2E0EF061196653D27d8C8f550fA0eA896b0",
|
|
29
29
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
30
30
|
"gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
31
31
|
"gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
|
|
32
32
|
"old_gauge_end_index": "4",
|
|
33
33
|
"leverage_zap_deprecated": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
|
|
34
34
|
"leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
|
|
35
|
-
"leverage_zap_v2_llv2": "
|
|
35
|
+
"leverage_zap_v2_llv2": "0xeDF9787de764ee2Bc1dFbbaD3d3c952Cc8042375",
|
|
36
36
|
"leverage_markets_start_id": "0",
|
|
37
37
|
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
|
|
38
38
|
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
|
package/lib/external-api.js
CHANGED
|
@@ -161,7 +161,7 @@ export function _getQuoteOdos(fromToken_1, toToken_1, _amount_1, blacklist_1, pa
|
|
|
161
161
|
toToken = "0x0000000000000000000000000000000000000000";
|
|
162
162
|
const url = `https://prices.curve.finance/odos/v3/quote?chain_id=${this.chainId}&from_address=${ethers.getAddress(fromToken)}` +
|
|
163
163
|
`&to_address=${ethers.getAddress(toToken)}&amount=${_amount.toString()}&slippage=${slippage}&pathVizImage=${pathVizImage}` +
|
|
164
|
-
`&caller_address=${ethers.getAddress(this.constants.ALIASES.
|
|
164
|
+
`&caller_address=${ethers.getAddress(this.constants.ALIASES.leverage_zap_deprecated)}&blacklist=${ethers.getAddress(blacklist)}`;
|
|
165
165
|
const response = yield fetch(url, { headers: { "accept": "application/json" } });
|
|
166
166
|
if (response.status !== 200) {
|
|
167
167
|
throw Error(`Odos quote error - ${response.status} ${response.statusText}`);
|
|
@@ -191,7 +191,7 @@ const _assembleTxOdosMemoized = memoize(function (leverageZapAddress, pathId) {
|
|
|
191
191
|
});
|
|
192
192
|
export function _assembleTxOdos(pathId) {
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
return _assembleTxOdosMemoized(this.constants.ALIASES.
|
|
194
|
+
return _assembleTxOdosMemoized(this.constants.ALIASES.leverage_zap_deprecated, pathId);
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
function fetchJson(url) {
|
|
@@ -51,7 +51,7 @@ export const fetchMintMarketsByAPI = (llamalend) => __awaiter(void 0, void 0, vo
|
|
|
51
51
|
controller_address: controllers[i],
|
|
52
52
|
monetary_policy_address,
|
|
53
53
|
collateral_address: is_eth ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : collateral_address,
|
|
54
|
-
leverage_zap: llamalend.constants.ALIASES.
|
|
54
|
+
leverage_zap: llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
55
55
|
deleverage_zap: "0x0000000000000000000000000000000000000000",
|
|
56
56
|
collateral_symbol: is_eth ? "ETH" : collateral_symbol,
|
|
57
57
|
collateral_decimals: market.collateral_token.decimals,
|
|
@@ -114,7 +114,7 @@ export const fetchMintMarketsByBlockchain = (llamalend) => __awaiter(void 0, voi
|
|
|
114
114
|
controller_address: controllers[i],
|
|
115
115
|
monetary_policy_address,
|
|
116
116
|
collateral_address: is_eth ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : collaterals[i],
|
|
117
|
-
leverage_zap: llamalend.constants.ALIASES.
|
|
117
|
+
leverage_zap: llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
118
118
|
deleverage_zap: "0x0000000000000000000000000000000000000000",
|
|
119
119
|
collateral_symbol: is_eth ? "ETH" : collateral_symbol,
|
|
120
120
|
collateral_decimals,
|
|
@@ -24,12 +24,12 @@ export class LeverageV2Module {
|
|
|
24
24
|
return this.market.index;
|
|
25
25
|
};
|
|
26
26
|
this.hasLeverage = () => {
|
|
27
|
-
return this.llamalend.constants.ALIASES.
|
|
27
|
+
return this.llamalend.constants.ALIASES.leverage_zap_deprecated !== this.llamalend.constants.ZERO_ADDRESS && this.market.isDeleverageSupported;
|
|
28
28
|
};
|
|
29
29
|
this.leverageCreateLoanMaxRecvAllRanges = memoize((userCollateral, userBorrowed) => __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
this._checkLeverageZap();
|
|
31
31
|
const _userCollateral = parseUnits(userCollateral, this.market.coinDecimals[1]);
|
|
32
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
32
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].multicallContract;
|
|
33
33
|
const oraclePriceBand = yield this.market.oraclePriceBand();
|
|
34
34
|
const pAvgApproxBN = BN(yield this.market.calcTickPrice(oraclePriceBand)); // upper tick of oracle price band
|
|
35
35
|
let pAvgBN = null;
|
|
@@ -261,7 +261,7 @@ export class LeverageV2Module {
|
|
|
261
261
|
let maxBorrowableBN = BN(0);
|
|
262
262
|
let _userEffectiveCollateral = BigInt(0);
|
|
263
263
|
let _maxLeverageCollateral = BigInt(0);
|
|
264
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
264
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].contract;
|
|
265
265
|
for (let i = 0; i < 5; i++) {
|
|
266
266
|
maxBorrowablePrevBN = maxBorrowableBN;
|
|
267
267
|
_userEffectiveCollateral = _userCollateral + fromBN(BN(userBorrowed).div(pAvgBN), this.market.coinDecimals[1]);
|
|
@@ -429,7 +429,7 @@ export class LeverageV2Module {
|
|
|
429
429
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
430
|
this._checkLeverageZap();
|
|
431
431
|
const collateralAllowance = yield hasAllowance.call(this.llamalend, [this.market.coinAddresses[1]], [userCollateral], this.llamalend.signerAddress, this.market.controller);
|
|
432
|
-
const borrowedAllowance = yield hasAllowance.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.
|
|
432
|
+
const borrowedAllowance = yield hasAllowance.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
433
433
|
return collateralAllowance && borrowedAllowance;
|
|
434
434
|
});
|
|
435
435
|
}
|
|
@@ -437,7 +437,7 @@ export class LeverageV2Module {
|
|
|
437
437
|
return __awaiter(this, void 0, void 0, function* () {
|
|
438
438
|
this._checkLeverageZap();
|
|
439
439
|
const collateralGas = yield ensureAllowanceEstimateGas.call(this.llamalend, [this.market.coinAddresses[1]], [userCollateral], this.market.controller);
|
|
440
|
-
const borrowedGas = yield ensureAllowanceEstimateGas.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.
|
|
440
|
+
const borrowedGas = yield ensureAllowanceEstimateGas.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
441
441
|
if (Array.isArray(collateralGas) && Array.isArray(borrowedGas)) {
|
|
442
442
|
return [collateralGas[0] + borrowedGas[0], collateralGas[1] + borrowedGas[1]];
|
|
443
443
|
}
|
|
@@ -450,7 +450,7 @@ export class LeverageV2Module {
|
|
|
450
450
|
return __awaiter(this, void 0, void 0, function* () {
|
|
451
451
|
this._checkLeverageZap();
|
|
452
452
|
const collateralApproveTx = yield ensureAllowance.call(this.llamalend, [this.market.coinAddresses[1]], [userCollateral], this.market.controller);
|
|
453
|
-
const borrowedApproveTx = yield ensureAllowance.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.
|
|
453
|
+
const borrowedApproveTx = yield ensureAllowance.call(this.llamalend, [this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
454
454
|
return [...collateralApproveTx, ...borrowedApproveTx];
|
|
455
455
|
});
|
|
456
456
|
}
|
|
@@ -475,12 +475,12 @@ export class LeverageV2Module {
|
|
|
475
475
|
throw Error(`You must call leverageV2.createLoanExpectedCollateral() with slippage=${slippage} first`);
|
|
476
476
|
const calldata = yield _assembleTxOdos.call(this.llamalend, swapData.pathId);
|
|
477
477
|
const contract = this.llamalend.contracts[this.market.controller].contract;
|
|
478
|
-
const gas = yield contract.create_loan_extended.estimateGas(_userCollateral, _debt, range, this.llamalend.constants.ALIASES.
|
|
478
|
+
const gas = yield contract.create_loan_extended.estimateGas(_userCollateral, _debt, range, this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userBorrowed], calldata, Object.assign({}, this.llamalend.constantOptions));
|
|
479
479
|
if (estimateGas)
|
|
480
480
|
return smartNumber(gas);
|
|
481
481
|
yield this.llamalend.updateFeeData();
|
|
482
482
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
483
|
-
return (yield contract.create_loan_extended(_userCollateral, _debt, range, this.llamalend.constants.ALIASES.
|
|
483
|
+
return (yield contract.create_loan_extended(_userCollateral, _debt, range, this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userBorrowed], calldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
484
484
|
});
|
|
485
485
|
}
|
|
486
486
|
leverageCreateLoanEstimateGas(userCollateral_1, userBorrowed_1, debt_1, range_1) {
|
|
@@ -519,7 +519,7 @@ export class LeverageV2Module {
|
|
|
519
519
|
let maxBorrowableBN = BN(0);
|
|
520
520
|
let _userEffectiveCollateral = BigInt(0);
|
|
521
521
|
let _maxLeverageCollateral = BigInt(0);
|
|
522
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
522
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].contract;
|
|
523
523
|
for (let i = 0; i < 5; i++) {
|
|
524
524
|
maxBorrowablePrevBN = maxBorrowableBN;
|
|
525
525
|
_userEffectiveCollateral = _userCollateral + fromBN(BN(userBorrowed).div(pAvgBN), this.market.coinDecimals[1]);
|
|
@@ -620,12 +620,12 @@ export class LeverageV2Module {
|
|
|
620
620
|
throw Error(`You must call leverageV2.borrowMoreExpectedCollateral() with slippage=${slippage} first`);
|
|
621
621
|
const calldata = yield _assembleTxOdos.call(this.llamalend, swapData.pathId);
|
|
622
622
|
const contract = this.llamalend.contracts[this.market.controller].contract;
|
|
623
|
-
const gas = yield contract.borrow_more_extended.estimateGas(_userCollateral, _debt, this.llamalend.constants.ALIASES.
|
|
623
|
+
const gas = yield contract.borrow_more_extended.estimateGas(_userCollateral, _debt, this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userBorrowed], calldata, Object.assign({}, this.llamalend.constantOptions));
|
|
624
624
|
if (estimateGas)
|
|
625
625
|
return smartNumber(gas);
|
|
626
626
|
yield this.llamalend.updateFeeData();
|
|
627
627
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
628
|
-
return (yield contract.borrow_more_extended(_userCollateral, _debt, this.llamalend.constants.ALIASES.
|
|
628
|
+
return (yield contract.borrow_more_extended(_userCollateral, _debt, this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userBorrowed], calldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
631
|
leverageBorrowMoreEstimateGas(userCollateral_1, userBorrowed_1, debt_1) {
|
|
@@ -735,19 +735,19 @@ export class LeverageV2Module {
|
|
|
735
735
|
leverageRepayIsApproved(userCollateral, userBorrowed) {
|
|
736
736
|
return __awaiter(this, void 0, void 0, function* () {
|
|
737
737
|
this._checkLeverageZap();
|
|
738
|
-
return yield hasAllowance.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.
|
|
738
|
+
return yield hasAllowance.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
leverageRepayApproveEstimateGas(userCollateral, userBorrowed) {
|
|
742
742
|
return __awaiter(this, void 0, void 0, function* () {
|
|
743
743
|
this._checkLeverageZap();
|
|
744
|
-
return yield ensureAllowanceEstimateGas.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.constants.ALIASES.
|
|
744
|
+
return yield ensureAllowanceEstimateGas.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
leverageRepayApprove(userCollateral, userBorrowed) {
|
|
748
748
|
return __awaiter(this, void 0, void 0, function* () {
|
|
749
749
|
this._checkLeverageZap();
|
|
750
|
-
return yield ensureAllowance.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.constants.ALIASES.
|
|
750
|
+
return yield ensureAllowance.call(this.llamalend, [this.market.coinAddresses[1], this.market.coinAddresses[0]], [userCollateral, userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
751
751
|
});
|
|
752
752
|
}
|
|
753
753
|
leverageRepayRouteImage(stateCollateral, userCollateral) {
|
|
@@ -774,12 +774,12 @@ export class LeverageV2Module {
|
|
|
774
774
|
}
|
|
775
775
|
console.log('params', [1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed], calldata);
|
|
776
776
|
const contract = this.llamalend.contracts[this.market.controller].contract;
|
|
777
|
-
const gas = yield contract.repay_extended.estimateGas(this.llamalend.constants.ALIASES.
|
|
777
|
+
const gas = yield contract.repay_extended.estimateGas(this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed], calldata);
|
|
778
778
|
if (estimateGas)
|
|
779
779
|
return smartNumber(gas);
|
|
780
780
|
yield this.llamalend.updateFeeData();
|
|
781
781
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
782
|
-
return (yield contract.repay_extended(this.llamalend.constants.ALIASES.
|
|
782
|
+
return (yield contract.repay_extended(this.llamalend.constants.ALIASES.leverage_zap_deprecated, [1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed], calldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
leverageRepayEstimateGas(stateCollateral_1, userCollateral_1, userBorrowed_1) {
|
package/package.json
CHANGED
package/src/constants/aliases.ts
CHANGED
|
@@ -29,14 +29,14 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
29
29
|
export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
30
30
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
31
31
|
"one_way_factory": "0x5EA8f3D674C70b020586933A0a5b250734798BeF",
|
|
32
|
-
"one_way_factory_v2": "
|
|
32
|
+
"one_way_factory_v2": "0xdB70c2E0EF061196653D27d8C8f550fA0eA896b0",
|
|
33
33
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
34
34
|
"gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
35
35
|
"gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
|
|
36
36
|
"old_gauge_end_index": "4",
|
|
37
37
|
"leverage_zap_deprecated": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
|
|
38
38
|
"leverage_zap_v2": "0xE94d1fBF399c27CCBf0185b2Dd11Bf0FA0f0D95C",
|
|
39
|
-
"leverage_zap_v2_llv2": "
|
|
39
|
+
"leverage_zap_v2_llv2": "0xeDF9787de764ee2Bc1dFbbaD3d3c952Cc8042375",
|
|
40
40
|
"leverage_markets_start_id": "0",
|
|
41
41
|
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
|
|
42
42
|
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
|
package/src/external-api.ts
CHANGED
|
@@ -207,7 +207,7 @@ export async function _getQuoteOdos(this: Llamalend, fromToken: string, toToken:
|
|
|
207
207
|
|
|
208
208
|
const url = `https://prices.curve.finance/odos/v3/quote?chain_id=${this.chainId}&from_address=${ethers.getAddress(fromToken)}` +
|
|
209
209
|
`&to_address=${ethers.getAddress(toToken)}&amount=${_amount.toString()}&slippage=${slippage}&pathVizImage=${pathVizImage}` +
|
|
210
|
-
`&caller_address=${ethers.getAddress(this.constants.ALIASES.
|
|
210
|
+
`&caller_address=${ethers.getAddress(this.constants.ALIASES.leverage_zap_deprecated)}&blacklist=${ethers.getAddress(blacklist)}`;
|
|
211
211
|
|
|
212
212
|
const response = await fetch(url, { headers: {"accept": "application/json"} });
|
|
213
213
|
if (response.status !== 200) {
|
|
@@ -239,7 +239,7 @@ const _assembleTxOdosMemoized = memoize(
|
|
|
239
239
|
);
|
|
240
240
|
|
|
241
241
|
export async function _assembleTxOdos(this: Llamalend, pathId: string): Promise<string> {
|
|
242
|
-
return _assembleTxOdosMemoized(this.constants.ALIASES.
|
|
242
|
+
return _assembleTxOdosMemoized(this.constants.ALIASES.leverage_zap_deprecated, pathId);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
async function fetchJson(url: string): Promise<any> {
|
|
@@ -250,4 +250,4 @@ async function fetchJson(url: string): Promise<any> {
|
|
|
250
250
|
async function fetchData(url: string) {
|
|
251
251
|
const {data} = await fetchJson(url);
|
|
252
252
|
return data;
|
|
253
|
-
}
|
|
253
|
+
}
|
|
@@ -49,7 +49,7 @@ export const fetchMintMarketsByAPI = async (llamalend: Llamalend): Promise<void>
|
|
|
49
49
|
controller_address: controllers[i],
|
|
50
50
|
monetary_policy_address,
|
|
51
51
|
collateral_address: is_eth ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : collateral_address,
|
|
52
|
-
leverage_zap: llamalend.constants.ALIASES.
|
|
52
|
+
leverage_zap: llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
53
53
|
deleverage_zap: "0x0000000000000000000000000000000000000000",
|
|
54
54
|
collateral_symbol: is_eth ? "ETH" : collateral_symbol,
|
|
55
55
|
collateral_decimals: market.collateral_token.decimals,
|
|
@@ -136,7 +136,7 @@ export const fetchMintMarketsByBlockchain = async (llamalend: Llamalend): Promis
|
|
|
136
136
|
controller_address: controllers[i],
|
|
137
137
|
monetary_policy_address,
|
|
138
138
|
collateral_address: is_eth ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : collaterals[i],
|
|
139
|
-
leverage_zap: llamalend.constants.ALIASES.
|
|
139
|
+
leverage_zap: llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
140
140
|
deleverage_zap: "0x0000000000000000000000000000000000000000",
|
|
141
141
|
collateral_symbol: is_eth ? "ETH" : collateral_symbol,
|
|
142
142
|
collateral_decimals,
|
|
@@ -52,7 +52,7 @@ export class LeverageV2Module {
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
public hasLeverage = (): boolean => {
|
|
55
|
-
return this.llamalend.constants.ALIASES.
|
|
55
|
+
return this.llamalend.constants.ALIASES.leverage_zap_deprecated !== this.llamalend.constants.ZERO_ADDRESS && this.market.isDeleverageSupported
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
public _checkLeverageZap(): void {
|
|
@@ -108,7 +108,7 @@ export class LeverageV2Module {
|
|
|
108
108
|
let _userEffectiveCollateral = BigInt(0);
|
|
109
109
|
let _maxLeverageCollateral = BigInt(0);
|
|
110
110
|
|
|
111
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
111
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].contract;
|
|
112
112
|
for (let i = 0; i < 5; i++) {
|
|
113
113
|
maxBorrowablePrevBN = maxBorrowableBN;
|
|
114
114
|
_userEffectiveCollateral = _userCollateral + fromBN(BN(userBorrowed).div(pAvgBN), this.market.coinDecimals[1]);
|
|
@@ -155,7 +155,7 @@ export class LeverageV2Module {
|
|
|
155
155
|
}>> => {
|
|
156
156
|
this._checkLeverageZap();
|
|
157
157
|
const _userCollateral = parseUnits(userCollateral, this.market.coinDecimals[1]);
|
|
158
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
158
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].multicallContract;
|
|
159
159
|
|
|
160
160
|
const oraclePriceBand = await this.market.oraclePriceBand();
|
|
161
161
|
const pAvgApproxBN = BN(await this.market.calcTickPrice(oraclePriceBand)); // upper tick of oracle price band
|
|
@@ -442,7 +442,7 @@ export class LeverageV2Module {
|
|
|
442
442
|
const collateralAllowance = await hasAllowance.call(this.llamalend,
|
|
443
443
|
[this.market.coinAddresses[1]], [userCollateral], this.llamalend.signerAddress, this.market.controller);
|
|
444
444
|
const borrowedAllowance = await hasAllowance.call(this.llamalend,
|
|
445
|
-
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.
|
|
445
|
+
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.signerAddress, this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
446
446
|
|
|
447
447
|
return collateralAllowance && borrowedAllowance
|
|
448
448
|
}
|
|
@@ -452,7 +452,7 @@ export class LeverageV2Module {
|
|
|
452
452
|
const collateralGas = await ensureAllowanceEstimateGas.call(this.llamalend,
|
|
453
453
|
[this.market.coinAddresses[1]], [userCollateral], this.market.controller);
|
|
454
454
|
const borrowedGas = await ensureAllowanceEstimateGas.call(this.llamalend,
|
|
455
|
-
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.
|
|
455
|
+
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
456
456
|
|
|
457
457
|
if(Array.isArray(collateralGas) && Array.isArray(borrowedGas)) {
|
|
458
458
|
return [collateralGas[0] + borrowedGas[0], collateralGas[1] + borrowedGas[1]]
|
|
@@ -466,7 +466,7 @@ export class LeverageV2Module {
|
|
|
466
466
|
const collateralApproveTx = await ensureAllowance.call(this.llamalend,
|
|
467
467
|
[this.market.coinAddresses[1]], [userCollateral], this.market.controller);
|
|
468
468
|
const borrowedApproveTx = await ensureAllowance.call(this.llamalend,
|
|
469
|
-
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.
|
|
469
|
+
[this.market.coinAddresses[0]], [userBorrowed], this.llamalend.constants.ALIASES.leverage_zap_deprecated);
|
|
470
470
|
|
|
471
471
|
return [...collateralApproveTx, ...borrowedApproveTx]
|
|
472
472
|
}
|
|
@@ -501,7 +501,7 @@ export class LeverageV2Module {
|
|
|
501
501
|
_userCollateral,
|
|
502
502
|
_debt,
|
|
503
503
|
range,
|
|
504
|
-
this.llamalend.constants.ALIASES.
|
|
504
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
505
505
|
[1, parseUnits(this._getMarketId(), 0), _userBorrowed],
|
|
506
506
|
calldata,
|
|
507
507
|
{ ...this.llamalend.constantOptions }
|
|
@@ -514,7 +514,7 @@ export class LeverageV2Module {
|
|
|
514
514
|
_userCollateral,
|
|
515
515
|
_debt,
|
|
516
516
|
range,
|
|
517
|
-
this.llamalend.constants.ALIASES.
|
|
517
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
518
518
|
[1, parseUnits(this._getMarketId(), 0), _userBorrowed],
|
|
519
519
|
calldata,
|
|
520
520
|
{ ...this.llamalend.options, gasLimit }
|
|
@@ -563,7 +563,7 @@ export class LeverageV2Module {
|
|
|
563
563
|
let _userEffectiveCollateral = BigInt(0);
|
|
564
564
|
let _maxLeverageCollateral = BigInt(0);
|
|
565
565
|
|
|
566
|
-
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.
|
|
566
|
+
const contract = this.llamalend.contracts[this.llamalend.constants.ALIASES.leverage_zap_deprecated].contract;
|
|
567
567
|
for (let i = 0; i < 5; i++) {
|
|
568
568
|
maxBorrowablePrevBN = maxBorrowableBN;
|
|
569
569
|
_userEffectiveCollateral = _userCollateral + fromBN(BN(userBorrowed).div(pAvgBN), this.market.coinDecimals[1]);
|
|
@@ -672,7 +672,7 @@ export class LeverageV2Module {
|
|
|
672
672
|
const gas = await contract.borrow_more_extended.estimateGas(
|
|
673
673
|
_userCollateral,
|
|
674
674
|
_debt,
|
|
675
|
-
this.llamalend.constants.ALIASES.
|
|
675
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
676
676
|
[1, parseUnits(this._getMarketId(), 0), _userBorrowed],
|
|
677
677
|
calldata,
|
|
678
678
|
{ ...this.llamalend.constantOptions }
|
|
@@ -685,7 +685,7 @@ export class LeverageV2Module {
|
|
|
685
685
|
return (await contract.borrow_more_extended(
|
|
686
686
|
_userCollateral,
|
|
687
687
|
_debt,
|
|
688
|
-
this.llamalend.constants.ALIASES.
|
|
688
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
689
689
|
[1, parseUnits(this._getMarketId(), 0), _userBorrowed],
|
|
690
690
|
calldata,
|
|
691
691
|
{ ...this.llamalend.options, gasLimit }
|
|
@@ -870,7 +870,7 @@ export class LeverageV2Module {
|
|
|
870
870
|
[this.market.coinAddresses[1], this.market.coinAddresses[0]],
|
|
871
871
|
[userCollateral, userBorrowed],
|
|
872
872
|
this.llamalend.signerAddress,
|
|
873
|
-
this.llamalend.constants.ALIASES.
|
|
873
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated
|
|
874
874
|
);
|
|
875
875
|
}
|
|
876
876
|
|
|
@@ -879,7 +879,7 @@ export class LeverageV2Module {
|
|
|
879
879
|
return await ensureAllowanceEstimateGas.call(this.llamalend,
|
|
880
880
|
[this.market.coinAddresses[1], this.market.coinAddresses[0]],
|
|
881
881
|
[userCollateral, userBorrowed],
|
|
882
|
-
this.llamalend.constants.ALIASES.
|
|
882
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated
|
|
883
883
|
);
|
|
884
884
|
}
|
|
885
885
|
|
|
@@ -888,7 +888,7 @@ export class LeverageV2Module {
|
|
|
888
888
|
return await ensureAllowance.call(this.llamalend,
|
|
889
889
|
[this.market.coinAddresses[1], this.market.coinAddresses[0]],
|
|
890
890
|
[userCollateral, userBorrowed],
|
|
891
|
-
this.llamalend.constants.ALIASES.
|
|
891
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated
|
|
892
892
|
);
|
|
893
893
|
}
|
|
894
894
|
|
|
@@ -921,7 +921,7 @@ export class LeverageV2Module {
|
|
|
921
921
|
console.log('params', [1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed], calldata)
|
|
922
922
|
const contract = this.llamalend.contracts[this.market.controller].contract;
|
|
923
923
|
const gas = await contract.repay_extended.estimateGas(
|
|
924
|
-
this.llamalend.constants.ALIASES.
|
|
924
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
925
925
|
[1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed],
|
|
926
926
|
calldata
|
|
927
927
|
);
|
|
@@ -931,7 +931,7 @@ export class LeverageV2Module {
|
|
|
931
931
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
932
932
|
|
|
933
933
|
return (await contract.repay_extended(
|
|
934
|
-
this.llamalend.constants.ALIASES.
|
|
934
|
+
this.llamalend.constants.ALIASES.leverage_zap_deprecated,
|
|
935
935
|
[1, parseUnits(this._getMarketId(), 0), _userCollateral, _userBorrowed],
|
|
936
936
|
calldata,
|
|
937
937
|
{ ...this.llamalend.options, gasLimit }
|
|
@@ -968,4 +968,4 @@ export class LeverageV2Module {
|
|
|
968
968
|
|
|
969
969
|
return futureCollateralState.div(futureTotalDepositFromUserPrecise).toString();
|
|
970
970
|
}
|
|
971
|
-
}
|
|
971
|
+
}
|