Created
May 7, 2021 03:11
-
-
Save 0xdef1/97a2ea6fd72aabb5510bd9117bd78791 to your computer and use it in GitHub Desktop.
Steps to deploy Terraswap into LocalTerra and create a functional pair
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clone the terraswap repo (optionally build the binaries yourself) | |
git clone https://github.com/terraswap/terraswap.git | |
cd terraswap/artifacts | |
# Upload terraswap_token contract and note the code_id | |
terracli tx wasm store terraswap_token.wasm --from test1 --chain-id=localterra --gas=auto --fees=100000uluna --broadcast-mode=block | |
> code_id: 2 | |
# Upload terraswap_pair contract and note the code_id | |
terracli tx wasm store terraswap_pair.wasm --from test1 --chain-id=localterra --gas=auto --fees=100000uluna --broadcast-mode=block | |
> code_id: 3 | |
# Upload terraswap_router contract and note the code_id | |
terracli tx wasm store terraswap_router.wasm --from test1 --chain-id=localterra --gas=auto --fees=100000uluna --broadcast-mode=block | |
> code_id: 4 | |
# Upload terraswap_factory contract and note the code_id | |
terracli tx wasm store terraswap_factory.wasm --from test1 --chain-id=localterra --gas=auto --fees=100000uluna --broadcast-mode=block | |
> code_id: 5 | |
# Instantiate new 'LocalTerra MIR' CW20 contract and mint 1,000,000 ltMIR to ourselves, note the contract_address | |
terracli tx wasm instantiate 2 '{"decimals": 6,"initial_balances":[{"address":"terra1dcegyrekltswvyy0xy69ydgxn9x8x32zdtapd8","amount":"1000000000000"}],"name":"LocalTerra Mirror","symbol":"ltMIR"}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
> contract_address: terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4 | |
# Check ltMIR token info: | |
terracli query wasm contract-store terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4 '{"token_info":{}}' | |
> {"name":"LocalTerra Mirror","symbol":"ltMIR","decimals":6,"total_supply":"1000000000000"} | |
# Instantiate new 'LocalTerra UST' CW20 contract and mint 5,000,000 ltUST to ourselves | |
terracli tx wasm instantiate 2 '{"decimals": 6,"initial_balances":[{"address":"terra1dcegyrekltswvyy0xy69ydgxn9x8x32zdtapd8","amount":"5000000000000"}],"name":"LocalTerra UST","symbol":"ltUST"}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
> contract_address: terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86 | |
# Check ltUST token info: | |
terracli query wasm contract-store terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86 '{"token_info":{}}' | |
> {"name":"LocalTerra UST","symbol":"ltUST","decimals":6,"total_supply":"5000000000000"} | |
# Instantiate Terraswap factory (using the correct code_id values for terraswap_pair and terraswap_token from above), note the contract_address | |
terracli tx wasm instantiate 5 '{"pair_code_id": 3,"token_code_id": 2}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
> contract_address: terra1plju286nnfj3z54wgcggd4enwaa9fgf5kgrgzl | |
# Check factory config | |
terracli query wasm contract-store terra1plju286nnfj3z54wgcggd4enwaa9fgf5kgrgzl '{"config":{}}' | |
> {"owner":"terra1dcegyrekltswvyy0xy69ydgxn9x8x32zdtapd8","pair_code_id":3,"token_code_id":2} | |
# Create ltMIR-ltUST pair, note the contract address of the new pair / lp token | |
terracli tx wasm execute terra1plju286nnfj3z54wgcggd4enwaa9fgf5kgrgzl '{"create_pair":{"asset_infos":[{"token":{"contract_addr":"terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4"}},{"token":{"contract_addr":"terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86"}}]}}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
> pair_contract_addr: terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr | |
> liquidity_token_addr: terra1gv07846a3867ezn3uqkk082c5ftke7hpemzu9q | |
# Approve (1) ltMIR (allow the pair created above to spend it) | |
terracli tx wasm execute terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4 '{"increase_allowance":{"amount":"1000000","spender":"terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr"}}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
# Approve (5) ltUST (allow the pair created above to spend it) | |
terracli tx wasm execute terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86 '{"increase_allowance":{"amount":"5000000","spender":"terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr"}}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
# Provide 1 ltMIR and 5 ltUST liquidity to the pair | |
terracli tx wasm execute terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr '{"provide_liquidity":{"assets":[{"info":{"token":{"contract_addr":"terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4"}},"amount":"1000000"},{"info":{"token":{"contract_addr":"terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86"}},"amount":"5000000"}]}}' --from test1 --chain-id=localterra --fees=10000uluna --gas=auto --broadcast-mode=block | |
# Check pool info | |
terracli query wasm contract-store terra17dkr9rnmtmu7x4azrpupukvur2crnptyfvsrvr '{"pool":{}}' | |
> {"assets":[{"info":{"token":{"contract_addr":"terra10pyejy66429refv3g35g2t7am0was7ya7kz2a4"}},"amount":"1000000"},{"info":{"token":{"contract_addr":"terra1sshdl5qajv0q0k6shlk8m9sd4lplpn6gggfr86"}},"amount":"5000000"}],"total_share":"2236067"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment