Imagine that I have a contract where a user can buy and sell tokens based on a dynamic price in ETH.
The price is calculated every 2 hours by a server. When buying or selling, the value used is the next one that will be produced in the future (not the past ones). This means that there will be 2 steps to buy tokens:
requestBuy to send the ETH and save the request on a mapping for sender's address, and
executeBuy to convert the amount to tokens based on the price and send it to the buyer (same for selling).
requestBuyis called by the client.
executeBuyis called by the server.
Should the owner write the price into the contract and call
executeBuy or should send the price as an argument to
executeBuy? What are the trade-offs for each one?
Main criteria: transparency of price history in the contract vs public API