-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdff27f
commit db294dc
Showing
8 changed files
with
189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import getApyBreakdown from '../common/getApyBreakdown'; | ||
import { getCurveGetBaseApys } from '../common/curve/getCurveApyData'; | ||
import { getCurveApysCommon } from '../common/curve/getCurveApysCommon'; | ||
import { FRAXTAL_CHAIN_ID as chainId } from '../../../constants'; | ||
|
||
const pools = require('../../../data/fraxtal/curvePools.json').filter(p => p.gauge && !p.convex); | ||
const subgraphApyUrl = 'https://api.curve.fi/api/getSubgraphData/fraxtal'; | ||
const baseApyUrl = 'https://api.curve.fi/v1/getBaseApys/fraxtal'; | ||
const tradingFees = 0.0002; | ||
|
||
export const getCurveApys = async () => { | ||
const [baseApys, farmApys] = await Promise.all([ | ||
getCurveGetBaseApys(pools, baseApyUrl), | ||
getCurveApysCommon(chainId, pools), | ||
]); | ||
const poolsMap = pools.map(p => ({ name: p.name, address: p.name })); | ||
return getApyBreakdown(poolsMap, baseApys, farmApys, tradingFees); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const { getCurveApys } = require('./getCurveApys'); | ||
|
||
const getApys = [getCurveApys]; | ||
|
||
const getFraxtalApys = async () => { | ||
const start = Date.now(); | ||
let apys = {}; | ||
let apyBreakdowns = {}; | ||
|
||
let promises = []; | ||
getApys.forEach(getApy => promises.push(getApy())); | ||
const results = await Promise.allSettled(promises); | ||
|
||
for (const result of results) { | ||
if (result.status !== 'fulfilled') { | ||
console.warn('getFraxtalApys error', result.reason); | ||
continue; | ||
} | ||
|
||
// Set default APY values | ||
let mappedApyValues = result.value; | ||
let mappedApyBreakdownValues = {}; | ||
|
||
// Loop through key values and move default breakdown format | ||
// To require totalApy key | ||
for (const [key, value] of Object.entries(result.value)) { | ||
mappedApyBreakdownValues[key] = { | ||
totalApy: value, | ||
}; | ||
} | ||
|
||
// Break out to apy and breakdowns if possible | ||
let hasApyBreakdowns = 'apyBreakdowns' in result.value; | ||
if (hasApyBreakdowns) { | ||
mappedApyValues = result.value.apys; | ||
mappedApyBreakdownValues = result.value.apyBreakdowns; | ||
} | ||
|
||
apys = { ...apys, ...mappedApyValues }; | ||
|
||
apyBreakdowns = { ...apyBreakdowns, ...mappedApyBreakdownValues }; | ||
} | ||
|
||
const end = Date.now(); | ||
console.log(`> [APY] Fraxtal finished updating in ${(end - start) / 1000}s`); | ||
|
||
return { | ||
apys, | ||
apyBreakdowns, | ||
}; | ||
}; | ||
|
||
module.exports = { getFraxtalApys }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
[ | ||
{ | ||
"name": "curve-fraxtal-crvusd-frax", | ||
"pool": "0x63eb7846642630456707c3efbb50a03c79b89d81", | ||
"gauge": "0x98a6c35546be6f7c545c99efb48f4673ed2c99fc", | ||
"rewards": [ | ||
{ | ||
"token": "0xFc00000000000000000000000000000000000002", | ||
"oracleId": "FXS" | ||
} | ||
], | ||
"tokens": [ | ||
{ | ||
"oracleId": "crvUSD", | ||
"decimals": "1e18" | ||
}, | ||
{ | ||
"oracleId": "FRAX", | ||
"decimals": "1e18" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "curve-fraxtal-fraxusdc", | ||
"pool": "0xa8eb7b41fe8df7ea3de982397ad183721784d987", | ||
"gauge": "0xaa6ddba00de48d41e41543ef0a78ab31aae4de8d", | ||
"rewards": [ | ||
{ | ||
"token": "0xFc00000000000000000000000000000000000002", | ||
"oracleId": "FXS" | ||
} | ||
], | ||
"tokens": [ | ||
{ | ||
"oracleId": "FRAX", | ||
"decimals": "1e18" | ||
}, | ||
{ | ||
"oracleId": "USDC", | ||
"decimals": "1e6" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "curve-fraxtal-trifxs", | ||
"pool": "0xa0d3911349e701a1f49c1ba2dda34b4ce9636569", | ||
"gauge": "0x8882eb84d0c4894753c0450f2d514e39883c0c82", | ||
"rewards": [ | ||
{ | ||
"token": "0xFc00000000000000000000000000000000000002", | ||
"oracleId": "FXS" | ||
} | ||
], | ||
"tokens": [ | ||
{ | ||
"oracleId": "FRAX", | ||
"decimals": "1e18" | ||
}, | ||
{ | ||
"oracleId": "wfrxETH", | ||
"decimals": "1e18" | ||
}, | ||
{ | ||
"oracleId": "FXS", | ||
"decimals": "1e18" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "curve-fraxtal-sfrxeth", | ||
"pool": "0xf2f426fe123de7b769b2d4f8c911512f065225d3", | ||
"gauge": "0xd1d981ddd0c9a0469e7d8cee877f83b5877d7260", | ||
"rewards": [ | ||
{ | ||
"token": "0xFc00000000000000000000000000000000000002", | ||
"oracleId": "FXS" | ||
} | ||
], | ||
"getDy": ["v1", 0, 1], | ||
"tokens": [ | ||
{ | ||
"oracleId": "wfrxETH", | ||
"decimals": "1e18" | ||
}, | ||
{ | ||
"oracleId": "sfrxETH", | ||
"decimals": "1e18" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters