The final product can be seen and interacted with at https://www.raclette.finance/ . There are 3 different sections of the web app:
- The swap area: allows the user to choose two tokens (red) and trade between them;
A V3 style swap on Tezos
Tests have to be done manually as there is no practical way to test interactions with the blockchain, since we do all signing of transactions with the Temple wallet extension.
- Flutter and a way to run flutter in chrome.
- Temple Wallet extension.
Import this private key into the wallet: edskS1TVJqsCXgYSEEiNrv8GDwpresD4FL49ipZErZ1mH9itZNSXfEnykvzLWyQVpVLsU69KvgtBTteCXfc9ZUpuAJg61zoUTW This wallet has some tezos for fees as well as 2 test tokens, Token X and Token Y, which are used by the contract.
Make sure in the main file that home leads to TestWalletInteraction().
After runing the application in the chrome emulator you will have to copy the url in a real chrome browser, as the emulator does not have the required extensions
On the test page you are presented with 4 buttons.
First is Connect wallet, you have to be connected for any other button to work.
Second is set_position. This sets a position with range 1-20 with 100 x and 100 y.
Third and forth is swap x to y and swap y to x respectively
- To compile to Michelson the contract code and/or its storage, you'll need to have the ligo executable installed;
- You'll need the stack tool installed, see The Haskell Tool Stack tutorial for instructions on how to obtain it;
- For deployment and contract interaction, you'll need the smartpy-cli for deployment;
x_token_type
: contract type of thex
token, can be either [FA1.2
][fa1.2] or [FA2
][fa2].y_token_type
: contract type of they
token, can be either [FA1.2
][fa1.2], [FA2
][fa2], or [CTEZ
][ctez].fee_bps
, a fraction determining how much of the tokens sent in a swap will be subtracted beforehand, see fees for more info.ctez_burn_fee_bps
, a percentage to be subtracted from theCTEZ
tokens being deposited/withdrawn on every swap. See fees for more info. This option is only valid when they_token_type
isCTEZ
.x_token_address
theaddress
of the contract holding thex
token.y_token_address
theaddress
of the contract holding they
token.x_token_id
the [FA2
][fa2]token_id
for thex
token. This option is only valid when thex_token_type
isCTEZ
orFA2
.y_token_id
the [FA2
][fa2]token_id
for they
token. This option is only valid when they_token_type
isCTEZ
orFA2
- Here you should replace the FA2 for FA1 or other types depending on the token in case:
make out/segmented_cfmm_default.tz \
x_token_type=FA2 \
y_token_type=FA2
- Replace with the correct token names and decimals.
make out/metadata_map \
x_token_symbol=TX \
x_token_name="TokenX" \
x_token_decimals=18 \
y_token_symbol=TY \
y_token_name="TokenY" \
y_token_decimals=18
- Replace correct token addresses and the other contract details as you like
make out/storage_default.tz \
fee_bps=3 \
ctez_burn_fee_bps=3 \
x_token_id=0 \
y_token_id=0 \
x_token_address=KT1NproXvHrDfc7NHyzGJhHVLf4ZMGz8pkae \
y_token_address=KT18suWgCHADCLkywTKD3pXg6ARHiw1YxWBq \
tick_spacing=1 \
init_cumulatives_buffer_extra_slots=0 \
metadata_map="$(cat out/metadata_map)"
- Deploying to the testnet (ghostnet):
smartpy originate-contract --code out/segmented_cfmm_default.tz --storage out/storage_default.tz --rpc https://ghostnet.tezos.marigold.dev/