Skip to content

Commit

Permalink
[OTE-829] upgrade handler for affiliates (backport #2332) (#2383)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohammed Affan <[email protected]>
  • Loading branch information
mergify[bot] and affanv14 authored Sep 27, 2024
1 parent de1265d commit 1a343f5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
23 changes: 22 additions & 1 deletion protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@
},
"affiliates": {
"affiliate_tiers": {
"tiers": []
"tiers": [
{
"req_referred_volume_quote_quantums": "0",
"req_staked_whole_coins": 0,
"taker_fee_share_ppm": 50000
},
{
"req_referred_volume_quote_quantums": "1000000000000",
"req_staked_whole_coins": 200,
"taker_fee_share_ppm": 100000
},
{
"req_referred_volume_quote_quantums": "5000000000000",
"req_staked_whole_coins": 1000,
"taker_fee_share_ppm": 125000
},
{
"req_referred_volume_quote_quantums": "25000000000000",
"req_staked_whole_coins": 5000,
"taker_fee_share_ppm": 150000
}
]
}
},
"auth": {
Expand Down
19 changes: 19 additions & 0 deletions protocol/app/upgrades/v7.0.0/upgrade_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/dtypes"
"github.com/dydxprotocol/v4-chain/protocol/testing/containertest"
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
affiliatestypes "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types"
vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -50,6 +51,9 @@ func postUpgradeChecks(node *containertest.Node, t *testing.T) {
// Add test for your upgrade handler logic below
postUpgradeVaultParamsCheck(node, t)
postUpgradeMegavaultSharesCheck(node, t)

// Check that the affiliates module has been initialized with the default tiers.
postUpgradeAffiliatesModuleTiersCheck(node, t)
}

func postUpgradeVaultParamsCheck(node *containertest.Node, t *testing.T) {
Expand Down Expand Up @@ -162,3 +166,18 @@ func postUpgradeMegavaultSharesCheck(node *containertest.Node, t *testing.T) {
require.Equal(t, expectedShares, gotOwnerShares[owner])
}
}

func postUpgradeAffiliatesModuleTiersCheck(node *containertest.Node, t *testing.T) {
resp, err := containertest.Query(
node,
affiliatestypes.NewQueryClient,
affiliatestypes.QueryClient.AllAffiliateTiers,
&affiliatestypes.AllAffiliateTiersRequest{},
)
require.NoError(t, err)
require.NotNil(t, resp)
affiliateTiersResp := affiliatestypes.AllAffiliateTiersResponse{}
err = proto.UnmarshalText(resp.String(), &affiliateTiersResp)
require.NoError(t, err)
require.Equal(t, affiliatestypes.DefaultAffiliateTiers, affiliateTiersResp.Tiers)
}
25 changes: 23 additions & 2 deletions protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@
"app_state": {
"affiliates": {
"affiliate_tiers": {
"tiers": []
"tiers": [
{
"req_referred_volume_quote_quantums": "0",
"req_staked_whole_coins": 0,
"taker_fee_share_ppm": 50000
},
{
"req_referred_volume_quote_quantums": "1000000000000",
"req_staked_whole_coins": 200,
"taker_fee_share_ppm": 100000
},
{
"req_referred_volume_quote_quantums": "5000000000000",
"req_staked_whole_coins": 1000,
"taker_fee_share_ppm": 125000
},
{
"req_referred_volume_quote_quantums": "25000000000000",
"req_staked_whole_coins": 5000,
"taker_fee_share_ppm": 150000
}
]
}
},
"assets": {
Expand Down Expand Up @@ -3995,7 +4016,7 @@
]
}
},
"app_version": "5.2.1-103-g5c95dd72",
"app_version": "5.2.1-172-g351fcccd",
"chain_id": "dydx-sample-1",
"consensus": {
"params": {
Expand Down
4 changes: 1 addition & 3 deletions protocol/x/affiliates/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package types
// DefaultGenesis returns the default stats genesis state.
func DefaultGenesis() *GenesisState {
return &GenesisState{
AffiliateTiers: AffiliateTiers{
Tiers: []AffiliateTiers_Tier{},
},
AffiliateTiers: DefaultAffiliateTiers,
}
}

Expand Down

0 comments on commit 1a343f5

Please sign in to comment.