@gearbox-protocol/sdk 3.0.0-next.112 → 3.0.0-next.113
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/defiLamaAPY.js +6 -14
- package/package.json +1 -1
package/lib/apy/defiLamaAPY.js
CHANGED
|
@@ -6,20 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getDefiLamaAPY = void 0;
|
|
7
7
|
const sdk_gov_1 = require("@gearbox-protocol/sdk-gov");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const LAMA_URL = "https://
|
|
9
|
+
const LAMA_URL = "https://testnet.gearbox.foundation/api/defillama?ids=";
|
|
10
10
|
async function getDefiLamaAPY(networkType) {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
acc[item.pool] = item;
|
|
17
|
-
}
|
|
12
|
+
const currentNormal = NORMAL_TO_LAMA[networkType];
|
|
13
|
+
const res = await axios_1.default.get(`${LAMA_URL}${Object.values(currentNormal).join(",")}`);
|
|
14
|
+
const itemsRecord = res.data.data.reduce((acc, item) => {
|
|
15
|
+
acc[item.pool] = item;
|
|
18
16
|
return acc;
|
|
19
17
|
}, {});
|
|
20
|
-
const currentNormal = NORMAL_TO_LAMA[networkType];
|
|
21
18
|
const allAPY = sdk_gov_1.TypedObjectUtils.fromEntries(sdk_gov_1.TypedObjectUtils.entries(currentNormal).map(([symbol, pool]) => {
|
|
22
|
-
const { apy = 0 } =
|
|
19
|
+
const { apy = 0 } = itemsRecord[pool] || {};
|
|
23
20
|
return [symbol, Math.round(apy * Number(sdk_gov_1.PERCENTAGE_FACTOR))];
|
|
24
21
|
}));
|
|
25
22
|
return allAPY;
|
|
@@ -30,11 +27,6 @@ async function getDefiLamaAPY(networkType) {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
exports.getDefiLamaAPY = getDefiLamaAPY;
|
|
33
|
-
const NETWORK_TO_LAMA = {
|
|
34
|
-
Mainnet: "Ethereum",
|
|
35
|
-
Optimism: "Optimism",
|
|
36
|
-
Arbitrum: "Arbitrum",
|
|
37
|
-
};
|
|
38
30
|
const NORMAL_TO_LAMA = {
|
|
39
31
|
Mainnet: {
|
|
40
32
|
sDAI: "c8a24fee-ec00-4f38-86c0-9f6daebc4225",
|