@curvefi/llamalend-api 2.0.24 → 2.0.26
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/MARKET_DATA_INPUTS.md +64 -0
- package/lib/constants/abis/ControllerV2.json +0 -93
- package/lib/constants/llammas.js +0 -8
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/interfaces.d.ts +0 -2
- package/lib/lendMarkets/fetch/fetchLendMarkets.js +2 -20
- package/lib/lendMarkets/lendMarketConstructor.d.ts +2 -0
- package/lib/lendMarkets/lendMarketConstructor.js +11 -0
- package/lib/lendMarkets/setupContracts.d.ts +3 -0
- package/lib/lendMarkets/setupContracts.js +30 -0
- package/lib/llamalend.js +2 -1
- package/lib/mintMarkets/fetch/fetchMintMarkets.js +23 -31
- package/lib/mintMarkets/mintMarketConstructor.d.ts +2 -0
- package/lib/mintMarkets/mintMarketConstructor.js +6 -0
- package/lib/mintMarkets/monetaryPolicyAbi.d.ts +1 -0
- package/lib/mintMarkets/monetaryPolicyAbi.js +10 -0
- package/lib/mintMarkets/setupContracts.d.ts +3 -0
- package/lib/mintMarkets/setupContracts.js +27 -0
- package/package.json +1 -1
- package/src/constants/abis/ControllerV2.json +0 -93
- package/src/constants/llammas.ts +0 -8
- package/src/index.ts +4 -0
- package/src/interfaces.ts +0 -2
- package/src/lendMarkets/fetch/fetchLendMarkets.ts +3 -22
- package/src/lendMarkets/lendMarketConstructor.ts +14 -0
- package/src/lendMarkets/setupContracts.ts +39 -0
- package/src/llamalend.ts +2 -1
- package/src/mintMarkets/fetch/fetchMintMarkets.ts +35 -33
- package/src/mintMarkets/mintMarketConstructor.ts +9 -0
- package/src/mintMarkets/monetaryPolicyAbi.ts +12 -0
- package/src/mintMarkets/setupContracts.ts +35 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Market Data Inputs
|
|
2
|
+
|
|
3
|
+
Data shapes required by the "by-data" constructors:
|
|
4
|
+
|
|
5
|
+
| Function | Input type |
|
|
6
|
+
|-------------------------|-----------------|
|
|
7
|
+
| `getMintMarketByData` | `ILlamma` |
|
|
8
|
+
| `getLendMarketByData` | `IOneWayMarket` |
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## `ILlamma` — for `getMintMarketByData`
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
interface ILlamma {
|
|
16
|
+
amm_address: string; // LLAMMA AMM address
|
|
17
|
+
controller_address: string; // Controller address
|
|
18
|
+
monetary_policy_address: string; // Monetary policy address
|
|
19
|
+
collateral_address: string; // Collateral ERC-20 (use 0xeee...eee for native ETH)
|
|
20
|
+
leverage_zap: string; // Leverage zap (ZERO_ADDRESS if unsupported)
|
|
21
|
+
deleverage_zap: string; // Deleverage zap (ZERO_ADDRESS if unsupported)
|
|
22
|
+
health_calculator_zap?: string; // Optional health-calc helper
|
|
23
|
+
collateral_symbol: string; // e.g. "ETH", "wstETH"
|
|
24
|
+
collateral_decimals: number; // Collateral decimals
|
|
25
|
+
min_bands: number; // Min bands (prod: 4)
|
|
26
|
+
max_bands: number; // Max bands (prod: 50)
|
|
27
|
+
default_bands: number; // Default bands (prod: 10)
|
|
28
|
+
A: number; // LLAMMA amplification (prod: 100)
|
|
29
|
+
is_deleverage_supported?: boolean; // Defaults to false
|
|
30
|
+
index?: number; // Sequential factory index
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## `IOneWayMarket` — for `getLendMarketByData`
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
interface IOneWayMarket {
|
|
40
|
+
name: string; // Empty → auto: "<collateral>/<borrowed>"
|
|
41
|
+
version: "v1" | "v2"; // Selects controller ABI & module set
|
|
42
|
+
addresses: {
|
|
43
|
+
amm: string;
|
|
44
|
+
controller: string;
|
|
45
|
+
borrowed_token: string;
|
|
46
|
+
collateral_token: string;
|
|
47
|
+
monetary_policy: string;
|
|
48
|
+
vault: string;
|
|
49
|
+
gauge: string; // ZERO_ADDRESS if none
|
|
50
|
+
};
|
|
51
|
+
borrowed_token: {
|
|
52
|
+
address: string; // Must match addresses.borrowed_token
|
|
53
|
+
name: string; // e.g. "Curve.Fi USD Stablecoin"
|
|
54
|
+
symbol: string; // e.g. "crvUSD"
|
|
55
|
+
decimals: number; // Token decimals
|
|
56
|
+
};
|
|
57
|
+
collateral_token: {
|
|
58
|
+
address: string; // Must match addresses.collateral_token
|
|
59
|
+
name: string; // e.g. "Wrapped Ether"
|
|
60
|
+
symbol: string; // e.g. "WETH"
|
|
61
|
+
decimals: number; // Token decimals
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
```
|
|
@@ -670,78 +670,6 @@
|
|
|
670
670
|
"stateMutability": "nonpayable",
|
|
671
671
|
"type": "function"
|
|
672
672
|
},
|
|
673
|
-
{
|
|
674
|
-
"inputs": [
|
|
675
|
-
{
|
|
676
|
-
"name": "_user",
|
|
677
|
-
"type": "address"
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
"name": "_min_x",
|
|
681
|
-
"type": "uint256"
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
"name": "_frac",
|
|
685
|
-
"type": "uint256"
|
|
686
|
-
}
|
|
687
|
-
],
|
|
688
|
-
"name": "liquidate",
|
|
689
|
-
"outputs": [],
|
|
690
|
-
"stateMutability": "nonpayable",
|
|
691
|
-
"type": "function"
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
"inputs": [
|
|
695
|
-
{
|
|
696
|
-
"name": "_user",
|
|
697
|
-
"type": "address"
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
"name": "_min_x",
|
|
701
|
-
"type": "uint256"
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
"name": "_frac",
|
|
705
|
-
"type": "uint256"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
"name": "_callbacker",
|
|
709
|
-
"type": "address"
|
|
710
|
-
}
|
|
711
|
-
],
|
|
712
|
-
"name": "liquidate",
|
|
713
|
-
"outputs": [],
|
|
714
|
-
"stateMutability": "nonpayable",
|
|
715
|
-
"type": "function"
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
"inputs": [
|
|
719
|
-
{
|
|
720
|
-
"name": "_user",
|
|
721
|
-
"type": "address"
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
"name": "_min_x",
|
|
725
|
-
"type": "uint256"
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
"name": "_frac",
|
|
729
|
-
"type": "uint256"
|
|
730
|
-
},
|
|
731
|
-
{
|
|
732
|
-
"name": "_callbacker",
|
|
733
|
-
"type": "address"
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
"name": "_calldata",
|
|
737
|
-
"type": "bytes"
|
|
738
|
-
}
|
|
739
|
-
],
|
|
740
|
-
"name": "liquidate",
|
|
741
|
-
"outputs": [],
|
|
742
|
-
"stateMutability": "nonpayable",
|
|
743
|
-
"type": "function"
|
|
744
|
-
},
|
|
745
673
|
{
|
|
746
674
|
"inputs": [],
|
|
747
675
|
"name": "save_rate",
|
|
@@ -1263,27 +1191,6 @@
|
|
|
1263
1191
|
"stateMutability": "view",
|
|
1264
1192
|
"type": "function"
|
|
1265
1193
|
},
|
|
1266
|
-
{
|
|
1267
|
-
"inputs": [
|
|
1268
|
-
{
|
|
1269
|
-
"name": "_user",
|
|
1270
|
-
"type": "address"
|
|
1271
|
-
},
|
|
1272
|
-
{
|
|
1273
|
-
"name": "_frac",
|
|
1274
|
-
"type": "uint256"
|
|
1275
|
-
}
|
|
1276
|
-
],
|
|
1277
|
-
"name": "tokens_to_liquidate",
|
|
1278
|
-
"outputs": [
|
|
1279
|
-
{
|
|
1280
|
-
"name": "",
|
|
1281
|
-
"type": "uint256"
|
|
1282
|
-
}
|
|
1283
|
-
],
|
|
1284
|
-
"stateMutability": "view",
|
|
1285
|
-
"type": "function"
|
|
1286
|
-
},
|
|
1287
1194
|
{
|
|
1288
1195
|
"inputs": [
|
|
1289
1196
|
{
|
package/lib/constants/llammas.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with { type: 'json' };
|
|
2
|
-
import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with { type: 'json' };
|
|
3
1
|
import { lowerCaseLlammasAddresses } from "./utils.js";
|
|
4
2
|
export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
5
3
|
sfrxeth: {
|
|
@@ -15,7 +13,6 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
15
13
|
max_bands: 50,
|
|
16
14
|
default_bands: 10,
|
|
17
15
|
A: 100,
|
|
18
|
-
monetary_policy_abi: MonetaryPolicyABI,
|
|
19
16
|
},
|
|
20
17
|
wsteth: {
|
|
21
18
|
amm_address: '0x37417b2238aa52d0dd2d6252d989e728e8f706e4',
|
|
@@ -30,7 +27,6 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
30
27
|
max_bands: 50,
|
|
31
28
|
default_bands: 10,
|
|
32
29
|
A: 100,
|
|
33
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
34
30
|
},
|
|
35
31
|
wbtc: {
|
|
36
32
|
amm_address: '0xe0438eb3703bf871e31ce639bd351109c88666ea',
|
|
@@ -46,7 +42,6 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
46
42
|
max_bands: 50,
|
|
47
43
|
default_bands: 10,
|
|
48
44
|
A: 100,
|
|
49
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
50
45
|
},
|
|
51
46
|
eth: {
|
|
52
47
|
amm_address: '0x1681195c176239ac5e72d9aebacf5b2492e0c4ee',
|
|
@@ -61,7 +56,6 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
61
56
|
max_bands: 50,
|
|
62
57
|
default_bands: 10,
|
|
63
58
|
A: 100,
|
|
64
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
65
59
|
},
|
|
66
60
|
sfrxeth2: {
|
|
67
61
|
amm_address: '0xfa96ad0a9e64261db86950e2da362f5572c5c6fd',
|
|
@@ -76,7 +70,6 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
76
70
|
max_bands: 50,
|
|
77
71
|
default_bands: 10,
|
|
78
72
|
A: 100,
|
|
79
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
80
73
|
},
|
|
81
74
|
tbtc: {
|
|
82
75
|
amm_address: '0xf9bd9da2427a50908c4c6d1599d8e62837c2bcb0',
|
|
@@ -91,6 +84,5 @@ export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
|
91
84
|
max_bands: 50,
|
|
92
85
|
default_bands: 10,
|
|
93
86
|
A: 100,
|
|
94
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
95
87
|
},
|
|
96
88
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare function createLlamalend(): {
|
|
|
28
28
|
MintMarketTemplate: typeof MintMarketTemplate;
|
|
29
29
|
getLendMarket: (lendMarketId: string) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
30
30
|
getMintMarket: (mintMarketId: string) => MintMarketTemplate;
|
|
31
|
+
getLendMarketByData: (id: string, marketData: import("./interfaces.js").IOneWayMarket) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
32
|
+
getMintMarketByData: (id: string, llammaData: import("./interfaces.js").ILlamma) => MintMarketTemplate;
|
|
31
33
|
totalSupply: () => Promise<{
|
|
32
34
|
total: string;
|
|
33
35
|
minted: string;
|
|
@@ -132,6 +134,8 @@ declare const _default: {
|
|
|
132
134
|
MintMarketTemplate: typeof MintMarketTemplate;
|
|
133
135
|
getLendMarket: (lendMarketId: string) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
134
136
|
getMintMarket: (mintMarketId: string) => MintMarketTemplate;
|
|
137
|
+
getLendMarketByData: (id: string, marketData: import("./interfaces.js").IOneWayMarket) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
138
|
+
getMintMarketByData: (id: string, llammaData: import("./interfaces.js").ILlamma) => MintMarketTemplate;
|
|
135
139
|
totalSupply: () => Promise<{
|
|
136
140
|
total: string;
|
|
137
141
|
minted: string;
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import { MintMarketTemplate, getMintMarket } from "./mintMarkets/index.js";
|
|
|
12
12
|
import { Llamalend } from "./llamalend.js";
|
|
13
13
|
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getGasPriceFromL2, getGasInfoForL2, getGasPriceFromL1, totalSupply, getLsdApy, } from "./utils.js";
|
|
14
14
|
import { convertToAssets, convertToShares, userBalances, totalSupplyAndCrvUSDLocked, maxDeposit, previewDeposit, depositIsApproved, depositAllowance, depositApproveEstimateGas, depositApprove, depositEstimateGas, deposit, maxMint, previewMint, mintIsApproved, mintAllowance, mintApproveEstimateGas, mintApprove, mintEstimateGas, mint, maxWithdraw, previewWithdraw, withdrawEstimateGas, withdraw, maxRedeem, previewRedeem, redeemEstimateGas, redeem, } from "./st-crvUSD.js";
|
|
15
|
+
import { getMintMarketByData } from "./mintMarkets/mintMarketConstructor.js";
|
|
16
|
+
import { getLendMarketByData } from "./lendMarkets/lendMarketConstructor.js";
|
|
15
17
|
export function createLlamalend() {
|
|
16
18
|
const llamalend = new Llamalend();
|
|
17
19
|
return {
|
|
@@ -32,6 +34,8 @@ export function createLlamalend() {
|
|
|
32
34
|
// Market constructors
|
|
33
35
|
getLendMarket: getLendMarket.bind(llamalend),
|
|
34
36
|
getMintMarket: getMintMarket.bind(llamalend),
|
|
37
|
+
getLendMarketByData: getLendMarketByData.bind(llamalend),
|
|
38
|
+
getMintMarketByData: getMintMarketByData.bind(llamalend),
|
|
35
39
|
// Utility functions
|
|
36
40
|
totalSupply: totalSupply.bind(llamalend),
|
|
37
41
|
getLsdApy: getLsdApy.bind(llamalend),
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export interface ILlamma {
|
|
|
34
34
|
max_bands: number;
|
|
35
35
|
default_bands: number;
|
|
36
36
|
A: number;
|
|
37
|
-
monetary_policy_abi: any;
|
|
38
37
|
is_deleverage_supported?: boolean;
|
|
39
38
|
index?: number;
|
|
40
39
|
}
|
|
@@ -215,7 +214,6 @@ export interface ILlamma {
|
|
|
215
214
|
max_bands: number;
|
|
216
215
|
default_bands: number;
|
|
217
216
|
A: number;
|
|
218
|
-
monetary_policy_abi: any;
|
|
219
217
|
}
|
|
220
218
|
export interface IResponseApi {
|
|
221
219
|
data: any;
|
|
@@ -8,26 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { getFactoryMarketDataV1, getFactoryMarketDataV2, getFactoryMarketDataByAPI } from "./fetchFactoryData.js";
|
|
11
|
-
import
|
|
12
|
-
import ControllerABI from '../../constants/abis/Controller.json' with { type: 'json' };
|
|
13
|
-
import ControllerV2ABI from '../../constants/abis/ControllerV2.json' with { type: 'json' };
|
|
14
|
-
import MonetaryPolicyABI from '../../constants/abis/MonetaryPolicy.json' with { type: 'json' };
|
|
15
|
-
import VaultABI from '../../constants/abis/Vault.json' with { type: 'json' };
|
|
16
|
-
import GaugeABI from '../../constants/abis/GaugeV5.json' with { type: 'json' };
|
|
17
|
-
import SidechainGaugeABI from '../../constants/abis/SidechainGauge.json' with { type: 'json' };
|
|
18
|
-
const controllerAbiMap = {
|
|
19
|
-
'v1': ControllerABI,
|
|
20
|
-
'v2': ControllerV2ABI,
|
|
21
|
-
};
|
|
11
|
+
import { setupLendMarketContracts } from "../setupContracts.js";
|
|
22
12
|
const registerMarkets = (llamalend, names, amms, controllers, borrowed_tokens, collateral_tokens, monetary_policies, vaults, gauges, COIN_DATA, version) => {
|
|
23
13
|
amms.forEach((amm, index) => {
|
|
24
|
-
llamalend.setContract(amms[index], LlammaABI);
|
|
25
|
-
llamalend.setContract(controllers[index], controllerAbiMap[version]);
|
|
26
|
-
llamalend.setContract(monetary_policies[index], MonetaryPolicyABI);
|
|
27
|
-
llamalend.setContract(vaults[index], VaultABI);
|
|
28
|
-
if (gauges[index]) {
|
|
29
|
-
llamalend.setContract(gauges[index], llamalend.chainId === 1 ? GaugeABI : SidechainGaugeABI);
|
|
30
|
-
}
|
|
31
14
|
COIN_DATA[vaults[index]] = {
|
|
32
15
|
address: vaults[index],
|
|
33
16
|
decimals: 18,
|
|
@@ -40,8 +23,6 @@ const registerMarkets = (llamalend, names, amms, controllers, borrowed_tokens, c
|
|
|
40
23
|
name: "curve.finance " + COIN_DATA[borrowed_tokens[index]].name + " Gauge Deposit",
|
|
41
24
|
symbol: "cv" + COIN_DATA[borrowed_tokens[index]].symbol + "-gauge",
|
|
42
25
|
};
|
|
43
|
-
llamalend.constants.DECIMALS[vaults[index]] = 18;
|
|
44
|
-
llamalend.constants.DECIMALS[gauges[index]] = 18;
|
|
45
26
|
const marketData = {
|
|
46
27
|
name: names[index] || `${COIN_DATA[collateral_tokens[index]].symbol}/${COIN_DATA[borrowed_tokens[index]].symbol}`,
|
|
47
28
|
version: version,
|
|
@@ -57,6 +38,7 @@ const registerMarkets = (llamalend, names, amms, controllers, borrowed_tokens, c
|
|
|
57
38
|
borrowed_token: COIN_DATA[borrowed_tokens[index]],
|
|
58
39
|
collateral_token: COIN_DATA[collateral_tokens[index]],
|
|
59
40
|
};
|
|
41
|
+
setupLendMarketContracts(llamalend, marketData);
|
|
60
42
|
if (version === 'v2') {
|
|
61
43
|
llamalend.constants.ONE_WAY_MARKETS_V2[`one-way-market-v2-${index}`] = marketData;
|
|
62
44
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { LendMarketTemplate } from "./LendMarketTemplate.js";
|
|
2
|
+
import type { IOneWayMarket } from "../interfaces.js";
|
|
2
3
|
import type { Llamalend } from "../llamalend.js";
|
|
3
4
|
export declare const getLendMarket: (this: Llamalend, lendMarketId: string) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
5
|
+
export declare const getLendMarketByData: (this: Llamalend, id: string, marketData: IOneWayMarket) => LendMarketTemplate<"v1"> | LendMarketTemplate<"v2">;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LendMarketTemplate } from "./LendMarketTemplate.js";
|
|
2
|
+
import { setupLendMarketContracts } from "./setupContracts.js";
|
|
2
3
|
export const getLendMarket = function (lendMarketId) {
|
|
3
4
|
if (!(lendMarketId in this.lendMarkets)) {
|
|
4
5
|
const marketData = this.constants.ONE_WAY_MARKETS[lendMarketId] || this.constants.ONE_WAY_MARKETS_V2[lendMarketId];
|
|
@@ -13,3 +14,13 @@ export const getLendMarket = function (lendMarketId) {
|
|
|
13
14
|
}
|
|
14
15
|
return this.lendMarkets[lendMarketId];
|
|
15
16
|
};
|
|
17
|
+
export const getLendMarketByData = function (id, marketData) {
|
|
18
|
+
setupLendMarketContracts(this, marketData);
|
|
19
|
+
if (marketData.version === 'v2') {
|
|
20
|
+
this.lendMarkets[id] = new LendMarketTemplate(id, marketData, this);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.lendMarkets[id] = new LendMarketTemplate(id, marketData, this);
|
|
24
|
+
}
|
|
25
|
+
return this.lendMarkets[id];
|
|
26
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import LlammaABI from '../constants/abis/Llamma.json' with { type: 'json' };
|
|
2
|
+
import ControllerABI from '../constants/abis/Controller.json' with { type: 'json' };
|
|
3
|
+
import ControllerV2ABI from '../constants/abis/ControllerV2.json' with { type: 'json' };
|
|
4
|
+
import MonetaryPolicyABI from '../constants/abis/MonetaryPolicy.json' with { type: 'json' };
|
|
5
|
+
import VaultABI from '../constants/abis/Vault.json' with { type: 'json' };
|
|
6
|
+
import GaugeABI from '../constants/abis/GaugeV5.json' with { type: 'json' };
|
|
7
|
+
import SidechainGaugeABI from '../constants/abis/SidechainGauge.json' with { type: 'json' };
|
|
8
|
+
import ERC20ABI from '../constants/abis/ERC20.json' with { type: 'json' };
|
|
9
|
+
const controllerAbiMap = {
|
|
10
|
+
v1: ControllerABI,
|
|
11
|
+
v2: ControllerV2ABI,
|
|
12
|
+
};
|
|
13
|
+
const VAULT_DECIMALS = 18;
|
|
14
|
+
const GAUGE_DECIMALS = 18;
|
|
15
|
+
export const setupLendMarketContracts = (llamalend, marketData) => {
|
|
16
|
+
const { addresses, borrowed_token, collateral_token, version } = marketData;
|
|
17
|
+
llamalend.setContract(addresses.amm, LlammaABI);
|
|
18
|
+
llamalend.setContract(addresses.controller, controllerAbiMap[version]);
|
|
19
|
+
llamalend.setContract(addresses.monetary_policy, MonetaryPolicyABI);
|
|
20
|
+
llamalend.setContract(addresses.vault, VaultABI);
|
|
21
|
+
llamalend.setContract(addresses.gauge, llamalend.chainId === 1 ? GaugeABI : SidechainGaugeABI);
|
|
22
|
+
llamalend.setContract(borrowed_token.address, ERC20ABI);
|
|
23
|
+
llamalend.setContract(collateral_token.address, ERC20ABI);
|
|
24
|
+
llamalend.constants.DECIMALS[borrowed_token.address] = borrowed_token.decimals;
|
|
25
|
+
llamalend.constants.DECIMALS[collateral_token.address] = collateral_token.decimals;
|
|
26
|
+
llamalend.constants.DECIMALS[addresses.vault] = VAULT_DECIMALS;
|
|
27
|
+
if (addresses.gauge && addresses.gauge !== llamalend.constants.ZERO_ADDRESS) {
|
|
28
|
+
llamalend.constants.DECIMALS[addresses.gauge] = GAUGE_DECIMALS;
|
|
29
|
+
}
|
|
30
|
+
};
|
package/lib/llamalend.js
CHANGED
|
@@ -31,6 +31,7 @@ import DeleverageZapABI from "./constants/abis/crvUSD/DeleverageZap.json" with {
|
|
|
31
31
|
import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_ARBITRUM, ALIASES_FRAXTAL, ALIASES_SONIC, } from "./constants/aliases.js";
|
|
32
32
|
import { COINS_ETHEREUM, COINS_OPTIMISM, COINS_ARBITRUM, COINS_FRAXTAL, COINS_SONIC, } from "./constants/coins.js";
|
|
33
33
|
import { LLAMMAS } from "./constants/llammas.js";
|
|
34
|
+
import { resolveMonetaryPolicyAbi } from "./mintMarkets/monetaryPolicyAbi.js";
|
|
34
35
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
35
36
|
import { createCall, handleMultiCallResponse } from "./utils.js";
|
|
36
37
|
import { _getMarketsData, _getCrvUsdMarketsData } from "./external-api.js";
|
|
@@ -406,7 +407,7 @@ class Llamalend {
|
|
|
406
407
|
llammas.forEach((llamma, i) => { llamma.monetary_policy_address = monetaryPolicies[i]; });
|
|
407
408
|
}
|
|
408
409
|
for (const llamma of llammas) {
|
|
409
|
-
this.setContract(llamma.monetary_policy_address, llamma.
|
|
410
|
+
this.setContract(llamma.monetary_policy_address, resolveMonetaryPolicyAbi(llamma.monetary_policy_address));
|
|
410
411
|
if (llamma.collateral_address === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") {
|
|
411
412
|
this.setContract(this.constants.WETH, ERC20ABI);
|
|
412
413
|
}
|
|
@@ -13,8 +13,9 @@ import llammaABI from "../../constants/abis/crvUSD/llamma.json" with { type: 'js
|
|
|
13
13
|
import controllerABI from "../../constants/abis/crvUSD/controller.json" with { type: 'json' };
|
|
14
14
|
import controllerV2ABI from "../../constants/abis/crvUSD/controller_v2.json";
|
|
15
15
|
import FactoryABI from "../../constants/abis/crvUSD/Factory.json" with { type: 'json' };
|
|
16
|
-
import MonetaryPolicy2ABI from "../../constants/abis/crvUSD/MonetaryPolicy2.json" with { type: 'json' };
|
|
17
16
|
import { extractDecimals } from "../../constants/utils.js";
|
|
17
|
+
import { handleMultiCallResponse } from "../../utils.js";
|
|
18
|
+
import { resolveMonetaryPolicyAbi } from "../monetaryPolicyAbi.js";
|
|
18
19
|
export const fetchMintMarketsByAPI = (llamalend) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
if (llamalend.chainId !== 1)
|
|
20
21
|
return;
|
|
@@ -39,7 +40,7 @@ export const fetchMintMarketsByAPI = (llamalend) => __awaiter(void 0, void 0, vo
|
|
|
39
40
|
const is_eth = collateral_address === llamalend.constants.WETH;
|
|
40
41
|
const collateral_symbol = market.collateral_token.symbol;
|
|
41
42
|
const monetary_policy_address = market.monetary_policy_address.toLowerCase();
|
|
42
|
-
llamalend.setContract(monetary_policy_address,
|
|
43
|
+
llamalend.setContract(monetary_policy_address, resolveMonetaryPolicyAbi(monetary_policy_address));
|
|
43
44
|
const _llammaId = is_eth ? "eth" : collateral_symbol.toLowerCase();
|
|
44
45
|
let llammaId = _llammaId;
|
|
45
46
|
let j = 2;
|
|
@@ -58,7 +59,6 @@ export const fetchMintMarketsByAPI = (llamalend) => __awaiter(void 0, void 0, vo
|
|
|
58
59
|
max_bands: 50,
|
|
59
60
|
default_bands: 10,
|
|
60
61
|
A: market.amm_a,
|
|
61
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
62
62
|
is_deleverage_supported: true,
|
|
63
63
|
index: N1 + i,
|
|
64
64
|
};
|
|
@@ -73,44 +73,37 @@ export const fetchMintMarketsByBlockchain = (llamalend) => __awaiter(void 0, voi
|
|
|
73
73
|
const factoryMulticallContract = llamalend.contracts[llamalend.constants.FACTORY].multicallContract;
|
|
74
74
|
const N1 = Object.keys(llamalend.constants.LLAMMAS).length;
|
|
75
75
|
const N2 = yield factoryContract.n_collaterals(llamalend.constantOptions);
|
|
76
|
+
const coreCallsMap = ['collaterals', 'amms', 'controllers'];
|
|
76
77
|
let calls = [];
|
|
77
78
|
for (let i = N1; i < N2; i++) {
|
|
78
79
|
calls.push(factoryMulticallContract.collaterals(i), factoryMulticallContract.amms(i), factoryMulticallContract.controllers(i));
|
|
79
80
|
}
|
|
80
|
-
const
|
|
81
|
-
const collaterals
|
|
82
|
-
const amms = res.filter((a, i) => i % 3 == 1);
|
|
83
|
-
const controllers = res.filter((a, i) => i % 3 == 2);
|
|
81
|
+
const coreAddresses = (yield llamalend.multicallProvider.all(calls)).map((c) => c.toLowerCase());
|
|
82
|
+
const { collaterals, amms, controllers } = handleMultiCallResponse(coreCallsMap, coreAddresses);
|
|
84
83
|
if (collaterals.length === 0)
|
|
85
84
|
return;
|
|
85
|
+
const N = collaterals.length;
|
|
86
86
|
for (const collateral of collaterals)
|
|
87
87
|
llamalend.setContract(collateral, ERC20ABI);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
for (const amm of amms)
|
|
89
|
+
llamalend.setContract(amm, llammaABI);
|
|
90
|
+
for (let i = 0; i < N; i++) {
|
|
91
|
+
llamalend.setContract(controllers[i], i >= N - 3 ? controllerV2ABI : controllerABI);
|
|
91
92
|
}
|
|
92
|
-
const
|
|
93
|
-
if (typeof x === "string")
|
|
94
|
-
return x.toLowerCase();
|
|
95
|
-
return x;
|
|
96
|
-
});
|
|
93
|
+
const detailsCallsMap = ['symbols', 'decimals', 'amm_a', 'monetary_policies'];
|
|
97
94
|
calls = [];
|
|
98
|
-
for (
|
|
99
|
-
llamalend.
|
|
100
|
-
calls.push(llamalend.contracts[amm].multicallContract.A());
|
|
95
|
+
for (let i = 0; i < N; i++) {
|
|
96
|
+
calls.push(llamalend.contracts[collaterals[i]].multicallContract.symbol(), llamalend.contracts[collaterals[i]].multicallContract.decimals(), llamalend.contracts[amms[i]].multicallContract.A(), llamalend.contracts[controllers[i]].multicallContract.monetary_policy());
|
|
101
97
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
98
|
+
const flat = (yield llamalend.multicallProvider.all(calls)).map((x) => typeof x === "string" ? x.toLowerCase() : x);
|
|
99
|
+
const { symbols, decimals, amm_a, monetary_policies } = handleMultiCallResponse(detailsCallsMap, flat);
|
|
100
|
+
for (const mp of monetary_policies)
|
|
101
|
+
llamalend.setContract(mp, resolveMonetaryPolicyAbi(mp));
|
|
102
|
+
for (let i = 0; i < N; i++) {
|
|
104
103
|
const is_eth = collaterals[i] === llamalend.constants.WETH;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
llamalend.setContract(controllers[i], controllerABI);
|
|
111
|
-
}
|
|
112
|
-
const monetary_policy_address = (yield llamalend.contracts[controllers[i]].contract.monetary_policy(llamalend.constantOptions)).toLowerCase();
|
|
113
|
-
llamalend.setContract(monetary_policy_address, MonetaryPolicy2ABI);
|
|
104
|
+
const collateral_symbol = symbols[i];
|
|
105
|
+
const collateral_decimals = Number(decimals[i]);
|
|
106
|
+
const monetary_policy_address = monetary_policies[i];
|
|
114
107
|
const _llammaId = is_eth ? "eth" : collateral_symbol.toLowerCase();
|
|
115
108
|
let llammaId = _llammaId;
|
|
116
109
|
let j = 2;
|
|
@@ -128,8 +121,7 @@ export const fetchMintMarketsByBlockchain = (llamalend) => __awaiter(void 0, voi
|
|
|
128
121
|
min_bands: 4,
|
|
129
122
|
max_bands: 50,
|
|
130
123
|
default_bands: 10,
|
|
131
|
-
A:
|
|
132
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
124
|
+
A: Number(amm_a[i]),
|
|
133
125
|
is_deleverage_supported: true,
|
|
134
126
|
index: N1 + i,
|
|
135
127
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { MintMarketTemplate } from "./MintMarketTemplate.js";
|
|
2
|
+
import type { ILlamma } from "../interfaces.js";
|
|
2
3
|
import type { Llamalend } from "../llamalend.js";
|
|
3
4
|
export declare const getMintMarket: (this: Llamalend, mintMarketId: string) => MintMarketTemplate;
|
|
5
|
+
export declare const getMintMarketByData: (this: Llamalend, id: string, llammaData: ILlamma) => MintMarketTemplate;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MintMarketTemplate } from "./MintMarketTemplate.js";
|
|
2
|
+
import { setupMintMarketContracts } from "./setupContracts.js";
|
|
2
3
|
export const getMintMarket = function (mintMarketId) {
|
|
3
4
|
if (!(mintMarketId in this.mintMarkets)) {
|
|
4
5
|
const llammaData = this.constants.LLAMMAS[mintMarketId];
|
|
@@ -8,3 +9,8 @@ export const getMintMarket = function (mintMarketId) {
|
|
|
8
9
|
}
|
|
9
10
|
return this.mintMarkets[mintMarketId];
|
|
10
11
|
};
|
|
12
|
+
export const getMintMarketByData = function (id, llammaData) {
|
|
13
|
+
setupMintMarketContracts(this, llammaData);
|
|
14
|
+
this.mintMarkets[id] = new MintMarketTemplate(id, llammaData, this);
|
|
15
|
+
return this.mintMarkets[id];
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveMonetaryPolicyAbi: (monetaryPolicyAddress: string) => any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import MonetaryPolicyABI from "../constants/abis/crvUSD/MonetaryPolicy.json" with { type: "json" };
|
|
2
|
+
import MonetaryPolicy2ABI from "../constants/abis/crvUSD/MonetaryPolicy2.json" with { type: "json" };
|
|
3
|
+
const LEGACY_MONETARY_POLICIES = new Set([
|
|
4
|
+
"0xc684432fd6322c6d58b6bc5d28b18569aa0ad0a1",
|
|
5
|
+
]);
|
|
6
|
+
export const resolveMonetaryPolicyAbi = (monetaryPolicyAddress) => {
|
|
7
|
+
return LEGACY_MONETARY_POLICIES.has(monetaryPolicyAddress.toLowerCase())
|
|
8
|
+
? MonetaryPolicyABI
|
|
9
|
+
: MonetaryPolicy2ABI;
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ERC20ABI from "../constants/abis/ERC20.json" with { type: "json" };
|
|
2
|
+
import llammaABI from "../constants/abis/crvUSD/llamma.json" with { type: "json" };
|
|
3
|
+
import controllerABI from "../constants/abis/crvUSD/controller.json" with { type: "json" };
|
|
4
|
+
import controllerV2ABI from "../constants/abis/crvUSD/controller_v2.json" with { type: "json" };
|
|
5
|
+
import LeverageZapCrvUSDABI from "../constants/abis/crvUSD/LeverageZap.json" with { type: "json" };
|
|
6
|
+
import DeleverageZapABI from "../constants/abis/crvUSD/DeleverageZap.json" with { type: "json" };
|
|
7
|
+
import HealthCalculatorZapABI from "../constants/abis/crvUSD/HealthCalculatorZap.json" with { type: "json" };
|
|
8
|
+
import { resolveMonetaryPolicyAbi } from "./monetaryPolicyAbi.js";
|
|
9
|
+
const NATIVE_ETH_PLACEHOLDER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
10
|
+
export const setupMintMarketContracts = (llamalend, llammaData) => {
|
|
11
|
+
const isV2Controller = llammaData.is_deleverage_supported === true;
|
|
12
|
+
llamalend.setContract(llammaData.amm_address, llammaABI);
|
|
13
|
+
llamalend.setContract(llammaData.controller_address, isV2Controller ? controllerV2ABI : controllerABI);
|
|
14
|
+
llamalend.setContract(llammaData.monetary_policy_address, resolveMonetaryPolicyAbi(llammaData.monetary_policy_address));
|
|
15
|
+
if (llammaData.collateral_address === NATIVE_ETH_PLACEHOLDER) {
|
|
16
|
+
llamalend.setContract(llamalend.constants.WETH, ERC20ABI);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
llamalend.setContract(llammaData.collateral_address, ERC20ABI);
|
|
20
|
+
}
|
|
21
|
+
llamalend.setContract(llammaData.leverage_zap, LeverageZapCrvUSDABI);
|
|
22
|
+
llamalend.setContract(llammaData.deleverage_zap, DeleverageZapABI);
|
|
23
|
+
if (llammaData.health_calculator_zap && llammaData.health_calculator_zap !== llamalend.constants.ZERO_ADDRESS) {
|
|
24
|
+
llamalend.setContract(llammaData.health_calculator_zap, HealthCalculatorZapABI);
|
|
25
|
+
}
|
|
26
|
+
llamalend.constants.DECIMALS[llammaData.collateral_address] = llammaData.collateral_decimals;
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -670,78 +670,6 @@
|
|
|
670
670
|
"stateMutability": "nonpayable",
|
|
671
671
|
"type": "function"
|
|
672
672
|
},
|
|
673
|
-
{
|
|
674
|
-
"inputs": [
|
|
675
|
-
{
|
|
676
|
-
"name": "_user",
|
|
677
|
-
"type": "address"
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
"name": "_min_x",
|
|
681
|
-
"type": "uint256"
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
"name": "_frac",
|
|
685
|
-
"type": "uint256"
|
|
686
|
-
}
|
|
687
|
-
],
|
|
688
|
-
"name": "liquidate",
|
|
689
|
-
"outputs": [],
|
|
690
|
-
"stateMutability": "nonpayable",
|
|
691
|
-
"type": "function"
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
"inputs": [
|
|
695
|
-
{
|
|
696
|
-
"name": "_user",
|
|
697
|
-
"type": "address"
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
"name": "_min_x",
|
|
701
|
-
"type": "uint256"
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
"name": "_frac",
|
|
705
|
-
"type": "uint256"
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
"name": "_callbacker",
|
|
709
|
-
"type": "address"
|
|
710
|
-
}
|
|
711
|
-
],
|
|
712
|
-
"name": "liquidate",
|
|
713
|
-
"outputs": [],
|
|
714
|
-
"stateMutability": "nonpayable",
|
|
715
|
-
"type": "function"
|
|
716
|
-
},
|
|
717
|
-
{
|
|
718
|
-
"inputs": [
|
|
719
|
-
{
|
|
720
|
-
"name": "_user",
|
|
721
|
-
"type": "address"
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
"name": "_min_x",
|
|
725
|
-
"type": "uint256"
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
"name": "_frac",
|
|
729
|
-
"type": "uint256"
|
|
730
|
-
},
|
|
731
|
-
{
|
|
732
|
-
"name": "_callbacker",
|
|
733
|
-
"type": "address"
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
"name": "_calldata",
|
|
737
|
-
"type": "bytes"
|
|
738
|
-
}
|
|
739
|
-
],
|
|
740
|
-
"name": "liquidate",
|
|
741
|
-
"outputs": [],
|
|
742
|
-
"stateMutability": "nonpayable",
|
|
743
|
-
"type": "function"
|
|
744
|
-
},
|
|
745
673
|
{
|
|
746
674
|
"inputs": [],
|
|
747
675
|
"name": "save_rate",
|
|
@@ -1263,27 +1191,6 @@
|
|
|
1263
1191
|
"stateMutability": "view",
|
|
1264
1192
|
"type": "function"
|
|
1265
1193
|
},
|
|
1266
|
-
{
|
|
1267
|
-
"inputs": [
|
|
1268
|
-
{
|
|
1269
|
-
"name": "_user",
|
|
1270
|
-
"type": "address"
|
|
1271
|
-
},
|
|
1272
|
-
{
|
|
1273
|
-
"name": "_frac",
|
|
1274
|
-
"type": "uint256"
|
|
1275
|
-
}
|
|
1276
|
-
],
|
|
1277
|
-
"name": "tokens_to_liquidate",
|
|
1278
|
-
"outputs": [
|
|
1279
|
-
{
|
|
1280
|
-
"name": "",
|
|
1281
|
-
"type": "uint256"
|
|
1282
|
-
}
|
|
1283
|
-
],
|
|
1284
|
-
"stateMutability": "view",
|
|
1285
|
-
"type": "function"
|
|
1286
|
-
},
|
|
1287
1194
|
{
|
|
1288
1195
|
"inputs": [
|
|
1289
1196
|
{
|
package/src/constants/llammas.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { IDict, ILlamma } from "../interfaces.js";
|
|
2
|
-
import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' with {type: 'json'};
|
|
3
|
-
import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' with {type: 'json'};
|
|
4
2
|
import { lowerCaseLlammasAddresses } from "./utils.js";
|
|
5
3
|
|
|
6
4
|
|
|
@@ -18,7 +16,6 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
18
16
|
max_bands: 50,
|
|
19
17
|
default_bands: 10,
|
|
20
18
|
A: 100,
|
|
21
|
-
monetary_policy_abi: MonetaryPolicyABI,
|
|
22
19
|
},
|
|
23
20
|
wsteth: {
|
|
24
21
|
amm_address: '0x37417b2238aa52d0dd2d6252d989e728e8f706e4',
|
|
@@ -33,7 +30,6 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
33
30
|
max_bands: 50,
|
|
34
31
|
default_bands: 10,
|
|
35
32
|
A: 100,
|
|
36
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
37
33
|
},
|
|
38
34
|
wbtc: {
|
|
39
35
|
amm_address: '0xe0438eb3703bf871e31ce639bd351109c88666ea',
|
|
@@ -49,7 +45,6 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
49
45
|
max_bands: 50,
|
|
50
46
|
default_bands: 10,
|
|
51
47
|
A: 100,
|
|
52
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
53
48
|
},
|
|
54
49
|
eth: {
|
|
55
50
|
amm_address: '0x1681195c176239ac5e72d9aebacf5b2492e0c4ee',
|
|
@@ -64,7 +59,6 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
64
59
|
max_bands: 50,
|
|
65
60
|
default_bands: 10,
|
|
66
61
|
A: 100,
|
|
67
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
68
62
|
},
|
|
69
63
|
sfrxeth2: {
|
|
70
64
|
amm_address: '0xfa96ad0a9e64261db86950e2da362f5572c5c6fd',
|
|
@@ -79,7 +73,6 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
79
73
|
max_bands: 50,
|
|
80
74
|
default_bands: 10,
|
|
81
75
|
A: 100,
|
|
82
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
83
76
|
},
|
|
84
77
|
tbtc: {
|
|
85
78
|
amm_address: '0xf9bd9da2427a50908c4c6d1599d8e62837c2bcb0',
|
|
@@ -94,6 +87,5 @@ export const LLAMMAS: IDict<ILlamma> = lowerCaseLlammasAddresses({
|
|
|
94
87
|
max_bands: 50,
|
|
95
88
|
default_bands: 10,
|
|
96
89
|
A: 100,
|
|
97
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
98
90
|
},
|
|
99
91
|
});
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
redeemEstimateGas,
|
|
46
46
|
redeem,
|
|
47
47
|
} from "./st-crvUSD.js";
|
|
48
|
+
import {getMintMarketByData} from "./mintMarkets/mintMarketConstructor.js";
|
|
49
|
+
import {getLendMarketByData} from "./lendMarkets/lendMarketConstructor.js";
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
export function createLlamalend() {
|
|
@@ -73,6 +75,8 @@ export function createLlamalend() {
|
|
|
73
75
|
// Market constructors
|
|
74
76
|
getLendMarket: getLendMarket.bind(llamalend),
|
|
75
77
|
getMintMarket: getMintMarket.bind(llamalend),
|
|
78
|
+
getLendMarketByData: getLendMarketByData.bind(llamalend),
|
|
79
|
+
getMintMarketByData: getMintMarketByData.bind(llamalend),
|
|
76
80
|
|
|
77
81
|
// Utility functions
|
|
78
82
|
totalSupply: totalSupply.bind(llamalend),
|
package/src/interfaces.ts
CHANGED
|
@@ -40,7 +40,6 @@ export interface ILlamma {
|
|
|
40
40
|
max_bands: number,
|
|
41
41
|
default_bands: number,
|
|
42
42
|
A: number,
|
|
43
|
-
monetary_policy_abi: any
|
|
44
43
|
is_deleverage_supported?: boolean
|
|
45
44
|
index?: number
|
|
46
45
|
}
|
|
@@ -226,7 +225,6 @@ export interface ILlamma {
|
|
|
226
225
|
max_bands: number,
|
|
227
226
|
default_bands: number,
|
|
228
227
|
A: number,
|
|
229
|
-
monetary_policy_abi: any
|
|
230
228
|
}
|
|
231
229
|
|
|
232
230
|
export interface IResponseApi {
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import type { Llamalend } from "../../llamalend.js";
|
|
2
2
|
import type { ICoin, IDict } from "../../interfaces.js";
|
|
3
3
|
import { getFactoryMarketDataV1, getFactoryMarketDataV2, getFactoryMarketDataByAPI } from "./fetchFactoryData.js";
|
|
4
|
-
|
|
5
|
-
import LlammaABI from '../../constants/abis/Llamma.json' with {type: 'json'};
|
|
6
|
-
import ControllerABI from '../../constants/abis/Controller.json' with {type: 'json'};
|
|
7
|
-
import ControllerV2ABI from '../../constants/abis/ControllerV2.json' with {type: 'json'};
|
|
8
|
-
import MonetaryPolicyABI from '../../constants/abis/MonetaryPolicy.json' with {type: 'json'};
|
|
9
|
-
import VaultABI from '../../constants/abis/Vault.json' with {type: 'json'};
|
|
10
|
-
import GaugeABI from '../../constants/abis/GaugeV5.json' with {type: 'json'};
|
|
11
|
-
import SidechainGaugeABI from '../../constants/abis/SidechainGauge.json' with {type: 'json'};
|
|
12
|
-
|
|
13
|
-
const controllerAbiMap = {
|
|
14
|
-
'v1' : ControllerABI,
|
|
15
|
-
'v2' : ControllerV2ABI,
|
|
16
|
-
}
|
|
4
|
+
import { setupLendMarketContracts } from "../setupContracts.js";
|
|
17
5
|
|
|
18
6
|
const registerMarkets = (
|
|
19
7
|
llamalend: Llamalend,
|
|
@@ -29,13 +17,6 @@ const registerMarkets = (
|
|
|
29
17
|
version: 'v1' | 'v2'
|
|
30
18
|
) => {
|
|
31
19
|
amms.forEach((amm: string, index: number) => {
|
|
32
|
-
llamalend.setContract(amms[index], LlammaABI);
|
|
33
|
-
llamalend.setContract(controllers[index], controllerAbiMap[version]);
|
|
34
|
-
llamalend.setContract(monetary_policies[index], MonetaryPolicyABI);
|
|
35
|
-
llamalend.setContract(vaults[index], VaultABI);
|
|
36
|
-
if (gauges[index]) {
|
|
37
|
-
llamalend.setContract(gauges[index], llamalend.chainId === 1 ? GaugeABI : SidechainGaugeABI);
|
|
38
|
-
}
|
|
39
20
|
COIN_DATA[vaults[index]] = {
|
|
40
21
|
address: vaults[index],
|
|
41
22
|
decimals: 18,
|
|
@@ -48,8 +29,6 @@ const registerMarkets = (
|
|
|
48
29
|
name: "curve.finance " + COIN_DATA[borrowed_tokens[index]].name + " Gauge Deposit",
|
|
49
30
|
symbol: "cv" + COIN_DATA[borrowed_tokens[index]].symbol + "-gauge",
|
|
50
31
|
};
|
|
51
|
-
llamalend.constants.DECIMALS[vaults[index]] = 18;
|
|
52
|
-
llamalend.constants.DECIMALS[gauges[index]] = 18;
|
|
53
32
|
|
|
54
33
|
const marketData = {
|
|
55
34
|
name: names[index] || `${COIN_DATA[collateral_tokens[index]].symbol}/${COIN_DATA[borrowed_tokens[index]].symbol}`,
|
|
@@ -67,6 +46,8 @@ const registerMarkets = (
|
|
|
67
46
|
collateral_token: COIN_DATA[collateral_tokens[index]],
|
|
68
47
|
};
|
|
69
48
|
|
|
49
|
+
setupLendMarketContracts(llamalend, marketData);
|
|
50
|
+
|
|
70
51
|
if (version === 'v2') {
|
|
71
52
|
llamalend.constants.ONE_WAY_MARKETS_V2[`one-way-market-v2-${index}`] = marketData;
|
|
72
53
|
} else {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LendMarketTemplate} from "./LendMarketTemplate.js";
|
|
2
|
+
import type { IOneWayMarket } from "../interfaces.js";
|
|
2
3
|
import type { Llamalend } from "../llamalend.js";
|
|
4
|
+
import { setupLendMarketContracts } from "./setupContracts.js";
|
|
3
5
|
|
|
4
6
|
export const getLendMarket = function (this: Llamalend, lendMarketId: string): LendMarketTemplate<'v1'> | LendMarketTemplate<'v2'> {
|
|
5
7
|
if (!(lendMarketId in this.lendMarkets)) {
|
|
@@ -13,3 +15,15 @@ export const getLendMarket = function (this: Llamalend, lendMarketId: string): L
|
|
|
13
15
|
}
|
|
14
16
|
return this.lendMarkets[lendMarketId];
|
|
15
17
|
}
|
|
18
|
+
|
|
19
|
+
export const getLendMarketByData = function (this: Llamalend, id: string, marketData: IOneWayMarket): LendMarketTemplate<'v1'> | LendMarketTemplate<'v2'> {
|
|
20
|
+
setupLendMarketContracts(this, marketData);
|
|
21
|
+
|
|
22
|
+
if (marketData.version === 'v2') {
|
|
23
|
+
this.lendMarkets[id] = new LendMarketTemplate<'v2'>(id, marketData, this);
|
|
24
|
+
} else {
|
|
25
|
+
this.lendMarkets[id] = new LendMarketTemplate<'v1'>(id, marketData, this);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return this.lendMarkets[id];
|
|
29
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Llamalend } from "../llamalend.js";
|
|
2
|
+
import type { IOneWayMarket } from "../interfaces.js";
|
|
3
|
+
|
|
4
|
+
import LlammaABI from '../constants/abis/Llamma.json' with {type: 'json'};
|
|
5
|
+
import ControllerABI from '../constants/abis/Controller.json' with {type: 'json'};
|
|
6
|
+
import ControllerV2ABI from '../constants/abis/ControllerV2.json' with {type: 'json'};
|
|
7
|
+
import MonetaryPolicyABI from '../constants/abis/MonetaryPolicy.json' with {type: 'json'};
|
|
8
|
+
import VaultABI from '../constants/abis/Vault.json' with {type: 'json'};
|
|
9
|
+
import GaugeABI from '../constants/abis/GaugeV5.json' with {type: 'json'};
|
|
10
|
+
import SidechainGaugeABI from '../constants/abis/SidechainGauge.json' with {type: 'json'};
|
|
11
|
+
import ERC20ABI from '../constants/abis/ERC20.json' with {type: 'json'};
|
|
12
|
+
|
|
13
|
+
const controllerAbiMap = {
|
|
14
|
+
v1: ControllerABI,
|
|
15
|
+
v2: ControllerV2ABI,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const VAULT_DECIMALS = 18;
|
|
19
|
+
const GAUGE_DECIMALS = 18;
|
|
20
|
+
|
|
21
|
+
export const setupLendMarketContracts = (llamalend: Llamalend, marketData: IOneWayMarket): void => {
|
|
22
|
+
const { addresses, borrowed_token, collateral_token, version } = marketData;
|
|
23
|
+
|
|
24
|
+
llamalend.setContract(addresses.amm, LlammaABI);
|
|
25
|
+
llamalend.setContract(addresses.controller, controllerAbiMap[version]);
|
|
26
|
+
llamalend.setContract(addresses.monetary_policy, MonetaryPolicyABI);
|
|
27
|
+
llamalend.setContract(addresses.vault, VaultABI);
|
|
28
|
+
llamalend.setContract(addresses.gauge, llamalend.chainId === 1 ? GaugeABI : SidechainGaugeABI);
|
|
29
|
+
|
|
30
|
+
llamalend.setContract(borrowed_token.address, ERC20ABI);
|
|
31
|
+
llamalend.setContract(collateral_token.address, ERC20ABI);
|
|
32
|
+
|
|
33
|
+
llamalend.constants.DECIMALS[borrowed_token.address] = borrowed_token.decimals;
|
|
34
|
+
llamalend.constants.DECIMALS[collateral_token.address] = collateral_token.decimals;
|
|
35
|
+
llamalend.constants.DECIMALS[addresses.vault] = VAULT_DECIMALS;
|
|
36
|
+
if (addresses.gauge && addresses.gauge !== llamalend.constants.ZERO_ADDRESS) {
|
|
37
|
+
llamalend.constants.DECIMALS[addresses.gauge] = GAUGE_DECIMALS;
|
|
38
|
+
}
|
|
39
|
+
};
|
package/src/llamalend.ts
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
COINS_SONIC,
|
|
46
46
|
} from "./constants/coins.js";
|
|
47
47
|
import {LLAMMAS} from "./constants/llammas.js";
|
|
48
|
+
import {resolveMonetaryPolicyAbi} from "./mintMarkets/monetaryPolicyAbi.js";
|
|
48
49
|
import {L2Networks} from "./constants/L2Networks.js";
|
|
49
50
|
import {createCall, handleMultiCallResponse} from "./utils.js";
|
|
50
51
|
import {_getMarketsData, _getCrvUsdMarketsData} from "./external-api.js";
|
|
@@ -414,7 +415,7 @@ class Llamalend implements ILlamalend {
|
|
|
414
415
|
}
|
|
415
416
|
|
|
416
417
|
for (const llamma of llammas) {
|
|
417
|
-
this.setContract(llamma.monetary_policy_address, llamma.
|
|
418
|
+
this.setContract(llamma.monetary_policy_address, resolveMonetaryPolicyAbi(llamma.monetary_policy_address));
|
|
418
419
|
if (llamma.collateral_address === "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") {
|
|
419
420
|
this.setContract(this.constants.WETH, ERC20ABI);
|
|
420
421
|
} else {
|
|
@@ -5,8 +5,9 @@ import llammaABI from "../../constants/abis/crvUSD/llamma.json" with {type: 'jso
|
|
|
5
5
|
import controllerABI from "../../constants/abis/crvUSD/controller.json" with {type: 'json'};
|
|
6
6
|
import controllerV2ABI from "../../constants/abis/crvUSD/controller_v2.json";
|
|
7
7
|
import FactoryABI from "../../constants/abis/crvUSD/Factory.json" with {type: 'json'};
|
|
8
|
-
import MonetaryPolicy2ABI from "../../constants/abis/crvUSD/MonetaryPolicy2.json" with {type: 'json'};
|
|
9
8
|
import {extractDecimals} from "../../constants/utils.js";
|
|
9
|
+
import {handleMultiCallResponse} from "../../utils.js";
|
|
10
|
+
import {resolveMonetaryPolicyAbi} from "../monetaryPolicyAbi.js";
|
|
10
11
|
|
|
11
12
|
export const fetchMintMarketsByAPI = async (llamalend: Llamalend): Promise<void> => {
|
|
12
13
|
if (llamalend.chainId !== 1) return;
|
|
@@ -36,7 +37,7 @@ export const fetchMintMarketsByAPI = async (llamalend: Llamalend): Promise<void>
|
|
|
36
37
|
const collateral_symbol = market.collateral_token.symbol;
|
|
37
38
|
const monetary_policy_address = market.monetary_policy_address.toLowerCase();
|
|
38
39
|
|
|
39
|
-
llamalend.setContract(monetary_policy_address,
|
|
40
|
+
llamalend.setContract(monetary_policy_address, resolveMonetaryPolicyAbi(monetary_policy_address));
|
|
40
41
|
|
|
41
42
|
const _llammaId = is_eth ? "eth" : collateral_symbol.toLowerCase();
|
|
42
43
|
let llammaId = _llammaId;
|
|
@@ -56,7 +57,6 @@ export const fetchMintMarketsByAPI = async (llamalend: Llamalend): Promise<void>
|
|
|
56
57
|
max_bands: 50,
|
|
57
58
|
default_bands: 10,
|
|
58
59
|
A: market.amm_a,
|
|
59
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
60
60
|
is_deleverage_supported: true,
|
|
61
61
|
index: N1 + i,
|
|
62
62
|
};
|
|
@@ -74,6 +74,8 @@ export const fetchMintMarketsByBlockchain = async (llamalend: Llamalend): Promis
|
|
|
74
74
|
|
|
75
75
|
const N1 = Object.keys(llamalend.constants.LLAMMAS).length;
|
|
76
76
|
const N2 = await factoryContract.n_collaterals(llamalend.constantOptions);
|
|
77
|
+
|
|
78
|
+
const coreCallsMap = ['collaterals', 'amms', 'controllers'];
|
|
77
79
|
let calls = [];
|
|
78
80
|
for (let i = N1; i < N2; i++) {
|
|
79
81
|
calls.push(
|
|
@@ -82,46 +84,47 @@ export const fetchMintMarketsByBlockchain = async (llamalend: Llamalend): Promis
|
|
|
82
84
|
factoryMulticallContract.controllers(i)
|
|
83
85
|
);
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
|
|
88
|
+
const coreAddresses = (await llamalend.multicallProvider.all(calls) as string[]).map((c) => c.toLowerCase());
|
|
89
|
+
const { collaterals, amms, controllers } = handleMultiCallResponse(coreCallsMap, coreAddresses) as {
|
|
90
|
+
collaterals: string[]; amms: string[]; controllers: string[];
|
|
91
|
+
};
|
|
89
92
|
|
|
90
93
|
if (collaterals.length === 0) return;
|
|
91
94
|
|
|
95
|
+
const N = collaterals.length;
|
|
96
|
+
|
|
92
97
|
for (const collateral of collaterals) llamalend.setContract(collateral, ERC20ABI);
|
|
98
|
+
for (const amm of amms) llamalend.setContract(amm, llammaABI);
|
|
99
|
+
for (let i = 0; i < N; i++) {
|
|
100
|
+
llamalend.setContract(controllers[i], i >= N - 3 ? controllerV2ABI : controllerABI);
|
|
101
|
+
}
|
|
93
102
|
|
|
103
|
+
const detailsCallsMap = ['symbols', 'decimals', 'amm_a', 'monetary_policies'];
|
|
94
104
|
calls = [];
|
|
95
|
-
for (
|
|
105
|
+
for (let i = 0; i < N; i++) {
|
|
96
106
|
calls.push(
|
|
97
|
-
llamalend.contracts[
|
|
98
|
-
llamalend.contracts[
|
|
107
|
+
llamalend.contracts[collaterals[i]].multicallContract.symbol(),
|
|
108
|
+
llamalend.contracts[collaterals[i]].multicallContract.decimals(),
|
|
109
|
+
llamalend.contracts[amms[i]].multicallContract.A(),
|
|
110
|
+
llamalend.contracts[controllers[i]].multicallContract.monetary_policy()
|
|
99
111
|
);
|
|
100
112
|
}
|
|
101
|
-
const collateralData = (await llamalend.multicallProvider.all(calls)).map((x) => {
|
|
102
|
-
if (typeof x === "string") return x.toLowerCase();
|
|
103
|
-
return x;
|
|
104
|
-
});
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
for (let i = 0; i < collaterals.length; i++) {
|
|
114
|
-
const is_eth = collaterals[i] === llamalend.constants.WETH;
|
|
115
|
-
const [collateral_symbol, collateral_decimals] = collateralData.splice(0, 2) as [string, number];
|
|
114
|
+
const flat = (await llamalend.multicallProvider.all(calls)).map((x) =>
|
|
115
|
+
typeof x === "string" ? x.toLowerCase() : x
|
|
116
|
+
);
|
|
117
|
+
const { symbols, decimals, amm_a, monetary_policies } = handleMultiCallResponse(detailsCallsMap, flat) as {
|
|
118
|
+
symbols: string[]; decimals: unknown[]; amm_a: unknown[]; monetary_policies: string[];
|
|
119
|
+
};
|
|
116
120
|
|
|
117
|
-
|
|
118
|
-
llamalend.setContract(controllers[i], controllerV2ABI);
|
|
119
|
-
} else {
|
|
120
|
-
llamalend.setContract(controllers[i], controllerABI);
|
|
121
|
-
}
|
|
121
|
+
for (const mp of monetary_policies) llamalend.setContract(mp, resolveMonetaryPolicyAbi(mp));
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
llamalend.
|
|
123
|
+
for (let i = 0; i < N; i++) {
|
|
124
|
+
const is_eth = collaterals[i] === llamalend.constants.WETH;
|
|
125
|
+
const collateral_symbol = symbols[i];
|
|
126
|
+
const collateral_decimals = Number(decimals[i]);
|
|
127
|
+
const monetary_policy_address = monetary_policies[i];
|
|
125
128
|
|
|
126
129
|
const _llammaId: string = is_eth ? "eth" : collateral_symbol.toLowerCase();
|
|
127
130
|
let llammaId = _llammaId;
|
|
@@ -140,8 +143,7 @@ export const fetchMintMarketsByBlockchain = async (llamalend: Llamalend): Promis
|
|
|
140
143
|
min_bands: 4,
|
|
141
144
|
max_bands: 50,
|
|
142
145
|
default_bands: 10,
|
|
143
|
-
A:
|
|
144
|
-
monetary_policy_abi: MonetaryPolicy2ABI,
|
|
146
|
+
A: Number(amm_a[i]),
|
|
145
147
|
is_deleverage_supported: true,
|
|
146
148
|
index: N1 + i,
|
|
147
149
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MintMarketTemplate} from "./MintMarketTemplate.js";
|
|
2
|
+
import type { ILlamma } from "../interfaces.js";
|
|
2
3
|
import type { Llamalend } from "../llamalend.js";
|
|
4
|
+
import { setupMintMarketContracts } from "./setupContracts.js";
|
|
3
5
|
|
|
4
6
|
export const getMintMarket = function (this: Llamalend, mintMarketId: string): MintMarketTemplate {
|
|
5
7
|
if (!(mintMarketId in this.mintMarkets)) {
|
|
@@ -9,3 +11,10 @@ export const getMintMarket = function (this: Llamalend, mintMarketId: string): M
|
|
|
9
11
|
}
|
|
10
12
|
return this.mintMarkets[mintMarketId]
|
|
11
13
|
}
|
|
14
|
+
|
|
15
|
+
export const getMintMarketByData = function (this: Llamalend, id: string, llammaData: ILlamma): MintMarketTemplate {
|
|
16
|
+
setupMintMarketContracts(this, llammaData);
|
|
17
|
+
this.mintMarkets[id] = new MintMarketTemplate(id, llammaData, this);
|
|
18
|
+
|
|
19
|
+
return this.mintMarkets[id];
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import MonetaryPolicyABI from "../constants/abis/crvUSD/MonetaryPolicy.json" with { type: "json" };
|
|
2
|
+
import MonetaryPolicy2ABI from "../constants/abis/crvUSD/MonetaryPolicy2.json" with { type: "json" };
|
|
3
|
+
|
|
4
|
+
const LEGACY_MONETARY_POLICIES: ReadonlySet<string> = new Set([
|
|
5
|
+
"0xc684432fd6322c6d58b6bc5d28b18569aa0ad0a1",
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
export const resolveMonetaryPolicyAbi = (monetaryPolicyAddress: string): any => {
|
|
9
|
+
return LEGACY_MONETARY_POLICIES.has(monetaryPolicyAddress.toLowerCase())
|
|
10
|
+
? MonetaryPolicyABI
|
|
11
|
+
: MonetaryPolicy2ABI;
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Llamalend } from "../llamalend.js";
|
|
2
|
+
import type { ILlamma } from "../interfaces.js";
|
|
3
|
+
|
|
4
|
+
import ERC20ABI from "../constants/abis/ERC20.json" with { type: "json" };
|
|
5
|
+
import llammaABI from "../constants/abis/crvUSD/llamma.json" with { type: "json" };
|
|
6
|
+
import controllerABI from "../constants/abis/crvUSD/controller.json" with { type: "json" };
|
|
7
|
+
import controllerV2ABI from "../constants/abis/crvUSD/controller_v2.json" with { type: "json" };
|
|
8
|
+
import LeverageZapCrvUSDABI from "../constants/abis/crvUSD/LeverageZap.json" with { type: "json" };
|
|
9
|
+
import DeleverageZapABI from "../constants/abis/crvUSD/DeleverageZap.json" with { type: "json" };
|
|
10
|
+
import HealthCalculatorZapABI from "../constants/abis/crvUSD/HealthCalculatorZap.json" with { type: "json" };
|
|
11
|
+
import { resolveMonetaryPolicyAbi } from "./monetaryPolicyAbi.js";
|
|
12
|
+
|
|
13
|
+
const NATIVE_ETH_PLACEHOLDER = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
14
|
+
|
|
15
|
+
export const setupMintMarketContracts = (llamalend: Llamalend, llammaData: ILlamma): void => {
|
|
16
|
+
const isV2Controller = llammaData.is_deleverage_supported === true;
|
|
17
|
+
|
|
18
|
+
llamalend.setContract(llammaData.amm_address, llammaABI);
|
|
19
|
+
llamalend.setContract(llammaData.controller_address, isV2Controller ? controllerV2ABI : controllerABI);
|
|
20
|
+
llamalend.setContract(llammaData.monetary_policy_address, resolveMonetaryPolicyAbi(llammaData.monetary_policy_address));
|
|
21
|
+
|
|
22
|
+
if (llammaData.collateral_address === NATIVE_ETH_PLACEHOLDER) {
|
|
23
|
+
llamalend.setContract(llamalend.constants.WETH, ERC20ABI);
|
|
24
|
+
} else {
|
|
25
|
+
llamalend.setContract(llammaData.collateral_address, ERC20ABI);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
llamalend.setContract(llammaData.leverage_zap, LeverageZapCrvUSDABI);
|
|
29
|
+
llamalend.setContract(llammaData.deleverage_zap, DeleverageZapABI);
|
|
30
|
+
if (llammaData.health_calculator_zap && llammaData.health_calculator_zap !== llamalend.constants.ZERO_ADDRESS) {
|
|
31
|
+
llamalend.setContract(llammaData.health_calculator_zap, HealthCalculatorZapABI);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
llamalend.constants.DECIMALS[llammaData.collateral_address] = llammaData.collateral_decimals;
|
|
35
|
+
};
|