@gearbox-protocol/sdk 1.20.20 → 1.20.21
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/lib/apy/lidoAPY.d.ts +2 -25
- package/lib/apy/lidoAPY.js +64 -64
- package/package.json +1 -1
package/lib/apy/lidoAPY.d.ts
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { MCall } from "../utils/multicall";
|
|
4
|
-
export declare type LidoDataCallResponse = [
|
|
5
|
-
Awaited<ReturnType<ILidoOracle["getLastCompletedReportDelta"]>>,
|
|
6
|
-
Awaited<ReturnType<IstETH["getFee"]>>
|
|
7
|
-
];
|
|
8
|
-
export interface GetLidoAPYProps {
|
|
9
|
-
generated: GetLidoAPYCallsReturns;
|
|
10
|
-
response: LidoDataCallResponse;
|
|
11
|
-
}
|
|
12
|
-
export declare function getLidoAPY({ response }: GetLidoAPYProps): readonly [import("ethers").BigNumber, number];
|
|
13
|
-
export declare const LIDO_FEE_DECIMALS = 10000;
|
|
14
|
-
export interface GetLidoAPYCallsProps {
|
|
15
|
-
networkType: NetworkType;
|
|
16
|
-
}
|
|
17
|
-
declare type GetLidoAPYCallsReturns = ReturnType<typeof getLidoAPYCalls>;
|
|
18
|
-
export declare function getLidoAPYCalls({ networkType }: GetLidoAPYCallsProps): {
|
|
19
|
-
poolInfo: {
|
|
20
|
-
lidoOracleAddress: string;
|
|
21
|
-
stETHAddress: string;
|
|
22
|
-
};
|
|
23
|
-
calls: [MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/lido/ILidoOracle").ILidoOracleInterface>, ...MCall<import("../types/@gearbox-protocol/integrations-v2/contracts/integrations/lido/IstETH.sol/IstETH").IstETHInterface>[]];
|
|
24
|
-
};
|
|
25
|
-
export {};
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
export declare function getLidoAPY(): Promise<BigNumber>;
|
package/lib/apy/lidoAPY.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
40
|
};
|
|
13
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
15
|
-
var
|
|
42
|
+
exports.getLidoAPY = void 0;
|
|
43
|
+
var axios_1 = __importDefault(require("axios"));
|
|
44
|
+
var ethers_1 = require("ethers");
|
|
16
45
|
var constants_1 = require("../core/constants");
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
function getLidoAPY(
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var lidoOracles = contracts_1.contractParams.LIDO_STETH_GATEWAY.oracle;
|
|
39
|
-
var lidoStEth = {
|
|
40
|
-
Mainnet: token_1.tokenDataByNetwork.Mainnet.STETH,
|
|
41
|
-
Goerli: token_1.tokenDataByNetwork.Goerli.STETH,
|
|
42
|
-
};
|
|
43
|
-
function getLidoInfo(networkType) {
|
|
44
|
-
if (!lidoOracles[networkType]) {
|
|
45
|
-
throw new Error("No Lido APR oracle found on current network: ".concat(networkType));
|
|
46
|
-
}
|
|
47
|
-
if (!lidoStEth[networkType]) {
|
|
48
|
-
throw new Error("No Lido stETH found on current network: ".concat(networkType));
|
|
49
|
-
}
|
|
50
|
-
var lidoOracleAddress = lidoOracles[networkType];
|
|
51
|
-
var stETHAddress = lidoStEth[networkType];
|
|
52
|
-
return { lidoOracleAddress: lidoOracleAddress, stETHAddress: stETHAddress };
|
|
53
|
-
}
|
|
54
|
-
function getLidoDataCalls(_a) {
|
|
55
|
-
var lidoOracleAddress = _a.lidoOracleAddress, stETHAddress = _a.stETHAddress, network = _a.network;
|
|
56
|
-
var calls = [
|
|
57
|
-
{
|
|
58
|
-
address: lidoOracleAddress,
|
|
59
|
-
interface: types_1.ILidoOracle__factory.createInterface(),
|
|
60
|
-
method: "getLastCompletedReportDelta()",
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
if (network === "Mainnet")
|
|
64
|
-
calls.push({
|
|
65
|
-
address: stETHAddress,
|
|
66
|
-
interface: types_1.IstETH__factory.createInterface(),
|
|
67
|
-
method: "getFee()",
|
|
46
|
+
var formatter_1 = require("../utils/formatter");
|
|
47
|
+
var LIDO_URL = "https://eth-api.lido.fi/v1/protocol/steth/apr/sma";
|
|
48
|
+
function getLidoAPY() {
|
|
49
|
+
var _a;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var res, _b, smaApr, e_1;
|
|
52
|
+
return __generator(this, function (_c) {
|
|
53
|
+
switch (_c.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
_c.trys.push([0, 2, , 3]);
|
|
56
|
+
return [4 /*yield*/, axios_1.default.get(LIDO_URL)];
|
|
57
|
+
case 1:
|
|
58
|
+
res = _c.sent();
|
|
59
|
+
_b = (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) || {}).smaApr, smaApr = _b === void 0 ? 0 : _b;
|
|
60
|
+
return [2 /*return*/, (0, formatter_1.toBN)(String(smaApr), constants_1.WAD_DECIMALS_POW).div(constants_1.PERCENTAGE_DECIMALS)];
|
|
61
|
+
case 2:
|
|
62
|
+
e_1 = _c.sent();
|
|
63
|
+
console.error(e_1);
|
|
64
|
+
return [2 /*return*/, ethers_1.BigNumber.from(0)];
|
|
65
|
+
case 3: return [2 /*return*/];
|
|
66
|
+
}
|
|
68
67
|
});
|
|
69
|
-
|
|
68
|
+
});
|
|
70
69
|
}
|
|
70
|
+
exports.getLidoAPY = getLidoAPY;
|