Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #1087

Merged
merged 109 commits into from
Jan 26, 2024
Merged

Feature #1087

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
67d493c
scaffolded module
sampocs Jan 17, 2024
3c759e8
scaffolded tx and query boilerplate
sampocs Jan 17, 2024
0b43ee5
added data structures
sampocs Jan 18, 2024
5001761
added message types
sampocs Jan 18, 2024
2f8147b
implemented sdk.Msg interface
sampocs Jan 18, 2024
2425da3
added queries
sampocs Jan 18, 2024
2f731a8
fixed query protos
sampocs Jan 18, 2024
d2043f6
added query cli txs
sampocs Jan 18, 2024
8888bc7
scaffolded keeper functions
sampocs Jan 18, 2024
ce4429c
added business logic helpers
sampocs Jan 18, 2024
6a1b0b1
nit changes to query cli commands
sampocs Jan 18, 2024
5d6da57
added message cli commands
sampocs Jan 18, 2024
cc25a3e
more nit
sampocs Jan 18, 2024
cbd2288
Added fields, changed time type
ethan-stride Jan 18, 2024
f53e3df
changed addresses to not be module accounts
sampocs Jan 18, 2024
78316d3
Merge branch 'scaffolding-cleanup' into nit_proto_updates
sampocs Jan 18, 2024
5a8fd2e
Merge branch 'staketia-private' into scaffolding-cleanup
sampocs Jan 18, 2024
eafb1d7
Merge branch 'scaffolding-cleanup' into nit_proto_updates
sampocs Jan 18, 2024
381d935
Update proto/stride/staketia/staketia.proto
sampocs Jan 18, 2024
e8960ba
Merge pull request #14 from Stride-Labs/nit_proto_updates
sampocs Jan 18, 2024
0426cdc
fixed query all redemption records
sampocs Jan 18, 2024
b03544f
Merge pull request #13 from Stride-Labs/scaffolding-cleanup
sampocs Jan 18, 2024
264395a
one more nit
sampocs Jan 18, 2024
7947547
added key prefix helper
sampocs Jan 18, 2024
9213f7a
added key prefix helper
sampocs Jan 18, 2024
04cf82e
Merge branch 'staketia-private' into sam/sttia-delegation-records
sampocs Jan 18, 2024
5dab7cd
resolving merge
ethan-stride Jan 18, 2024
4ce875c
added delegation keepers
sampocs Jan 18, 2024
852efb9
added unit tests
sampocs Jan 18, 2024
83cb9fa
added unbonding record keepers
sampocs Jan 18, 2024
4744976
added unbonding record unit tests
sampocs Jan 18, 2024
cda244d
renamed tallying -> accumulating
sampocs Jan 18, 2024
7d88bcc
Host Zone Keepers
ethan-stride Jan 18, 2024
32490ca
added redemption record keeper helpers
sampocs Jan 18, 2024
686957a
remove error type for panic, add unit test
ethan-stride Jan 19, 2024
66ae838
added redemption record unit tests
sampocs Jan 19, 2024
42832c0
addressed ethan PR comments
sampocs Jan 19, 2024
6861b0d
addressed ethan PR comments
sampocs Jan 19, 2024
a28faa8
Merge pull request #18 from Stride-Labs/host-zone-keeper
sampocs Jan 19, 2024
6a76a1e
added staketia to middleware stack
sampocs Jan 19, 2024
176578e
addressed ethan PR comments
sampocs Jan 19, 2024
34b3d17
wired up epochs module
sampocs Jan 19, 2024
e0958ce
Merge branch 'staketia-private' into sam/sttia-delegation-records
sampocs Jan 19, 2024
580ad44
Merge pull request #15 from Stride-Labs/sam/sttia-delegation-records
sampocs Jan 19, 2024
5b6c466
moved archived records to separate store
sampocs Jan 19, 2024
dc8b25f
fixed tests for archive store
sampocs Jan 19, 2024
d8e2097
Merge branch 'staketia-private' into sam/sttia-unbonding-records
sampocs Jan 19, 2024
80e212e
nit
sampocs Jan 19, 2024
c80a4c8
addressed ethan PR comments
sampocs Jan 19, 2024
7b9ed4c
added unit test for redemption record by address
sampocs Jan 19, 2024
fbab2ba
Merge pull request #17 from Stride-Labs/sam/sttia-unbonding-records
sampocs Jan 19, 2024
c95096b
Merge pull request #19 from Stride-Labs/sam/sttia-redemption-records
sampocs Jan 19, 2024
11dd343
server -> k
sampocs Jan 19, 2024
ed43b6d
StakeTiaKeeper -> StaketiaKeeper
sampocs Jan 19, 2024
6f913e2
added archive store for delegation records
sampocs Jan 19, 2024
5668c4f
lil cleanup
sampocs Jan 19, 2024
6c65fb0
Merge pull request #23 from Stride-Labs/sam/sttia-delegation-archive-…
sampocs Jan 19, 2024
2092287
pass through in open confirm
sampocs Jan 19, 2024
bd389fd
Merge pull request #21 from Stride-Labs/sam/sttia-epochs
sampocs Jan 19, 2024
7567958
fixed build
sampocs Jan 19, 2024
38843da
added cleanup todo
sampocs Jan 19, 2024
c44cb59
Merge pull request #20 from Stride-Labs/sam/sttia-ibc-middleware
sampocs Jan 19, 2024
175c07f
grpc queries (#22)
sampocs Jan 19, 2024
c6f251c
validate basic and tests liquidstake, redeemstake (#25)
ethan-stride Jan 19, 2024
3246f68
transfer in progress record id keepers (#24)
ethan-stride Jan 19, 2024
f3a84fa
implement UpdateInnerRedemptionRateBounds (#28)
asalzmann Jan 19, 2024
19d6ef1
Slash Records (#16)
riley-stride Jan 20, 2024
d3b0c07
Remove -> Archive
sampocs Jan 20, 2024
6fcb01c
Merge branch 'sttia' of github.com:Stride-Labs/stride-staketia into s…
sampocs Jan 20, 2024
8afc0fe
check redemption rate bounds (#33)
sampocs Jan 20, 2024
274be1b
liquid stake message (#32)
sampocs Jan 20, 2024
7da5513
update workflows to run on pulls against sttia (#39)
asalzmann Jan 20, 2024
df7b732
Add resume host zone transaction (#38)
asalzmann Jan 20, 2024
77a797e
Adminlist (#30)
riley-stride Jan 21, 2024
875253c
distribute claims (#35)
sampocs Jan 21, 2024
080d82e
update redemption rate (#34)
sampocs Jan 21, 2024
46fed7a
check unbonding finished (#42)
sampocs Jan 21, 2024
8bde8f5
prepare delegation (#36)
riley-stride Jan 21, 2024
66d37b6
implementing redeem stake tx logic (#26)
ethan-stride Jan 21, 2024
61bb7ce
prepare undelegation (#41)
sampocs Jan 22, 2024
1a3bfc3
allow multisig to poke rr & update records (#37)
riley-stride Jan 22, 2024
c4af0d7
Add Confirm Unbonded Tokens Swept (#43)
shellvish Jan 22, 2024
25c2092
add transfer callback (#45)
asalzmann Jan 22, 2024
0dbda00
skip if no liquid stakes in past epoch (#49)
sampocs Jan 22, 2024
1cfbfd0
genesis functions (#44)
sampocs Jan 22, 2024
a59b1ff
Add ConfirmDelegation (#40)
shellvish Jan 22, 2024
9c040ff
Add non-positive check to ConfirmUnbondingTokenSweep tx (#51)
shellvish Jan 22, 2024
8e93568
implemented epoch hooks (#48)
sampocs Jan 22, 2024
158cea5
Add confirm undelegation (#53)
sampocs Jan 23, 2024
fb0d964
nit cleanup (#52)
sampocs Jan 23, 2024
dd50c6b
dockernet setup (#56)
sampocs Jan 24, 2024
dccb464
admin address tests (#57)
sampocs Jan 24, 2024
6eb3be1
remove archive status from delegation records (#58)
sampocs Jan 24, 2024
bc303a1
remove archive status unbonding records (#59)
sampocs Jan 24, 2024
7ec3017
Ethan/admin tx fixes (#63)
ethan-stride Jan 25, 2024
84f46f5
audit batch 1 (#61)
sampocs Jan 25, 2024
0d608d6
liquid stake fees (#62)
sampocs Jan 25, 2024
43156c1
Add HaltZone function (#60)
asalzmann Jan 25, 2024
d599415
Return estimated unbonding time (#65)
asalzmann Jan 25, 2024
5f0406a
Merge branch 'sttia' into aidan/new-feature
asalzmann Jan 25, 2024
be03038
audit batch 2 (#69)
sampocs Jan 25, 2024
7b7711a
Revert "update workflows to run on pulls against sttia" (#70)
asalzmann Jan 25, 2024
3c3a40c
Operator/SafeAddress -> Operator/SafeAddressOnStride (#71)
riley-stride Jan 26, 2024
25a2fdd
Merge branch 'sttia' into aidan/new-feature
asalzmann Jan 26, 2024
fcfa689
celestia mainnet constants (#74)
sampocs Jan 26, 2024
ff523b4
nit names (#77)
sampocs Jan 26, 2024
a042563
added logs to hooks (#78)
sampocs Jan 26, 2024
52b3611
Merge branch 'sttia' into aidan/new-feature
asalzmann Jan 26, 2024
5dd92fe
fix
asalzmann Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ import (
stakeibcclient "github.com/Stride-Labs/stride/v17/x/stakeibc/client"
stakeibcmodulekeeper "github.com/Stride-Labs/stride/v17/x/stakeibc/keeper"
stakeibcmoduletypes "github.com/Stride-Labs/stride/v17/x/stakeibc/types"
staketia "github.com/Stride-Labs/stride/v17/x/staketia"
staketiakeeper "github.com/Stride-Labs/stride/v17/x/staketia/keeper"
staketiatypes "github.com/Stride-Labs/stride/v17/x/staketia/types"

ccvconsumer "github.com/cosmos/interchain-security/v3/x/ccv/consumer"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
Expand Down Expand Up @@ -230,6 +233,7 @@ var (
tendermint.AppModuleBasic{},
packetforward.AppModuleBasic{},
evmosvesting.AppModuleBasic{},
staketia.AppModuleBasic{},
)

// module account permissions
Expand All @@ -249,6 +253,7 @@ var (
interchainquerytypes.ModuleName: nil,
icatypes.ModuleName: nil,
stakeibcmoduletypes.RewardCollectorName: nil,
staketiatypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}
)

Expand Down Expand Up @@ -327,6 +332,7 @@ type StrideApp struct {
RatelimitKeeper ratelimitmodulekeeper.Keeper
ClaimKeeper claimkeeper.Keeper
ICAOracleKeeper icaoraclekeeper.Keeper
StaketiaKeeper staketiakeeper.Keeper

mm *module.Manager
sm *module.SimulationManager
Expand Down Expand Up @@ -376,6 +382,7 @@ func NewStrideApp(
consensusparamtypes.StoreKey,
packetforwardtypes.StoreKey,
evmosvestingtypes.StoreKey,
staketiatypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -642,6 +649,17 @@ func NewStrideApp(
)
autopilotModule := autopilot.NewAppModule(appCodec, app.AutopilotKeeper)

// Staketia Keeper must be initialized after TransferKeeper
app.StaketiaKeeper = *staketiakeeper.NewKeeper(
appCodec,
keys[staketiatypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.TransferKeeper,
app.RatelimitKeeper,
)
stakeTiaModule := staketia.NewAppModule(appCodec, app.StaketiaKeeper)

app.VestingKeeper = evmosvestingkeeper.NewKeeper(
keys[evmosvestingtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName), appCodec,
app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.StakingKeeper,
Expand Down Expand Up @@ -676,6 +694,7 @@ func NewStrideApp(
app.MintKeeper.Hooks(),
app.ClaimKeeper.Hooks(),
app.RatelimitKeeper.Hooks(),
app.StaketiaKeeper.Hooks(),
),
)
epochsModule := epochsmodule.NewAppModule(appCodec, app.EpochsKeeper)
Expand Down Expand Up @@ -732,6 +751,7 @@ func NewStrideApp(
// - core ibc
// - autopilot
// - records
// - staketia
// - ratelimit
// - pfm
// - transfer
Expand All @@ -747,6 +767,7 @@ func NewStrideApp(
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
)
transferStack = ratelimitmodule.NewIBCMiddleware(app.RatelimitKeeper, transferStack)
transferStack = staketia.NewIBCMiddleware(app.StaketiaKeeper, transferStack)
transferStack = recordsmodule.NewIBCModule(app.RecordsKeeper, transferStack)
transferStack = autopilot.NewIBCModule(app.AutopilotKeeper, transferStack)

Expand Down Expand Up @@ -811,6 +832,7 @@ func NewStrideApp(
consumerModule,
autopilotModule,
icaoracleModule,
stakeTiaModule,
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -851,6 +873,7 @@ func NewStrideApp(
icaoracletypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
staketiatypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -887,6 +910,7 @@ func NewStrideApp(
icaoracletypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
staketiatypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -928,6 +952,7 @@ func NewStrideApp(
icaoracletypes.ModuleName,
consensusparamtypes.ModuleName,
packetforwardtypes.ModuleName,
staketiatypes.ModuleName,
)

app.mm.RegisterInvariants(app.CrisisKeeper)
Expand Down Expand Up @@ -1078,7 +1103,10 @@ func (app *StrideApp) BlacklistedModuleAccountAddrs() map[string]bool {
// DO NOT REMOVE: StringMapKeys fixes non-deterministic map iteration
for _, acc := range utils.StringMapKeys(maccPerms) {
// don't blacklist stakeibc module account, so that it can ibc transfer tokens
if acc == stakeibcmoduletypes.ModuleName || acc == stakeibcmoduletypes.RewardCollectorName || acc == ccvconsumertypes.ConsumerToSendToProviderName {
if acc == stakeibcmoduletypes.ModuleName ||
acc == stakeibcmoduletypes.RewardCollectorName ||
acc == ccvconsumertypes.ConsumerToSendToProviderName ||
acc == staketiatypes.ModuleName {
continue
}
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
Expand Down
7 changes: 7 additions & 0 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (s *AppTestHelper) Setup() {
s.TestAccs = CreateRandomAccounts(3)
s.IbcEnabled = false
s.IcaAddresses = make(map[string]string)

// Remove host zone and accumulating record for staketia, by default,
// since the tests will override it directly if needed
s.App.StaketiaKeeper.RemoveHostZone(s.Ctx)
for _, unbondingRecord := range s.App.StaketiaKeeper.GetAllActiveUnbondingRecords(s.Ctx) {
s.App.StaketiaKeeper.RemoveUnbondingRecord(s.Ctx, unbondingRecord.Id)
}
}

// Instantiates an TestHelper without the test suite
Expand Down
14 changes: 14 additions & 0 deletions dockernet/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ REV_MNEMONIC="tonight bonus finish chaos orchard plastic view nurse salad regret
USER_MNEMONIC="brief play describe burden half aim soccer carbon hope wait output play vacuum joke energy crucial output mimic cruise brother document rail anger leaf"
USER_ACCT=user

# stTIA MNEMONICS
## On Stride
DEPOSIT_MNEMONIC="alpha annual multiply search scene gospel wood empower video estate erosion sister legend title man bicycle find adjust conduct exercise jewel great state park"
REDEMPTION_MNEMONIC="frame noodle guilt clinic laugh pink own reflect clog lady slice execute renew excess ranch face praise knife spare accident catch figure pony feel"
CLAIM_MNEMONIC="boat caution burst hybrid melody input kitten account pull explain couch pact educate omit inmate area drastic town sugar rail spare nothing matrix gate"
SAFE_MNEMONIC="chat mechanic patient palm screen response beef cactus report rebuild equal cargo essay craft rigid injury rocket below monster boost clay charge toss debate"
OPERATOR_MNEMONIC="equal fetch soccer crouch dash similar dinosaur divide video polar fork banana engine tomorrow thought web ramp slight stumble throw kid ridge today afford"

## On Host Chain
DELEGATION_ADDRESS="cosmos1n4reqytr7arvpk5z2ute274h2yukcss8dtxjyd"
REWARD_ADDRESS="cosmos1atchlrd8m4868t5ep2fywxhl2u9c3qg0grnt0e"
DELEGATION_MNEMONIC="arrange indicate grass click bulk wage vivid strong evil uncover raven solar stone hole strategy about rate negative word inch enforce alley never wealth"
REWARD_MNEMONIC="drive someone knee omit disease clerk stand rebel asthma lift valid era armed ticket any undo increase magnet rabbit improve rude fortune afraid soon"

# STRIDE
STRIDE_CHAIN_ID=STRIDE
STRIDE_NODE_PREFIX=stride
Expand Down
38 changes: 38 additions & 0 deletions dockernet/scripts/staketia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Staketia Integration Tests
* Use the default host chain settings, but shorten the day and stride epochs in `config.sh`
```
STRIDE_DAY_EPOCH_DURATION="40s"
STRIDE_EPOCH_EPOCH_DURATION="10s"
```
* Start dockernet
```bash
make start-docker
```
* As you go through the below flow, watch the `balances.log` and `state.log` files
* Run the setup script to transfer native tokens to Stride and set the withdrawal address
```bash
bash dockernet/scripts/staketia/setup.sh
```
* Run the liquid stake script. Watch the stToken appear in the validator account and a delegation record be created during the next epoch.
```bash
bash dockernet/scripts/staketia/liquid_stake.sh
```
* Delegate on the host zone and confirm on stride. Watch the delegated balance increase and the delegation record be removed.
```bash
bash dockernet/scripts/staketia/delegate.sh
```
* Redeem the stTokens. Watch the stTokens move into the redemption account and the accumulation unbonding record be incremented. A redemption record should also be created.
```bash
bash dockernet/scripts/staketia/redeem_stake.sh
```
* Wait for the next 4 day epoch and see the unbonding record change to status `UNBONDING_QUEUE`. This may take a few minutes.
* Unbond from the host zone and submit the confirm tx back to stride
```bash
bash dockernet/scripts/staketia/undelegate.sh
```
* Wait for the unbonding record's status to change to `UNBONDED`, after the tokens have finished unbonding. This will take a couple minutes.
* Sweep the tokens back to stride and confirm the tx. During the next epoch, the native tokens should be returned the redeemer and the redemption record should be removed.
```bash
bash dockernet/scripts/staketia/sweep.sh
```

25 changes: 25 additions & 0 deletions dockernet/scripts/staketia/delegate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

HOST_CHAIN="${HOST_CHAINS[0]}"
HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD)
HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM)

echo ">>> Querying action from records..."
$STRIDE_MAIN_CMD q staketia delegation-records
delegation_amount=$($STRIDE_MAIN_CMD q staketia delegation-records | grep -B 2 "DELEGATION_QUEUE" | grep "native_amount" | NUMBERS_ONLY)
record_id=$($STRIDE_MAIN_CMD q staketia delegation-records | grep -B 3 "DELEGATION_QUEUE" | grep "id" | NUMBERS_ONLY)
sleep 1

echo -e "\n>>> Delegating ${delegation_amount}${HOST_DENOM} for record $record_id..."
validator_address=$(GET_VAL_ADDR $HOST_CHAIN 1)
output=$($HOST_MAIN_CMD tx staking delegate $validator_address ${delegation_amount}${HOST_DENOM} \
--from delegation -y | TRIM_TX)
echo $output
sleep 1

echo -e "\n>>> Submitting confirm-delegation tx for record $record_id on Stride..."
tx_hash=$(echo $output | awk '{print $4}')
$STRIDE_MAIN_CMD tx staketia confirm-delegation $record_id $tx_hash --from operator -y | TRIM_TX
8 changes: 8 additions & 0 deletions dockernet/scripts/staketia/liquid_stake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

echo ">>> Liquid staking..."
$STRIDE_MAIN_CMD tx staketia liquid-stake 1000000 --from ${STRIDE_VAL_PREFIX}1 -y | TRIM_TX
sleep 1
8 changes: 8 additions & 0 deletions dockernet/scripts/staketia/redeem_stake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

echo ">>> Redeeming stake..."
$STRIDE_MAIN_CMD tx staketia redeem-stake 1000000 --from ${STRIDE_VAL_PREFIX}1 -y | TRIM_TX
sleep 1
37 changes: 37 additions & 0 deletions dockernet/scripts/staketia/reinvest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

HOST_CHAIN="${HOST_CHAINS[0]}"
HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD)
HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM)

reward_address=$($HOST_MAIN_CMD keys show -a reward)
deposit_address=$($STRIDE_MAIN_CMD keys show -a deposit)
fee_address=$($STRIDE_MAIN_CMD q staketia host-zone | grep fee_address | awk '{print $2}')

echo ">>> Claiming outstanding rewards records..."
$HOST_MAIN_CMD tx distribution withdraw-all-rewards --from delegation -y | TRIM_TX
sleep 5

echo -e "\n>>> Querying rewards balance..."
output=$($HOST_MAIN_CMD q bank balances $reward_address --denom $HOST_DENOM)
echo $output
reward_amount=$(echo $output | NUMBERS_ONLY)
sleep 1

reinvest_amount=$(echo "scale=0; $reward_amount * 90 / 100" | bc -l)
fee_amount=$(echo "scale=0; $reward_amount * 10 / 100" | bc -l)

echo -e "\n>>> Sweeping ${reinvest_amount}${HOST_DENOM} for reinvestment..."
output=$($HOST_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $deposit_address ${reinvest_amount}${HOST_DENOM} \
--from delegation -y | TRIM_TX)
echo $output
sleep 10

echo -e "\n>>> Sweeping ${fee_amount}${HOST_DENOM} for fee collection..."
output=$($HOST_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $fee_address ${fee_amount}${HOST_DENOM} \
--from delegation -y | TRIM_TX)
echo $output
sleep 10
19 changes: 19 additions & 0 deletions dockernet/scripts/staketia/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

HOST_CHAIN="${HOST_CHAINS[0]}"
HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD)
HOST_VAL_PREFIX=$(GET_VAR_VALUE ${HOST_CHAIN}_VAL_PREFIX)
HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM)

echo ">>> Transfering native tokens to stride..."
$HOST_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $(STRIDE_ADDRESS) 10000000${HOST_DENOM} \
--from ${HOST_VAL_PREFIX}1 -y | TRIM_TX
sleep 10

echo ">>> Setting withdrawal address..."
reward_address=$($HOST_MAIN_CMD keys show -a reward)
$HOST_MAIN_CMD tx distribution set-withdraw-addr $reward_address --from delegation -y | TRIM_TX
sleep 10
25 changes: 25 additions & 0 deletions dockernet/scripts/staketia/sweep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

HOST_CHAIN="${HOST_CHAINS[0]}"
HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD)
HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM)

echo ">>> Querying action from records..."
$STRIDE_MAIN_CMD q staketia unbonding-records
unbond_amount=$($STRIDE_MAIN_CMD q staketia unbonding-records | grep -B 2 "UNBONDED" | grep "native_amount" | NUMBERS_ONLY)
record_id=$($STRIDE_MAIN_CMD q staketia unbonding-records | grep -B 4 "UNBONDED" | grep "id" | NUMBERS_ONLY)
sleep 1

echo -e "\n>>> Sweeping ${unbond_amount}${HOST_DENOM} for record $record_id..."
claim_address=$($STRIDE_MAIN_CMD keys show -a claim)
output=$($HOST_MAIN_CMD tx ibc-transfer transfer transfer channel-0 $claim_address ${unbond_amount}${HOST_DENOM} \
--from delegation -y | TRIM_TX)
echo $output
sleep 10

echo -e "\n>>> Submitting confirm-sweep tx for record $record_id on Stride..."
tx_hash=$(echo $output | awk '{print $4}')
$STRIDE_MAIN_CMD tx staketia confirm-sweep $record_id $tx_hash --from operator -y | TRIM_TX
25 changes: 25 additions & 0 deletions dockernet/scripts/staketia/undelegate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../../config.sh

HOST_CHAIN="${HOST_CHAINS[0]}"
HOST_MAIN_CMD=$(GET_VAR_VALUE ${HOST_CHAIN}_MAIN_CMD)
HOST_DENOM=$(GET_VAR_VALUE ${HOST_CHAIN}_DENOM)

echo ">>> Querying action from records..."
$STRIDE_MAIN_CMD q staketia unbonding-records
unbond_amount=$($STRIDE_MAIN_CMD q staketia unbonding-records | grep -B 2 "UNBONDING_QUEUE" | grep "native_amount" | NUMBERS_ONLY)
record_id=$($STRIDE_MAIN_CMD q staketia unbonding-records | grep -B 4 "UNBONDING_QUEUE" | grep "id" | NUMBERS_ONLY)
sleep 1

echo -e "\n>>> Unbonding ${unbond_amount}${HOST_DENOM} for record $record_id..."
validator_address=$(GET_VAL_ADDR $HOST_CHAIN 1)
output=$($HOST_MAIN_CMD tx staking unbond $validator_address ${unbond_amount}${HOST_DENOM} \
--from delegation -y | TRIM_TX)
echo $output
sleep 1

echo -e "\n>>> Submitting confirm-undelegation tx for record $record_id on Stride..."
tx_hash=$(echo $output | awk '{print $4}')
$STRIDE_MAIN_CMD tx staketia confirm-undelegation $record_id $tx_hash --from operator -y | TRIM_TX
Loading
Loading