@curvefi/llamalend-api 2.0.16 → 2.0.18

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.
@@ -510,22 +510,6 @@
510
510
  "stateMutability": "nonpayable",
511
511
  "type": "function"
512
512
  },
513
- {
514
- "inputs": [
515
- {
516
- "name": "_collateral",
517
- "type": "uint256"
518
- },
519
- {
520
- "name": "_for",
521
- "type": "address"
522
- }
523
- ],
524
- "name": "remove_collateral",
525
- "outputs": [],
526
- "stateMutability": "nonpayable",
527
- "type": "function"
528
- },
529
513
  {
530
514
  "inputs": [
531
515
  {
@@ -1015,10 +999,6 @@
1015
999
  "name": "_for",
1016
1000
  "type": "address"
1017
1001
  },
1018
- {
1019
- "name": "_caller",
1020
- "type": "address"
1021
- },
1022
1002
  {
1023
1003
  "name": "_full",
1024
1004
  "type": "bool"
@@ -1624,27 +1604,6 @@
1624
1604
  "stateMutability": "view",
1625
1605
  "type": "function"
1626
1606
  },
1627
- {
1628
- "inputs": [
1629
- {
1630
- "name": "_debt",
1631
- "type": "uint256"
1632
- },
1633
- {
1634
- "name": "_N",
1635
- "type": "uint256"
1636
- }
1637
- ],
1638
- "name": "min_collateral",
1639
- "outputs": [
1640
- {
1641
- "name": "",
1642
- "type": "uint256"
1643
- }
1644
- ],
1645
- "stateMutability": "view",
1646
- "type": "function"
1647
- },
1648
1607
  {
1649
1608
  "inputs": [
1650
1609
  {
@@ -25,7 +25,7 @@ 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": "0x68f33663b76874166Bf3C3cB2D7C117dFf38a262",
28
+ "one_way_factory_v2": "0x1973ED17c267245510a390e0dce4FBcD9D2685f0",
29
29
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
30
30
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
31
31
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
@@ -5,6 +5,7 @@ export declare class LoanV2Module extends LoanBaseModule implements ILoanV2 {
5
5
  createLoanHealth(collateral: number | string, debt: number | string, range: number, full?: boolean): Promise<string>;
6
6
  addCollateralHealth(collateral: number | string, full?: boolean, address?: string): Promise<string>;
7
7
  removeCollateralHealth(collateral: number | string, full?: boolean, address?: string): Promise<string>;
8
+ maxRemovable(): Promise<string>;
8
9
  borrowMoreHealth(collateral: number | string, debt: number | string, full?: boolean, address?: string): Promise<string>;
9
10
  repayHealth({ debt, shrink, full, address }: {
10
11
  debt: number | string;
@@ -35,7 +35,7 @@ export class LoanV2Module extends LoanBaseModule {
35
35
  address = _getAddress.call(this.llamalend, address);
36
36
  const _collateral = parseUnits(collateral, this.market.collateral_token.decimals);
37
37
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
38
- const _health = yield contract.add_collateral_health_preview(_collateral, address, address, full, this.llamalend.constantOptions);
38
+ const _health = yield contract.add_collateral_health_preview(_collateral, address, full, this.llamalend.constantOptions);
39
39
  return formatUnits(_health * BigInt(100));
40
40
  });
41
41
  }
@@ -48,6 +48,14 @@ export class LoanV2Module extends LoanBaseModule {
48
48
  return formatUnits(_health * BigInt(100));
49
49
  });
50
50
  }
51
+ maxRemovable() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const address = _getAddress.call(this.llamalend, '');
54
+ const { _collateral: _currentCollateral, _debt: _currentDebt, _N } = yield this.market.userPosition.userStateBigInt();
55
+ const _requiredCollateral = yield this.llamalend.contracts[this.market.addresses.controller].contract.min_collateral(_currentDebt, _N, address, this.llamalend.constantOptions);
56
+ return formatUnits(_currentCollateral - _requiredCollateral, this.market.collateral_token.decimals);
57
+ });
58
+ }
51
59
  borrowMoreHealth(collateral_1, debt_1) {
52
60
  return __awaiter(this, arguments, void 0, function* (collateral, debt, full = true, address = "") {
53
61
  address = _getAddress.call(this.llamalend, address);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/llamalend-api",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "description": "JavaScript library for Curve Lending",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -510,22 +510,6 @@
510
510
  "stateMutability": "nonpayable",
511
511
  "type": "function"
512
512
  },
513
- {
514
- "inputs": [
515
- {
516
- "name": "_collateral",
517
- "type": "uint256"
518
- },
519
- {
520
- "name": "_for",
521
- "type": "address"
522
- }
523
- ],
524
- "name": "remove_collateral",
525
- "outputs": [],
526
- "stateMutability": "nonpayable",
527
- "type": "function"
528
- },
529
513
  {
530
514
  "inputs": [
531
515
  {
@@ -1015,10 +999,6 @@
1015
999
  "name": "_for",
1016
1000
  "type": "address"
1017
1001
  },
1018
- {
1019
- "name": "_caller",
1020
- "type": "address"
1021
- },
1022
1002
  {
1023
1003
  "name": "_full",
1024
1004
  "type": "bool"
@@ -1624,27 +1604,6 @@
1624
1604
  "stateMutability": "view",
1625
1605
  "type": "function"
1626
1606
  },
1627
- {
1628
- "inputs": [
1629
- {
1630
- "name": "_debt",
1631
- "type": "uint256"
1632
- },
1633
- {
1634
- "name": "_N",
1635
- "type": "uint256"
1636
- }
1637
- ],
1638
- "name": "min_collateral",
1639
- "outputs": [
1640
- {
1641
- "name": "",
1642
- "type": "uint256"
1643
- }
1644
- ],
1645
- "stateMutability": "view",
1646
- "type": "function"
1647
- },
1648
1607
  {
1649
1608
  "inputs": [
1650
1609
  {
@@ -29,7 +29,7 @@ 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": "0x68f33663b76874166Bf3C3cB2D7C117dFf38a262",
32
+ "one_way_factory_v2": "0x1973ED17c267245510a390e0dce4FBcD9D2685f0",
33
33
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
34
34
  "gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
35
35
  "gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
@@ -59,4 +59,4 @@ export const ALIASES_SONIC = lowerCaseValues({
59
59
  "leverage_zap": "0x0fE38dCC905eC14F6099a83Ac5C93BF2601300CF", // odos v3
60
60
  "leverage_zap_v2": "0x0000000000000000000000000000000000000000",
61
61
  "leverage_markets_start_id": "0",
62
- });
62
+ });
@@ -28,7 +28,7 @@ export class LoanV2Module extends LoanBaseModule implements ILoanV2 {
28
28
  const _collateral = parseUnits(collateral, this.market.collateral_token.decimals);
29
29
 
30
30
  const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
31
- const _health = await contract.add_collateral_health_preview(_collateral, address, address, full, this.llamalend.constantOptions) as bigint;
31
+ const _health = await contract.add_collateral_health_preview(_collateral, address, full, this.llamalend.constantOptions) as bigint;
32
32
 
33
33
  return formatUnits(_health * BigInt(100));
34
34
  }
@@ -43,6 +43,14 @@ export class LoanV2Module extends LoanBaseModule implements ILoanV2 {
43
43
  return formatUnits(_health * BigInt(100));
44
44
  }
45
45
 
46
+ public async maxRemovable(): Promise<string> {
47
+ const address = _getAddress.call(this.llamalend, '');
48
+ const { _collateral: _currentCollateral, _debt: _currentDebt, _N } = await this.market.userPosition.userStateBigInt();
49
+ const _requiredCollateral = await this.llamalend.contracts[this.market.addresses.controller].contract.min_collateral(_currentDebt, _N, address, this.llamalend.constantOptions)
50
+
51
+ return formatUnits(_currentCollateral - _requiredCollateral, this.market.collateral_token.decimals);
52
+ }
53
+
46
54
  public async borrowMoreHealth(collateral: number | string, debt: number | string, full = true, address = ""): Promise<string> {
47
55
  address = _getAddress.call(this.llamalend, address);
48
56
  const _collateral = parseUnits(collateral, this.market.collateral_token.decimals);