pendulum-chain / pendulum-squids

The subsquid squids we use for Pendulum/Amplitude/Foucoco.
GNU General Public License v3.0
0 stars 0 forks source link

9 add processing for farming events to indexer #10

Closed ebma closed 10 months ago

ebma commented 10 months ago

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 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.

Closes #9.