Skip to content

Commit

Permalink
feat(scripts): updated scripts for local run, added sponsored stream …
Browse files Browse the repository at this point in the history
…creation (#1046)
  • Loading branch information
keruch authored Aug 14, 2024
1 parent b8d9823 commit c8fc1fd
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ SDK Checklist
Full security checklist [here](https://www.faulttolerant.xyz/2024-01-16-cosmos-security-1/)


----;
----

For Reviewer:

- [ ] Confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] Reviewers assigned
- [ ] Confirmed all author checklist items have been addressed

---;
----

After reviewer approval:

Expand Down
9 changes: 0 additions & 9 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,6 @@ func (a *AppKeepers) InitKeepers(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

a.SponsorshipKeeper = sponsorshipkeeper.NewKeeper(
appCodec,
a.keys[sponsorshiptypes.StoreKey],
a.AccountKeeper,
a.StakingKeeper,
a.IncentivesKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

a.StreamerKeeper = *streamermodulekeeper.NewKeeper(
a.keys[streamermoduletypes.StoreKey],
a.GetSubspace(streamermoduletypes.ModuleName),
Expand Down
23 changes: 21 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ sh scripts/pools/pools_bootstrap.sh

### Creating incentives streams

After creating the pools above, we create 2 incentive streams through gov:
After creating the pools above, we create 3 incentive streams through gov:

```sh
sh scripts/incentives/fund_incentives.sh
Expand All @@ -134,6 +134,8 @@ Wait for the gov proposal to pass, and validate with:
dymd q streamer streams
```

The last stream is community-driven and governed by `x/sponsorship`.

### Locking tokens

To get incentives, we need to lock the LP tokens:
Expand All @@ -148,7 +150,7 @@ validate with:
dymd q lockup module-balance
```

### check rewards
### Checking rewards

Every minute a share of the rewards will be distributed!

Expand All @@ -161,6 +163,23 @@ dymd q incentives active-gauges
# watch -n1 -d "dymd q incentives active-gauges --output json | jq '.data[] | { "id": .id, "coins": .coins } '"
```

### Updating a community-driven distribution

The following script casts two votes for a community-driven distribution.
```sh
sh scripts/incentives/sponsorship_vote.sh
```

This will change the corresponding stream distribution at the end of the current epoch.
```sh
dymd q streamer streams
```

The community-driven distribution may be queried with:
```sh
dymd q sponsorship distribution
```

## Debugging Container

Pre-requisite:
Expand Down
40 changes: 32 additions & 8 deletions scripts/incentives/fund_incentives.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
#!/bin/bash

# fund streamer
dymd tx bank send local-user \
dymd tx bank send user \
dym1ysjlrjcankjpmpxxzk27mvzhv25e266r80p5pv \
300000dym --keyring-backend test -b block -y --gas-prices 100000000adym
300000dym --keyring-backend test -y --gas-prices 100000000adym
sleep 7

# create new gauges for lockdrop
echo "Creating gauges for lockdrop of uatom"
dymd tx incentives create-gauge uatom 30dym --duration="60s" --perpetual --from local-user -b block --gas auto -y --gas-prices 100000000adym
dymd tx incentives create-gauge uatom 30dym --duration="60s" --perpetual --from user --gas auto -y --gas-prices 100000000adym
sleep 7

# create first stream for the LP holders
echo "Gov proposal for creating new stream with LP1 and LP2 as incentives targets"
dymd tx gov submit-legacy-proposal create-stream-proposal 1,2 40,60 20000dym --epoch-identifier minute --from local-user -b block --title sfasfas --description ddasda --deposit 11dym -y --gas auto --gas-prices 100000000adym
dymd tx gov submit-legacy-proposal create-stream-proposal 1,2 40,60 20000dym --epoch-identifier minute --from user --title sfasfas --description ddasda --deposit 11dym -y --gas auto --gas-prices 100000000adym
sleep 7

last_proposal_id=$(dymd q gov proposals -o json | jq '.proposals | map(.id | tonumber) | max')
dymd tx gov vote "$last_proposal_id" yes --from local-user -b block -y --gas-prices 100000000adym

dymd tx gov vote "$last_proposal_id" yes --from hub-user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from pools -y --gas-prices 100000000adym
sleep 7

# create second stream for the Lockdrop
echo "Gov proposal for creating new stream for lockdrop"
dymd tx gov submit-legacy-proposal create-stream-proposal 3 100 10000dym --epoch-identifier minute --from local-user -b block --title sfasfas --description ddasda --deposit 1dym -y --gas auto --gas-prices 100000000adym
dymd tx gov submit-legacy-proposal create-stream-proposal 3 100 10000dym --epoch-identifier minute --from user --title sfasfas --description ddasda --deposit 11dym -y --gas auto --gas-prices 100000000adym
sleep 7

last_proposal_id=$(dymd q gov proposals -o json | jq '.proposals | map(.id | tonumber) | max')

dymd tx gov vote "$last_proposal_id" yes --from hub-user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from pools -y --gas-prices 100000000adym
sleep 7

# create sponsored stream
echo "Gov proposal for creating a new sponsored stream"
dymd tx gov submit-legacy-proposal create-stream-proposal - - 10000dym --sponsored --epoch-identifier minute --from user --title sfasfas --description ddasda --deposit 11dym -y --gas auto --gas-prices 100000000adym
sleep 7

last_proposal_id=$(dymd q gov proposals -o json | jq '.proposals | map(.id | tonumber) | max')
dymd tx gov vote "$last_proposal_id" yes --from local-user -b block -y --gas-prices 100000000adym
~

dymd tx gov vote "$last_proposal_id" yes --from hub-user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from user -y --gas-prices 100000000adym
dymd tx gov vote "$last_proposal_id" yes --from pools -y --gas-prices 100000000adym
4 changes: 4 additions & 0 deletions scripts/incentives/lockup_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

echo "locking LP1 tokens for 2 weeks"
dymd tx lockup lock-tokens 50000000000000000000gamm/pool/1 --duration="60s" --from pools --keyring-backend=test -b block -y --gas-prices 100000000adym
sleep 7

echo "locking uatom tokens for 1h"
dymd tx lockup lock-tokens 500000000uatom --duration="3600s" --from user --keyring-backend=test -b block -y --gas-prices 100000000adym
sleep 7

echo "locking dym tokens for 1 day"
dymd tx lockup lock-tokens 100dym --duration="24h" --from user --keyring-backend=test -b block -y --gas-prices 100000000adym
sleep 7

echo "unlocking dym tokens"
dymd tx lockup begin-unlock-by-id 2 --from user --keyring-backend=test -b block -y --gas-prices 100000000adym
13 changes: 13 additions & 0 deletions scripts/incentives/sponsorship_vote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echo "Delegate to the active validator"
# dymvaloper139mq752delxv78jvtmwxhasyrycufsvrd7p5rl is a validator address of hub-user
dymd tx staking delegate dymvaloper139mq752delxv78jvtmwxhasyrycufsvrd7p5rl 10000dym --from user -y --gas-prices 100000000adym
sleep 7

echo "Voting on gauge as 'user'"
dymd tx sponsorship vote 1=30,2=30,3=40 --from user -y --gas-prices 100000000adym
sleep 7

echo "Voting on gauge as 'hub-user'"
dymd tx sponsorship vote 1=20,2=20 --from hub-user -y --gas-prices 100000000adym
16 changes: 9 additions & 7 deletions scripts/pools/pools_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@

# Define the functions using the new function
create_asset_pool() {
dymd tx gamm create-pool --pool-file=$1 --from pools --keyring-backend=test -b block --gas auto --yes --gas-prices 100000000adym
dymd tx gamm create-pool --pool-file=$1 --from pools --keyring-backend=test --gas auto --yes --gas-prices 100000000adym
}

join_to_pool() {
dymd tx gamm join-pool --pool-id 1 --share-amount-out 20000000000000000000 --max-amounts-in "" --from user --keyring-backend test -b block --gas-prices 100000000adym
dymd tx gamm join-swap-extern-amount-in 100dym 20000000000000000000 --pool-id 1 --from user --keyring-backend test -b block --gas-prices 100000000adym
dymd tx gamm join-pool --pool-id 1 --share-amount-out 20000000000000000000 --max-amounts-in "" --from user --keyring-backend test --gas-prices 100000000adym
dymd tx gamm join-swap-extern-amount-in 100dym 20000000000000000000 --pool-id 1 --from user --keyring-backend test --gas-prices 100000000adym
}

exit_pool() {
dymd tx gamm exit-pool --pool-id=$1 --shares=$2 --from pools --keyring-backend=test -b block --gas auto --yes --gas-prices 100000000adym
dymd tx gamm exit-pool --pool-id=$1 --shares=$2 --from pools --keyring-backend=test --gas auto --yes --gas-prices 100000000adym
}

swap_tokens() {
# dymd tx gamm swap --exact-amount-in=$1 --exact-amount-out=$2 --from pools --keyring-backend=test -b block --gas auto --yes
dymd tx gamm swap-exact-amount-in 50adym 50000000 --swap-route-pool-ids 1 --swap-route-denoms uatom --from user --keyring-backend test -b block --gas-prices 100000000adym
# dymd tx gamm swap --exact-amount-in=$1 --exact-amount-out=$2 --from pools --keyring-backend=test --gas auto --yes
dymd tx gamm swap-exact-amount-in 50adym 50000000 --swap-route-pool-ids 1 --swap-route-denoms uatom --from user --keyring-backend test --gas-prices 100000000adym
}

multi_hop_swap() {
dymd tx gamm swap-exact-amount-in 50000000uatom 20000000 --swap-route-pool-ids 1,2 --swap-route-denoms adym,uusd --from user --keyring-backend test -b block --gas-prices 100000000adym
dymd tx gamm swap-exact-amount-in 50000000uatom 20000000 --swap-route-pool-ids 1,2 --swap-route-denoms adym,uusd --from user --keyring-backend test --gas-prices 100000000adym
}

echo "Creating pools"
echo "Creating adym/uatom pool"
create_asset_pool "$(dirname "$0")/nativeDenomPoolA.json"
sleep 7

echo "Creating adym/uusd pool"
create_asset_pool "$(dirname "$0")/nativeDenomPoolB.json"

6 changes: 3 additions & 3 deletions scripts/setup_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ "$EXECUTABLE" = "" ]; then
exit 1
fi
echo "EXECUTABLE is not set, using '${DEFAULT_EXECUTABLE}'"
EXECUTABLE=$DEFAULT_SEQUENCER_KEY_PATH
EXECUTABLE=$DEFAULT_EXECUTABLE
fi

# Validate dymension binary exists
Expand All @@ -17,7 +17,7 @@ if ! command -v "$EXECUTABLE" > /dev/null; then
make install

if ! command -v "$EXECUTABLE"; then
echo "dymension binary not found in $PATH"
echo "dymension binary $EXECUTABLE not found in $PATH"
exit 1
fi
fi
Expand Down Expand Up @@ -114,7 +114,7 @@ if [ ! "$answer" != "${answer#[Nn]}" ] ;then
# Add genesis accounts and provide coins to the accounts
"$EXECUTABLE" add-genesis-account "$(dymd keys show pools --keyring-backend test -a)" 1000000000000000000000000adym,10000000000uatom,500000000000uusd
# Give some uatom to the local-user as well
"$EXECUTABLE" add-genesis-account "$(dymd keys show user --keyring-backend test -a)" 1000000000000000000000adym,10000000000uatom
"$EXECUTABLE" add-genesis-account "$(dymd keys show user --keyring-backend test -a)" 1000000000000000000000000adym,10000000000uatom
fi

echo "$MNEMONIC" | "$EXECUTABLE" keys add "$KEY_NAME" --recover --keyring-backend test
Expand Down
6 changes: 3 additions & 3 deletions scripts/src/genesis_config_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ tmp=$(mktemp)

set_gov_params() {
echo "setting gov params"
jq '.app_state.gov.deposit_params.min_deposit[0].denom = "adym"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.gov.deposit_params.min_deposit[0].amount = "10000000000"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.gov.voting_params.voting_period = "1m"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.gov.params.min_deposit[0].denom = "adym"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.gov.params.min_deposit[0].amount = "10000000000"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
jq '.app_state.gov.params.voting_period = "1m"' "$GENESIS_FILE" > "$tmp" && mv "$tmp" "$GENESIS_FILE"
}

set_hub_params() {
Expand Down
1 change: 0 additions & 1 deletion x/streamer/keeper/keeper_create_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func (suite *KeeperTestSuite) TestCreateStream() {
}

for _, tc := range tests {

_, err := suite.App.StreamerKeeper.CreateStream(suite.Ctx, tc.coins, tc.distrTo, time.Time{}, tc.epochIdentifier, tc.numEpochsPaidOver, NonSponsored)
if tc.expectErr {
suite.Require().Error(err, tc.name)
Expand Down

0 comments on commit c8fc1fd

Please sign in to comment.