@curvefi/llamalend-api 2.0.10 → 2.0.12
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/docs/SUPPORT_LLv2.md +30 -0
- package/lib/constants/abis/ControllerV2.json +523 -508
- package/lib/constants/aliases.js +1 -1
- package/lib/lendMarkets/fetch/fetchFactoryData.js +2 -4
- package/lib/lendMarkets/fetch/fetchLendMarkets.js +1 -1
- package/lib/lendMarkets/interfaces/common/userPosition.d.ts +2 -0
- package/lib/lendMarkets/modules/common/userPosition.d.ts +2 -0
- package/lib/lendMarkets/modules/common/userPosition.js +3 -1
- package/lib/lendMarkets/modules/v2/loanV2.js +1 -1
- package/lib/mintMarkets/MintMarketTemplate.d.ts +1 -0
- package/lib/mintMarkets/MintMarketTemplate.js +1 -0
- package/package.json +1 -1
- package/src/constants/abis/ControllerV2.json +523 -508
- package/src/constants/aliases.ts +1 -1
- package/src/lendMarkets/fetch/fetchFactoryData.ts +2 -4
- package/src/lendMarkets/fetch/fetchLendMarkets.ts +1 -1
- package/src/lendMarkets/interfaces/common/userPosition.ts +2 -2
- package/src/lendMarkets/modules/common/userPosition.ts +5 -3
- package/src/lendMarkets/modules/v2/loanV2.ts +1 -1
- package/src/mintMarkets/MintMarketTemplate.ts +2 -1
package/src/constants/aliases.ts
CHANGED
|
@@ -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": "
|
|
32
|
+
"one_way_factory_v2": "0x68f33663b76874166Bf3C3cB2D7C117dFf38a262",
|
|
33
33
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
34
34
|
"gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
35
35
|
"gauge_factory": "0x871fBD4E01012e2E8457346059e8C189d664DbA4",
|
|
@@ -72,7 +72,6 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
|
|
|
72
72
|
|
|
73
73
|
for (let i = 0; i < markets_count; i++) {
|
|
74
74
|
calls.push(createCall(factory, 'markets', [i]));
|
|
75
|
-
calls.push(createCall(factory, 'names', [i]));
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
const res = await llamalend.multicallProvider.all(calls);
|
|
@@ -87,8 +86,7 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
|
|
|
87
86
|
const gauges: string[] = [];
|
|
88
87
|
|
|
89
88
|
for (let i = 0; i < markets_count; i++) {
|
|
90
|
-
const marketData = res[i
|
|
91
|
-
const name = res[(i * 2) + 1] as string;
|
|
89
|
+
const marketData = res[i] as any;
|
|
92
90
|
|
|
93
91
|
vaults.push(marketData[0].toLowerCase());
|
|
94
92
|
controllers.push(marketData[1].toLowerCase());
|
|
@@ -96,7 +94,7 @@ export const getFactoryMarketDataV2 = async (llamalend: Llamalend) => {
|
|
|
96
94
|
collateral_tokens.push(marketData[3].toLowerCase());
|
|
97
95
|
borrowed_tokens.push(marketData[4].toLowerCase());
|
|
98
96
|
monetary_policies.push(marketData[6].toLowerCase());
|
|
99
|
-
names.push(
|
|
97
|
+
names.push(''); // new factory does not give names, it's generated at the market creation level
|
|
100
98
|
gauges.push(llamalend.constants.ZERO_ADDRESS);
|
|
101
99
|
}
|
|
102
100
|
|
|
@@ -52,7 +52,7 @@ const registerMarkets = (
|
|
|
52
52
|
llamalend.constants.DECIMALS[gauges[index]] = 18;
|
|
53
53
|
|
|
54
54
|
const marketData = {
|
|
55
|
-
name: names[index]
|
|
55
|
+
name: names[index] || `${COIN_DATA[collateral_tokens[index]].symbol}/${COIN_DATA[borrowed_tokens[index]].symbol}`,
|
|
56
56
|
version: version,
|
|
57
57
|
addresses: {
|
|
58
58
|
amm: amms[index],
|
|
@@ -2,9 +2,9 @@ import {IDict} from "../../../interfaces";
|
|
|
2
2
|
|
|
3
3
|
export interface IUserPosition {
|
|
4
4
|
userLoanExists: (address?: string) => Promise<boolean>,
|
|
5
|
-
userStateBigInt: (address?: string) => Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint }>,
|
|
5
|
+
userStateBigInt: (address?: string) => Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint, isSoftLiquidation: boolean }>,
|
|
6
6
|
userBandsBigInt:(address: string) => Promise<bigint[]>,
|
|
7
|
-
userState: (address?: string) => Promise<{ collateral: string, borrowed: string, debt: string, N: string }>,
|
|
7
|
+
userState: (address?: string) => Promise<{ collateral: string, borrowed: string, debt: string, N: string, isSoftLiquidation: boolean }>,
|
|
8
8
|
userHealth: (full?: boolean, address?: string) => Promise<string>,
|
|
9
9
|
userBands: (address?: string) => Promise<number[]>,
|
|
10
10
|
userRange: (address?: string) => Promise<number>,
|
|
@@ -36,7 +36,7 @@ export class UserPositionModule implements IUserPosition {
|
|
|
36
36
|
maxAge: 10 * 1000, // 10s
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
public async userState(address = ""): Promise<{ collateral: string, borrowed: string, debt: string, N: string }> {
|
|
39
|
+
public async userState(address = ""): Promise<{ collateral: string, borrowed: string, debt: string, N: string, isSoftLiquidation: boolean }> {
|
|
40
40
|
const { _collateral, _borrowed, _debt, _N } = await this._userState(address);
|
|
41
41
|
|
|
42
42
|
return {
|
|
@@ -44,11 +44,13 @@ export class UserPositionModule implements IUserPosition {
|
|
|
44
44
|
borrowed: formatUnits(_borrowed, this.market.borrowed_token.decimals),
|
|
45
45
|
debt: formatUnits(_debt, this.market.borrowed_token.decimals),
|
|
46
46
|
N: formatUnits(_N, 0),
|
|
47
|
+
isSoftLiquidation: !!_debt && !!_borrowed,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
public async userStateBigInt(address = ""): Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint }> {
|
|
51
|
-
|
|
51
|
+
public async userStateBigInt(address = ""): Promise<{ _collateral: bigint, _borrowed: bigint, _debt: bigint, _N: bigint, isSoftLiquidation: boolean }> {
|
|
52
|
+
const state = await this._userState(address);
|
|
53
|
+
return { ...state, isSoftLiquidation: !!state._debt && !!state._borrowed };
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
public async userHealth(full = true, address = ""): Promise<string> {
|
|
@@ -68,7 +68,7 @@ export class LoanV2Module extends LoanBaseModule implements ILoanV2 {
|
|
|
68
68
|
const contract = this.llamalend.contracts[this.market.addresses.controller].contract;
|
|
69
69
|
const collateral = parseUnits(collateralAmount, this.market.collateral_token.decimals)
|
|
70
70
|
const address = _getAddress.call(this.llamalend, '');
|
|
71
|
-
const N =
|
|
71
|
+
const N = BigInt(range || 0);
|
|
72
72
|
|
|
73
73
|
return contract.max_borrowable(collateral, N, address, this.llamalend.constantOptions);
|
|
74
74
|
}
|
|
@@ -536,13 +536,14 @@ export class MintMarketTemplate {
|
|
|
536
536
|
return { _collateral, _stablecoin, _debt }
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
-
public async userState(address = ""): Promise<{ collateral: string, stablecoin: string, debt: string }> {
|
|
539
|
+
public async userState(address = ""): Promise<{ collateral: string, stablecoin: string, debt: string, isSoftLiquidation: boolean }> {
|
|
540
540
|
const { _collateral, _stablecoin, _debt } = await this._userState(address);
|
|
541
541
|
|
|
542
542
|
return {
|
|
543
543
|
collateral: formatUnits(_collateral, this.collateralDecimals),
|
|
544
544
|
stablecoin: formatUnits(_stablecoin),
|
|
545
545
|
debt: formatUnits(_debt),
|
|
546
|
+
isSoftLiquidation: !!_debt && !!_stablecoin,
|
|
546
547
|
};
|
|
547
548
|
}
|
|
548
549
|
|