diff --git a/CHANGELOG.md b/CHANGELOG.md index a5f85759..90173a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Contains all the PRs that improved the code without changing the behaviors. - Removed unused module account - Disabled System Validator Rewards - Default Mint params set to zero +- Validator and Delegator rewards from Reserve Module ## Fixed - Testnet binary generation using go build diff --git a/app/app.go b/app/app.go index 5e6d31b1..da6bc410 100644 --- a/app/app.go +++ b/app/app.go @@ -210,7 +210,8 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, claimmoduletypes.ModuleName: {authtypes.Minter}, - arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + arkeomoduletypes.ReserveName: {}, + arkeomoduletypes.ModuleName: {}, arkeomoduletypes.ProviderName: {}, arkeomoduletypes.ContractName: {}, } diff --git a/app/app_regtest.go b/app/app_regtest.go index 6c15ea47..72cc4c8b 100644 --- a/app/app_regtest.go +++ b/app/app_regtest.go @@ -222,7 +222,8 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - arkeomoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + arkeomoduletypes.ReserveName: {}, + arkeomoduletypes.ModuleName: {}, arkeomoduletypes.ProviderName: {}, arkeomoduletypes.ContractName: {}, claimmoduletypes.ModuleName: {authtypes.Minter}, diff --git a/common/common.go b/common/common.go index 41d1e092..fe3d7abb 100644 --- a/common/common.go +++ b/common/common.go @@ -20,7 +20,7 @@ const ( ) // GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total -func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int { +func GetSafeShare(part, total, allocation cosmos.Dec) cosmos.Dec { if part.GTE(total) { part = total } @@ -29,33 +29,17 @@ func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int { // GetUncappedShare this method will panic if any of the input parameter can't be convert to cosmos.Dec // which shouldn't happen -func GetUncappedShare(part, total, allocation cosmos.Int) (share cosmos.Int) { +func GetUncappedShare(part, total, allocation cosmos.Dec) (share cosmos.Dec) { if part.IsZero() || total.IsZero() { - return cosmos.ZeroInt() + return cosmos.ZeroDec() } defer func() { if err := recover(); err != nil { - share = cosmos.ZeroInt() + share = cosmos.ZeroDec() } }() - // use string to convert cosmos.Int to cosmos.Dec is the only way I can find out without being constrain to uint64 - // cosmos.Int can hold values way larger than uint64 , because it is using big.Int internally - aD, err := cosmos.NewDecFromStr(allocation.String()) - if err != nil { - panic(fmt.Errorf("fail to convert %s to cosmos.Dec: %w", allocation.String(), err)) - } - - pD, err := cosmos.NewDecFromStr(part.String()) - if err != nil { - panic(fmt.Errorf("fail to convert %s to cosmos.Dec: %w", part.String(), err)) - } - tD, err := cosmos.NewDecFromStr(total.String()) - if err != nil { - panic(fmt.Errorf("fail to convert%s to cosmos.Dec: %w", total.String(), err)) - } // A / (Total / part) == A * (part/Total) but safer when part < Totals - result := aD.Quo(tD.Quo(pD)) - share = cosmos.NewIntFromBigInt(result.RoundInt().BigInt()) + share = allocation.Quo(total.Quo(part)) return } diff --git a/common/common_test.go b/common/common_test.go index ff66a1a8..6e4b3f91 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -1,6 +1,7 @@ package common import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -12,14 +13,15 @@ func TestGetUncappedShare(t *testing.T) { part := cosmos.NewInt(149506590) total := cosmos.NewInt(50165561086) alloc := cosmos.NewInt(50000000) - share := GetUncappedShare(part, total, alloc) - require.True(t, share.Equal(cosmos.NewInt(149013))) + share := GetUncappedShare(part.ToLegacyDec(), total.ToLegacyDec(), alloc.ToLegacyDec()) + fmt.Println(share) + require.True(t, share.RoundInt().Equal(cosmos.NewInt(149013))) } func TestGetSafeShare(t *testing.T) { part := cosmos.NewInt(14950659000000000) total := cosmos.NewInt(50165561086) alloc := cosmos.NewInt(50000000) - share := GetSafeShare(part, total, alloc) - require.True(t, share.Equal(cosmos.NewInt(50000000))) + share := GetSafeShare(part.ToLegacyDec(), total.ToLegacyDec(), alloc.ToLegacyDec()) + require.True(t, share.Equal(cosmos.NewDec(50000000))) } diff --git a/proto/arkeo/arkeo/params.proto b/proto/arkeo/arkeo/params.proto index 7b4358c0..b85886be 100644 --- a/proto/arkeo/arkeo/params.proto +++ b/proto/arkeo/arkeo/params.proto @@ -10,44 +10,6 @@ option go_package = "github.com/arkeonetwork/arkeo/x/arkeo/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - string community_pool_percentage= 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - string dev_fund_percentage= 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - string grant_fund_percentage= 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - string inflation_change_percentage = 4 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - string inflation_min = 5 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - - string inflation_max = 6 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - - string goal_bonded = 7 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - uint64 block_per_year = 8; uint64 emission_curve = 9; diff --git a/scripts/genesis.sh b/scripts/genesis.sh index cbd3b47b..7473e463 100755 --- a/scripts/genesis.sh +++ b/scripts/genesis.sh @@ -64,6 +64,27 @@ add_claim_records() { mv /tmp/genesis.json ~/.arkeo/config/genesis.json } +set_fee_pool() { + local denom="$1" + local amount="$2" + + jq --arg DENOM "$denom" --arg AMOUNT "$amount" '.app_state.distribution.fee_pool.community_pool = [{ + "denom": $DENOM, + "amount": $AMOUNT + }]' <~/.arkeo/config/genesis.json >/tmp/genesis.json + mv /tmp/genesis.json ~/.arkeo/config/genesis.json +} + +disable_mint_params() { + jq '.app_state.mint.minter.inflation = "0.000000000000000000" | + .app_state.mint.minter.annual_provisions = "0.000000000000000000" | + .app_state.mint.params.inflation_rate_change = "0.000000000000000000" | + .app_state.mint.params.inflation_max = "0.000000000000000000" | + .app_state.mint.params.inflation_min = "0.000000000000000000"' \ + <~/.arkeo/config/genesis.json >/tmp/genesis.json + mv /tmp/genesis.json ~/.arkeo/config/genesis.json +} + if [ ! -f ~/.arkeo/config/priv_validator_key.json ]; then # remove the original generate genesis file, as below will init chain again rm -rf ~/.arkeo/config/genesis.json @@ -79,28 +100,24 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then arkeod keys add faucet --keyring-backend test FAUCET=$(arkeod keys show faucet -a --keyring-backend test) - add_account "$FAUCET" $TOKEN 10000000000000000 # faucet, 10m + add_account "$FAUCET" $TOKEN 2900000000000000 # faucet, 29m + disable_mint_params if [ "$NET" = "mocknet" ] || [ "$NET" = "testnet" ]; then - add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 30250000000000 'claimarkeo' - - echo "shoulder heavy loyal save patient deposit crew bag pull club escape eyebrow hip verify border into wire start pact faint fame festival solve shop" | arkeod keys add alice --keyring-backend test --recover - ALICE=$(arkeod keys show alice -a --keyring-backend test) - add_account "$ALICE" $TOKEN 1100000000000000 # alice, 1.1m - - echo "clog swear steak glide artwork glory solution short company borrow aerobic idle corn climb believe wink forum destroy miracle oak cover solid valve make" | arkeod keys add bob --keyring-backend test --recover - BOB=$(arkeod keys show bob -a --keyring-backend test) - add_account "$BOB" $TOKEN 1000000000000000 # bob, 1m - add_claim_records "ARKEO" "$BOB" 1000 1000 1000 true + add_module tarkeo1d0m97ywk2y4vq58ud6q5e0r3q9khj9e3unfe4t $TOKEN 2420000000000000 'arkeo-reserve' + add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 3025000000000000 'claimarkeo' + add_module tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e $TOKEN 4840000000000000 'distribution' + # this is to handle the balance set to distribution as a community pool + set_fee_pool $TOKEN 4840000000000000 + - # Add Foundational Accounts - # FoundationCommunityAccount = "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc" - add_account "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc" $TOKEN 1048400000000000000 + # Add Foundational Accounts # FoundationDevAccount = "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" - add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 12100000000000 + add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 1210000000000000 # FoundationGrantsAccount = "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" - add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 6050000000000 + add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 605000000000000 + # Thorchain derived test addresses diff --git a/test/regression/mnt/exports/suites_contracts_pay-as-you-go.json b/test/regression/mnt/exports/suites_contracts_pay-as-you-go.json index 6a7155e8..7a501b76 100644 --- a/test/regression/mnt/exports/suites_contracts_pay-as-you-go.json +++ b/test/regression/mnt/exports/suites_contracts_pay-as-you-go.json @@ -47,14 +47,7 @@ "next_contract_id": "2", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [ { @@ -87,13 +80,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -108,13 +94,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -168,7 +147,7 @@ { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { - "account_number": "12", + "account_number": "10", "address": "tarkeo1kz2dkl8zlxwte008astc5e65htrxdcse6x3h3h", "pub_key": null, "sequence": "0" @@ -185,10 +164,7 @@ "sequence": "0" }, "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] + "permissions": [] }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", @@ -257,15 +233,6 @@ } ] }, - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "1200605009566", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -275,15 +242,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "600538144583", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -297,7 +255,7 @@ "address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e", "coins": [ { - "amount": "15830782786", + "amount": "16066162928", "denom": "uarkeo" } ] @@ -311,15 +269,6 @@ } ] }, - { - "address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz", - "coins": [ - { - "amount": "103474", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1uhapc6jjq6ns0ydnk7zld5x7f5kl2ukemjw5fg", "coins": [ @@ -338,7 +287,7 @@ "send_enabled": [], "supply": [ { - "amount": "52002816974040409", + "amount": "52001016066162928", "denom": "uarkeo" } ] @@ -413,7 +362,7 @@ "fee_pool": { "community_pool": [ { - "amount": "85688652.700000000000000000", + "amount": "321323258.560000000000000000", "denom": "uarkeo" } ] @@ -422,7 +371,7 @@ { "outstanding_rewards": [ { - "amount": "15745094231.300000000000000000", + "amount": "15744839669.440000000000000000", "denom": "uarkeo" } ], @@ -441,7 +390,7 @@ "accumulated": { "commission": [ { - "amount": "1574509423.130000000000000000", + "amount": "1574483966.944000000000000000", "denom": "uarkeo" } ] @@ -455,7 +404,7 @@ "period": "2", "rewards": [ { - "amount": "14170584808.170000000000000000", + "amount": "14170355702.496000000000000000", "denom": "uarkeo" } ] @@ -630,8 +579,8 @@ }, "mint": { "minter": { - "annual_provisions": "6760343469143471.564097458997205602", - "inflation": "0.129999865577861409" + "annual_provisions": "6760124958900879.440734825593079684", + "inflation": "0.129999865570695682" }, "params": { "blocks_per_year": "6311520", diff --git a/test/regression/mnt/exports/suites_contracts_subscription.json b/test/regression/mnt/exports/suites_contracts_subscription.json index 16d96cc5..0f673df1 100644 --- a/test/regression/mnt/exports/suites_contracts_subscription.json +++ b/test/regression/mnt/exports/suites_contracts_subscription.json @@ -68,14 +68,7 @@ "next_contract_id": "3", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [ { @@ -108,13 +101,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -129,13 +115,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -186,7 +165,7 @@ { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { - "account_number": "12", + "account_number": "10", "address": "tarkeo1kz2dkl8zlxwte008astc5e65htrxdcse6x3h3h", "pub_key": null, "sequence": "0" @@ -203,10 +182,7 @@ "sequence": "0" }, "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] + "permissions": [] }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", @@ -275,15 +251,6 @@ } ] }, - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "1440727141200", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -293,15 +260,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "720749166049", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -315,7 +273,7 @@ "address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e", "coins": [ { - "amount": "18894177023", + "amount": "19279394116", "denom": "uarkeo" } ] @@ -329,15 +287,6 @@ } ] }, - { - "address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz", - "coins": [ - { - "amount": "125647", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1uhapc6jjq6ns0ydnk7zld5x7f5kl2ukemjw5fg", "coins": [ @@ -356,7 +305,7 @@ "send_enabled": [], "supply": [ { - "amount": "52003180370609919", + "amount": "52001019279394116", "denom": "uarkeo" } ] @@ -431,7 +380,7 @@ "fee_pool": { "community_pool": [ { - "amount": "0.440000000000000000", + "amount": "385587882.320000000000000000", "denom": "uarkeo" } ] @@ -440,7 +389,7 @@ { "outstanding_rewards": [ { - "amount": "18894177141.560000000000000000", + "amount": "18893806233.680000000000000000", "denom": "uarkeo" } ], @@ -459,7 +408,7 @@ "accumulated": { "commission": [ { - "amount": "1889417714.156000000000000000", + "amount": "1889380623.368000000000000000", "denom": "uarkeo" } ] @@ -473,7 +422,7 @@ "period": "2", "rewards": [ { - "amount": "17004759427.404000000000000000", + "amount": "17004425610.312000000000000000", "denom": "uarkeo" } ] @@ -648,8 +597,8 @@ }, "mint": { "minter": { - "annual_provisions": "6760389312648620.453696029191955035", - "inflation": "0.129999838695292701" + "annual_provisions": "6760123978529236.587874847213850985", + "inflation": "0.129999838684851257" }, "params": { "blocks_per_year": "6311520", diff --git a/test/regression/mnt/exports/suites_core_send.json b/test/regression/mnt/exports/suites_core_send.json index 53fb2bfc..d72943be 100644 --- a/test/regression/mnt/exports/suites_core_send.json +++ b/test/regression/mnt/exports/suites_core_send.json @@ -8,14 +8,7 @@ "next_contract_id": "1", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [], "user_contract_sets": [], @@ -23,13 +16,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -44,13 +30,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -98,20 +77,6 @@ "minter" ] }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "9", - "address": "tarkeo1k8925g52vwe5jgfp4nqr7ljuhs7nzu2f8g0za5", - "pub_key": null, - "sequence": "0" - }, - "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] - }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "0", @@ -170,15 +135,6 @@ }, "bank": { "balances": [ - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "240000255341", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -188,15 +144,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "120042970010", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -210,16 +157,7 @@ "address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e", "coins": [ { - "amount": "3170336802", - "denom": "uarkeo" - } - ] - }, - { - "address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz", - "coins": [ - { - "amount": "14774", + "amount": "3213171726", "denom": "uarkeo" } ] @@ -242,7 +180,7 @@ "send_enabled": [], "supply": [ { - "amount": "52000363213576927", + "amount": "52000003213171726", "denom": "uarkeo" } ] @@ -317,7 +255,7 @@ "fee_pool": { "community_pool": [ { - "amount": "21421242.840000000000000000", + "amount": "64263434.520000000000000000", "denom": "uarkeo" } ] @@ -326,7 +264,7 @@ { "outstanding_rewards": [ { - "amount": "3148915573.160000000000000000", + "amount": "3148908291.480000000000000000", "denom": "uarkeo" } ], @@ -345,7 +283,7 @@ "accumulated": { "commission": [ { - "amount": "314891557.316000000000000000", + "amount": "314890829.148000000000000000", "denom": "uarkeo" } ] @@ -359,7 +297,7 @@ "period": "2", "rewards": [ { - "amount": "2834024015.844000000000000000", + "amount": "2834017462.332000000000000000", "denom": "uarkeo" } ] @@ -534,8 +472,8 @@ }, "mint": { "minter": { - "annual_provisions": "6760030080351352.543315475191878170", - "inflation": "0.129999973112627482" + "annual_provisions": "6759998880320819.659730123458173168", + "inflation": "0.129999973112422838" }, "params": { "blocks_per_year": "6311520", diff --git a/test/regression/mnt/exports/suites_initialize.json b/test/regression/mnt/exports/suites_initialize.json index b0f4ffe3..13d7817d 100644 --- a/test/regression/mnt/exports/suites_initialize.json +++ b/test/regression/mnt/exports/suites_initialize.json @@ -8,14 +8,7 @@ "next_contract_id": "1", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [], "user_contract_sets": [], @@ -23,13 +16,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -44,13 +30,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -98,20 +77,6 @@ "minter" ] }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "9", - "address": "tarkeo1k8925g52vwe5jgfp4nqr7ljuhs7nzu2f8g0za5", - "pub_key": null, - "sequence": "0" - }, - "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] - }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "0", @@ -167,15 +132,6 @@ }, "bank": { "balances": [ - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "160000128527", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -185,15 +141,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "80042906603", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -207,16 +154,7 @@ "address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e", "coins": [ { - "amount": "2099274668", - "denom": "uarkeo" - } - ] - }, - { - "address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz", - "coins": [ - { - "amount": "7387", + "amount": "2142114536", "denom": "uarkeo" } ] @@ -239,7 +177,7 @@ "send_enabled": [], "supply": [ { - "amount": "52000242142317185", + "amount": "52000002142114536", "denom": "uarkeo" } ] @@ -314,7 +252,7 @@ "fee_pool": { "community_pool": [ { - "amount": "0.160000000000000000", + "amount": "42842290.720000000000000000", "denom": "uarkeo" } ] @@ -323,7 +261,7 @@ { "outstanding_rewards": [ { - "amount": "2099274674.840000000000000000", + "amount": "2099272245.280000000000000000", "denom": "uarkeo" } ], @@ -342,7 +280,7 @@ "accumulated": { "commission": [ { - "amount": "209927467.484000000000000000", + "amount": "209927224.528000000000000000", "denom": "uarkeo" } ] @@ -356,7 +294,7 @@ "period": "2", "rewards": [ { - "amount": "1889347207.356000000000000000", + "amount": "1889345020.752000000000000000", "denom": "uarkeo" } ] @@ -531,8 +469,8 @@ }, "mint": { "minter": { - "annual_provisions": "6760014807144472.792103205454968905", - "inflation": "0.129999982075016165" + "annual_provisions": "6759999207134722.421242256517847300", + "inflation": "0.129999982074947950" }, "params": { "blocks_per_year": "6311520", diff --git a/test/regression/mnt/exports/suites_providers_providers.json b/test/regression/mnt/exports/suites_providers_providers.json index 596a5ef5..07cd9f65 100644 --- a/test/regression/mnt/exports/suites_providers_providers.json +++ b/test/regression/mnt/exports/suites_providers_providers.json @@ -8,14 +8,7 @@ "next_contract_id": "1", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [], "user_contract_sets": [], @@ -26,7 +19,7 @@ { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { - "account_number": "12", + "account_number": "9", "address": "tarkeo1rcvm4v5mcepj53fh2526uve0tly4grdsx5yw7k", "pub_key": null, "sequence": "0" @@ -34,13 +27,6 @@ "name": "providers", "permissions": [] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -55,13 +41,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -112,20 +91,6 @@ "minter" ] }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "9", - "address": "tarkeo1k8925g52vwe5jgfp4nqr7ljuhs7nzu2f8g0za5", - "pub_key": null, - "sequence": "0" - }, - "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] - }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "0", @@ -181,15 +146,6 @@ }, "bank": { "balances": [ - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "480000890270", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -199,15 +155,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "240128972735", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -221,16 +168,7 @@ "address": "tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e", "coins": [ { - "amount": "6297852460", - "denom": "uarkeo" - } - ] - }, - { - "address": "tarkeo1hnyy4gp5tgarpg3xu6w5cw4zsyphx2lyvls9rz", - "coins": [ - { - "amount": "36935", + "amount": "6426342986", "denom": "uarkeo" } ] @@ -253,7 +191,7 @@ "send_enabled": [], "supply": [ { - "amount": "52000726427752400", + "amount": "52000006426342986", "denom": "uarkeo" } ] @@ -328,7 +266,7 @@ "fee_pool": { "community_pool": [ { - "amount": "0.220000000000000000", + "amount": "128526859.720000000000000000", "denom": "uarkeo" } ] @@ -337,7 +275,7 @@ { "outstanding_rewards": [ { - "amount": "6297852494.780000000000000000", + "amount": "6297816126.280000000000000000", "denom": "uarkeo" } ], @@ -356,7 +294,7 @@ "accumulated": { "commission": [ { - "amount": "629785249.478000000000000000", + "amount": "629781612.628000000000000000", "denom": "uarkeo" } ] @@ -370,7 +308,7 @@ "period": "2", "rewards": [ { - "amount": "5668067245.302000000000000000", + "amount": "5668034513.652000000000000000", "denom": "uarkeo" } ] @@ -545,8 +483,8 @@ }, "mint": { "minter": { - "annual_provisions": "6760075900031454.898464351600071864", - "inflation": "0.129999946225874372" + "annual_provisions": "6759997899879145.760700882792909356", + "inflation": "0.129999946224851156" }, "params": { "blocks_per_year": "6311520", diff --git a/test/regression/mnt/exports/suites_sentinel_contract_config.json b/test/regression/mnt/exports/suites_sentinel_contract_config.json index dfb45920..dc413497 100644 --- a/test/regression/mnt/exports/suites_sentinel_contract_config.json +++ b/test/regression/mnt/exports/suites_sentinel_contract_config.json @@ -72,14 +72,7 @@ "next_contract_id": "1", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [ { @@ -112,13 +105,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -133,13 +119,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -187,20 +166,6 @@ "minter" ] }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "9", - "address": "tarkeo1k8925g52vwe5jgfp4nqr7ljuhs7nzu2f8g0za5", - "pub_key": null, - "sequence": "0" - }, - "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] - }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "0", @@ -265,15 +230,6 @@ } ] }, - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "80040042843", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -283,15 +239,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "40020021422", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -337,7 +284,7 @@ "send_enabled": [], "supply": [ { - "amount": "52001121131142456", + "amount": "52001001071078191", "denom": "uarkeo" } ] diff --git a/test/regression/mnt/exports/suites_sentinel_sentinel.json b/test/regression/mnt/exports/suites_sentinel_sentinel.json index 761167df..efdd4fa1 100644 --- a/test/regression/mnt/exports/suites_sentinel_sentinel.json +++ b/test/regression/mnt/exports/suites_sentinel_sentinel.json @@ -8,14 +8,7 @@ "next_contract_id": "1", "params": { "block_per_year": "6311520", - "community_pool_percentage": "0.100000000000000000", - "dev_fund_percentage": "0.200000000000000000", - "emission_curve": "6", - "goal_bonded": "0.670000000000000000", - "grant_fund_percentage": "0.000000000000000000", - "inflation_change_percentage": "0.030000000000000000", - "inflation_max": "0.050000000000000000", - "inflation_min": "0.020000000000000000" + "emission_curve": "6" }, "providers": [], "user_contract_sets": [], @@ -23,13 +16,6 @@ }, "auth": { "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "10", - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -44,13 +30,6 @@ "staking" ] }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "11", - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "pub_key": null, - "sequence": "0" - }, { "@type": "/cosmos.auth.v1beta1.ModuleAccount", "base_account": { @@ -98,20 +77,6 @@ "minter" ] }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "9", - "address": "tarkeo1k8925g52vwe5jgfp4nqr7ljuhs7nzu2f8g0za5", - "pub_key": null, - "sequence": "0" - }, - "name": "arkeo", - "permissions": [ - "minter", - "burner" - ] - }, { "@type": "/cosmos.auth.v1beta1.BaseAccount", "account_number": "0", @@ -167,15 +132,6 @@ }, "bank": { "balances": [ - { - "address": "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q", - "coins": [ - { - "amount": "80000042842", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3e79s43", "coins": [ @@ -185,15 +141,6 @@ } ] }, - { - "address": "tarkeo124qmjmg55v6q5c5vy0vcpefrywxnxhkm7426pc", - "coins": [ - { - "amount": "40000021421", - "denom": "uarkeo" - } - ] - }, { "address": "tarkeo1v0n7wer498vqq6yddkr4clg3lck7kaw9lstp4k", "coins": [ @@ -230,7 +177,7 @@ "send_enabled": [], "supply": [ { - "amount": "52000121071121557", + "amount": "52000001071057294", "denom": "uarkeo" } ] diff --git a/test/regression/suites/contracts/subscription.yaml b/test/regression/suites/contracts/subscription.yaml index 875db64c..ac5c0d62 100644 --- a/test/regression/suites/contracts/subscription.yaml +++ b/test/regression/suites/contracts/subscription.yaml @@ -111,8 +111,8 @@ asserts: - .client_pubkey == "tarkeopub1addwnpepq2res6tu0m73ulk5sepgp6g3y37schfgymxy8z6l3lc78k7ju9u45yajwem" - .contract_type == "SUBSCRIPTION" - .settlement_duration == 11 - - .paid == 0 - - .reserve_contrib_asset == 0 + - .paid == 100 + - .reserve_contrib_asset == 10 # - .reserve_contrib_usd == 10 # TODO --- ######################################################################################## diff --git a/testutil/keeper/arkeo.go b/testutil/keeper/arkeo.go index b4fccf2a..33ea51c2 100644 --- a/testutil/keeper/arkeo.go +++ b/testutil/keeper/arkeo.go @@ -80,6 +80,7 @@ func ArkeoKeeper(t testing.TB) (cosmos.Context, keeper.Keeper) { stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, types.ModuleName: {authtypes.Minter, authtypes.Burner}, + types.ReserveName: {authtypes.Minter, authtypes.Burner}, types.ProviderName: {}, types.ContractName: {}, minttypes.ModuleName: {authtypes.Minter}, diff --git a/testutil/keeper/claim.go b/testutil/keeper/claim.go index 0ba2044b..98c1cfce 100644 --- a/testutil/keeper/claim.go +++ b/testutil/keeper/claim.go @@ -105,6 +105,7 @@ func CreateTestClaimKeepers(t testing.TB) (TestKeepers, sdk.Context) { stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, types.ModuleName: {authtypes.Minter}, + arkeotypes.ReserveName: {authtypes.Minter}, arkeotypes.ProviderName: {}, arkeotypes.ContractName: {}, }, diff --git a/x/arkeo/keeper/keeper.go b/x/arkeo/keeper/keeper.go index 4b364486..5ccfd460 100644 --- a/x/arkeo/keeper/keeper.go +++ b/x/arkeo/keeper/keeper.go @@ -7,15 +7,12 @@ import ( "cosmossdk.io/errors" "cosmossdk.io/log" - "cosmossdk.io/math" - sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/keeper" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -28,8 +25,6 @@ import ( "github.com/arkeonetwork/arkeo/x/arkeo/types" ) -var inflation math.LegacyDec = math.LegacyNewDec(0) - type dbPrefix string func (p dbPrefix) String() string { @@ -65,12 +60,8 @@ type Keeper interface { GetActiveValidators(ctx cosmos.Context) ([]stakingtypes.Validator, error) GetAccount(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Account StakingSetParams(ctx cosmos.Context, params stakingtypes.Params) error - MintAndDistributeTokens(ctx cosmos.Context, newlyMinted sdk.DecCoin) (sdk.DecCoin, error) - GetCirculatingSupply(ctx cosmos.Context, denom string) (sdk.DecCoin, error) - GetInflationRate(ctx cosmos.Context) (math.LegacyDec, error) - MoveTokensFromDistributionToFoundationPoolAccount(ctx cosmos.Context) error AllocateTokensToValidator(ctx context.Context, val stakingtypes.ValidatorI, tokens sdk.DecCoins) error - BurnCoins(ctx context.Context, moduleName string, coins sdk.Coins) error + SendToCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error // Query Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) @@ -384,182 +375,6 @@ func (k KVStore) GetAuthority() string { return k.authority } -func (k KVStore) GetCirculatingSupply(ctx cosmos.Context, denom string) (sdk.DecCoin, error) { - // Get Total Supply - fullTokenSupply, err := k.coinKeeper.SupplyOf(ctx, &banktypes.QuerySupplyOfRequest{Denom: configs.Denom}) - if err != nil { - k.Logger().Error("Failed to get full token supply data", err) - return sdk.NewDecCoin(denom, sdkmath.NewInt(0)), err - } - totalSupply := fullTokenSupply.GetAmount().Amount - - k.Logger().Info(fmt.Sprintf("TotalSupply %v", totalSupply)) - - // Get the account addresses whose balances need to be exempted - devAccountAddress, err := k.getFoundationDevAccountAddress() - if err != nil { - return sdk.NewDecCoin(denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - communityAccountAddress, err := k.getFoundationCommunityAccountAddress() - if err != nil { - return sdk.NewDecCoin(denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - grantAccountAddress, err := k.getFoundationGrantsAccountAddress() - if err != nil { - return sdk.NewDecCoin(denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - // Account Address for which the circulating supply should be exempted - addressToExempt := []sdk.AccAddress{ - devAccountAddress, - communityAccountAddress, - grantAccountAddress, - k.stakingKeeper.GetBondedPool(ctx).GetAddress(), - k.GetModuleAccAddress("claimarkeo"), - k.GetModuleAccAddress(types.ModuleName), - } - - exemptBalance := cosmos.NewInt(0) - - k.Logger().Info("Starting to calculate exempt balances") - - // Range over the module accounts to create exempt balances - for _, address := range addressToExempt { - moduleBalance := k.coinKeeper.GetBalance(ctx, address, denom) - k.Logger().Info(fmt.Sprintf("Module address: %v, Balance: %v %v", address.String(), moduleBalance.Amount, denom)) - - if !moduleBalance.IsZero() { - exemptBalance = exemptBalance.Add(moduleBalance.Amount) - } else { - k.Logger().Info(fmt.Sprintf("Module address: %v has zero balance for denom: %v", address.String(), denom)) - } - } - - circulatingSupply := totalSupply.Sub(exemptBalance) - k.Logger().Info(fmt.Sprintf("TotalSupply=%v Foundation Accounts Exempted Balance=%v, Circulating Supply=%v", totalSupply, exemptBalance, circulatingSupply)) - - return sdk.NewDecCoin(denom, circulatingSupply), nil -} - -func (k KVStore) MintAndDistributeTokens(ctx cosmos.Context, newlyMinted sdk.DecCoin) (sdk.DecCoin, error) { - params := k.GetParams(ctx) - newlyMintedAmount := newlyMinted.Amount - - devFundAmount := newlyMintedAmount.Mul(params.DevFundPercentage) - communityPoolAmount := newlyMintedAmount.Mul(params.CommunityPoolPercentage) - grantFundAmount := newlyMintedAmount.Mul(params.GrantFundPercentage) - - devAccountAddress, err := k.getFoundationDevAccountAddress() - if err != nil { - k.Logger().Error(fmt.Sprintf("failed to fetch foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - communityAccountAddress, err := k.getFoundationCommunityAccountAddress() - if err != nil { - k.Logger().Error(fmt.Sprintf("failed to fetch foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - grantAccountAddress, err := k.getFoundationGrantsAccountAddress() - if err != nil { - k.Logger().Error(fmt.Sprintf("failed to fetch foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("failed to fetch foundational account %s", err) - } - - if !devFundAmount.IsZero() { - if err := k.MintAndSendToAccount(ctx, devAccountAddress, cosmos.NewCoin(newlyMinted.Denom, devFundAmount.RoundInt())); err != nil { - k.Logger().Error(fmt.Sprintf("failed to send amount to Dev foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("error sending amount to module %s", err) - } - } - - if !communityPoolAmount.IsZero() { - if err := k.MintAndSendToAccount(ctx, communityAccountAddress, cosmos.NewCoin(newlyMinted.Denom, communityPoolAmount.RoundInt())); err != nil { - k.Logger().Error(fmt.Sprintf("failed to send amount to Community foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("error sending amount to module %s", err) - } - } - - if !grantFundAmount.IsZero() { - if err := k.MintAndSendToAccount(ctx, grantAccountAddress, cosmos.NewCoin(newlyMinted.Denom, grantFundAmount.RoundInt())); err != nil { - k.Logger().Error(fmt.Sprintf("failed to send amount to Grant foundational account %s", err)) - return sdk.NewDecCoin(newlyMinted.Denom, sdkmath.NewInt(0)), fmt.Errorf("error sending amount to module %s", err) - } - } - - balance := newlyMintedAmount.Sub(devFundAmount).Sub(communityPoolAmount).Sub(grantFundAmount) - return sdk.NewDecCoin(newlyMinted.Denom, balance.RoundInt()), nil -} - -func (k KVStore) GetInflationRate(ctx cosmos.Context) (math.LegacyDec, error) { - params := k.GetParams(ctx) - - bondedRatio, err := k.stakingKeeper.BondedRatio(ctx) - if err != nil { - ctx.Logger().Error(fmt.Sprintf("failed to get bonded ration %s", err.Error())) - return math.LegacyNewDec(0), err - } - - inflationRateChangePerYear := math.LegacyOneDec().Sub(bondedRatio.Quo(params.GoalBonded)).Mul(params.InflationChangePercentage) - - inflationRateChange := inflationRateChangePerYear.Quo(sdkmath.LegacyNewDec(int64(params.BlockPerYear))) - - inflationRate := inflation.Add(inflationRateChange) - - if inflationRate.GT(params.InflationMax) { - inflationRate = params.InflationMax - } - if inflation.LT(params.InflationMin) { - inflationRate = params.InflationMin - } - - return inflationRate, nil -} - -// transfer tokens form the Distribution to Foundation Community Pool -func (k KVStore) MoveTokensFromDistributionToFoundationPoolAccount(ctx cosmos.Context) error { - // get pool balance - pool, err := k.distributionKeeper.FeePool.Get(ctx) - if err != nil { - return err - } - amount := pool.CommunityPool.AmountOf(configs.Denom) - - communityAccountAddress, err := k.getFoundationCommunityAccountAddress() - if err != nil { - return fmt.Errorf("failed to fetch foundational account %s", err) - } - - if !amount.IsZero() { - if err := k.distributionKeeper.DistributeFromFeePool(ctx, cosmos.NewCoins(cosmos.NewCoin(configs.Denom, amount.RoundInt())), communityAccountAddress); err != nil { - if err.Error() == "community pool does not have sufficient coins to distribute" { - ctx.Logger().Info(fmt.Sprintf("%s", err)) - return nil - } else { - ctx.Logger().Error(fmt.Sprintf("failed to distribute from community pool %s", err)) - return err - } - } - } - - return nil -} - -func (k KVStore) getFoundationDevAccountAddress() (cosmos.AccAddress, error) { - return sdk.AccAddressFromBech32(types.FoundationDevAccount) -} - -func (k KVStore) getFoundationCommunityAccountAddress() (cosmos.AccAddress, error) { - return sdk.AccAddressFromBech32(types.FoundationCommunityAccount) -} - -func (k KVStore) getFoundationGrantsAccountAddress() (cosmos.AccAddress, error) { - return sdk.AccAddressFromBech32(types.FoundationGrantsAccount) -} - func (k KVStore) AllocateTokensToValidator(ctx context.Context, val stakingtypes.ValidatorI, tokens sdk.DecCoins) error { return k.distributionKeeper.AllocateTokensToValidator(ctx, val, tokens) } @@ -567,3 +382,7 @@ func (k KVStore) AllocateTokensToValidator(ctx context.Context, val stakingtypes func (k KVStore) BurnCoins(ctx context.Context, moduleName string, coins sdk.Coins) error { return k.coinKeeper.BurnCoins(ctx, moduleName, coins) } + +func (k KVStore) SendToCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error { + return k.distributionKeeper.FundCommunityPool(ctx, amount, sender) +} diff --git a/x/arkeo/keeper/keeper_test.go b/x/arkeo/keeper/keeper_test.go index 498e06f9..909b84e4 100644 --- a/x/arkeo/keeper/keeper_test.go +++ b/x/arkeo/keeper/keeper_test.go @@ -105,6 +105,7 @@ func SetupKeeper(t testing.TB) (cosmos.Context, Keeper) { stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, types.ModuleName: {authtypes.Minter, authtypes.Burner}, + types.ReserveName: {authtypes.Minter, authtypes.Burner}, types.ProviderName: {}, types.ContractName: {}, minttypes.ModuleName: {authtypes.Minter}, @@ -225,17 +226,15 @@ func SetupKeeperWithStaking(t testing.TB) (cosmos.Context, Keeper, stakingkeeper runtime.NewKVStoreService(keyAcc), authtypes.ProtoBaseAccount, map[string][]string{ - distrtypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - types.ModuleName: {authtypes.Minter, authtypes.Burner}, - types.ProviderName: {}, - types.ContractName: {}, - govtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - types.FoundationDevAccount: {authtypes.Minter, authtypes.Burner}, - types.FoundationGrantsAccount: {authtypes.Minter, authtypes.Burner}, - types.FoundationCommunityAccount: {authtypes.Minter, authtypes.Burner}, - minttypes.ModuleName: {authtypes.Minter}, + distrtypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + types.ModuleName: {authtypes.Minter, authtypes.Burner}, + types.ReserveName: {authtypes.Minter, authtypes.Burner}, + types.ProviderName: {}, + types.ContractName: {}, + govtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + minttypes.ModuleName: {authtypes.Minter}, }, authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.Bech32PrefixAccAddr, diff --git a/x/arkeo/keeper/manager.go b/x/arkeo/keeper/manager.go index 607e9db0..99055d1b 100644 --- a/x/arkeo/keeper/manager.go +++ b/x/arkeo/keeper/manager.go @@ -48,33 +48,19 @@ func (mgr *Manager) BeginBlock(ctx cosmos.Context) error { } mgr.keeper.SetVersion(ctx, ver) // update stored version - // Get the circulating supply after calculating inflation - circSupply, err := mgr.circulatingSupplyAfterInflationCalc(ctx) + // Get the reserve supply + reserveSupply, err := mgr.reserveSupply(ctx) if err != nil { mgr.keeper.Logger().Error("unable to get supply with inflation calculation", "error", err) return err } - err = mgr.keeper.MoveTokensFromDistributionToFoundationPoolAccount(ctx) - if err != nil { - mgr.keeper.Logger().Error("unable to send tokens from distribution to pool account", "error", err) - } - validatorPayoutCycle := sdkmath.LegacyNewDec(mgr.FetchConfig(ctx, configs.ValidatorPayoutCycle)) emissionCurve := sdkmath.LegacyNewDec(int64(params.EmissionCurve)) // Emission curve factor blocksPerYear := sdkmath.LegacyNewDec(int64(params.BlockPerYear)) - // Distribute Minted To Pools - balanceDistribution, err := mgr.keeper.MintAndDistributeTokens(ctx, circSupply) - if err != nil { - mgr.keeper.Logger().Error("unable to mint and distribute tokens", "error", err) - } - - mgr.keeper.Logger().Info(fmt.Sprintf("Circulating Supply After Funding Foundational Account %s", balanceDistribution)) - - // Calculate Block Rewards - blockReward := mgr.calcBlockReward(ctx, balanceDistribution.Amount, emissionCurve, blocksPerYear, validatorPayoutCycle) + blockReward := mgr.calcBlockReward(ctx, reserveSupply.Amount, emissionCurve, blocksPerYear, validatorPayoutCycle) mgr.keeper.Logger().Info(fmt.Sprintf("Block Reward for block number %d, %v", ctx.BlockHeight(), blockReward)) var votes = []abci.VoteInfo{} @@ -108,9 +94,9 @@ func (mgr Manager) EndBlock(ctx cosmos.Context) error { if err := mgr.invariantContractModule(ctx); err != nil { panic(err) } - // if err := mgr.invariantMaxSupply(ctx); err != nil { - // panic(err) - // } + if err := mgr.invariantMaxSupply(ctx); err != nil { + panic(err) + } return nil } @@ -230,7 +216,7 @@ func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo, bl } // sum tokens - total := cosmos.ZeroInt() + total := cosmos.ZeroDec() for _, vote := range votes { val, err := mgr.sk.ValidatorByConsAddr(ctx, vote.Validator.Address) if err != nil { @@ -240,12 +226,14 @@ func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo, bl if !val.IsBonded() || val.IsJailed() { continue } - total = total.Add(val.GetDelegatorShares().RoundInt()) + total = total.Add(val.GetDelegatorShares()) } if total.IsZero() { return nil } + var totalRemainder cosmos.Dec = cosmos.ZeroDec() + for _, vote := range votes { if vote.BlockIdFlag.String() == "BLOCK_ID_FLAG_ABSENT" || vote.BlockIdFlag.String() == "BLOCK_ID_FLAG_UNKNOWN" { mgr.keeper.Logger().Info(fmt.Sprintf("validator rewards skipped due to lack of signature: %s, validator : %s ", vote.BlockIdFlag.String(), string(vote.Validator.GetAddress()))) @@ -274,9 +262,9 @@ func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo, bl } acc := cosmos.AccAddress(val.GetOperator()) - totalReward := common.GetSafeShare(val.GetDelegatorShares().RoundInt(), total, blockReward.Amount.RoundInt()) - validatorReward := cosmos.ZeroInt() - rateBasisPts := val.GetCommission().MulInt64(100).RoundInt() + totalReward := common.GetSafeShare(val.GetDelegatorShares(), total, blockReward.Amount) + validatorReward := cosmos.ZeroDec() + rateBasisPts := val.GetCommission().MulInt64(100) delegates, err := mgr.sk.GetValidatorDelegations(ctx, valBz) if err != nil { @@ -289,14 +277,17 @@ func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo, bl mgr.keeper.Logger().Error("unable to fetch delegate address", "delegate", delegate.DelegatorAddress, "error", err) continue } - delegateReward := common.GetSafeShare(delegate.GetShares().RoundInt(), val.GetDelegatorShares().RoundInt(), totalReward) + delegateReward := common.GetSafeShare(delegate.GetShares(), val.GetDelegatorShares(), totalReward) if acc.String() != delegate.DelegatorAddress { - valFee := common.GetSafeShare(rateBasisPts, cosmos.NewInt(configs.MaxBasisPoints), delegateReward) + valFee := common.GetSafeShare(rateBasisPts, cosmos.NewDec(configs.MaxBasisPoints), delegateReward) delegateReward = delegateReward.Sub(valFee) validatorReward = validatorReward.Add(valFee) } - if err := mgr.keeper.MintAndSendToAccount(ctx, delegateAcc, cosmos.NewCoin(blockReward.Denom, delegateReward)); err != nil { + intReward, remainder := delegateReward.TruncateInt(), delegateReward.Sub(cosmos.NewDec(delegateReward.TruncateInt().Int64())) + totalRemainder = totalRemainder.Add(remainder) + + if err := mgr.keeper.SendFromModuleToAccount(ctx, types.ReserveName, delegateAcc, cosmos.NewCoins(cosmos.NewCoin(blockReward.Denom, intReward))); err != nil { mgr.keeper.Logger().Error("unable to pay rewards to delegate", "delegate", delegate.DelegatorAddress, "error", err) continue } @@ -304,17 +295,25 @@ func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo, bl } if !validatorReward.IsZero() { - if err := mgr.keeper.AllocateTokensToValidator(ctx, val, sdk.NewDecCoins(sdk.NewDecCoin(blockReward.Denom, validatorReward))); err != nil { + intValidatorReward, remainder := validatorReward.TruncateInt(), validatorReward.Sub(cosmos.NewDec(validatorReward.TruncateInt().Int64())) + totalRemainder = totalRemainder.Add(remainder) + if err := mgr.keeper.SendFromModuleToAccount(ctx, types.ReserveName, acc, sdk.NewCoins(sdk.NewCoin(blockReward.Denom, intValidatorReward))); err != nil { mgr.keeper.Logger().Error("unable to pay rewards to validator", "validator", val.GetOperator(), "error", err) continue } - mgr.keeper.Logger().Info("validator additional rewards", "validator", acc.String(), "amount", validatorReward) + mgr.keeper.Logger().Info("validator rewards", "validator", acc.String(), "amount", validatorReward) } - if err := mgr.EmitValidatorPayoutEvent(ctx, acc, validatorReward); err != nil { + if err := mgr.EmitValidatorPayoutEvent(ctx, acc, validatorReward.TruncateInt()); err != nil { mgr.keeper.Logger().Error("unable to emit validator payout event", "validator", acc.String(), "error", err) } } + // Send remainder to the community pool + if !totalRemainder.IsZero() { + if err := mgr.keeper.SendToCommunityPool(ctx, cosmos.NewCoins(cosmos.NewCoin(blockReward.Denom, totalRemainder.RoundInt())), mgr.keeper.GetModuleAccAddress(types.ReserveName)); err != nil { + mgr.keeper.Logger().Error("unable to send remainder to community pool", "error", err) + } + } return nil } @@ -351,8 +350,8 @@ func (mgr Manager) SettleContract(ctx cosmos.Context, contract types.Contract, n contract.Nonce = nonce } totalDebt, err := mgr.contractDebt(ctx, contract) - valIncome := common.GetSafeShare(cosmos.NewInt(mgr.FetchConfig(ctx, configs.ReserveTax)), cosmos.NewInt(configs.MaxBasisPoints), totalDebt) - debt := totalDebt.Sub(valIncome) + valIncome := common.GetSafeShare(cosmos.NewDec(mgr.FetchConfig(ctx, configs.ReserveTax)), cosmos.NewDec(configs.MaxBasisPoints), totalDebt.ToLegacyDec()) + debt := totalDebt.Sub(valIncome.RoundInt()) if err != nil { return contract, err } @@ -364,7 +363,7 @@ func (mgr Manager) SettleContract(ctx cosmos.Context, contract types.Contract, n if err := mgr.keeper.SendFromModuleToAccount(ctx, types.ContractName, provider, cosmos.NewCoins(cosmos.NewCoin(contract.Rate.Denom, debt))); err != nil { return contract, err } - if err := mgr.keeper.SendFromModuleToModule(ctx, types.ContractName, types.ModuleName, cosmos.NewCoins(cosmos.NewCoin(contract.Rate.Denom, valIncome))); err != nil { + if err := mgr.keeper.SendFromModuleToModule(ctx, types.ContractName, types.ModuleName, cosmos.NewCoins(cosmos.NewCoin(contract.Rate.Denom, valIncome.RoundInt()))); err != nil { return contract, err } } @@ -399,7 +398,7 @@ func (mgr Manager) SettleContract(ctx cosmos.Context, contract types.Contract, n return contract, err } - if err = mgr.EmitContractSettlementEvent(ctx, totalDebt, valIncome, &contract); err != nil { + if err = mgr.EmitContractSettlementEvent(ctx, totalDebt, valIncome.RoundInt(), &contract); err != nil { return contract, err } @@ -433,25 +432,10 @@ func (mgr Manager) contractDebt(ctx cosmos.Context, contract types.Contract) (co return debt, nil } -func (mgr Manager) circulatingSupplyAfterInflationCalc(ctx cosmos.Context) (sdk.DecCoin, error) { - // Get the circulating supply - circulatingSupply, err := mgr.keeper.GetCirculatingSupply(ctx, configs.Denom) - if err != nil { - mgr.keeper.Logger().Error(fmt.Sprintf("failed to get circulating supply %s", err)) - return sdk.NewDecCoin(configs.Denom, sdkmath.NewInt(0)), err - } - - // Get the inflation rate - inflationRate, err := mgr.keeper.GetInflationRate(ctx) - if err != nil { - return sdk.NewDecCoin(configs.Denom, sdkmath.NewInt(0)), err - } - mgr.keeper.Logger().Info(fmt.Sprintf("inflation rate: %d", inflationRate)) - - // Multiply circulating supply by inflation rate to get the newly minted token amount - newTokenAmountMintedDec := circulatingSupply.Amount.Mul(inflationRate).QuoInt64(100) +func (mgr Manager) reserveSupply(ctx cosmos.Context) (sdk.DecCoin, error) { + reserveSupply := mgr.keeper.GetBalanceOfModule(ctx, types.ReserveName, configs.Denom) - mgr.keeper.Logger().Info(fmt.Sprintf("After Inflation Calculation: %v", newTokenAmountMintedDec)) + mgr.keeper.Logger().Info(fmt.Sprintf("Reserve Supply: %v", reserveSupply)) - return sdk.NewDecCoin(configs.Denom, newTokenAmountMintedDec.RoundInt()), nil + return sdk.NewDecCoin(configs.Denom, reserveSupply), nil } diff --git a/x/arkeo/keeper/manager_test.go b/x/arkeo/keeper/manager_test.go index 06c1adbe..97bd9c94 100644 --- a/x/arkeo/keeper/manager_test.go +++ b/x/arkeo/keeper/manager_test.go @@ -5,8 +5,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" @@ -287,23 +285,7 @@ func TestParamsRewardsPercentage(t *testing.T) { params := k.GetParams(ctx) - require.Equal(t, params.CommunityPoolPercentage, sdkmath.LegacyMustNewDecFromStr("0.100000000000000000")) -} -func TestCommunityPoolDistributionToFoundationCommunityPool(t *testing.T) { - ctx, k, sk := SetupKeeperWithStaking(t) - mgr := NewManager(k, sk) - - require.NoError(t, k.MintToModule(ctx, disttypes.ModuleName, getCoin(common.Tokens(200000)))) - - err := mgr.keeper.MoveTokensFromDistributionToFoundationPoolAccount(ctx) - require.NoError(t, err) - - address, err := sdk.AccAddressFromBech32(types.FoundationCommunityAccount) - require.NoError(t, err) - - bal := mgr.keeper.GetBalance(ctx, address).AmountOf(configs.Denom) - - require.Equal(t, bal, sdkmath.NewInt(10000)) + require.Equal(t, params.BlockPerYear, uint64(6311520)) } func TestBlockRewardCalculation(t *testing.T) { @@ -407,7 +389,7 @@ func TestValidatorPayouts(t *testing.T) { require.NoError(t, sk.SetDelegation(ctx, del3)) // Mint initial funds to the reserve - require.NoError(t, k.MintToModule(ctx, types.ModuleName, getCoin(common.Tokens(200000)))) + require.NoError(t, k.MintToModule(ctx, types.ReserveName, getCoin(common.Tokens(200000)))) ctx = ctx.WithBlockHeight(mgr.FetchConfig(ctx, configs.ValidatorPayoutCycle)) @@ -424,49 +406,31 @@ func TestValidatorPayouts(t *testing.T) { BlockIdFlag: 2, } } - balanceDistribution, err := mgr.keeper.MintAndDistributeTokens(ctx, blockReward) - if err != nil { - ctx.Logger().Error("unable to mint and distribute tokens", "error", err) - } - devAccountAddress, err := sdk.AccAddressFromBech32(types.FoundationDevAccount) - require.NoError(t, err) - grantAccountAddress, err := sdk.AccAddressFromBech32(types.FoundationGrantsAccount) - require.NoError(t, err) + moduleBalance := k.GetBalanceOfModule(ctx, types.ReserveName, configs.Denom) + require.Equal(t, moduleBalance.Int64(), int64(20000000000000)) - communityAccountAddress, err := sdk.AccAddressFromBech32(types.FoundationCommunityAccount) + reserveSupply, err := mgr.reserveSupply(ctx) require.NoError(t, err) - devAccountBal := k.GetBalance(ctx, devAccountAddress).AmountOf(configs.Denom) - require.Equal(t, devAccountBal, sdkmath.NewInt(400000)) - - grantAccountBal := k.GetBalance(ctx, grantAccountAddress).AmountOf(configs.Denom) - require.Equal(t, grantAccountBal, sdkmath.NewInt(0)) - - communityAccountBal := k.GetBalance(ctx, communityAccountAddress).AmountOf(configs.Denom) - require.Equal(t, communityAccountBal, sdkmath.NewInt(200000)) - - moduleBalance := k.GetBalanceOfModule(ctx, types.ModuleName, configs.Denom) - require.Equal(t, moduleBalance.Int64(), int64(20000000000000)) - - require.NoError(t, mgr.ValidatorPayout(ctx, votes, balanceDistribution)) + require.NoError(t, mgr.ValidatorPayout(ctx, votes, reserveSupply)) totalBal := cosmos.ZeroInt() // Check balances of validators 7 - checkBalance(ctx, t, k, acc1, configs.Denom, 164541, &totalBal) - checkBalance(ctx, t, k, acc2, configs.Denom, 328753, &totalBal) - checkBalance(ctx, t, k, acc3, configs.Denom, 819411, &totalBal) + checkBalance(ctx, t, k, acc1, configs.Denom, 2350588235294, &totalBal) + checkBalance(ctx, t, k, acc2, configs.Denom, 4696470588235, &totalBal) + checkBalance(ctx, t, k, acc3, configs.Denom, 11705882352941, &totalBal) // Check balances of delegates - checkBalance(ctx, t, k, delAcc1, configs.Denom, 16455, &totalBal) - checkBalance(ctx, t, k, delAcc2, configs.Denom, 32875, &totalBal) - checkBalance(ctx, t, k, delAcc3, configs.Denom, 32776, &totalBal) + checkBalance(ctx, t, k, delAcc1, configs.Denom, 235058823529, &totalBal) + checkBalance(ctx, t, k, delAcc2, configs.Denom, 469647058823, &totalBal) + checkBalance(ctx, t, k, delAcc3, configs.Denom, 468235294117, &totalBal) - require.Equal(t, totalBal.ToLegacyDec(), sdkmath.LegacyNewDec(1394811)) + require.Equal(t, totalBal.ToLegacyDec(), sdkmath.LegacyNewDec(19925882352939)) - moduleBalance = k.GetBalanceOfModule(ctx, types.ModuleName, configs.Denom) - require.Equal(t, moduleBalance.ToLegacyDec().RoundInt64(), int64(20000000000000)) + moduleBalance = k.GetBalanceOfModule(ctx, types.ReserveName, configs.Denom) + require.Equal(t, moduleBalance.ToLegacyDec().RoundInt64(), int64(0)) } func checkBalance(ctx cosmos.Context, t *testing.T, k Keeper, acc cosmos.AccAddress, denom string, expectedAmt int64, total *sdkmath.Int) { bal := k.GetBalance(ctx, acc) diff --git a/x/arkeo/types/params.go b/x/arkeo/types/params.go index 7f26761e..656ce4f4 100644 --- a/x/arkeo/types/params.go +++ b/x/arkeo/types/params.go @@ -1,7 +1,6 @@ package types import ( - "cosmossdk.io/math" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) @@ -16,15 +15,8 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams() Params { return Params{ - CommunityPoolPercentage: math.LegacyMustNewDecFromStr("0.100000000000000000"), - DevFundPercentage: math.LegacyMustNewDecFromStr("0.200000000000000000"), - GrantFundPercentage: math.LegacyMustNewDecFromStr("0.000000000000000000"), - InflationChangePercentage: math.LegacyMustNewDecFromStr("0.030000000000000000"), - InflationMin: math.LegacyMustNewDecFromStr("0.020000000000000000"), - InflationMax: math.LegacyMustNewDecFromStr("0.050000000000000000"), - GoalBonded: math.LegacyMustNewDecFromStr("0.670000000000000000"), - BlockPerYear: 6311520, - EmissionCurve: 6, + BlockPerYear: 6311520, + EmissionCurve: 6, } } diff --git a/x/arkeo/types/params.pb.go b/x/arkeo/types/params.pb.go index d7602f97..699eb8a5 100644 --- a/x/arkeo/types/params.pb.go +++ b/x/arkeo/types/params.pb.go @@ -5,7 +5,6 @@ package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types" @@ -29,15 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - CommunityPoolPercentage cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=community_pool_percentage,json=communityPoolPercentage,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"community_pool_percentage"` - DevFundPercentage cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=dev_fund_percentage,json=devFundPercentage,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"dev_fund_percentage"` - GrantFundPercentage cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=grant_fund_percentage,json=grantFundPercentage,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"grant_fund_percentage"` - InflationChangePercentage cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=inflation_change_percentage,json=inflationChangePercentage,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_change_percentage"` - InflationMin cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=inflation_min,json=inflationMin,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_min"` - InflationMax cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=inflation_max,json=inflationMax,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_max"` - GoalBonded cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=goal_bonded,json=goalBonded,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"goal_bonded"` - BlockPerYear uint64 `protobuf:"varint,8,opt,name=block_per_year,json=blockPerYear,proto3" json:"block_per_year,omitempty"` - EmissionCurve uint64 `protobuf:"varint,9,opt,name=emission_curve,json=emissionCurve,proto3" json:"emission_curve,omitempty"` + BlockPerYear uint64 `protobuf:"varint,8,opt,name=block_per_year,json=blockPerYear,proto3" json:"block_per_year,omitempty"` + EmissionCurve uint64 `protobuf:"varint,9,opt,name=emission_curve,json=emissionCurve,proto3" json:"emission_curve,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -93,35 +85,23 @@ func init() { func init() { proto.RegisterFile("arkeo/arkeo/params.proto", fileDescriptor_47c871f4fc73dfc5) } var fileDescriptor_47c871f4fc73dfc5 = []byte{ - // 445 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x13, 0xad, 0xd5, 0x9d, 0xfd, 0x01, 0x66, 0x15, 0xd3, 0x5d, 0x48, 0x17, 0x51, 0x58, - 0x10, 0x13, 0x8a, 0x37, 0x8f, 0xdd, 0xd5, 0x93, 0x42, 0xe9, 0x41, 0xd0, 0x4b, 0x78, 0x99, 0xbc, - 0x4d, 0x87, 0x66, 0xe6, 0xc5, 0xc9, 0xa4, 0xb6, 0x7f, 0x83, 0x17, 0x8f, 0x1e, 0xfd, 0x23, 0xfc, - 0x23, 0xf6, 0xb8, 0x78, 0x12, 0x0f, 0x8b, 0xb4, 0xff, 0x88, 0x74, 0x52, 0x6b, 0xa9, 0xb7, 0xb0, - 0x97, 0x97, 0xe4, 0xfb, 0x5e, 0x3e, 0x1f, 0x98, 0xe1, 0x31, 0x1f, 0xf4, 0x18, 0x29, 0xaa, 0x6b, - 0x01, 0x1a, 0x64, 0x19, 0x16, 0x9a, 0x0c, 0x79, 0xbb, 0x36, 0x0b, 0x6d, 0x3d, 0x7a, 0x90, 0x51, - 0x46, 0x36, 0x8f, 0x96, 0x6f, 0xf5, 0xc8, 0x51, 0xc0, 0xa9, 0x94, 0x54, 0x46, 0x09, 0x94, 0x18, - 0x4d, 0x7a, 0x09, 0x1a, 0xe8, 0x45, 0x9c, 0x84, 0x5a, 0xf5, 0x3b, 0x75, 0x3f, 0xae, 0x7f, 0xac, - 0x3f, 0xea, 0xd6, 0xe3, 0xcf, 0x6d, 0xd6, 0x1e, 0x58, 0x9d, 0x27, 0x59, 0x87, 0x93, 0x94, 0x95, - 0x12, 0x66, 0x16, 0x17, 0x44, 0x79, 0x5c, 0xa0, 0xe6, 0xa8, 0x0c, 0x64, 0xe8, 0xbb, 0x27, 0xee, - 0xe9, 0x4e, 0xbf, 0x77, 0x79, 0xdd, 0x75, 0x7e, 0x5d, 0x77, 0x8f, 0x6b, 0x46, 0x99, 0x8e, 0x43, - 0x41, 0x91, 0x04, 0x33, 0x0a, 0xdf, 0x60, 0x06, 0x7c, 0x76, 0x8e, 0xfc, 0xc7, 0xf7, 0xe7, 0x6c, - 0xa5, 0x38, 0x47, 0x3e, 0x7c, 0xb4, 0x66, 0x0e, 0x88, 0xf2, 0xc1, 0x9a, 0xe8, 0x01, 0x3b, 0x4c, - 0x71, 0x12, 0x5f, 0x54, 0x2a, 0xdd, 0x14, 0xdd, 0x6a, 0x2a, 0xba, 0x9f, 0xe2, 0xe4, 0x75, 0xa5, - 0xd2, 0x0d, 0x05, 0xb2, 0x87, 0x99, 0x06, 0x65, 0xfe, 0x93, 0xdc, 0x6e, 0x2a, 0x39, 0xb4, 0xbc, - 0x2d, 0xcd, 0x47, 0x76, 0x2c, 0xd4, 0x45, 0x0e, 0x46, 0x90, 0x8a, 0xf9, 0x08, 0x54, 0x86, 0x9b, - 0xb2, 0x56, 0x53, 0x59, 0x67, 0x4d, 0x3d, 0xb3, 0xd0, 0x0d, 0xe5, 0x3b, 0xb6, 0xff, 0x4f, 0x29, - 0x85, 0xf2, 0xef, 0x34, 0x95, 0xec, 0xad, 0x39, 0x6f, 0x85, 0xda, 0xe2, 0xc2, 0xd4, 0x6f, 0xdf, - 0x00, 0x17, 0xa6, 0xde, 0x90, 0xed, 0x66, 0x04, 0x79, 0x9c, 0x90, 0x4a, 0x31, 0xf5, 0xef, 0x36, - 0xa5, 0xb2, 0x25, 0xa5, 0x6f, 0x21, 0xde, 0x13, 0x76, 0x90, 0xe4, 0xc4, 0xc7, 0xcb, 0xb3, 0x8e, - 0x67, 0x08, 0xda, 0xbf, 0x77, 0xe2, 0x9e, 0xb6, 0x86, 0x7b, 0x36, 0x1d, 0xa0, 0x7e, 0x8f, 0xa0, - 0xbd, 0xa7, 0xec, 0x00, 0xa5, 0x28, 0x4b, 0x7b, 0x37, 0x95, 0x9e, 0xa0, 0xbf, 0x63, 0xa7, 0xf6, - 0xff, 0xa6, 0x67, 0xcb, 0xf0, 0x65, 0xeb, 0xeb, 0xb7, 0xae, 0xd3, 0x7f, 0x75, 0x39, 0x0f, 0xdc, - 0xab, 0x79, 0xe0, 0xfe, 0x9e, 0x07, 0xee, 0x97, 0x45, 0xe0, 0x5c, 0x2d, 0x02, 0xe7, 0xe7, 0x22, - 0x70, 0x3e, 0x3c, 0xcb, 0x84, 0x19, 0x55, 0x49, 0xc8, 0x49, 0xd6, 0x4b, 0xaa, 0xd0, 0x7c, 0x22, - 0x3d, 0x5e, 0x6d, 0xec, 0x74, 0xf5, 0x34, 0xb3, 0x02, 0xcb, 0xa4, 0x6d, 0x77, 0xeb, 0xc5, 0x9f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x94, 0x80, 0x25, 0xba, 0xd5, 0x03, 0x00, 0x00, + // 242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x48, 0x2c, 0xca, 0x4e, + 0xcd, 0xd7, 0x87, 0x90, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, + 0x42, 0xdc, 0x60, 0x31, 0x3d, 0x30, 0x29, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x16, 0xd7, 0x07, + 0xb1, 0x20, 0x4a, 0xa4, 0xe4, 0x92, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x93, 0x12, 0x8b, 0x53, + 0xf5, 0xcb, 0x0c, 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x93, 0xf3, 0x33, 0xf3, 0xa0, 0xf2, 0x92, + 0x10, 0xf9, 0x78, 0x88, 0x46, 0x08, 0x07, 0x22, 0xa5, 0x14, 0xcd, 0xc5, 0x16, 0x00, 0xb6, 0x4d, + 0x48, 0x85, 0x8b, 0x2f, 0x29, 0x27, 0x3f, 0x39, 0x3b, 0xbe, 0x20, 0xb5, 0x28, 0xbe, 0x32, 0x35, + 0xb1, 0x48, 0x82, 0x43, 0x81, 0x51, 0x83, 0x25, 0x88, 0x07, 0x2c, 0x1a, 0x90, 0x5a, 0x14, 0x99, + 0x9a, 0x58, 0x24, 0xa4, 0xca, 0xc5, 0x97, 0x9a, 0x9b, 0x59, 0x5c, 0x9c, 0x99, 0x9f, 0x17, 0x9f, + 0x5c, 0x5a, 0x54, 0x96, 0x2a, 0xc1, 0x09, 0x56, 0xc5, 0x0b, 0x13, 0x75, 0x06, 0x09, 0x5a, 0xb1, + 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x7a, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, + 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, + 0x51, 0xda, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0x10, 0x3f, 0xe7, 0xa5, + 0x96, 0x94, 0xe7, 0x17, 0x65, 0x43, 0x03, 0xa0, 0x02, 0x4a, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, + 0xb1, 0x81, 0x9d, 0x6a, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x40, 0x26, 0xf7, 0x24, 0x01, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -154,76 +134,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x40 } - { - size := m.GoalBonded.Size() - i -= size - if _, err := m.GoalBonded.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size := m.InflationMax.Size() - i -= size - if _, err := m.InflationMax.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.InflationMin.Size() - i -= size - if _, err := m.InflationMin.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.InflationChangePercentage.Size() - i -= size - if _, err := m.InflationChangePercentage.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.GrantFundPercentage.Size() - i -= size - if _, err := m.GrantFundPercentage.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.DevFundPercentage.Size() - i -= size - if _, err := m.DevFundPercentage.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.CommunityPoolPercentage.Size() - i -= size - if _, err := m.CommunityPoolPercentage.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -244,20 +154,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = m.CommunityPoolPercentage.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.DevFundPercentage.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.GrantFundPercentage.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.InflationChangePercentage.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.InflationMin.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.InflationMax.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.GoalBonded.Size() - n += 1 + l + sovParams(uint64(l)) if m.BlockPerYear != 0 { n += 1 + sovParams(uint64(m.BlockPerYear)) } @@ -302,244 +198,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolPercentage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CommunityPoolPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DevFundPercentage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DevFundPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GrantFundPercentage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GrantFundPercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationChangePercentage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationChangePercentage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationMin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationMin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InflationMax", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InflationMax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GoalBonded", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GoalBonded.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field BlockPerYear", wireType)