mirror of
https://github.com/uniwhale-io/DefiLlama-yield-server.git
synced 2026-01-12 17:12:21 +08:00
add 7d apy field for dexes (#455)
This commit is contained in:
5
migrations/1669374124328_add-apy7d-field.js
Normal file
5
migrations/1669374124328_add-apy7d-field.js
Normal file
@@ -0,0 +1,5 @@
|
||||
exports.up = (pgm) => {
|
||||
pgm.addColumns('yield', {
|
||||
apyBase7d: 'numeric',
|
||||
});
|
||||
};
|
||||
@@ -30,6 +30,7 @@ describe(`Running ${process.env.npm_config_adapter} Test`, () => {
|
||||
'borrowable',
|
||||
'debtCeilingUsd',
|
||||
'mintedCoin',
|
||||
'apyBase7d',
|
||||
];
|
||||
const fields = [...Object.keys(baseFields), ...optionalFields, 'tvlUsd'];
|
||||
apy.forEach((pool) => {
|
||||
|
||||
@@ -355,6 +355,7 @@ const buildInsertYieldQuery = (payload) => {
|
||||
'apyBase',
|
||||
'apyReward',
|
||||
'il7d',
|
||||
'apyBase7d',
|
||||
{ name: 'apyBaseBorrow', def: null },
|
||||
{ name: 'apyRewardBorrow', def: null },
|
||||
{ name: 'totalSupplyUsd', def: null },
|
||||
|
||||
@@ -68,6 +68,7 @@ const main = async (body) => {
|
||||
apyReward: strToNum(p.apyReward),
|
||||
apyBaseBorrow: strToNum(p.apyBaseBorrow),
|
||||
apyRewardBorrow: strToNum(p.apyRewardBorrow),
|
||||
apyBase7d: strToNum(p.apyBase7d),
|
||||
}));
|
||||
|
||||
// filter tvl to be btw lb-ub
|
||||
@@ -87,6 +88,7 @@ const main = async (body) => {
|
||||
apyRewardBorrow: Number.isFinite(p.apyRewardBorrow)
|
||||
? p.apyRewardBorrow
|
||||
: null,
|
||||
apyBase7d: Number.isFinite(p.apyBase7d) ? p.apyBase7d : null,
|
||||
}));
|
||||
|
||||
// remove pools where all 3 apy related fields are null
|
||||
@@ -102,6 +104,7 @@ const main = async (body) => {
|
||||
apyReward: p.apyReward < 0 ? 0 : p.apyReward,
|
||||
apyBaseBorrow: p.apyBaseBorrow < 0 ? 0 : p.apyBaseBorrow,
|
||||
apyRewardBorrow: p.apyRewardBorrow < 0 ? 0 : p.apyRewardBorrow,
|
||||
apyBase7d: p.apyBase7d < 0 ? 0 : p.apyBase7d,
|
||||
}));
|
||||
|
||||
// derive final total apy field
|
||||
@@ -311,6 +314,8 @@ const main = async (body) => {
|
||||
mintedCoin: p.mintedCoin ? utils.formatSymbol(p.mintedCoin) : null,
|
||||
poolMeta: p.poolMeta === undefined ? null : p.poolMeta,
|
||||
il7d: p.il7d ? +p.il7d.toFixed(precision) : null,
|
||||
apyBase7d:
|
||||
p.apyBase7d !== null ? +p.apyBase7d.toFixed(precision) : p.apyBase7d,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user