-
Notifications
You must be signed in to change notification settings - Fork 24
Conversation
I'm breaking APY/SAVE. need to fix it first. |
fixed the APY save endpoint which was broken before and removed ethereum-blocks-by-date.js file as this is not needed. |
@@ -276,7 +276,7 @@ const readVault = async (vault) => { | |||
return data; | |||
}; | |||
|
|||
module.exports.handler = async () => { | |||
const handler = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this? was it broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end of the file I have set:
module.exports = { handler, getVirtualPrice };
The reason is that I'm reusing the same getVirtualPrice function in : https://github.com/miguel567/yearn-api/blob/91c1696f5f5fa309126883fd17a51ee964a1448b/services/vaults/holdings/save/getHoldings.js#L94
so I had to modify the exports module to include both functions.
README.md
Outdated
|
||
## Stages | ||
|
||
- Currently four stages are available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is intention behind removing this README section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally believe this is a mistake. Shoud I fix it and push again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
} | ||
try{ | ||
const holdings= await getHoldings(vault); | ||
const priceFeed = await axios.get('https://api.coingecko.com/api/v3/coins/' + vault.price_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get price on-chain from uniswap instead perhaps? this way we don't have to maintain the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I need to investigate how to perform that. Any guidance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this on an improvement ticket? Unless it is a blocker, I could make the other improvements easily, deliver the TVL endpoint and then focus on changing the price feed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "earn" products: yWBTC, yCRV and ybCRV are using getVirtualPrice = on-chain price.
Rest of tokens are using coingecko. I would merge as it is and create a new issue to move all pricing infro to on-chain using chainlink, for example. issue: #34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be good, we can just use Andre's keep3r price oracles, which already have all of the pairs we need. I updated with the relevant info on issue #34
|
||
|
||
module.exports = [ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get vaults from vaults endpoint instead? The vaults endpoint pulls from the vault registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I saw you improved that part, I think I can do this easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icannot use vaults from DB as the ABI is not stored. I could use:
const fetchAbi = async (address) => { const url =
https://api.etherscan.io/api?module=contract&action=getabi&address=${address}&apikey=${etherscanApiKey}`;
const resp = await fetch(url).then((res) => res.json());
const abi = JSON.parse(resp.result);
await delay(delayTime);
return abi;
};
`
from services/vaults/holdings/save/handler.js, but we would rely on etherscan API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in discord this cannot be done for now. We cannot fetch the ABI on-chain. Also, the services/vaults/holdings/save/vaults.js file is defining where the ABI is coming from. Also I cannot remove the vault.js file as, for instance the aLink and Link strategies have 6 decimals and there is no on-chain "decimals" method for these strategies for me to fetch the correct decimals. So for now we need to rely on the code in the files and not on-chain data :S
require('dotenv').config(); | ||
const _ = require('lodash'); | ||
const dynamodb = require('../../../utils/dynamoDb'); | ||
const fetch = require('node-fetch'); | ||
const Web3 = require('web3'); | ||
const yRegistryAbi = require('../../../abi/yRegistry.json'); | ||
const delay = require('delay'); | ||
|
||
const db = dynamodb.doc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice fix, i spotted this as well
const vaultContract = new web3.eth.Contract(vault.vaultContractABI, vault.vaultContractAddress); | ||
const vaultHoldings = await vaultContract.methods.balance().call() / Math.pow(1,vault.decimals); | ||
const strategyHoldings = await strategyContract.methods.balanceOf().call() / Math.pow(1,vault.decimals); | ||
/* console.log(holdings); */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove commented out console.log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in the new push all the commented out code.
|
||
|
||
return holdings; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need an empty line at end of file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal opinion but I think 4 blank lines here is a lot, better to have 1 or 2. Same above as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a few instances of commented out code that I think we should remove unless it is there for a good reason.
I've reviewed your feedback @graham-u and @x48-crypto from the previous push, please check it above. Also I've added to this push:
FYI: I'm following Dudesahn's documented holdings calculation guide: https://hackmd.io/@dudesahn/BkxKfTzqw |
Issue: #8
I'm following the approach from dudesahn as defined here: hackmd.io/@dudesahn/BkxKfTzqw
TODO: We believe we are missing to calculate the pool balance of yWBTC token.
This is the pre-requirement for calculating TVL (my next step).