@curvefi/llamalend-api 2.2.6 → 2.3.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.
- package/.yarn/install-state.gz +0 -0
- package/README.md +23 -26
- package/lib/constants/aliases.js +6 -6
- package/lib/lendMarkets/interfaces/leverageZapV2.d.ts +31 -63
- package/lib/lendMarkets/modules/common/leverageZapV2Base.d.ts +34 -65
- package/lib/lendMarkets/modules/common/leverageZapV2Base.js +107 -127
- package/lib/lendMarkets/modules/v1/leverageV1ZapV2.d.ts +3 -3
- package/lib/lendMarkets/modules/v1/leverageV1ZapV2.js +12 -12
- package/lib/lendMarkets/modules/v2/leverageV2ZapV2.d.ts +3 -3
- package/lib/lendMarkets/modules/v2/leverageV2ZapV2.js +10 -17
- package/lib/utils.d.ts +3 -11
- package/lib/utils.js +2 -10
- package/package.json +2 -2
- package/src/constants/aliases.ts +6 -6
- package/src/lendMarkets/interfaces/leverageZapV2.ts +30 -72
- package/src/lendMarkets/modules/common/leverageZapV2Base.ts +112 -175
- package/src/lendMarkets/modules/v1/leverageV1ZapV2.ts +9 -12
- package/src/lendMarkets/modules/v2/leverageV2ZapV2.ts +7 -17
- package/src/utils.ts +5 -27
|
@@ -42,40 +42,40 @@ export class LeverageV1ZapV2Module extends LeverageZapV2BaseModule {
|
|
|
42
42
|
return yield this.llamalend.contracts[this.market.addresses.controller].contract.health_calculator(user, _dCollateral, _dDebt, full, N, this.llamalend.constantOptions);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
_createLoanContractCall(_userCollateral,
|
|
45
|
+
_createLoanContractCall(_userCollateral, _debt, _minRecv, range, router, exchangeCalldata, estimateGas) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const zapCalldata = buildCalldataForLeverageZapV2(router, exchangeCalldata);
|
|
47
|
+
const zapCalldata = buildCalldataForLeverageZapV2({ controllerId: parseUnits(this._getMarketId(), 0), _minRecv, router, exchangeCalldata });
|
|
48
48
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
49
|
-
const gas = yield contract.create_loan_extended.estimateGas(_userCollateral, _debt, range, this._getLeverageZapAddress(), [
|
|
49
|
+
const gas = yield contract.create_loan_extended.estimateGas(_userCollateral, _debt, range, this._getLeverageZapAddress(), [], zapCalldata, Object.assign({}, this.llamalend.constantOptions));
|
|
50
50
|
if (estimateGas)
|
|
51
51
|
return smartNumber(gas);
|
|
52
52
|
yield this.llamalend.updateFeeData();
|
|
53
53
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
54
|
-
return (yield contract.create_loan_extended(_userCollateral, _debt, range, this._getLeverageZapAddress(), [
|
|
54
|
+
return (yield contract.create_loan_extended(_userCollateral, _debt, range, this._getLeverageZapAddress(), [], zapCalldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
_borrowMoreContractCall(_userCollateral,
|
|
57
|
+
_borrowMoreContractCall(_userCollateral, _debt, _minRecv, router, exchangeCalldata, estimateGas) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const zapCalldata = buildCalldataForLeverageZapV2(router, exchangeCalldata);
|
|
59
|
+
const zapCalldata = buildCalldataForLeverageZapV2({ controllerId: parseUnits(this._getMarketId(), 0), _minRecv, router, exchangeCalldata });
|
|
60
60
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
61
|
-
const gas = yield contract.borrow_more_extended.estimateGas(_userCollateral, _debt, this._getLeverageZapAddress(), [
|
|
61
|
+
const gas = yield contract.borrow_more_extended.estimateGas(_userCollateral, _debt, this._getLeverageZapAddress(), [], zapCalldata, Object.assign({}, this.llamalend.constantOptions));
|
|
62
62
|
if (estimateGas)
|
|
63
63
|
return smartNumber(gas);
|
|
64
64
|
yield this.llamalend.updateFeeData();
|
|
65
65
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
66
|
-
return (yield contract.borrow_more_extended(_userCollateral, _debt, this._getLeverageZapAddress(), [
|
|
66
|
+
return (yield contract.borrow_more_extended(_userCollateral, _debt, this._getLeverageZapAddress(), [], zapCalldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
_repayContractCall(_userCollateral,
|
|
69
|
+
_repayContractCall(_userCollateral, _minRecv, router, exchangeCalldata, estimateGas) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const zapCalldata = buildCalldataForLeverageZapV2(router, exchangeCalldata);
|
|
71
|
+
const zapCalldata = buildCalldataForLeverageZapV2({ controllerId: parseUnits(this._getMarketId(), 0), _minRecv, router, exchangeCalldata });
|
|
72
72
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
73
|
-
const gas = yield contract.repay_extended.estimateGas(this._getLeverageZapAddress(), [
|
|
73
|
+
const gas = yield contract.repay_extended.estimateGas(this._getLeverageZapAddress(), [], zapCalldata);
|
|
74
74
|
if (estimateGas)
|
|
75
75
|
return smartNumber(gas);
|
|
76
76
|
yield this.llamalend.updateFeeData();
|
|
77
77
|
const gasLimit = _mulBy1_3(DIGas(gas));
|
|
78
|
-
return (yield contract.repay_extended(this._getLeverageZapAddress(), [
|
|
78
|
+
return (yield contract.repay_extended(this._getLeverageZapAddress(), [], zapCalldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -8,7 +8,7 @@ export declare class LeverageV2ZapV2Module extends LeverageZapV2BaseModule {
|
|
|
8
8
|
protected _calcCreateLoanHealthCall(_collateral: bigint, _dDebt: bigint, N: number | bigint, full: boolean): Promise<bigint>;
|
|
9
9
|
protected _calcBorrowMoreHealthCall(_collateral: bigint, _dDebt: bigint, _N: number | bigint, user: string, full: boolean): Promise<bigint>;
|
|
10
10
|
protected _calcRepayHealthCall(_dCollateral: bigint, _dDebt: bigint, _N: number | bigint, user: string, full: boolean): Promise<bigint>;
|
|
11
|
-
protected _createLoanContractCall(_userCollateral: bigint,
|
|
12
|
-
protected _borrowMoreContractCall(_userCollateral: bigint,
|
|
13
|
-
protected _repayContractCall(_userCollateral: bigint,
|
|
11
|
+
protected _createLoanContractCall(_userCollateral: bigint, _debt: bigint, _minRecv: bigint, range: number, router: string, exchangeCalldata: string, estimateGas: boolean): Promise<string | TGas>;
|
|
12
|
+
protected _borrowMoreContractCall(_userCollateral: bigint, _debt: bigint, _minRecv: bigint, router: string, exchangeCalldata: string, estimateGas: boolean): Promise<string | TGas>;
|
|
13
|
+
protected _repayContractCall(_userCollateral: bigint, _minRecv: bigint, router: string, exchangeCalldata: string, estimateGas: boolean): Promise<string | TGas>;
|
|
14
14
|
}
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { LeverageZapV2BaseModule } from "../common/leverageZapV2Base.js";
|
|
11
|
-
import { _getAddress, smartNumber, _mulBy1_3, DIGas, MAX_ACTIVE_BAND,
|
|
11
|
+
import { _getAddress, smartNumber, _mulBy1_3, DIGas, MAX_ACTIVE_BAND, buildCalldataForLeverageZapV2, } from "../../../utils";
|
|
12
12
|
export class LeverageV2ZapV2Module extends LeverageZapV2BaseModule {
|
|
13
13
|
_getLeverageZapAddress() {
|
|
14
14
|
return this.llamalend.constants.ALIASES.leverage_zap_v2_llv2;
|
|
@@ -47,16 +47,14 @@ export class LeverageV2ZapV2Module extends LeverageZapV2BaseModule {
|
|
|
47
47
|
return yield this.llamalend.contracts[this.market.addresses.controller].contract.repay_health_preview(_dCollateralAbs, _dDebtAbs, user, _shrink, full, this.llamalend.constantOptions);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
_createLoanContractCall(_userCollateral,
|
|
50
|
+
_createLoanContractCall(_userCollateral, _debt, _minRecv, range, router, exchangeCalldata, estimateGas) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
52
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
53
53
|
const _for = _getAddress.call(this.llamalend, '');
|
|
54
54
|
const _callbacker = this._getLeverageZapAddress();
|
|
55
|
-
const zapCalldata =
|
|
56
|
-
op: 'create_loan',
|
|
55
|
+
const zapCalldata = buildCalldataForLeverageZapV2({
|
|
57
56
|
controllerId: this._getMarketId(),
|
|
58
|
-
|
|
59
|
-
minRecv: _minRecv,
|
|
57
|
+
_minRecv,
|
|
60
58
|
router,
|
|
61
59
|
exchangeCalldata,
|
|
62
60
|
});
|
|
@@ -68,16 +66,14 @@ export class LeverageV2ZapV2Module extends LeverageZapV2BaseModule {
|
|
|
68
66
|
return (yield contract.create_loan(_userCollateral, _debt, range, _for, _callbacker, zapCalldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
|
-
_borrowMoreContractCall(_userCollateral,
|
|
69
|
+
_borrowMoreContractCall(_userCollateral, _debt, _minRecv, router, exchangeCalldata, estimateGas) {
|
|
72
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
71
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
74
72
|
const _for = _getAddress.call(this.llamalend, '');
|
|
75
73
|
const _callbacker = this._getLeverageZapAddress();
|
|
76
|
-
const zapCalldata =
|
|
77
|
-
op: 'borrow_more',
|
|
74
|
+
const zapCalldata = buildCalldataForLeverageZapV2({
|
|
78
75
|
controllerId: this._getMarketId(),
|
|
79
|
-
|
|
80
|
-
minRecv: _minRecv,
|
|
76
|
+
_minRecv,
|
|
81
77
|
router,
|
|
82
78
|
exchangeCalldata,
|
|
83
79
|
});
|
|
@@ -89,17 +85,14 @@ export class LeverageV2ZapV2Module extends LeverageZapV2BaseModule {
|
|
|
89
85
|
return (yield contract.borrow_more(_userCollateral, _debt, _for, _callbacker, zapCalldata, Object.assign(Object.assign({}, this.llamalend.options), { gasLimit }))).hash;
|
|
90
86
|
});
|
|
91
87
|
}
|
|
92
|
-
_repayContractCall(_userCollateral,
|
|
88
|
+
_repayContractCall(_userCollateral, _minRecv, router, exchangeCalldata, estimateGas) {
|
|
93
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
90
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
95
91
|
const _for = _getAddress.call(this.llamalend, '');
|
|
96
92
|
const _callbacker = this._getLeverageZapAddress();
|
|
97
|
-
const zapCalldata =
|
|
98
|
-
op: 'repay',
|
|
93
|
+
const zapCalldata = buildCalldataForLeverageZapV2({
|
|
99
94
|
controllerId: this._getMarketId(),
|
|
100
|
-
|
|
101
|
-
userBorrowed: _userBorrowed,
|
|
102
|
-
minRecv: _minRecv,
|
|
95
|
+
_minRecv,
|
|
103
96
|
router,
|
|
104
97
|
exchangeCalldata,
|
|
105
98
|
});
|
package/lib/utils.d.ts
CHANGED
|
@@ -58,18 +58,10 @@ export declare const getLsdApy: ((name: "wstETH" | "sfrxETH") => Promise<{
|
|
|
58
58
|
apyMean30d: number;
|
|
59
59
|
}>>;
|
|
60
60
|
export declare const calculateFutureLeverage: (currentCollateral: number | string, totalDepositFromUser: number | string, collateral: number | string, operation: "add" | "remove") => string;
|
|
61
|
-
export declare const buildCalldataForLeverageZapV2: (routerAddress: string, exchangeCalldata: string) => string;
|
|
62
61
|
export type LeverageZapV2LLv2CalldataParams = {
|
|
63
62
|
controllerId: number | string | bigint;
|
|
64
|
-
|
|
63
|
+
_minRecv: bigint;
|
|
65
64
|
router: string;
|
|
66
65
|
exchangeCalldata: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
userBorrowed: bigint;
|
|
70
|
-
} | {
|
|
71
|
-
op: 'repay';
|
|
72
|
-
userCollateral: bigint;
|
|
73
|
-
userBorrowed: bigint;
|
|
74
|
-
});
|
|
75
|
-
export declare const buildCalldataForLeverageZapV2Llv2: (params: LeverageZapV2LLv2CalldataParams) => string;
|
|
66
|
+
};
|
|
67
|
+
export declare const buildCalldataForLeverageZapV2: (params: LeverageZapV2LLv2CalldataParams) => string;
|
package/lib/utils.js
CHANGED
|
@@ -443,17 +443,9 @@ export const calculateFutureLeverage = (currentCollateral, totalDepositFromUser,
|
|
|
443
443
|
return currentCollateralBN.minus(collateralBN).div(totalDepositBN.minus(collateralBN)).toString();
|
|
444
444
|
}
|
|
445
445
|
};
|
|
446
|
-
export const buildCalldataForLeverageZapV2 = (
|
|
447
|
-
const cleanCalldata = exchangeCalldata.startsWith('0x') ? exchangeCalldata.slice(2) : exchangeCalldata;
|
|
448
|
-
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
449
|
-
return abiCoder.encode(['address', 'bytes'], [routerAddress, '0x' + cleanCalldata]);
|
|
450
|
-
};
|
|
451
|
-
export const buildCalldataForLeverageZapV2Llv2 = (params) => {
|
|
446
|
+
export const buildCalldataForLeverageZapV2 = (params) => {
|
|
452
447
|
const cleanCalldata = params.exchangeCalldata.startsWith('0x') ? params.exchangeCalldata.slice(2) : params.exchangeCalldata;
|
|
453
448
|
const exchangeBytes = '0x' + cleanCalldata;
|
|
454
449
|
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
|
|
455
|
-
|
|
456
|
-
return abiCoder.encode(['uint256', 'uint256', 'uint256', 'uint256', 'address', 'bytes'], [BigInt(params.controllerId), params.userCollateral, params.userBorrowed, params.minRecv, params.router, exchangeBytes]);
|
|
457
|
-
}
|
|
458
|
-
return abiCoder.encode(['uint256', 'uint256', 'uint256', 'address', 'bytes'], [BigInt(params.controllerId), params.userBorrowed, params.minRecv, params.router, exchangeBytes]);
|
|
450
|
+
return abiCoder.encode(['uint256', 'uint256', 'address', 'bytes'], [BigInt(params.controllerId), params._minRecv, params.router, exchangeBytes]);
|
|
459
451
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/llamalend-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "JavaScript library for Curve Lending",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Macket",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@curvefi/ethcall": "6.0.16",
|
|
50
50
|
"bignumber.js": "9.3.1",
|
|
51
|
-
"ethers": "6.
|
|
51
|
+
"ethers": "6.17.0",
|
|
52
52
|
"memoizee": "0.4.17"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/constants/aliases.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const ALIASES_ETHEREUM = lowerCaseValues({
|
|
|
8
8
|
"minter": '0xd061D61a4d941c39E5453435B6345Dc261C2fcE0',
|
|
9
9
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
10
10
|
"leverage_zap_deprecated": "0xC8E8430dc7Cb23C32543329acCC68c9055C23e18", // odos v3
|
|
11
|
-
"leverage_zap_v2": "
|
|
11
|
+
"leverage_zap_v2": "0x19010d0f5D5a88aC609B568c91057679eed643d3",
|
|
12
12
|
"leverage_zap_v2_llv2": "0x0000000000000000000000000000000000000000",
|
|
13
13
|
"leverage_markets_start_id": "9",
|
|
14
14
|
"crvUSD": "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
@@ -21,7 +21,7 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
21
21
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
22
22
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
23
23
|
"leverage_zap_deprecated": "0xFE02553d3Ba4c3f39F36a4632F91404DF94b9AE2", // odos v3
|
|
24
|
-
"leverage_zap_v2": "
|
|
24
|
+
"leverage_zap_v2": "0x227d2f40E3a66C0344D8Af373b4d48A8744d6560",
|
|
25
25
|
"leverage_zap_v2_llv2": "0x0000000000000000000000000000000000000000",
|
|
26
26
|
"leverage_markets_start_id": "9",
|
|
27
27
|
});
|
|
@@ -35,8 +35,8 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
35
35
|
"gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
|
|
36
36
|
"old_gauge_end_index": "4",
|
|
37
37
|
"leverage_zap_deprecated": "0xBFab8ebc836E1c4D81837798FC076D219C9a1855", // odos v3
|
|
38
|
-
"leverage_zap_v2": "
|
|
39
|
-
"leverage_zap_v2_llv2": "
|
|
38
|
+
"leverage_zap_v2": "0x56C526b0159a258887e0d79ec3a80dfb940d0cD7",
|
|
39
|
+
"leverage_zap_v2_llv2": "0xdbeBDaE6f2D47B553B984E4091693824cf38584a",
|
|
40
40
|
"leverage_markets_start_id": "0",
|
|
41
41
|
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
|
|
42
42
|
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
|
|
@@ -50,7 +50,7 @@ export const ALIASES_FRAXTAL = lowerCaseValues({
|
|
|
50
50
|
"gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
|
|
51
51
|
"old_gauge_end_index": "3",
|
|
52
52
|
"leverage_zap_deprecated": "0x3294514B78Df4Bb90132567fcf8E5e99f390B687", // odos v3
|
|
53
|
-
"leverage_zap_v2": "
|
|
53
|
+
"leverage_zap_v2": "0xA7a4bb50AF91f90b6fEb3388E7f8286aF45b299B",
|
|
54
54
|
"leverage_zap_v2_llv2": "0x0000000000000000000000000000000000000000",
|
|
55
55
|
"leverage_markets_start_id": "0",
|
|
56
56
|
});
|
|
@@ -61,7 +61,7 @@ export const ALIASES_SONIC = lowerCaseValues({
|
|
|
61
61
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
62
62
|
"gauge_factory": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
|
|
63
63
|
"leverage_zap_deprecated": "0x0fE38dCC905eC14F6099a83Ac5C93BF2601300CF", // odos v3
|
|
64
|
-
"leverage_zap_v2": "
|
|
64
|
+
"leverage_zap_v2": "0xEfadDdE5B43917CcC738AdE6962295A0B343f7CE",
|
|
65
65
|
"leverage_zap_v2_llv2": "0x0000000000000000000000000000000000000000",
|
|
66
66
|
"leverage_markets_start_id": "0",
|
|
67
67
|
});
|
|
@@ -7,12 +7,10 @@ export interface ILeverageZapV2 {
|
|
|
7
7
|
|
|
8
8
|
createLoanMaxRecv: ({
|
|
9
9
|
userCollateral,
|
|
10
|
-
userBorrowed,
|
|
11
10
|
range,
|
|
12
11
|
getExpected,
|
|
13
12
|
}: {
|
|
14
13
|
userCollateral: TAmount,
|
|
15
|
-
userBorrowed: TAmount,
|
|
16
14
|
range: number,
|
|
17
15
|
getExpected: GetExpectedFn
|
|
18
16
|
}) => Promise<{
|
|
@@ -26,11 +24,9 @@ export interface ILeverageZapV2 {
|
|
|
26
24
|
}>,
|
|
27
25
|
createLoanMaxRecvAllRanges: ({
|
|
28
26
|
userCollateral,
|
|
29
|
-
userBorrowed,
|
|
30
27
|
getExpected,
|
|
31
28
|
}: {
|
|
32
29
|
userCollateral: TAmount,
|
|
33
|
-
userBorrowed: TAmount,
|
|
34
30
|
getExpected: GetExpectedFn
|
|
35
31
|
}) => Promise<IDict<{
|
|
36
32
|
maxDebt: string,
|
|
@@ -43,12 +39,10 @@ export interface ILeverageZapV2 {
|
|
|
43
39
|
}>>,
|
|
44
40
|
createLoanExpectedCollateral: ({
|
|
45
41
|
userCollateral,
|
|
46
|
-
userBorrowed,
|
|
47
42
|
debt,
|
|
48
43
|
quote,
|
|
49
44
|
}: {
|
|
50
45
|
userCollateral: TAmount,
|
|
51
|
-
userBorrowed: TAmount,
|
|
52
46
|
debt: TAmount,
|
|
53
47
|
quote: IQuote
|
|
54
48
|
}) => Promise<{
|
|
@@ -61,14 +55,12 @@ export interface ILeverageZapV2 {
|
|
|
61
55
|
}>,
|
|
62
56
|
createLoanExpectedMetrics: ({
|
|
63
57
|
userCollateral,
|
|
64
|
-
userBorrowed,
|
|
65
58
|
debt,
|
|
66
59
|
range,
|
|
67
60
|
quote,
|
|
68
61
|
healthIsFull,
|
|
69
62
|
}: {
|
|
70
63
|
userCollateral: TAmount,
|
|
71
|
-
userBorrowed: TAmount,
|
|
72
64
|
debt: TAmount,
|
|
73
65
|
range: number,
|
|
74
66
|
quote: IQuote,
|
|
@@ -76,59 +68,48 @@ export interface ILeverageZapV2 {
|
|
|
76
68
|
}) => Promise<ILeverageMetrics>,
|
|
77
69
|
createLoanMaxRange: ({
|
|
78
70
|
userCollateral,
|
|
79
|
-
userBorrowed,
|
|
80
71
|
debt,
|
|
81
72
|
getExpected,
|
|
82
73
|
}: {
|
|
83
74
|
userCollateral: TAmount,
|
|
84
|
-
userBorrowed: TAmount,
|
|
85
75
|
debt: TAmount,
|
|
86
76
|
getExpected: GetExpectedFn
|
|
87
77
|
}) => Promise<number>,
|
|
88
78
|
createLoanBandsAllRanges: ({
|
|
89
79
|
userCollateral,
|
|
90
|
-
userBorrowed,
|
|
91
80
|
debt,
|
|
92
81
|
getExpected,
|
|
93
82
|
quote,
|
|
94
83
|
}: {
|
|
95
84
|
userCollateral: TAmount,
|
|
96
|
-
userBorrowed: TAmount,
|
|
97
85
|
debt: TAmount,
|
|
98
86
|
getExpected: GetExpectedFn,
|
|
99
87
|
quote: IQuote
|
|
100
88
|
}) => Promise<IDict<[number, number] | null>>,
|
|
101
89
|
createLoanPricesAllRanges: ({
|
|
102
90
|
userCollateral,
|
|
103
|
-
userBorrowed,
|
|
104
91
|
debt,
|
|
105
92
|
getExpected,
|
|
106
93
|
quote,
|
|
107
94
|
}: {
|
|
108
95
|
userCollateral: TAmount,
|
|
109
|
-
userBorrowed: TAmount,
|
|
110
96
|
debt: TAmount,
|
|
111
97
|
getExpected: GetExpectedFn,
|
|
112
98
|
quote: IQuote
|
|
113
99
|
}) => Promise<IDict<[string, string] | null>>,
|
|
114
100
|
createLoanIsApproved: ({
|
|
115
101
|
userCollateral,
|
|
116
|
-
userBorrowed,
|
|
117
102
|
}: {
|
|
118
|
-
userCollateral: TAmount
|
|
119
|
-
userBorrowed: TAmount
|
|
103
|
+
userCollateral: TAmount
|
|
120
104
|
}) => Promise<boolean>,
|
|
121
105
|
createLoanApprove: ({
|
|
122
106
|
userCollateral,
|
|
123
|
-
userBorrowed,
|
|
124
107
|
}: {
|
|
125
|
-
userCollateral: TAmount
|
|
126
|
-
userBorrowed: TAmount
|
|
108
|
+
userCollateral: TAmount
|
|
127
109
|
}) => Promise<string[]>,
|
|
128
110
|
calcMinRecv: (expected: TAmount, slippage: number) => string,
|
|
129
111
|
createLoan: ({
|
|
130
112
|
userCollateral,
|
|
131
|
-
userBorrowed,
|
|
132
113
|
debt,
|
|
133
114
|
range,
|
|
134
115
|
minRecv,
|
|
@@ -136,7 +117,6 @@ export interface ILeverageZapV2 {
|
|
|
136
117
|
calldata,
|
|
137
118
|
}: {
|
|
138
119
|
userCollateral: TAmount,
|
|
139
|
-
userBorrowed: TAmount,
|
|
140
120
|
debt: TAmount,
|
|
141
121
|
range: number,
|
|
142
122
|
minRecv: TAmount,
|
|
@@ -144,9 +124,8 @@ export interface ILeverageZapV2 {
|
|
|
144
124
|
calldata: string
|
|
145
125
|
}) => Promise<string>,
|
|
146
126
|
|
|
147
|
-
borrowMoreMaxRecv: ({ userCollateral,
|
|
127
|
+
borrowMoreMaxRecv: ({ userCollateral, getExpected, address }: {
|
|
148
128
|
userCollateral: TAmount,
|
|
149
|
-
userBorrowed: TAmount,
|
|
150
129
|
getExpected: GetExpectedFn,
|
|
151
130
|
address?: string
|
|
152
131
|
}) => Promise<{
|
|
@@ -157,9 +136,8 @@ export interface ILeverageZapV2 {
|
|
|
157
136
|
collateralFromMaxDebt: string,
|
|
158
137
|
avgPrice: string,
|
|
159
138
|
}>,
|
|
160
|
-
borrowMoreExpectedCollateral: ({ userCollateral,
|
|
139
|
+
borrowMoreExpectedCollateral: ({ userCollateral, dDebt, quote, address }: {
|
|
161
140
|
userCollateral: TAmount,
|
|
162
|
-
userBorrowed: TAmount,
|
|
163
141
|
dDebt: TAmount,
|
|
164
142
|
quote: IQuote,
|
|
165
143
|
address?: string
|
|
@@ -170,42 +148,36 @@ export interface ILeverageZapV2 {
|
|
|
170
148
|
collateralFromDebt: string,
|
|
171
149
|
avgPrice: string
|
|
172
150
|
}>,
|
|
173
|
-
borrowMoreExpectedMetrics: ({ userCollateral,
|
|
151
|
+
borrowMoreExpectedMetrics: ({ userCollateral, debt, quote, healthIsFull, address }: {
|
|
174
152
|
userCollateral: TAmount,
|
|
175
|
-
userBorrowed: TAmount,
|
|
176
153
|
debt: TAmount,
|
|
177
154
|
quote: IQuote,
|
|
178
155
|
healthIsFull?: boolean,
|
|
179
156
|
address?: string
|
|
180
157
|
}) => Promise<ILeverageMetrics>,
|
|
181
|
-
borrowMoreIsApproved: ({ userCollateral
|
|
182
|
-
userCollateral: TAmount
|
|
183
|
-
userBorrowed: TAmount
|
|
158
|
+
borrowMoreIsApproved: ({ userCollateral }: {
|
|
159
|
+
userCollateral: TAmount
|
|
184
160
|
}) => Promise<boolean>,
|
|
185
|
-
borrowMoreApprove: ({ userCollateral
|
|
186
|
-
userCollateral: TAmount
|
|
187
|
-
userBorrowed: TAmount
|
|
161
|
+
borrowMoreApprove: ({ userCollateral }: {
|
|
162
|
+
userCollateral: TAmount
|
|
188
163
|
}) => Promise<string[]>,
|
|
189
|
-
borrowMore: ({ userCollateral,
|
|
164
|
+
borrowMore: ({ userCollateral, debt, minRecv, router, calldata }: {
|
|
190
165
|
userCollateral: TAmount,
|
|
191
|
-
userBorrowed: TAmount,
|
|
192
166
|
debt: TAmount,
|
|
193
167
|
minRecv: TAmount,
|
|
194
168
|
router: string,
|
|
195
169
|
calldata: string
|
|
196
170
|
}) => Promise<string>,
|
|
197
|
-
borrowMoreFutureLeverage: ({ userCollateral,
|
|
171
|
+
borrowMoreFutureLeverage: ({ userCollateral, debt, quote, address }: {
|
|
198
172
|
userCollateral: TAmount,
|
|
199
|
-
userBorrowed: TAmount,
|
|
200
173
|
debt: TAmount,
|
|
201
174
|
quote: IQuote,
|
|
202
175
|
address?: string
|
|
203
176
|
}) => Promise<string>,
|
|
204
177
|
|
|
205
|
-
repayExpectedBorrowed: ({ stateCollateral, userCollateral,
|
|
178
|
+
repayExpectedBorrowed: ({ stateCollateral, userCollateral, quote }: {
|
|
206
179
|
stateCollateral: TAmount,
|
|
207
180
|
userCollateral: TAmount,
|
|
208
|
-
userBorrowed: TAmount,
|
|
209
181
|
quote: IQuote
|
|
210
182
|
}) => Promise<{
|
|
211
183
|
totalBorrowed: string,
|
|
@@ -214,60 +186,50 @@ export interface ILeverageZapV2 {
|
|
|
214
186
|
userBorrowed: string,
|
|
215
187
|
avgPrice: string
|
|
216
188
|
}>,
|
|
217
|
-
repayIsFull: ({ stateCollateral, userCollateral,
|
|
189
|
+
repayIsFull: ({ stateCollateral, userCollateral, quote, address }: {
|
|
218
190
|
stateCollateral: TAmount,
|
|
219
191
|
userCollateral: TAmount,
|
|
220
|
-
userBorrowed: TAmount,
|
|
221
192
|
quote: IQuote,
|
|
222
193
|
address?: string
|
|
223
194
|
}) => Promise<boolean>,
|
|
224
|
-
repayIsAvailable: ({ stateCollateral, userCollateral,
|
|
195
|
+
repayIsAvailable: ({ stateCollateral, userCollateral, quote, address }: {
|
|
225
196
|
stateCollateral: TAmount,
|
|
226
197
|
userCollateral: TAmount,
|
|
227
|
-
userBorrowed: TAmount,
|
|
228
198
|
quote: IQuote,
|
|
229
199
|
address?: string
|
|
230
200
|
}) => Promise<boolean>,
|
|
231
|
-
repayExpectedMetrics: ({ stateCollateral, userCollateral,
|
|
201
|
+
repayExpectedMetrics: ({ stateCollateral, userCollateral, healthIsFull, quote, address }: {
|
|
232
202
|
stateCollateral: TAmount,
|
|
233
203
|
userCollateral: TAmount,
|
|
234
|
-
userBorrowed: TAmount,
|
|
235
204
|
healthIsFull: boolean,
|
|
236
205
|
quote: IQuote,
|
|
237
206
|
address: string
|
|
238
207
|
}) => Promise<ILeverageMetrics>,
|
|
239
|
-
repayIsApproved: ({ userCollateral
|
|
240
|
-
userCollateral: TAmount
|
|
241
|
-
userBorrowed: TAmount
|
|
208
|
+
repayIsApproved: ({ userCollateral }: {
|
|
209
|
+
userCollateral: TAmount
|
|
242
210
|
}) => Promise<boolean>,
|
|
243
|
-
repayApprove: ({ userCollateral
|
|
244
|
-
userCollateral: TAmount
|
|
245
|
-
userBorrowed: TAmount
|
|
211
|
+
repayApprove: ({ userCollateral }: {
|
|
212
|
+
userCollateral: TAmount
|
|
246
213
|
}) => Promise<string[]>,
|
|
247
|
-
repay: ({ stateCollateral, userCollateral,
|
|
214
|
+
repay: ({ stateCollateral, userCollateral, minRecv, router, calldata }: {
|
|
248
215
|
stateCollateral: TAmount,
|
|
249
216
|
userCollateral: TAmount,
|
|
250
|
-
userBorrowed: TAmount,
|
|
251
217
|
minRecv: TAmount,
|
|
252
218
|
router: string,
|
|
253
219
|
calldata: string
|
|
254
220
|
}) => Promise<string>,
|
|
255
|
-
repayFutureLeverage: ({ stateCollateral, userCollateral,
|
|
221
|
+
repayFutureLeverage: ({ stateCollateral, userCollateral, address }: {
|
|
256
222
|
stateCollateral: TAmount,
|
|
257
223
|
userCollateral: TAmount,
|
|
258
|
-
userBorrowed: TAmount,
|
|
259
|
-
quote: IQuote,
|
|
260
224
|
address?: string
|
|
261
225
|
}) => Promise<string>,
|
|
262
226
|
|
|
263
227
|
estimateGas: {
|
|
264
|
-
createLoanApprove: ({ userCollateral
|
|
265
|
-
userCollateral: TAmount
|
|
266
|
-
userBorrowed: TAmount
|
|
228
|
+
createLoanApprove: ({ userCollateral }: {
|
|
229
|
+
userCollateral: TAmount
|
|
267
230
|
}) => Promise<TGas>,
|
|
268
|
-
createLoan: ({ userCollateral,
|
|
231
|
+
createLoan: ({ userCollateral, debt, range, minRecv, router, calldata }: {
|
|
269
232
|
userCollateral: TAmount,
|
|
270
|
-
userBorrowed: TAmount,
|
|
271
233
|
debt: TAmount,
|
|
272
234
|
range: number,
|
|
273
235
|
minRecv: TAmount,
|
|
@@ -275,27 +237,23 @@ export interface ILeverageZapV2 {
|
|
|
275
237
|
calldata: string
|
|
276
238
|
}) => Promise<number>,
|
|
277
239
|
|
|
278
|
-
borrowMoreApprove: ({ userCollateral
|
|
279
|
-
userCollateral: TAmount
|
|
280
|
-
userBorrowed: TAmount
|
|
240
|
+
borrowMoreApprove: ({ userCollateral }: {
|
|
241
|
+
userCollateral: TAmount
|
|
281
242
|
}) => Promise<TGas>,
|
|
282
|
-
borrowMore: ({ userCollateral,
|
|
243
|
+
borrowMore: ({ userCollateral, debt, minRecv, router, calldata }: {
|
|
283
244
|
userCollateral: TAmount,
|
|
284
|
-
userBorrowed: TAmount,
|
|
285
245
|
debt: TAmount,
|
|
286
246
|
minRecv: TAmount,
|
|
287
247
|
router: string,
|
|
288
248
|
calldata: string
|
|
289
249
|
}) => Promise<number>,
|
|
290
250
|
|
|
291
|
-
repayApprove: ({ userCollateral
|
|
292
|
-
userCollateral: TAmount
|
|
293
|
-
userBorrowed: TAmount
|
|
251
|
+
repayApprove: ({ userCollateral }: {
|
|
252
|
+
userCollateral: TAmount
|
|
294
253
|
}) => Promise<TGas>,
|
|
295
|
-
repay: ({ stateCollateral, userCollateral,
|
|
254
|
+
repay: ({ stateCollateral, userCollateral, minRecv, router, calldata }: {
|
|
296
255
|
stateCollateral: TAmount,
|
|
297
256
|
userCollateral: TAmount,
|
|
298
|
-
userBorrowed: TAmount,
|
|
299
257
|
minRecv: TAmount,
|
|
300
258
|
router: string,
|
|
301
259
|
calldata: string
|