mirror of
https://github.com/uniwhale-io/DefiLlama-yield-server.git
synced 2026-01-12 22:45:36 +08:00
ribbon fix, add inception apy
This commit is contained in:
5
migrations/1674563888630_add-inception-apy.js
Normal file
5
migrations/1674563888630_add-inception-apy.js
Normal file
@@ -0,0 +1,5 @@
|
||||
exports.up = (pgm) => {
|
||||
pgm.addColumns('yield', {
|
||||
apyBaseInception: 'numeric',
|
||||
});
|
||||
};
|
||||
@@ -12,7 +12,7 @@ const getNWeekApy = (perf, weekN) => {
|
||||
return (
|
||||
((1 +
|
||||
(perf[weekN].pricePerShare - perf[weekN - 1].pricePerShare) /
|
||||
perf[weekN].pricePerShare) **
|
||||
perf[weekN - 1].pricePerShare) **
|
||||
52 -
|
||||
1) *
|
||||
100
|
||||
@@ -87,9 +87,10 @@ const apyChain = async (chain) => {
|
||||
// for 7d IL we use the current weeks performance, if positive -> no IL, otherwise use that
|
||||
// value as the IL
|
||||
const weekN = perf.length - 1;
|
||||
(perf[weekN].pricePerShare - perf[weekN - 1].pricePerShare) /
|
||||
perf[weekN].pricePerShare;
|
||||
const il7d = weekN > 0 ? null : weekN;
|
||||
const weeklyPerf =
|
||||
(perf[weekN].pricePerShare - perf[weekN - 1].pricePerShare) /
|
||||
perf[weekN - 1].pricePerShare;
|
||||
const il7d = weeklyPerf > 0 ? null : weeklyPerf;
|
||||
|
||||
const price = prices[vault.underlyingAsset];
|
||||
|
||||
@@ -106,6 +107,10 @@ const apyChain = async (chain) => {
|
||||
underlyingTokens: [vault.underlyingAsset],
|
||||
poolMeta: vault.name.includes('Put') ? 'Put-Selling' : 'Covered-Call',
|
||||
il7d,
|
||||
apyBaseInception:
|
||||
((perf[perf.length - 1].pricePerShare - perf[0].pricePerShare) /
|
||||
perf[0].pricePerShare) *
|
||||
100,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ describe(`Running ${process.env.npm_config_adapter} Test`, () => {
|
||||
'il7d',
|
||||
'volumeUsd1d',
|
||||
'volumeUsd7d',
|
||||
'apyBaseInception',
|
||||
];
|
||||
const fields = [...Object.keys(baseFields), ...optionalFields, 'tvlUsd'];
|
||||
apy.forEach((pool) => {
|
||||
|
||||
@@ -404,6 +404,7 @@ const buildInsertYieldQuery = (payload) => {
|
||||
'apyRewardBorrowFake',
|
||||
'volumeUsd1d',
|
||||
'volumeUsd7d',
|
||||
'apyBaseInception',
|
||||
{ name: 'apyBaseBorrow', def: null },
|
||||
{ name: 'apyRewardBorrow', def: null },
|
||||
{ name: 'totalSupplyUsd', def: null },
|
||||
|
||||
@@ -75,6 +75,7 @@ const main = async (body) => {
|
||||
apyBase7d: strToNum(p.apyBase7d),
|
||||
apyRewardFake: strToNum(p.apyRewardFake),
|
||||
apyRewardBorrowFake: strToNum(p.apyRewardBorrowFake),
|
||||
apyBaseInception: strToNum(p.apyBaseInception),
|
||||
}));
|
||||
|
||||
// filter tvl to be btw lb-ub
|
||||
@@ -99,6 +100,9 @@ const main = async (body) => {
|
||||
apyRewardBorrowFake: Number.isFinite(p.apyRewardBorrowFake)
|
||||
? p.apyRewardBorrowFake
|
||||
: null,
|
||||
apyBaseInception: Number.isFinite(p.apyBaseInception)
|
||||
? p.apyBaseInception
|
||||
: null,
|
||||
}));
|
||||
|
||||
// remove pools where all 3 apy related fields are null
|
||||
@@ -339,9 +343,11 @@ const main = async (body) => {
|
||||
p.apyRewardBorrowFake !== null
|
||||
? +p.apyRewardBorrowFake.toFixed(precision)
|
||||
: p.apyRewardBorrowFake,
|
||||
|
||||
volumeUsd1d: p.volumeUsd1d ? +p.volumeUsd1d.toFixed(precision) : null,
|
||||
volumeUsd7d: p.volumeUsd7d ? +p.volumeUsd7d.toFixed(precision) : null,
|
||||
apyBaseInception: p.apyBaseInception
|
||||
? +p.apyBaseInception.toFixed(precision)
|
||||
: null,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user