Skip to content

c-vision/CrossChain-Router

 
 

Repository files navigation

How to deploy router swap

0. compile

make all

run the above command, it will generate ./build/bin/swaprouter binary.

1. deploy AnyswapRouter

deploy a AnyswapRouter contract for each supported blockchain

2. deploy AnyswapERC20

deploy a AnyswapERC20 contract for each token on each blockchain

3. deploy RouterConfig

deploy a RouterConfig contract to store router bridge configs

4. set router config on chain

call RouterConfig contract to set configs on blcokchain.

The following is the most used functions, please ref. the abi for more info.

4.1 set chain config

call the following contract function:

setChainConfig(uint256 chainID, ChainConfig config)

input data can be generated by the following method.

./build/bin/swaprouter config genSetChainConfigData --c.ChainID 4 --c.BlockChain eth --c.RouterContract 0x3302f922b24420f3a3048dddc4e2761ce37ea098 --c.Confirmations 3 --c.InitialHeight 0

Output:

chain config struct is {
  "ChainID": "4",
  "BlockChain": "eth",
  "RouterContract": "0x3302f922b24420f3a3048dddc4e2761ce37ea098",
  "Confirmations": 3,
  "InitialHeight": 0
}
set chain config input data is 0xdefb3a0d0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000003302f922b24420f3a3048dddc4e2761ce37ea0980000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036574680000000000000000000000000000000000000000000000000000000000

4.2 set token config

call the following contract function:

setTokenConfig(string tokenID, uint256 chainID, TokenConfig config)

input data can be generated by the following method.

./build/bin/swaprouter config genSetTokenConfigData --c.ChainID 46688 --c.TokenID test --c.Decimals 18 --c.ContractAddress 0xb302f922b24420f3a3048dddc4e2761ce37ea098 --c.ContractVersion 4

Output:

tokenID is test
chainID is 46688
token config struct is {
  "TokenID": "test",
  "Decimals": 18,
  "ContractAddress": "0xb302f922b24420f3a3048dddc4e2761ce37ea098",
  "ContractVersion": 4
}
set token config input data is 0xba6e0d0f00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000b6600000000000000000000000000000000000000000000000000000000000000012000000000000000000000000b302f922b24420f3a3048dddc4e2761ce37ea098000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000

4.3 set swap config

call the following contract function:

setSwapConfig(string tokenID, uint256 toChainID, SwapConfig config)

Notice: you should set swap config for all tokenIDs and all toChainIDs.

input data can be generated by the following method.

./build/bin/swaprouter config genSetSwapConfigData --c.ToChainID 46688 --c.TokenID test --c.MaximumSwap 1000000 --c.MinimumSwap 100 --c.BigValueThreshold 100000 --c.SwapFeeRate 0.001 --c.MaximumSwapFee 10 --c.MinimumSwapFee 1.5

Output:

tokenID is test
toChainID is 46688
swap config struct is {
  "MaximumSwap": 1000000000000000000000000,
  "MinimumSwap": 100000000000000000000,
  "BigValueThreshold": 100000000000000000000000,
  "SwapFeeRatePerMillion": 1000,
  "MaximumSwapFee": 10000000000000000000,
  "MinimumSwapFee": 1500000000000000000
}
set swap config input data is 0xca29ee960000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000b66000000000000000000000000000000000000000000000d3c21bcecceda10000000000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000152d02c7e14af680000000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000014d1120d7b16000000000000000000000000000000000000000000000000000000000000000000047465737400000000000000000000000000000000000000000000000000000000

4.4 set mpc address's public key

call the following contract function:

setMPCPubkey(address addr, string pubkey)

5. add local config file

please ref. config-example.toml

6. run swaprouter

# for server run (add '--runserver' option)
setsid ./build/bin/swaprouter --config config.toml --log logs/routerswap.log --runserver

# for oracle run
setsid ./build/bin/swaprouter --config config.toml --log logs/routerswap.log

7. sub commands

get all sub command list and help info, run

./build/bin/swaprouter -h

sub commands:

admin is admin tool

config is tool to process and query config data

8. RPC api

please ref. server rpc api

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Other 0.1%