GrowFi - UDT Swap

UPDATE: Checkpoint 2 Update

First let’s recall the goals of Checkpoint 2:

UDTswap’s UX/UI MVP model, Test case, and documents were released at this checkpoint.

UDTswap UX/UI:

UDTswap’s overall UX/UI has been made familiar to existing swap users, so you can proceed with swap without learning.

Swap:

Send:

Pool(Add):

Pool (Remove):

Pool (Create):

Documents:

In the documentation, you can see the basic introduction of the basic UDTswap, technical specification, script architecture, and User Defined Token Listing form.

Documents:https://docs.udtswap.io/

Test case

We created swap, pool(add/remove/create), multiple pool swap test cases for CKB/UDT pair and UDT/UDT pair to test scripts and functions of UDTswap. If you want to see the contents of this, please refer to GitHub.

Src:

https://github.com/bannplayer/UDTswap/tree/master/src

Test:

https://github.com/bannplayer/UDTswap/tree/master/test

Prerequisite

  • local testnet (private) node rpc endpoint
  • 1 account for deploying UDTswap scripts
  • 2 accounts for minting test UDT
  • 1 account for testing (all accounts should have enough ckb)

How to test

Compile

  1. sudo docker run --rm -it -v pwd:/code nervos/ckb-riscv-gnu-toolchain:xenial bash
  2. cd /code/UDTswap_scripts
  3. riscv64-unknown-elf-gcc -c bn.c
  4. ar rc libbn.a bn.o
  5. riscv64-unknown-elf-gcc -o UDTswap_udt_based UDTswap_udt_based.c -L ./ -lbn
  • Execute 3. 4. only once
  • Execute 5. with same name for all scripts (test_udt.c, UDTswap_liquidity_UDT_udt_based.c, UDTswap_lock_udt_based.c, UDTswap_udt_based.c)

Deploy

  1. npm install
  2. Change sk to deploying account’s secret key in ‘/src/udtswap_consts.js’
  3. Change nodeUrl to local testnet node rpc endpoint in ‘/src/udtswap_consts.js’
  4. Compile scripts
  5. node deploy_scripts 0 in ‘/test/deploy’
  6. Change udtswap_type_script_code_hash_buf , udtswap_lock_code_hash_buf , udtswap_liquidity_udt_code_hash_buf to 5. outputs
  7. Compile scripts again
  8. node deploy_scripts 1 in ‘/test/deploy’
  9. Change CodeHash, Deps, Type to 5. outputs and 8. outputs

Mint test UDTs

  1. Change UDT1Owner , UDT2Owner , skTesting to 2 accounts secret key minting test UDT, 1 account’s secret key testing
  2. node deploy_scripts 2 in ‘test/deploy’

Test

npm test

We made it easy to test UDTswap thanks to the @harryliu team.

8 Likes