Skip to content

Commit

Permalink
feat: add script to deploy & test on devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
nseguias committed Aug 27, 2024
1 parent 4e3014c commit 22e546a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 6 deletions.
95 changes: 95 additions & 0 deletions deploy/00-devnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

# ➜ injective-auction-pool git:(main) ✗ injectived config
# {
# "chain-id": "injective-777",
# "keyring-backend": "os",
# "output": "json",
# "node": "https://devnet.tm.injective.dev:443",
# "broadcast-mode": "sync"
# }

export FROM=devnet
export FROM_ADDR=inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku

# 1) optimize both contracts
#
just optimize


# 2) store the treasure chest contract
#
TREASURE_TX_HASH=$(injectived tx wasm store ./artifacts/treasurechest_contract.wasm --from ${FROM} --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto | jq -r '.txhash')
echo $TREASURE_TX_HASH
# TREASURE_TX_HASH=634BB9BA7186D46BD74A08F0FAFBB9EB6811CF657477A2004EB0BDCA666FADE9

export TREASURE_CODE_ID=$(injectived query tx ${TREASURE_TX_HASH} |jq -e -r ' .events[] | select(.type=="cosmwasm.wasm.v1.EventCodeStored").attributes[] | select(.key=="code_id").value ' | tr -d '"')
echo $TREASURE_CODE_ID
# TREASURE_CODE_ID=18


# 3) store the auction pool contract
#
AUCTION_TX_HASH=$(injectived tx wasm store ./artifacts/injective_auction_pool.wasm --from ${FROM} --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto | jq -r '.txhash')
echo $AUCTION_TX_HASH
# TX_HASH_AUCTION=FDE2C32FE3058F60AEEB2B2DB07FE7D83EA229094DC0DFF9A648526EE419F328

export AUCTION_CODE_ID=$(injectived query tx ${AUCTION_TX_HASH} |jq -e -r ' .events[] | select(.type=="cosmwasm.wasm.v1.EventCodeStored").attributes[] | select(.key=="code_id").value ' | tr -d '"')
echo $AUCTION_CODE_ID
# AUCTION_CODE_ID=19

# 4) instantiate the auction pool contract
#
export FEE_AMT=$(injectived query tokenfactory params|jq -r '.params.denom_creation_fee[0].amount')
echo $FEE_AMT
#export FEE_AMT=10000000000000000000

INIT_MSG=$(envsubst < ./deploy/testnet/auction.json)
date_label=$(date +"%Y-%m-%d %H:%M")
echo $INIT_MSG

AUCTION_INIT_TX_HASH=$(injectived tx wasm instantiate $AUCTION_CODE_ID ${INIT_MSG} \
--label auction_${date_label} \
--admin $FROM_ADDR \
--amount ${FEE_AMT}inj \
--from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto | jq -r '.txhash')
echo $AUCTION_INIT_TX_HASH
# AUCTION_INIT_TX_HASH=B9BD43827063E56CC61F84EE43A23450922B9ABE98AAC1C2EE6EEB36ED612A0D

export AUCTION_CONTRACT=$(injectived query tx $AUCTION_INIT_TX_HASH | jq -r '.events[]| select(.type=="cosmwasm.wasm.v1.EventContractInstantiated").attributes[] |select(.key=="contract_address").value '|tr -d '"')
echo $AUCTION_CONTRACT
# AUCTION_CONTRACT=inj1puua6kj5v5vtrglpumr4evlug4sl8tpsk46sar

injectived query wasm cs smart $AUCTION_CONTRACT '{"current_auction_basket":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"whitelisted_addresses":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"funds_locked":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"bidding_balance":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"config":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"unsettled_auction":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"treasure_chest_contracts":{}}' | jq

injectived query wasm cs smart $tc '{"config":{}}' | jq

# join pool with 100inj
injectived tx wasm execute $AUCTION_CONTRACT '{"join_pool":{"auction_round":1}}' \
--from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto \
--amount 100000000000000000000inj | jq

# exit pool
injectived tx wasm execute $AUCTION_CONTRACT '{"exit_pool":{}}' --from $FROM --yes \
--gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto --amount 1000000000000000000factory/$AUCTION_CONTRACT/auction.0 | jq

# join pool again with 1inj
injectived tx wasm execute $AUCTION_CONTRACT '{"join_pool":{"auction_round":0}}' \
--from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto \
--amount 1000000000000000000inj | jq

# try bid with basket value of 10_000
injectived tx wasm execute $AUCTION_CONTRACT '{"try_bid":{"auction_round":1, "basket_value":"1000000000000000000000"}}' \
--from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto | jq

# settle auction
injectived tx wasm execute $AUCTION_CONTRACT '{"settle_auction":{"auction_round":1, "auction_winner":"inj1puua6kj5v5vtrglpumr4evlug4sl8tpsk46sar", "auction_winning_bid": "100250000000000000001"}}' --from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto --amount $FEE_AMT"inj" | jq

# withdraw from treasure chest
injectived tx wasm execute $TREASURE_CHEST_CONTRACT '{"withdraw":{}}' --from $FROM --yes --gas-prices "500000000inj" --gas-adjustment 1.3 --gas auto --amount 1000000000000000000factory/$AUCTION_CONTRACT/auction.0 | jq
11 changes: 6 additions & 5 deletions deploy/02-testnet-auction.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,26 @@ injectived query wasm cs smart $AUCTION_CONTRACT '{"whitelisted_addresses":{}}'
injectived query wasm cs smart $AUCTION_CONTRACT '{"funds_locked":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"bidding_balance":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"config":{}}' | jq
injectived query wasm cs smart $AUCTION_CONTRACT '{"unsettled_auction":{}}' | jq

# add address to whitelist
injectived tx wasm execute $AUCTION_CONTRACT '{"update_white_listed_addresses":{"add":["inj12nn88vtuf893cpfkke23dszpr5uccqj2zqukt6"], "remove":[]}}' \
--from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto \
--node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq

# join pool with 1inj
injectived tx wasm execute $AUCTION_CONTRACT '{"join_pool":{"auction_round":108}}' \
# join pool with 4inj
injectived tx wasm execute $AUCTION_CONTRACT '{"join_pool":{"auction_round":112}}' \
--from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto \
--node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 \
--amount 1000000000000000000inj | jq
--amount 4000000000000000000inj | jq

# exit pool
injectived tx wasm execute $AUCTION_CONTRACT '{"exit_pool":{}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes \
--gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --amount 1000000000000000000factory/$AUCTION_CONTRACT/auction.0 \
--node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq

# try bid
injectived tx wasm execute $AUCTION_CONTRACT '{"try_bid":{"auction_round":108, "basket_value":"1000"}}' \
injectived tx wasm execute $AUCTION_CONTRACT '{"try_bid":{"auction_round":112, "basket_value":"10000000000000000000000"}}' \
--from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto \
--node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq

Expand Down Expand Up @@ -107,7 +108,7 @@ injectived tx wasm execute $AUCTION_CONTRACT '{"exit_pool":{}}' --from inj1cdugm
injectived tx wasm execute inj1kar690fes35rm0dx5zcjwt5pjhtvcf572w3ffe '{"exit_pool":{}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --amount 102factory/$AUCTION_CONTRACT/auction.0 --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 | jq

# settle auction
injectived tx wasm execute $AUCTION_CONTRACT '{"settle_auction":{"auction_round":108, "auction_winner":"inj1dlyumvy7rfmq534hnh8et2ft58zpm0d84vjkfd", "auction_winning_bid": "7230370850000000000001"}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 --amount 1000000000000000000inj | jq | jq
injectived tx wasm execute $AUCTION_CONTRACT '{"settle_auction":{"auction_round":110, "auction_winner":"inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh", "auction_winning_bid": "7230370850000000000001"}}' --from inj1cdugmt5t0mgfsmfc99eyhe4fzps0937ae0jgqh --yes --gas-prices "160000000inj" --gas-adjustment 1.3 --gas auto --node https://testnet.sentry.tm.injective.network:443 --output json --chain-id injective-888 --amount 1000000000000000000inj | jq | jq

# claim from treasure_chest contract
TREASURE_CHEST_CONTRACT=inj1jzc67t0t445dzdd96ksywf0tfj7ah2qljfrlp9
Expand Down
2 changes: 1 addition & 1 deletion deploy/testnet/auction.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"$FROM_ADDR"
],
"min_next_bid_increment_rate": "0.0025",
"treasury_chest_code_id": $TREASURE,
"treasury_chest_code_id": $TREASURE_CODE_ID,
"min_return": "0.05"
}

0 comments on commit 22e546a

Please sign in to comment.