@curvefi/llamalend-api 2.0.2 → 2.0.4
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 +6 -0
- package/lib/constants/abis/ControllerV2.json +1891 -0
- package/lib/index.d.ts +2 -2
- package/lib/lendMarkets/LendMarketTemplate.d.ts +9 -5
- package/lib/lendMarkets/LendMarketTemplate.js +12 -11
- package/lib/lendMarkets/fetch/fetchLendMarkets.js +6 -1
- package/lib/lendMarkets/interfaces/v1/statsV1.d.ts +1 -0
- package/lib/lendMarkets/interfaces/v2/loanV2.d.ts +1 -1
- package/lib/lendMarkets/interfaces/v2/statsV2.d.ts +1 -0
- package/lib/lendMarkets/lendMarketConstructor.d.ts +1 -1
- package/lib/lendMarkets/lendMarketConstructor.js +6 -1
- package/lib/lendMarkets/modules/common/loanBase.d.ts +0 -1
- package/lib/lendMarkets/modules/common/loanBase.js +8 -23
- package/lib/lendMarkets/modules/common/statsBase.d.ts +4 -2
- package/lib/lendMarkets/modules/common/statsBase.js +56 -85
- package/lib/lendMarkets/modules/v1/loanV1.d.ts +1 -0
- package/lib/lendMarkets/modules/v1/loanV1.js +19 -0
- package/lib/lendMarkets/modules/v2/loanV2.d.ts +5 -0
- package/lib/lendMarkets/modules/v2/loanV2.js +57 -0
- package/lib/lendMarkets/modules/v2/statsV2.d.ts +2 -0
- package/lib/lendMarkets/modules/v2/statsV2.js +19 -0
- package/lib/lendMarkets/utils.d.ts +14 -0
- package/lib/lendMarkets/utils.js +31 -0
- package/lib/llamalend.d.ts +1 -1
- package/package.json +9 -3
- package/src/constants/abis/ControllerV2.json +1891 -0
- package/src/lendMarkets/LendMarketTemplate.ts +24 -19
- package/src/lendMarkets/fetch/fetchLendMarkets.ts +7 -1
- package/src/lendMarkets/interfaces/v1/statsV1.ts +1 -0
- package/src/lendMarkets/interfaces/v2/loanV2.ts +1 -1
- package/src/lendMarkets/interfaces/v2/statsV2.ts +1 -0
- package/src/lendMarkets/lendMarketConstructor.ts +6 -2
- package/src/lendMarkets/modules/common/loanBase.ts +9 -24
- package/src/lendMarkets/modules/common/statsBase.ts +74 -92
- package/src/lendMarkets/modules/v1/loanV1.ts +12 -1
- package/src/lendMarkets/modules/v2/loanV2.ts +55 -1
- package/src/lendMarkets/modules/v2/statsV2.ts +9 -1
- package/src/lendMarkets/utils.ts +44 -0
- package/src/llamalend.ts +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BN, toBN } from "../utils";
|
|
11
|
+
/**
|
|
12
|
+
* Computes borrow/lend APR and APY from a raw per-second rate and current debt/cap.
|
|
13
|
+
* borrowApy = e^(rate * 365 * 86400) - 1
|
|
14
|
+
* lendApy = (debt * e^(rate * 365 * 86400) - debt) / cap
|
|
15
|
+
*/
|
|
16
|
+
export const computeRatesFromRate = (_rate, debt, cap) => {
|
|
17
|
+
const annualFactor = toBN(_rate).times(365).times(86400);
|
|
18
|
+
const expFactor = Math.pow(Math.E, annualFactor.toNumber());
|
|
19
|
+
const borrowApr = annualFactor.times(100).toString();
|
|
20
|
+
const borrowApy = String((expFactor - 1) * 100);
|
|
21
|
+
const lendApr = annualFactor.times(debt).div(cap).times(100).toString();
|
|
22
|
+
const lendApy = BN(debt).times(expFactor).minus(debt).div(cap).times(100).toString();
|
|
23
|
+
return { borrowApr, lendApr, borrowApy, lendApy };
|
|
24
|
+
};
|
|
25
|
+
export const fetchMarketDataByVault = (networkName, vaultAddress, getData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const response = yield getData(networkName);
|
|
27
|
+
const market = response.lendingVaultData.find((item) => item.address.toLowerCase() === vaultAddress.toLowerCase());
|
|
28
|
+
if (!market)
|
|
29
|
+
throw new Error("Market not found in API");
|
|
30
|
+
return market;
|
|
31
|
+
});
|
package/lib/llamalend.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare class Llamalend implements ILlamalend {
|
|
|
21
21
|
[addres: string]: MintMarketTemplate;
|
|
22
22
|
};
|
|
23
23
|
lendMarkets: {
|
|
24
|
-
[
|
|
24
|
+
[address: string]: LendMarketTemplate<'v1'> | LendMarketTemplate<'v2'>;
|
|
25
25
|
};
|
|
26
26
|
feeData: {
|
|
27
27
|
gasPrice?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/llamalend-api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "JavaScript library for Curve Lending",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Macket",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"watch": "tsc --watch",
|
|
21
21
|
"watch:lib": "rm -rf lib && tsc --watch --project tsconfig.build.json"
|
|
22
22
|
},
|
|
23
|
-
"engines": {
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "24"
|
|
25
|
+
},
|
|
24
26
|
"type": "module",
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@eslint/eslintrc": "^3.3.1",
|
|
@@ -35,10 +37,14 @@
|
|
|
35
37
|
"chai": "^5.3.3",
|
|
36
38
|
"eslint": "^9.38.0",
|
|
37
39
|
"globals": "^16.4.0",
|
|
38
|
-
"mocha": "^11.7.
|
|
40
|
+
"mocha": "^11.7.5",
|
|
39
41
|
"typescript": "^5.9.3",
|
|
40
42
|
"vue-eslint-parser": "^10.2.0"
|
|
41
43
|
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"serialize-javascript": "^7.0.4",
|
|
46
|
+
"diff": "^8.0.3"
|
|
47
|
+
},
|
|
42
48
|
"dependencies": {
|
|
43
49
|
"@curvefi/ethcall": "6.0.16",
|
|
44
50
|
"bignumber.js": "9.3.1",
|