Closed ebma closed 9 months ago
@pendulum-chain/product This ticket is about adding changes to our price-feeding service such that we don't have to manually feed a price on Foucoco/Amplitude once per week anymore. Please prioritize as you see fit.
Hey team! Please add your planning poker estimate with Zenhub @adelarja @b-yap @ebma @TorstenStueber
@annatekl add to epic after current one for Spacewalk launch on Amplitude.
@ebma what is the batching server?
What is the flow of data here: the batching server should request the price from the squid, which gets the price from the chain and then feed it into the chain? Isn't that circular?
The batching server is the service that provides prices from the DIA price feed to the off-chain worker. So on every block the offchain worker tries to get the latest prices of the designated assets from the batching server.
The difficulty here is how we derive the AMPE price. AMPE is not listed on a CEX so DIA has no data for it. What we decided to do instead is to base the AMPE price on the ratio of the liquidity in the AMPE/KSM pool. So we check how many AMPE are 'equal' to 1 KSM according to the current pool ratio and then use the latest dollar price of KSM to define the AMPE price.
The ticket describes that the batching server should query the price from the indexer because the indexer does this price derivation on each block. However, we can also change the batching server to connect to Amplitude and query the on-chain ratio of the AMPE/KSM pool and then do the price derivation locally. IMO querying it from the indexer is easier and faster.
Makes perfect sense now and I also do remember what the batching server is now. Thanks for the explanation.
@pendulum-chain/product I realized that implementing this ticket has an implication for Spacewalk issue requests on Amplitude. At the moment we manually feed a price for AMPE of $0.1 to Amplitude. Once we support the 'actual price' represented by the Zenlink pool, the value of the AMPE token will be around $0.0042. Thus, users will have to lock twice as many AMPE as griefing collateral for issue requests than they have to lock right now. Just FYI. This is not a flaw but important for the overall bridge security.
Makes sense @ebma and how it is expected to work.
@b-yap does this require any runtime upgrade or root transaction?
No it does not.
We want to have the latest price of the AMPE token on-chain. So far, we are feeding the AMPE price manually once per week and we set it to a fixed price of 1$. However, we should add support for the AMPE token to the batching server so that the latest price of the AMPE token is updated on every block and we don't need to feed it manually anymore.
TODO
We need to change the logic of the batching server to:
blockchain
=Amplitude
andsymbol
=AMPE
. Capitalization should not matter here.ethPrice
represents the price of AMPE in USD.AMPLITUDE:AMPE
to the list of default values here.GraphQL
For the graphql queries, we should use some crate like graphql-client. The schema can be found here.
To be done