From 279a58a8eac071b9d09e31d6338b7a5f74115731 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 13:42:49 -0500 Subject: [PATCH 01/10] changes with setup and added README instructions --- deps/osmosis | 2 +- dockernet/config.sh | 2 +- .../scripts/community-pool-staking/README.md | 8 +++++++ .../community-pool-staking/add_trade_route.sh | 21 ++++++++++++++++++- .../scripts/community-pool-staking/rebate.sh | 9 ++++++++ dockernet/src/create_logs.sh | 10 ++++++--- dockernet/src/init_chain.sh | 4 ++-- dockernet/src/register_host.sh | 7 ++++++- 8 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 dockernet/scripts/community-pool-staking/rebate.sh diff --git a/deps/osmosis b/deps/osmosis index 3e2c326301..30532bd83e 160000 --- a/deps/osmosis +++ b/deps/osmosis @@ -1 +1 @@ -Subproject commit 3e2c326301aff138214c1d25630edb360459c0fd +Subproject commit 30532bd83ebac4e8985fb9d4ead91bc2722810fb diff --git a/dockernet/config.sh b/dockernet/config.sh index e38a16c1c9..91a2b76959 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -18,7 +18,7 @@ KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log # List of hosts enabled # HOST_CHAINS have liquid staking support, ACCESSORY_CHAINS do not HOST_CHAINS=() -ACCESSORY_CHAINS=() +ACCESSORY_CHAINS=(NOBLE OSMO) # If no host zones are specified above: # `start-docker` defaults to just GAIA if HOST_CHAINS is empty diff --git a/dockernet/scripts/community-pool-staking/README.md b/dockernet/scripts/community-pool-staking/README.md index 95b2beae21..ad005fbf95 100644 --- a/dockernet/scripts/community-pool-staking/README.md +++ b/dockernet/scripts/community-pool-staking/README.md @@ -49,3 +49,11 @@ bash dockernet/scripts/community-pool-staking/add_trade_route.sh ```bash bash dockernet/scripts/community-pool-staking/reinvest.sh ``` +* To register a rebate, run the following script. +```bash +bash dockernet/scripts/community-pool-staking/rebate.sh +``` +* Then trigger reinvestment again. This time, you should notice USDC goes straight from the withdrawal account to the relevant community pool account. For Gaia, this account is the standard community pool, and for dYdX, the account is the community pool treasury. +```bash +bash dockernet/scripts/community-pool-staking/reinvest.sh +``` \ No newline at end of file diff --git a/dockernet/scripts/community-pool-staking/add_trade_route.sh b/dockernet/scripts/community-pool-staking/add_trade_route.sh index 173b7a9647..7b2a45d129 100644 --- a/dockernet/scripts/community-pool-staking/add_trade_route.sh +++ b/dockernet/scripts/community-pool-staking/add_trade_route.sh @@ -21,6 +21,10 @@ host_to_noble_client=$(GET_CLIENT_ID_FROM_CHAIN_ID $HOST_CHAIN NOBLE) host_to_noble_connection=$(GET_CONNECTION_ID_FROM_CLIENT_ID $HOST_CHAIN $host_to_noble_client) host_to_noble_channel=$(GET_TRANSFER_CHANNEL_ID_FROM_CONNECTION_ID $HOST_CHAIN $host_to_noble_connection) +host_to_osmo_client=$(GET_CLIENT_ID_FROM_CHAIN_ID $HOST_CHAIN OSMO) +host_to_osmo_connection=$(GET_CONNECTION_ID_FROM_CLIENT_ID $HOST_CHAIN $host_to_osmo_client) +host_to_osmo_channel=$(GET_TRANSFER_CHANNEL_ID_FROM_CONNECTION_ID $HOST_CHAIN $host_to_osmo_connection) + noble_to_host_client=$(GET_CLIENT_ID_FROM_CHAIN_ID NOBLE $HOST_CHAIN) noble_to_host_connection=$(GET_CONNECTION_ID_FROM_CLIENT_ID NOBLE $noble_to_host_client) noble_to_host_channel=$(GET_TRANSFER_CHANNEL_ID_FROM_CONNECTION_ID NOBLE $noble_to_host_connection) @@ -60,11 +64,26 @@ echo " Client: $osmo_to_host_client" echo " Connection: $osmo_to_host_connection" echo " Transfer Channel: $osmo_to_host_channel" -echo -e "\nTransferring $USDC_DENOM to $HOST_DENOM to create ibc denom..." +echo -e "\n$HOST_CHAIN -> OSMO:" +echo " Client: $host_to_osmo_client" +echo " Connection: $host_to_osmo_connection" +echo " Transfer Channel: $host_to_osmo_channel" + +echo -e "\nTransferring $USDC_DENOM to $HOST_CHAIN to create ibc denom..." $NOBLE_MAIN_CMD tx ibc-transfer transfer transfer $noble_to_host_channel $HOST_VAL_ADDRESS 10000${USDC_DENOM} \ --from ${NOBLE_VAL_PREFIX}1 -y | TRIM_TX sleep 15 +echo -e "\nTransferring $USDC_DENOM to OSMO to create ibc denom..." +$NOBLE_MAIN_CMD tx ibc-transfer transfer transfer $noble_to_osmo_channel $(OSMO_ADDRESS) 10000${USDC_DENOM} \ + --from ${NOBLE_VAL_PREFIX}1 -y | TRIM_TX +sleep 15 + +echo -e "\nTransferring $HOST_DENOM to OSMO to create ibc denom..." +$HOST_MAIN_CMD tx ibc-transfer transfer transfer $host_to_osmo_channel $(OSMO_ADDRESS) 10000${HOST_DENOM} \ + --from ${HOST_VAL_PREFIX}1 -y | TRIM_TX +sleep 15 + echo -e "\nDetermining IBC Denoms..." usdc_denom_on_host=$(GET_IBC_DENOM $HOST_CHAIN_ID $host_to_noble_channel $USDC_DENOM) usdc_denom_on_osmo=$(GET_IBC_DENOM OSMO $osmo_to_noble_channel $USDC_DENOM) diff --git a/dockernet/scripts/community-pool-staking/rebate.sh b/dockernet/scripts/community-pool-staking/rebate.sh new file mode 100644 index 0000000000..d41287c050 --- /dev/null +++ b/dockernet/scripts/community-pool-staking/rebate.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -eu +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source ${SCRIPT_DIR}/../../config.sh + +HOST_CHAIN=$REWARD_CONVERTER_HOST_ZONE +HOST_CHAIN_ID=$(GET_VAR_VALUE ${HOST_CHAIN}_CHAIN_ID) + +$STRIDE_MAIN_CMD tx stakeibc set-rebate $HOST_CHAIN_ID 100000 --from ${STRIDE_VAL_PREFIX}1 -y \ No newline at end of file diff --git a/dockernet/src/create_logs.sh b/dockernet/src/create_logs.sh index 0c22c43282..9b29706842 100755 --- a/dockernet/src/create_logs.sh +++ b/dockernet/src/create_logs.sh @@ -184,21 +184,25 @@ while true; do print_stride_balance $community_pool_stake_address "COMMUNITY POOL STAKE HOLDING ACCT BALANCE" print_stride_balance $community_pool_redeem_address "COMMUNITY POOL REDEEM HOLDING ACCT BALANCE" + community_pool_treasury=$($STRIDE_MAIN_CMD q stakeibc show-host-zone $HOST_CHAIN_ID | grep community_pool_treasury | awk '{print $2}' | tr -d '"') + if [[ "$community_pool_treasury" != "" ]]; then + print_host_balance $chain $community_pool_treasury "COMMUNITY POOL TREASURY ADDRESS" + fi + # Log host channels print_separator "$chain" $channels $HOST_MAIN_CMD q ibc channel channels | grep -E "channel_id|port|state" >> $channels || true done - TRADE_ICA_ADDR=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep trade_account -A 2 | grep address | awk '{print $2}') if [[ "$TRADE_ICA_ADDR" == "$OSMO_ADDRESS_PREFIX"* ]]; then - print_header "TRADE ACCT BALANCE" >> $balances + print_header "TRADE ACCT BALANCE" $balances $OSMO_MAIN_CMD q bank balances $TRADE_ICA_ADDR >> $balances fi for chain in ${ACCESSORY_CHAINS[@]:-}; do ACCESSORY_MAIN_CMD=$(GET_VAR_VALUE ${chain}_MAIN_CMD) - print_header "========================== $chain =============================" >> $channels + print_header "========================== $chain =============================" $channels $ACCESSORY_MAIN_CMD q ibc channel channels | grep -E "channel_id|port|state" >> $channels || true done diff --git a/dockernet/src/init_chain.sh b/dockernet/src/init_chain.sh index 9dc283243b..9f04dc9a32 100644 --- a/dockernet/src/init_chain.sh +++ b/dockernet/src/init_chain.sh @@ -335,7 +335,7 @@ if [[ "$CHAIN" != "STRIDE" && "$CHAIN" != "HOST" ]]; then fi # wipe out the persistent peers for the main node (these are incorrectly autogenerated for each validator during collect-gentxs) -sed -i -E "s|persistent_peers = .*|persistent_peers = \"\"|g" $MAIN_CONFIG +sed -i -E "s|^persistent_peers = .*|persistent_peers = \"\"|g" $MAIN_CONFIG # update chain-specific genesis settings if [ "$CHAIN" == "STRIDE" ]; then @@ -362,7 +362,7 @@ for (( i=2; i <= $NUM_NODES; i++ )); do genesis_json="${STATE}/${node_name}/config/genesis.json" # add the main node as a persistent peer - sed -i -E "s|persistent_peers = .*|persistent_peers = \"${MAIN_NODE_ID}\"|g" $config_toml + sed -i -E "s|^persistent_peers = .*|persistent_peers = \"${MAIN_NODE_ID}\"|g" $config_toml # copy the main node's genesis to the peer nodes to ensure they all have the same genesis cp $MAIN_GENESIS $genesis_json diff --git a/dockernet/src/register_host.sh b/dockernet/src/register_host.sh index 6ef5f11da9..52c89f6c96 100644 --- a/dockernet/src/register_host.sh +++ b/dockernet/src/register_host.sh @@ -23,9 +23,14 @@ if [[ "$CHAIN" == "GAIA" ]]; then LSM_ENABLED="true" fi +COMMUNITY_POOL_TREASURY_ADDRESS="" +if [[ "$CHAIN" == "DYDX" ]]; then + COMMUNITY_POOL_TREASURY_ADDRESS="--community-pool-treasury-address XXX" +fi + echo "$CHAIN - Registering host zone..." $STRIDE_MAIN_CMD tx stakeibc register-host-zone \ - $CONNECTION $HOST_DENOM $ADDRESS_PREFIX $IBC_DENOM $CHANNEL 1 $LSM_ENABLED \ + $CONNECTION $HOST_DENOM $ADDRESS_PREFIX $IBC_DENOM $CHANNEL 1 $LSM_ENABLED $COMMUNITY_POOL_TREASURY_ADDRESS \ --gas 1000000 --from $STRIDE_ADMIN_ACCT --home $DOCKERNET_HOME/state/stride1 -y | TRIM_TX sleep 10 From 8ad57b69d6933683969f8d7b20f1243eb8190dbf Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 15:05:44 -0500 Subject: [PATCH 02/10] disabled swap price check --- x/stakeibc/keeper/reward_converter.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/x/stakeibc/keeper/reward_converter.go b/x/stakeibc/keeper/reward_converter.go index 78b1a8418a..2155402aa2 100644 --- a/x/stakeibc/keeper/reward_converter.go +++ b/x/stakeibc/keeper/reward_converter.go @@ -296,12 +296,6 @@ func (k Keeper) TransferRewardTokensHostToTrade(ctx sdk.Context, amount sdkmath. return nil } - // Similarly, if there's no price on the trade route yet, don't initiate the transfer because - // we know the swap will not be submitted - if route.TradeConfig.SwapPrice.IsZero() { - return nil - } - // Build the PFM transfer message from host to trade zone msg, err := k.BuildHostToTradeTransferMsg(ctx, amount, route) if err != nil { From b37ef9879b465f26a789a59ec4e70e2ddfc9f112 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 15:06:03 -0500 Subject: [PATCH 03/10] nit changes while testing flow --- dockernet/config/ica_host.json | 3 +++ dockernet/scripts/community-pool-staking/README.md | 4 ++++ dockernet/scripts/community-pool-staking/add_trade_route.sh | 6 ++++-- dockernet/scripts/community-pool-staking/rebate.sh | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dockernet/config/ica_host.json b/dockernet/config/ica_host.json index 0017667db7..cb35245554 100644 --- a/dockernet/config/ica_host.json +++ b/dockernet/config/ica_host.json @@ -19,7 +19,10 @@ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + "/cosmos.authz.v1beta1.MsgGrant", + "/cosmos.authz.v1beta1.MsgRevoke", "/ibc.applications.transfer.v1.MsgTransfer", + "/cosmos.bank.v1beta1.MsgMultiSend", "/cosmwasm.wasm.v1.MsgExecuteContract", "/cosmwasm.wasm.v1.MsgInstantiateContract", "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn" diff --git a/dockernet/scripts/community-pool-staking/README.md b/dockernet/scripts/community-pool-staking/README.md index ad005fbf95..3bf8a1b9e3 100644 --- a/dockernet/scripts/community-pool-staking/README.md +++ b/dockernet/scripts/community-pool-staking/README.md @@ -45,6 +45,10 @@ bash dockernet/scripts/community-pool-staking/create_pool.sh ```bash bash dockernet/scripts/community-pool-staking/add_trade_route.sh ``` +* Liquid stake to create TVL +```bash +bash dockernet/scripts/community-pool-staking/stake.sh +``` * Finally, test the reinvestment flow by sending USDC to the withdrawal address. View `logs/balances.log` to watch the funds traverse the different accounts ```bash bash dockernet/scripts/community-pool-staking/reinvest.sh diff --git a/dockernet/scripts/community-pool-staking/add_trade_route.sh b/dockernet/scripts/community-pool-staking/add_trade_route.sh index 7b2a45d129..8fe3b39341 100644 --- a/dockernet/scripts/community-pool-staking/add_trade_route.sh +++ b/dockernet/scripts/community-pool-staking/add_trade_route.sh @@ -5,8 +5,10 @@ source ${SCRIPT_DIR}/../../config.sh HOST_CHAIN=$REWARD_CONVERTER_HOST_ZONE HOST_VAL_ADDRESS=$(${HOST_CHAIN}_ADDRESS) -HOST_CHAIN_ID=$(GET_VAR_VALUE ${HOST_CHAIN}_CHAIN_ID) -HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM) +HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD) +HOST_CHAIN_ID=$(GET_VAR_VALUE ${HOST_CHAIN}_CHAIN_ID) +HOST_VAL_PREFIX=$(GET_VAR_VALUE ${HOST_CHAIN}_VAL_PREFIX) +HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM) GAS="--gas-prices 0.1ustrd --gas auto --gas-adjustment 1.3" diff --git a/dockernet/scripts/community-pool-staking/rebate.sh b/dockernet/scripts/community-pool-staking/rebate.sh index d41287c050..1bfad1c96f 100644 --- a/dockernet/scripts/community-pool-staking/rebate.sh +++ b/dockernet/scripts/community-pool-staking/rebate.sh @@ -6,4 +6,4 @@ source ${SCRIPT_DIR}/../../config.sh HOST_CHAIN=$REWARD_CONVERTER_HOST_ZONE HOST_CHAIN_ID=$(GET_VAR_VALUE ${HOST_CHAIN}_CHAIN_ID) -$STRIDE_MAIN_CMD tx stakeibc set-rebate $HOST_CHAIN_ID 100000 --from ${STRIDE_VAL_PREFIX}1 -y \ No newline at end of file +$STRIDE_MAIN_CMD tx stakeibc set-rebate $HOST_CHAIN_ID 0.25 100000 --from admin -y \ No newline at end of file From dd85762cddb48ed294a631ec286c21832edce1ae Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 15:53:54 -0500 Subject: [PATCH 04/10] nit changes while testing flow with dydx --- dockernet/config.sh | 2 +- dockernet/src/create_logs.sh | 82 ++++++++++++++++++---------------- dockernet/src/register_host.sh | 2 +- dockernet/start_network.sh | 8 ++++ 4 files changed, 53 insertions(+), 41 deletions(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index 91a2b76959..d86854f471 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -17,7 +17,7 @@ KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log # List of hosts enabled # HOST_CHAINS have liquid staking support, ACCESSORY_CHAINS do not -HOST_CHAINS=() +HOST_CHAINS=(DYDX) ACCESSORY_CHAINS=(NOBLE OSMO) # If no host zones are specified above: diff --git a/dockernet/src/create_logs.sh b/dockernet/src/create_logs.sh index 9b29706842..f89d62ec52 100755 --- a/dockernet/src/create_logs.sh +++ b/dockernet/src/create_logs.sh @@ -88,53 +88,57 @@ while true; do print_header "TRADE ROUTES" $state $STRIDE_MAIN_CMD q stakeibc list-trade-routes >> $state - print_separator "STAKETIA" $state - - print_header "HOST ZONE" $state - $STRIDE_MAIN_CMD q staketia host-zone >> $state - print_header "DELEGATION RECORDS" $state - $STRIDE_MAIN_CMD q staketia delegation-records >> $state - print_header "UNBONDING RECORDS" $state - $STRIDE_MAIN_CMD q staketia unbonding-records >> $state - print_header "REDEMPTION RECORDS" $state - $STRIDE_MAIN_CMD q staketia redemption-records >> $state - print_header "SLASH RECORDS" $state - $STRIDE_MAIN_CMD q staketia slash-records >> $state + host_chain="${HOST_CHAINS[0]}" + if [[ "$host_chain" == "GAIA" ]]; then + print_separator "STAKETIA" $state + + print_header "HOST ZONE" $state + $STRIDE_MAIN_CMD q staketia host-zone >> $state + print_header "DELEGATION RECORDS" $state + $STRIDE_MAIN_CMD q staketia delegation-records >> $state + print_header "UNBONDING RECORDS" $state + $STRIDE_MAIN_CMD q staketia unbonding-records >> $state + print_header "REDEMPTION RECORDS" $state + $STRIDE_MAIN_CMD q staketia redemption-records >> $state + print_header "SLASH RECORDS" $state + $STRIDE_MAIN_CMD q staketia slash-records >> $state + fi # Log stride stakeibc balances print_separator "VALIDATORS" $balances - host_chain="${HOST_CHAINS[0]}" host_val_address="$(${host_chain}_ADDRESS)" host_cmd=$(GET_VAR_VALUE ${host_chain}_MAIN_CMD) print_stride_balance $(STRIDE_ADDRESS) "STRIDE" print_host_balance $host_chain $host_val_address $host_chain - # Log stride staketia balances - print_separator "STAKETIA STRIDE" $balances - - deposit_address=$($STRIDE_MAIN_CMD keys show -a deposit) - redemption_address=$($STRIDE_MAIN_CMD keys show -a redemption) - claim_address=$($STRIDE_MAIN_CMD keys show -a claim) - fee_address=$($STRIDE_MAIN_CMD q auth module-account staketia_fee_address | grep "address:" | awk '{print $2}') - - print_stride_balance $deposit_address "DEPOSIT" - print_stride_balance $redemption_address "REDEMPTION" - print_stride_balance $claim_address "CLAIM" - print_stride_balance $fee_address "FEE" - - # Log staketia balance on host chain - print_separator "STAKETIA HOST" $balances - print_host_balance "$host_chain" $DELEGATION_ADDRESS "DELEGATION CONTROLLER" - print_host_balance "$host_chain" $REWARD_ADDRESS "REWARD CONTROLLER" - - # Log staketia delegations/undelegations - print_separator "STAKETIA STAKING" $balances - delegation_address=$($STRIDE_MAIN_CMD q staketia host-zone | grep "delegation_address" | awk '{print $2}') - - print_header "DELEGATIONS $host_chain" $balances - $host_cmd q staking delegations $delegation_address | grep -vE "pagination|total|next_key" >> $balances - print_header "UNBONDING-DELEGATIONS $host_chain" $balances - $host_cmd q staking unbonding-delegations $delegation_address | grep -vE "pagination|total|next_key" >> $balances + if [[ "$host_chain" == "GAIA" ]]; then + # Log stride staketia balances + print_separator "STAKETIA STRIDE" $balances + + deposit_address=$($STRIDE_MAIN_CMD keys show -a deposit) + redemption_address=$($STRIDE_MAIN_CMD keys show -a redemption) + claim_address=$($STRIDE_MAIN_CMD keys show -a claim) + fee_address=$($STRIDE_MAIN_CMD q auth module-account staketia_fee_address | grep "address:" | awk '{print $2}') + + print_stride_balance $deposit_address "DEPOSIT" + print_stride_balance $redemption_address "REDEMPTION" + print_stride_balance $claim_address "CLAIM" + print_stride_balance $fee_address "FEE" + + # Log staketia balance on host chain + print_separator "STAKETIA HOST" $balances + print_host_balance "$host_chain" $DELEGATION_ADDRESS "DELEGATION CONTROLLER" + print_host_balance "$host_chain" $REWARD_ADDRESS "REWARD CONTROLLER" + + # Log staketia delegations/undelegations + print_separator "STAKETIA STAKING" $balances + delegation_address=$($STRIDE_MAIN_CMD q staketia host-zone | grep "delegation_address" | awk '{print $2}') + + print_header "DELEGATIONS $host_chain" $balances + $host_cmd q staking delegations $delegation_address | grep -vE "pagination|total|next_key" >> $balances + print_header "UNBONDING-DELEGATIONS $host_chain" $balances + $host_cmd q staking unbonding-delegations $delegation_address | grep -vE "pagination|total|next_key" >> $balances + fi # Log stride channels print_separator "STRIDE" $channels diff --git a/dockernet/src/register_host.sh b/dockernet/src/register_host.sh index 52c89f6c96..fc7252ddc4 100644 --- a/dockernet/src/register_host.sh +++ b/dockernet/src/register_host.sh @@ -25,7 +25,7 @@ fi COMMUNITY_POOL_TREASURY_ADDRESS="" if [[ "$CHAIN" == "DYDX" ]]; then - COMMUNITY_POOL_TREASURY_ADDRESS="--community-pool-treasury-address XXX" + COMMUNITY_POOL_TREASURY_ADDRESS="--community-pool-treasury-address dydx15ztc7xy42tn2ukkc0qjthkucw9ac63pgp70urn" fi echo "$CHAIN - Registering host zone..." diff --git a/dockernet/start_network.sh b/dockernet/start_network.sh index 831b5137ec..64511fa5f0 100755 --- a/dockernet/start_network.sh +++ b/dockernet/start_network.sh @@ -57,8 +57,16 @@ done # Start each chain, create the transfer channels and start the relayers +# For dydx, sleep before and after the relayers are setup to get it some time to startup +# since it's a computationally expensive chain bash $SRC/start_chain.sh +if [[ "$chain" == "DYDX" ]]; then + sleep 30 +fi bash $SRC/start_relayers.sh +if [[ "$chain" == "DYDX" ]]; then + sleep 30 +fi # Create governors for chains running the stride binary for chain in STRIDE ${HOST_CHAINS[@]}; do From 7a81c85a5e75ec9c901921f8f8598e33a3cc4f13 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 16:22:21 -0500 Subject: [PATCH 05/10] added trade script --- .../scripts/community-pool-staking/add_trade_route.sh | 2 +- dockernet/scripts/community-pool-staking/trade.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 dockernet/scripts/community-pool-staking/trade.sh diff --git a/dockernet/scripts/community-pool-staking/add_trade_route.sh b/dockernet/scripts/community-pool-staking/add_trade_route.sh index 8fe3b39341..0b9b02ca87 100644 --- a/dockernet/scripts/community-pool-staking/add_trade_route.sh +++ b/dockernet/scripts/community-pool-staking/add_trade_route.sh @@ -82,7 +82,7 @@ $NOBLE_MAIN_CMD tx ibc-transfer transfer transfer $noble_to_osmo_channel $(OSMO_ sleep 15 echo -e "\nTransferring $HOST_DENOM to OSMO to create ibc denom..." -$HOST_MAIN_CMD tx ibc-transfer transfer transfer $host_to_osmo_channel $(OSMO_ADDRESS) 10000${HOST_DENOM} \ +$HOST_MAIN_CMD tx ibc-transfer transfer transfer $host_to_osmo_channel $(OSMO_ADDRESS) 10000000${HOST_DENOM} \ --from ${HOST_VAL_PREFIX}1 -y | TRIM_TX sleep 15 diff --git a/dockernet/scripts/community-pool-staking/trade.sh b/dockernet/scripts/community-pool-staking/trade.sh new file mode 100644 index 0000000000..0153ebe492 --- /dev/null +++ b/dockernet/scripts/community-pool-staking/trade.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -eu +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source ${SCRIPT_DIR}/../../config.sh + +# Simulates a trade by sending the native token to the trade account +# We'll send the amount that should have been sent from the ICA, which has the rebate excluded +trade_account=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep trade_account -A 3 | grep address | awk '{print $2}') +host_denom_on_trade=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep host_denom_on_trade | awk '{print $2}') +$OSMO_MAIN_CMD tx bank send ${OSMO_VAL_PREFIX}1 $trade_account 997500${host_denom_on_trade} --from ${OSMO_VAL_PREFIX}1 -y \ No newline at end of file From c55b585c0c3dbf7efe3bef6421041d181fbdc448 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 16:39:57 -0500 Subject: [PATCH 06/10] nit revert --- dockernet/start_network.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dockernet/start_network.sh b/dockernet/start_network.sh index 64511fa5f0..9cd6c36093 100755 --- a/dockernet/start_network.sh +++ b/dockernet/start_network.sh @@ -60,13 +60,7 @@ done # For dydx, sleep before and after the relayers are setup to get it some time to startup # since it's a computationally expensive chain bash $SRC/start_chain.sh -if [[ "$chain" == "DYDX" ]]; then - sleep 30 -fi bash $SRC/start_relayers.sh -if [[ "$chain" == "DYDX" ]]; then - sleep 30 -fi # Create governors for chains running the stride binary for chain in STRIDE ${HOST_CHAINS[@]}; do From e0dae0d4a65eeffee9b8d2bf25673e26cce8404a Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 17:40:30 -0500 Subject: [PATCH 07/10] fixed typo in denom --- x/stakeibc/keeper/icqcallbacks_withdrawal_reward_balance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/stakeibc/keeper/icqcallbacks_withdrawal_reward_balance.go b/x/stakeibc/keeper/icqcallbacks_withdrawal_reward_balance.go index 0fdbf05e04..fb66c69078 100644 --- a/x/stakeibc/keeper/icqcallbacks_withdrawal_reward_balance.go +++ b/x/stakeibc/keeper/icqcallbacks_withdrawal_reward_balance.go @@ -67,7 +67,7 @@ func WithdrawalRewardBalanceCallback(k Keeper, ctx sdk.Context, args []byte, que // If there's a rebate portion, fund the community pool with that amount if rebateAmount.GT(sdkmath.ZeroInt()) { - rebateToken := sdk.NewCoin(tradeRouteCallback.RewardDenom, rebateAmount) + rebateToken := sdk.NewCoin(tradeRoute.RewardDenomOnHostZone, rebateAmount) if err := k.FundCommunityPool(ctx, hostZone, rebateToken, types.ICAAccountType_WITHDRAWAL); err != nil { return errorsmod.Wrapf(err, "unable to submit fund community pool ICA") } From 6a16f0e45e15d5085f0d90e340f6d7179794c485 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 22:11:17 -0500 Subject: [PATCH 08/10] updated authz ica to include expiration and updated trade script to use authz --- dockernet/config.sh | 2 +- .../scripts/community-pool-staking/trade.sh | 17 ++++++++++++++--- x/stakeibc/keeper/reward_converter.go | 6 +++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index d86854f471..91a2b76959 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -17,7 +17,7 @@ KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log # List of hosts enabled # HOST_CHAINS have liquid staking support, ACCESSORY_CHAINS do not -HOST_CHAINS=(DYDX) +HOST_CHAINS=() ACCESSORY_CHAINS=(NOBLE OSMO) # If no host zones are specified above: diff --git a/dockernet/scripts/community-pool-staking/trade.sh b/dockernet/scripts/community-pool-staking/trade.sh index 0153ebe492..0556b74ed2 100644 --- a/dockernet/scripts/community-pool-staking/trade.sh +++ b/dockernet/scripts/community-pool-staking/trade.sh @@ -3,8 +3,19 @@ set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source ${SCRIPT_DIR}/../../config.sh -# Simulates a trade by sending the native token to the trade account -# We'll send the amount that should have been sent from the ICA, which has the rebate excluded +TRADE_AMOUNT=997500 + trade_account=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep trade_account -A 3 | grep address | awk '{print $2}') host_denom_on_trade=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep host_denom_on_trade | awk '{print $2}') -$OSMO_MAIN_CMD tx bank send ${OSMO_VAL_PREFIX}1 $trade_account 997500${host_denom_on_trade} --from ${OSMO_VAL_PREFIX}1 -y \ No newline at end of file +reward_denom_on_trade=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep reward_denom_on_trade | awk '{print $2}') + +tx_file=${STATE}/${OSMO_NODE_PREFIX}1/swap_tx.json +$OSMO_MAIN_CMD tx gamm swap-exact-amount-in ${TRADE_AMOUNT}${reward_denom_on_trade} 1 \ + --swap-route-pool-ids 1 --swap-route-denoms $host_denom_on_trade \ + --from $trade_account --generate-only > $tx_file +sleep 5 + +echo "Executing swap through authz..." +$OSMO_MAIN_CMD tx authz exec $tx_file --from ${OSMO_VAL_PREFIX}1 -y | TRIM_TX +sleep 1 +rm -f $tx_file \ No newline at end of file diff --git a/x/stakeibc/keeper/reward_converter.go b/x/stakeibc/keeper/reward_converter.go index 2155402aa2..554278dbdb 100644 --- a/x/stakeibc/keeper/reward_converter.go +++ b/x/stakeibc/keeper/reward_converter.go @@ -197,7 +197,9 @@ func (k Keeper) BuildTradeAuthzMsg( switch permissionChange { case types.AuthzPermissionChange_GRANT: authorization := authz.NewGenericAuthorization(swapMsgTypeUrl) - grant, err := authz.NewGrant(ctx.BlockTime(), authorization, nil) + expiration := ctx.BlockTime().Add(time.Hour * 24 * 365 * 100) // 100 years + + grant, err := authz.NewGrant(ctx.BlockTime(), authorization, &expiration) if err != nil { return nil, errorsmod.Wrapf(err, "unable to build grant struct") } @@ -206,12 +208,14 @@ func (k Keeper) BuildTradeAuthzMsg( Grantee: grantee, Grant: grant, }} + case types.AuthzPermissionChange_REVOKE: authzMsg = []proto.Message{&authz.MsgRevoke{ Granter: tradeRoute.TradeAccount.Address, Grantee: grantee, MsgTypeUrl: swapMsgTypeUrl, }} + default: return nil, errors.New("invalid permission change") } From 89a46fad32668e39b95107ada7a9a2507fb26128 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 22:28:05 -0500 Subject: [PATCH 09/10] nit --- dockernet/config.sh | 2 +- dockernet/config/ica_host.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dockernet/config.sh b/dockernet/config.sh index 91a2b76959..e38a16c1c9 100755 --- a/dockernet/config.sh +++ b/dockernet/config.sh @@ -18,7 +18,7 @@ KEYS_LOGS=$DOCKERNET_HOME/logs/keys.log # List of hosts enabled # HOST_CHAINS have liquid staking support, ACCESSORY_CHAINS do not HOST_CHAINS=() -ACCESSORY_CHAINS=(NOBLE OSMO) +ACCESSORY_CHAINS=() # If no host zones are specified above: # `start-docker` defaults to just GAIA if HOST_CHAINS is empty diff --git a/dockernet/config/ica_host.json b/dockernet/config/ica_host.json index cb35245554..3ca3c342f8 100644 --- a/dockernet/config/ica_host.json +++ b/dockernet/config/ica_host.json @@ -22,7 +22,6 @@ "/cosmos.authz.v1beta1.MsgGrant", "/cosmos.authz.v1beta1.MsgRevoke", "/ibc.applications.transfer.v1.MsgTransfer", - "/cosmos.bank.v1beta1.MsgMultiSend", "/cosmwasm.wasm.v1.MsgExecuteContract", "/cosmwasm.wasm.v1.MsgInstantiateContract", "/osmosis.gamm.v1beta1.MsgSwapExactAmountIn" From b16dfc4474c386cd6266a57cbd68355f744e8d45 Mon Sep 17 00:00:00 2001 From: sampocs Date: Wed, 20 Mar 2024 22:53:22 -0500 Subject: [PATCH 10/10] granted authz in trade script --- dockernet/scripts/community-pool-staking/trade.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dockernet/scripts/community-pool-staking/trade.sh b/dockernet/scripts/community-pool-staking/trade.sh index 0556b74ed2..2996dce7c6 100644 --- a/dockernet/scripts/community-pool-staking/trade.sh +++ b/dockernet/scripts/community-pool-staking/trade.sh @@ -9,6 +9,10 @@ trade_account=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep trade_accou host_denom_on_trade=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep host_denom_on_trade | awk '{print $2}') reward_denom_on_trade=$($STRIDE_MAIN_CMD q stakeibc list-trade-routes | grep reward_denom_on_trade | awk '{print $2}') +echo "Granting authz permissions..." +$STRIDE_MAIN_CMD tx stakeibc toggle-trade-controller $OSMO_CHAIN_ID grant $(OSMO_ADDRESS) --from admin -y +sleep 15 + tx_file=${STATE}/${OSMO_NODE_PREFIX}1/swap_tx.json $OSMO_MAIN_CMD tx gamm swap-exact-amount-in ${TRADE_AMOUNT}${reward_denom_on_trade} 1 \ --swap-route-pool-ids 1 --swap-route-denoms $host_denom_on_trade \