@curvefi/llamalend-api 1.0.3 → 1.0.6
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/.github/workflows/lint.yml +2 -2
- package/.github/workflows/publish.yml +11 -7
- package/eslint.config.mjs +87 -0
- package/lib/cache/index.js +18 -19
- package/lib/constants/L2Networks.js +1 -1
- package/lib/constants/abis/crvUSD/controller_v2.json +979 -0
- package/lib/constants/aliases.js +34 -34
- package/lib/constants/coins.js +16 -16
- package/lib/constants/llammas.js +1 -1
- package/lib/constants/utils.js +8 -10
- package/lib/external-api.d.ts +8 -6
- package/lib/external-api.js +136 -397
- package/lib/index.d.ts +9 -10
- package/lib/index.js +46 -81
- package/lib/interfaces.d.ts +2 -20
- package/lib/lendMarkets/LendMarketTemplate.js +2438 -4419
- package/lib/lendMarkets/lendMarketConstructor.js +2 -2
- package/lib/llamalend.js +511 -696
- package/lib/mintMarkets/MintMarketTemplate.js +1469 -2799
- package/lib/mintMarkets/mintMarketConstructor.js +1 -1
- package/lib/st-crvUSD.js +172 -488
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +318 -548
- package/package.json +21 -16
- package/src/cache/index.ts +1 -0
- package/src/constants/abis/crvUSD/controller_v2.json +979 -0
- package/src/constants/aliases.ts +7 -7
- package/src/external-api.ts +25 -148
- package/src/interfaces.ts +2 -21
- package/src/lendMarkets/LendMarketTemplate.ts +31 -6
- package/src/llamalend.ts +36 -6
- package/src/mintMarkets/MintMarketTemplate.ts +2 -2
- package/src/utils.ts +8 -8
- package/tsconfig.json +1 -1
- package/.eslintrc.json +0 -40
package/lib/constants/aliases.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { lowerCaseValues } from "./utils.js";
|
|
2
|
-
export
|
|
2
|
+
export const ALIASES_ETHEREUM = lowerCaseValues({
|
|
3
3
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
4
4
|
"one_way_factory": "0xeA6876DDE9e3467564acBeE1Ed5bac88783205E0",
|
|
5
5
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
6
6
|
"minter": '0xd061D61a4d941c39E5453435B6345Dc261C2fcE0',
|
|
7
7
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
8
8
|
// "leverage_zap": "0x3294514B78Df4Bb90132567fcf8E5e99f390B687", // 1inch
|
|
9
|
-
"leverage_zap": "0xC5898606BdB494a994578453B92e7910a90aA873",
|
|
9
|
+
"leverage_zap": "0xC5898606BdB494a994578453B92e7910a90aA873", // odos
|
|
10
10
|
"leverage_markets_start_id": "9",
|
|
11
11
|
"crvUSD": "0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E",
|
|
12
12
|
"st_crvUSD": "0x0655977FEb2f289A4aB78af67BAB0d17aAb84367",
|
|
13
13
|
});
|
|
14
|
-
export
|
|
14
|
+
export const ALIASES_POLYGON = lowerCaseValues({
|
|
15
15
|
"crv": "0x172370d5cd63279efa6d502dab29171933a610af",
|
|
16
16
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
17
17
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
18
18
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
19
19
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
20
20
|
});
|
|
21
|
-
export
|
|
21
|
+
export const ALIASES_FANTOM = lowerCaseValues({
|
|
22
22
|
"crv": "0x1E4F97b9f9F913c46F1632781732927B9019C68b",
|
|
23
23
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
24
24
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
25
25
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
26
26
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
27
27
|
});
|
|
28
|
-
export
|
|
28
|
+
export const ALIASES_AVALANCHE = lowerCaseValues({
|
|
29
29
|
"crv": "0x47536F17F4fF30e64A96a7555826b8f9e66ec468",
|
|
30
30
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
31
31
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
32
32
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
33
33
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
34
34
|
});
|
|
35
|
-
export
|
|
35
|
+
export const ALIASES_ARBITRUM = lowerCaseValues({
|
|
36
36
|
"crv": "0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978",
|
|
37
37
|
"one_way_factory": "0xcaEC110C784c9DF37240a8Ce096D352A75922DeA",
|
|
38
38
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
39
39
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
40
40
|
// "leverage_zap": "0x61C404B60ee9c5fB09F70F9A645DD38fE5b3A956", // 1inch
|
|
41
|
-
"leverage_zap": "0xb7b240CFa985306563A301bC417Bc9715059a117",
|
|
41
|
+
"leverage_zap": "0xb7b240CFa985306563A301bC417Bc9715059a117", // odos
|
|
42
42
|
"leverage_markets_start_id": "9",
|
|
43
43
|
});
|
|
44
|
-
export
|
|
44
|
+
export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
45
45
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
46
46
|
"one_way_factory": "0x5EA8f3D674C70b020586933A0a5b250734798BeF",
|
|
47
47
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -50,75 +50,75 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
50
50
|
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
|
|
51
51
|
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
|
|
52
52
|
});
|
|
53
|
-
export
|
|
53
|
+
export const ALIASES_XDAI = lowerCaseValues({
|
|
54
54
|
"crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
|
|
55
55
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
56
56
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
57
57
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
58
58
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
59
59
|
});
|
|
60
|
-
export
|
|
60
|
+
export const ALIASES_MOONBEAM = lowerCaseValues({
|
|
61
61
|
"crv": "0x7C598c96D02398d89FbCb9d41Eab3DF0C16F227D",
|
|
62
62
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
63
63
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
64
64
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
65
65
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
66
66
|
});
|
|
67
|
-
export
|
|
67
|
+
export const ALIASES_AURORA = lowerCaseValues({
|
|
68
68
|
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
69
69
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
70
70
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
71
71
|
"gauge_factory": "0x0000000000000000000000000000000000000000",
|
|
72
72
|
});
|
|
73
|
-
export
|
|
74
|
-
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
73
|
+
export const ALIASES_KAVA = lowerCaseValues({
|
|
74
|
+
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205", // <--- TODO CHANGE
|
|
75
75
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
76
76
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
77
77
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
78
78
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
79
79
|
});
|
|
80
|
-
export
|
|
81
|
-
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
|
|
80
|
+
export const ALIASES_CELO = lowerCaseValues({
|
|
81
|
+
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB", // <--- TODO CHANGE
|
|
82
82
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
83
83
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
84
84
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
85
85
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
86
86
|
});
|
|
87
|
-
export
|
|
88
|
-
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
|
|
87
|
+
export const ALIASES_ZKSYNC = lowerCaseValues({
|
|
88
|
+
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB", // <--- TODO CHANGE
|
|
89
89
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
90
|
-
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
90
|
+
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB", // <--- TODO CHANGE
|
|
91
91
|
"gauge_factory": "0x0000000000000000000000000000000000000000",
|
|
92
92
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
93
93
|
});
|
|
94
|
-
export
|
|
94
|
+
export const ALIASES_BASE = lowerCaseValues({
|
|
95
95
|
"crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
|
|
96
96
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
97
|
-
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
97
|
+
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB", // <--- TODO CHANGE
|
|
98
98
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
99
99
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
100
100
|
});
|
|
101
|
-
export
|
|
102
|
-
"crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
|
|
101
|
+
export const ALIASES_BSC = lowerCaseValues({
|
|
102
|
+
"crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415", // <--- TODO CHANGE
|
|
103
103
|
"one_way_factory": "0x0000000000000000000000000000000000000000",
|
|
104
|
-
"gauge_controller": "0x0000000000000000000000000000000000000000",
|
|
104
|
+
"gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
|
|
105
105
|
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
106
106
|
"leverage_zap": "0x0000000000000000000000000000000000000000",
|
|
107
107
|
});
|
|
108
|
-
export
|
|
108
|
+
export const ALIASES_FRAXTAL = lowerCaseValues({
|
|
109
109
|
"crv": "0x331B9182088e2A7d6D3Fe4742AbA1fB231aEcc56",
|
|
110
110
|
"one_way_factory": "0xf3c9bdAB17B7016fBE3B77D17b1602A7db93ac66",
|
|
111
|
-
"gauge_controller": "0x0000000000000000000000000000000000000000",
|
|
112
|
-
"
|
|
113
|
-
"
|
|
111
|
+
"gauge_controller": "0x0000000000000000000000000000000000000000", // <--- TODO CHANGE
|
|
112
|
+
"gauge_factory_old": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
|
|
113
|
+
"gauge_factory": "0x0b8d6b6cefc7aa1c2852442e518443b1b22e1c52",
|
|
114
|
+
"leverage_zap": "0x37c5ab57AF7100Bdc9B668d766e193CCbF6614FD", // odos
|
|
114
115
|
"leverage_markets_start_id": "0",
|
|
115
116
|
});
|
|
116
|
-
export
|
|
117
|
-
"crv": "
|
|
118
|
-
"one_way_factory": "
|
|
117
|
+
export const ALIASES_SONIC = lowerCaseValues({
|
|
118
|
+
"crv": "0x5Af79133999f7908953E94b7A5CF367740Ebee35",
|
|
119
|
+
"one_way_factory": "0x30d1859dad5a52ae03b6e259d1b48c4b12933993",
|
|
119
120
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
120
|
-
"gauge_factory": "
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
"leverage_markets_start_id": "9",
|
|
121
|
+
"gauge_factory": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
|
|
122
|
+
"leverage_zap": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7", // odos
|
|
123
|
+
"leverage_markets_start_id": "0",
|
|
124
124
|
});
|
package/lib/constants/coins.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { lowerCaseValues } from "./utils.js";
|
|
2
|
-
export
|
|
2
|
+
export const COINS_ETHEREUM = lowerCaseValues({
|
|
3
3
|
'eth': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
4
4
|
'sfrxeth': '0xac3E018457B222d93114458476f3E3416Abbe38F',
|
|
5
5
|
'crvusd': '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
|
|
6
6
|
});
|
|
7
|
-
export
|
|
7
|
+
export const COINS_POLYGON = lowerCaseValues({
|
|
8
8
|
'sdt': '0x361a5a4993493ce00f61c32d4ecca5512b82ce90',
|
|
9
9
|
'weth': '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
10
10
|
});
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
11
|
+
export const COINS_FANTOM = lowerCaseValues({});
|
|
12
|
+
export const COINS_AVALANCHE = lowerCaseValues({});
|
|
13
|
+
export const COINS_ARBITRUM = lowerCaseValues({});
|
|
14
|
+
export const COINS_OPTIMISM = lowerCaseValues({});
|
|
15
|
+
export const COINS_XDAI = lowerCaseValues({});
|
|
16
|
+
export const COINS_MOONBEAM = lowerCaseValues({});
|
|
17
|
+
export const COINS_AURORA = lowerCaseValues({});
|
|
18
|
+
export const COINS_KAVA = lowerCaseValues({});
|
|
19
|
+
export const COINS_CELO = lowerCaseValues({});
|
|
20
|
+
export const COINS_ZKSYNC = lowerCaseValues({});
|
|
21
|
+
export const COINS_BASE = lowerCaseValues({});
|
|
22
|
+
export const COINS_BSC = lowerCaseValues({});
|
|
23
|
+
export const COINS_FRAXTAL = lowerCaseValues({});
|
|
24
|
+
export const COINS_SONIC = lowerCaseValues({});
|
package/lib/constants/llammas.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MonetaryPolicyABI from './abis/crvUSD/MonetaryPolicy.json' assert { type: 'json' };
|
|
2
2
|
import MonetaryPolicy2ABI from './abis/crvUSD/MonetaryPolicy2.json' assert { type: 'json' };
|
|
3
3
|
import { lowerCaseLlammasAddresses } from "./utils";
|
|
4
|
-
export
|
|
4
|
+
export const LLAMMAS = lowerCaseLlammasAddresses({
|
|
5
5
|
sfrxeth: {
|
|
6
6
|
amm_address: '0x136e783846ef68C8Bd00a3369F787dF8d683a696',
|
|
7
7
|
controller_address: '0x8472A9A7632b173c8Cf3a86D3afec50c35548e76',
|
package/lib/constants/utils.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export var lowerCaseLlammasAddresses = function (llammas) {
|
|
5
|
-
for (var llammaId in llammas) {
|
|
1
|
+
export const lowerCaseValues = (dict) => Object.fromEntries(Object.entries(dict).map((entry) => [entry[0], entry[1].toLowerCase()]));
|
|
2
|
+
export const lowerCaseLlammasAddresses = (llammas) => {
|
|
3
|
+
for (const llammaId in llammas) {
|
|
6
4
|
if (!Object.prototype.hasOwnProperty.call(llammas, llammaId))
|
|
7
5
|
continue;
|
|
8
|
-
|
|
6
|
+
const llamma = llammas[llammaId];
|
|
9
7
|
llamma.amm_address = llamma.amm_address.toLowerCase();
|
|
10
8
|
llamma.controller_address = llamma.controller_address.toLowerCase();
|
|
11
9
|
llamma.collateral_address = llamma.collateral_address.toLowerCase();
|
|
@@ -14,12 +12,12 @@ export var lowerCaseLlammasAddresses = function (llammas) {
|
|
|
14
12
|
}
|
|
15
13
|
return llammas;
|
|
16
14
|
};
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
for (
|
|
15
|
+
export const extractDecimals = (llammas) => {
|
|
16
|
+
const DECIMALS = {};
|
|
17
|
+
for (const llammaId in llammas) {
|
|
20
18
|
if (!Object.prototype.hasOwnProperty.call(llammas, llammaId))
|
|
21
19
|
continue;
|
|
22
|
-
|
|
20
|
+
const llamma = llammas[llammaId];
|
|
23
21
|
// Collateral
|
|
24
22
|
DECIMALS[llamma.collateral_address] = llamma.collateral_decimals;
|
|
25
23
|
}
|
package/lib/external-api.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import memoize from "memoizee";
|
|
2
|
-
import {
|
|
2
|
+
import { IDict, IMarketData, INetworkName, IQuoteOdos } from "./interfaces";
|
|
3
3
|
export declare const _getUsdPricesFromApi: () => Promise<IDict<number>>;
|
|
4
|
-
|
|
4
|
+
type UserCollateral = {
|
|
5
|
+
total_deposit_precise: string;
|
|
6
|
+
total_deposit_from_user: number;
|
|
7
|
+
total_deposit_usd_value: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const _getUserCollateral: ((network: INetworkName, controller: string, user: string) => Promise<UserCollateral>) & memoize.Memoized<(network: INetworkName, controller: string, user: string) => Promise<UserCollateral>>;
|
|
5
10
|
export declare const _getUserCollateralCrvUsd: ((network: INetworkName, controller: string, user: string) => Promise<string>) & memoize.Memoized<(network: INetworkName, controller: string, user: string) => Promise<string>>;
|
|
6
11
|
export declare const _getMarketsData: ((network: INetworkName) => Promise<IMarketData>) & memoize.Memoized<(network: INetworkName) => Promise<IMarketData>>;
|
|
7
12
|
export declare const _getQuoteOdos: (fromToken: string, toToken: string, _amount: bigint, blacklist: string, pathVizImage: boolean, slippage?: number) => Promise<IQuoteOdos>;
|
|
8
13
|
export declare const _getExpectedOdos: (fromToken: string, toToken: string, _amount: bigint, blacklist: string) => Promise<string>;
|
|
9
14
|
export declare const _assembleTxOdos: ((pathId: string) => Promise<string>) & memoize.Memoized<(pathId: string) => Promise<string>>;
|
|
10
|
-
export
|
|
11
|
-
export declare const _getExpected1inch: ((fromToken: string, toToken: string, _amount: bigint) => Promise<string>) & memoize.Memoized<(fromToken: string, toToken: string, _amount: bigint) => Promise<string>>;
|
|
12
|
-
export declare const _getSwapData1inch: ((fromToken: string, toToken: string, _amount: bigint, slippage: number) => Promise<I1inchSwapData>) & memoize.Memoized<(fromToken: string, toToken: string, _amount: bigint, slippage: number) => Promise<I1inchSwapData>>;
|
|
13
|
-
export declare const _getSpotPrice1inch: ((fromToken: string, toToken: string) => Promise<string | undefined>) & memoize.Memoized<(fromToken: string, toToken: string) => Promise<string | undefined>>;
|
|
15
|
+
export {};
|