Skip to content

Commit

Permalink
[scripts]feat: Add new DEX - deploy contracts step
Browse files Browse the repository at this point in the history
  • Loading branch information
desislavva authored and ivivanov committed Dec 6, 2023
1 parent 92d331d commit c0553e1
Showing 1 changed file with 98 additions and 1 deletion.
99 changes: 98 additions & 1 deletion scripts/add-new-dex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ source "$SCRIPTS_DIR"/internal/add-dex-support.sh

NOLUS_NET="http://localhost:26612/"
NOLUS_HOME_DIR="$HOME/.nolus"
NOLUS_MONEY_MARKET_DIR="$SCRIPTS_DIR/../../nolus-money-market"
ACCOUNT_KEY_TO_FEED_HERMES_ADDRESS="reserve"
DEX_ADMIN_KEY=""
STORE_CODE_PRIVILEGED_USER_KEY=""
WASM_ARTIFACTS_PATH=""

HERMES_CONFIG_DIR_PATH="$HOME/.hermes"
HERMES_BINARY_DIR_PATH="$HOME/hermes"
DEX_NAME=""
CHAIN_ID=""
CHAIN_IP_ADDR_RPC=""
CHAIN_IP_ADDR_GRPC=""
Expand All @@ -22,6 +27,11 @@ CHAIN_PRICE_DENOM=""
CHAIN_TRUSTING_PERIOD=""
IF_INTERCHAIN_SECURITY="true"

PROTOCOL_CURRENCY=""
ADMIN_CONTRACT_ADDRESS="nolus1gurgpv8savnfw66lckwzn4zk7fp394lpe667dhu7aw48u40lj6jsqxf8nd"
TRASURY_CONTRACT_ADDRESS="nolus14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0k0puz"
TIMEALARMS_CONTRACT_ADDRESS="nolus1zwv6feuzhy6a9wekh96cd57lsarmqlwxdypdsplw6zhfncqw6ftqmx7chl"
SWAP_TREE=""

while [[ $# -gt 0 ]]; do
key="$1"
Expand All @@ -32,16 +42,26 @@ while [[ $# -gt 0 ]]; do
printf \
"Usage: %s
[--nolus-home-dir <nolus_home_dir>]
[--nolusd-money-market-dir <nolus_money_market_dir>]
[--account-key-to-feed-hermes-address <account_key_to_feed_hermes_address>]
[--dex-admin-key <dex_admin_key>]
[--store-code-privileged-user-key <store_code_privileged_user_key>]
[--wasm-artifacts-path <wasm_artifacts_path>]
[--hermes-config-dir-path <config.toml_and_hermes.seed_dir_path>]
[--hermes-binary-dir-path <hermes_binary_dir_path>]
[--dex-name <dex_name>]
[--dex-chain-id <new_dex_chain_id>]
[--dex-ip-addr-rpc-host <new_dex_chain_ip_addr_rpc_fully_host>]
[--dex-ip-addr-grpc-host <new_dex_chain_ip_addr_grpc_fully_host>]
[--dex-account-prefix <new_dex_account_prefix>]
[--dex-price-denom <new_dex_price_denom>]
[--dex-trusting-period-secs <new_dex_trusting_period_in_seconds>]
[--dex-if-interchain-security <new_dex_if_interchain_security_true/false>]" \
[--dex-if-interchain-security <new_dex_if_interchain_security_true/false>]
[--protocol-currency <new_protocol_currency>]
[--admin-contract-address <admin_contract_address>]
[--treasury-contract-address <treasury_contract_address>]
[--timealarms-contract-address <timealarms_contract_address>]
[--protocol-swap-tree <new_protocol_swap_tree>]" \
"$0"
exit 0
;;
Expand All @@ -52,12 +72,36 @@ while [[ $# -gt 0 ]]; do
shift
;;

--nolus-money-market-dir)
NOLUS_MONEY_MARKET_DIR="$2"
shift
shift
;;

--account-key-to-feed-hermes-address)
ACCOUNT_KEY_TO_FEED_HERMES_ADDRESS="$2"
shift
shift
;;

--dex-admin-key)
DEX_ADMIN_KEY="$2"
shift
shift
;;

--store-code-privileged-user-key)
STORE_CODE_PRIVILEGED_USER_KEY="$2"
shift
shift
;;

--wasm-artifacts-path)
WASM_ARTIFACTS_PATH="$2"
shift
shift
;;

--hermes-config-dir-path)
HERMES_CONFIG_DIR_PATH="$2"
shift
Expand All @@ -70,6 +114,12 @@ while [[ $# -gt 0 ]]; do
shift
;;

--dex-name)
DEX_NAME="$2"
shift
shift
;;

--dex-chain-id)
CHAIN_ID="$2"
shift
Expand Down Expand Up @@ -112,6 +162,36 @@ while [[ $# -gt 0 ]]; do
shift
;;

--protocol-currency)
PROTOCOL_CURRENCY="$2"
shift
shift
;;

--admin-contract-address)
ADMIN_CONTRACT_ADDRESS="$2"
shift
shift
;;

--treasury-contract-address)
TRASURY_CONTRACT_ADDRESS="$2"
shift
shift
;;

--timealarms-contract-address)
TIMEALARMS_CONTRACT_ADDRESS="$2"
shift
shift
;;

--protocol-swap-tree)
SWAP_TREE="$2"
shift
shift
;;

*)
echo >&2 "The provided option '$key' is not recognized"
exit 1
Expand All @@ -122,12 +202,24 @@ done

NOLUS_CHAIN_ID=$(grep -oP 'chain-id = "\K[^"]+' "$NOLUS_HOME_DIR"/config/client.toml)

verify_dir_exist "$NOLUS_MONEY_MARKET_DIR" "The NOLUS_MONEY_MARKET_DIR dir does not exist"
DEPLOY_CONTRACTS_SCRIPT="$NOLUS_MONEY_MARKET_DIR/scripts/deploy-contracts-live.sh"

verify_dir_exist "$WASM_ARTIFACTS_PATH" "The WASM_ARTIFACTS_PATH dir does not exist"
verify_mandatory "$DEX_NAME" "new DEX name"
verify_mandatory "$DEX_ADMIN_KEY" "dex-admin key name"
verify_mandatory "$STORE_CODE_PRIVILEGED_USER_KEY" "sotre-code privileged user key"
verify_mandatory "$CHAIN_ID" "new DEX chain_id"
verify_mandatory "$CHAIN_IP_ADDR_RPC" "new DEX RPC addr - fully host part"
verify_mandatory "$CHAIN_IP_ADDR_GRPC" "new DEX gRPC addr - fully host part"
verify_mandatory "$CHAIN_ACCOUNT_PREFIX" "new DEX account prefix"
verify_mandatory "$CHAIN_PRICE_DENOM" "new DEX price denom"
verify_mandatory "$CHAIN_TRUSTING_PERIOD" "new DEX trusting period"
verify_mandatory "$PROTOCOL_CURRENCY" "new protocol currency"
verify_mandatory "$SWAP_TREE" "new protocol swap_tree"

verify_file_exist "$DEPLOY_CONTRACTS_SCRIPT" "The script does not exist"
source "$DEPLOY_CONTRACTS_SCRIPT"

if [[ $IF_INTERCHAIN_SECURITY != "true" && $IF_INTERCHAIN_SECURITY != "false" ]]; then
echo >&2 "the dex-if-interchain-security value must be true or false"
Expand All @@ -146,3 +238,8 @@ NOLUS_HERMES_ADDRESS=$(get_hermes_address "$HERMES_BINARY_DIR_PATH" "$NOLUS_CHAI
# Open a connection
open_connection "$NOLUS_NET" "$NOLUS_HOME_DIR" "$ACCOUNT_KEY_TO_FEED_HERMES_ADDRESS" "$HERMES_BINARY_DIR_PATH" \
"$NOLUS_HERMES_ADDRESS" "$NOLUS_CHAIN_ID" "$CHAIN_ID"

# Deploy contracts
_=$(deploy_contracts "$NOLUS_NET" "$NOLUS_CHAIN_ID" "$NOLUS_HOME_DIR" "$DEX_ADMIN_KEY" "$STORE_CODE_PRIVILEGED_USER_KEY" \
"$ADMIN_CONTRACT_ADDRESS" "$WASM_ARTIFACTS_PATH/$DEX_NAME" "$DEX_NAME" "$PROTOCOL_CURRENCY" \
"$TRASURY_CONTRACT_ADDRESS" "$TIMEALARMS_CONTRACT_ADDRESS" "$SWAP_TREE")

0 comments on commit c0553e1

Please sign in to comment.