tezos-checker / checker

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

Implement an FA2 wrapper for ctez #279

Closed gkaracha closed 2 years ago

gkaracha commented 2 years ago

Now that we've switched to the tez-wrapper-based design, the biggest remaining obstacle for finishing #213 is dealing with the structural differences between TEZ and FA2 that we've found no way to share between the two build/deployment paths. As far as I can tell, this boils down to two specific issues, interrelating with each other:

  1. Price calculation in touch:

    • collateral = TEZ: KIT/CHF = TEZ/CHF (from index) CTEZ/TEZ (from ctez) KIT/CTEZ (from cfmm)
    • collateral = FA2: KIT/CHF = FA2/CHF (from index) * KIT/FA2 (from cfmm)

    this issue is discussed here: https://github.com/tezos-checker/checker/issues/213#issuecomment-923758356

  2. The token contained in the CFMM compared to the token used as collateral:

    • collateral = TEZ: cfmm.ml contains ctez specifically, also distinct from the collateral which is tez_token specifically
    • collateral = FA2: cfmm.ml contains the same token as is used for collateral, whichever token that is.

The comment on #213 is primarily focused on the first issue, but, while trying to make progress on the the second issue (on this branch), I came across another structural difference:

  1. Token standard used for fund transfer:
    • collateral = TEZ: cfmm.ml contains ctez and it uses ctez's FA1.2 API
    • collateral = FA2: cfmm.ml contains the same FA2 that is used as collateral so I expect it'll use the token's FA2 API

FA1.2 and FA2 are structurally different, so the branching as stated above is quite pervasive (i.e., we'll need conditional compilation or something equivalent to get generalization to work). Ideally we won't have to go that way. However, as far as I can tell, ctez does not offer an FA2 interface. To achieve uniformity in the %transfer calls we'd have to always use the FA1.2 standard for the cfmm, but then we require the token used to respect both the FA2 and the FA1.2 standard.

This looks like a blocker for #213.

gkaracha commented 2 years ago

After discussing this we have agreed to proceed with implementing an FA2 wrapper for ctez.