tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Deriving the price of kit in tez #239

Closed gkaracha closed 3 years ago

gkaracha commented 3 years ago

When touching the parameters (in Checker.touch_with_index) we need the price of kit in tez (units: tez/kit). This we can get by multiplying

  1. the price of kit in ctez (units: ctez/kit), as provided by Cfmm.cfmm_kit_in_ctez_in_prev_block, and
  2. the price of ctez in tez (units: tez/ctez), as provided by the ctez contract.

When we changed the cfmm to use ctez instead of tez and removed the delegation auction we refrained from further complicating matters and assumed that the price of ctez in tez was exactly 1 (i.e., ctez ~ tez). I reckon it's time we switched to a more accurate calculation. I can see three possible ways to deal with (2) above:

  1. Assume tez/ctez = 1 (current approach). Simple, since no calls to the ctez contract are required, but probably inaccurate.
  2. Assume tez/ctez = 1.05 - 1.06 (that is, the somewhat expected target factor of ctez). Simple, since no calls to the ctez contract are required. Hopefully rather accurate, but probably too firm.
  3. Ask the ctez contract what the current tez/ctez price is. This is clearly the most complicated but at the same time the most accurate option.
gkaracha commented 3 years ago

A possibly non-exhaustive list of things I expect us to have to change, should we decide to go with option (3) above:

dorranh commented 3 years ago

I think that option (3) would also be required for #213 since it isn't necessarily true that an arbitrary token will have a price of exactly 1 ctez/some_token, right? That is unless we are able to parameterize the cfmm and burrow collateral using the same token.

gkaracha commented 3 years ago

Ah, yes, quite possibly. I wrote the above assuming that the cfmm will keep using ctez though, independently of the choice of collateral, which makes the problems orthogonal to each other. If we use the same FA2 token for both the cfmm and as collateral then the problems are not so independent anymore.

gkaracha commented 3 years ago

Note to self: this is currently blocked on https://github.com/tezos-checker/ctez/pull/30.

gkaracha commented 3 years ago

Roadmap: once tezos-checker/ctez#30 is merged we need to at least do the following on the Checker side:

We could probably start working on the infrastructure already, but I'm not sure yet if we should do that.

gkaracha commented 3 years ago

Though #280 did most of the work on addressing this issue, we still ignore the fraction we receive from the cfmm of ctez (see https://github.com/tezos-checker/checker/pull/280#discussion_r739295216). Let's leave #239 open until that FIXME is finally addressed.