This PR adds support for farming events, and also processing of our on-chain price updates to the squid. The price data is needed to derive and provide prices for our pool tokens.
TODO
[x] ~Remove stored farming pool data when killed~. I decided not to change this, because the killing of a farming pool is handled very thoroughly in the Bifrost indexer, see here, and I don't want to remove this logic without knowing all the implications.
[x] Add proper event handling for the Amplitude squid. Currently only the foucoco events are considered.
Notes
The naming of the functions in utils/pricing.ts is a bit confusing but I left it the way it is in the bifrost squid. As far as I understand, our native currency is represents 'eth', thus the return value of findEthPerToken() is 1 unit for our native currency. The prices for other assets are then represented in relation to our native currency amount (aka. 'eth').
The derivation of the price of our native asset now happens based on the AMPE/KSM pair. We have access to the real-world KSM price since it's fed to our on-chain storage by the off-chain worker every block. So to derive the price of our native token we check the ratio of the pair balances to get the value of the native asset compared to KSM, and then check that value to the KSM price.
This PR adds support for farming events, and also processing of our on-chain price updates to the squid. The price data is needed to derive and provide prices for our pool tokens.
TODO
Notes
The naming of the functions in
utils/pricing.ts
is a bit confusing but I left it the way it is in the bifrost squid. As far as I understand, our native currency is represents 'eth', thus the return value offindEthPerToken()
is 1 unit for our native currency. The prices for other assets are then represented in relation to our native currency amount (aka. 'eth'). The derivation of the price of our native asset now happens based on the AMPE/KSM pair. We have access to the real-world KSM price since it's fed to our on-chain storage by the off-chain worker every block. So to derive the price of our native token we check the ratio of the pair balances to get the value of the native asset compared to KSM, and then check that value to the KSM price.Closes #9.