Unverified Commit 197171b8 authored by Sunny Aggarwal's avatar Sunny Aggarwal Committed by GitHub
Browse files

Sunny/fix airdrop supply (#242)


* fix airdrop supply

* fixed airdrop

* Apply suggestions from code review

Co-authored-by: default avatarDev Ojha <ValarDragon@users.noreply.github.com>

Co-authored-by: default avatarDev Ojha <ValarDragon@users.noreply.github.com>
parent 9a279fc3
Showing with 45 additions and 7 deletions
+45 -7
......@@ -48,7 +48,7 @@ type GenesisParams struct {
func MainnetGenesisParams() GenesisParams {
genParams := GenesisParams{}
genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5^13 uosmo, 5^7 (50 million) osmo
genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5*10^13 uosmo, 5*10^7 (50 million) osmo
genParams.ChainID = "osmosis-1"
genParams.GenesisTime = time.Date(2021, 6, 16, 17, 0, 0, 0, time.UTC) // Jun 16, 2021 - 17:00 UTC
......@@ -143,7 +143,7 @@ func MainnetGenesisParams() GenesisParams {
func TestnetGenesisParams() GenesisParams {
genParams := GenesisParams{}
genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5^13 uosmo, 5^7 (50 million) osmo
genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5*10^13 uosmo, 5*10^7 (50 million) osmo
genParams.ChainID = "osmo-testnet-thanatos"
genParams.GenesisTime = time.Now()
......
......@@ -202,14 +202,14 @@ Example:
// OsmoBalance = sqrt( all atoms) * (1 + 1.5) * (staked atom percent) =
acc.OsmoBalance = allOsmo.RoundInt()
totalOsmoBalance = totalOsmoBalance.Add(allOsmo.RoundInt())
if allAtoms.LTE(sdk.NewDec(1000000)) {
acc.OsmoBalanceBase = sdk.ZeroInt()
acc.OsmoBalanceBonus = sdk.ZeroInt()
acc.OsmoBalance = sdk.ZeroInt()
}
totalOsmoBalance = totalOsmoBalance.Add(acc.OsmoBalance)
snapshotAccs[address] = acc
}
......
......@@ -267,17 +267,18 @@ Example:
}
// get normalized osmo balance for account
normalizedOsmoBalance := normalizationFactor.MulInt(acc.OsmoBalance)
normalizedOsmoBalance := acc.OsmoBalance.ToDec().Mul(normalizationFactor)
// initial liquid amounts
liquidAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.2")).RoundInt() // 20% of airdrop amount
// We consistently round down to the nearest uosmo
liquidAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.2")).TruncateInt() // 20% of airdrop amount
liquidBalances = append(liquidBalances, banktypes.Balance{
Address: address.String(),
Coins: sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadata.Base, liquidAmount)),
})
// claimable balances
claimableAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.8")).RoundInt()
claimableAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.8")).TruncateInt()
claimRecords = append(claimRecords, claimtypes.ClaimRecord{
Address: address.String(),
......@@ -327,6 +328,43 @@ Example:
}
appState[claimtypes.ModuleName] = claimGenStateBz
// TODO: add remaining extra to community pool
// The total airdrop osmo is a smidge short (~1 osmo) short of the stated 50M supply.
// This is due to consistently rounding down.
// We place this remaining 1 osmo into the community pool at genesis
// sumAirdrop := sdk.Coins{}
// for _, balance := range bankGenState.Balances {
// sumAirdrop = sumAirdrop.Add(balance.Coins...)
// }
// for _, claim := range claimGenState.ClaimRecords {
// sumAirdrop = sumAirdrop.Add(claim.InitialClaimableAmount...)
// }
// var distributionGenState distributiontypes.GenesisState
// if appState[distributiontypes.ModuleName] != nil {
// cdc.MustUnmarshalJSON(appState[distributiontypes.ModuleName], &distributionGenState)
// }
// communityPoolExtra := sdk.NewCoins(
// sdk.NewCoin(
// genesisParams.NativeCoinMetadata.Base,
// genesisParams.AirdropSupply,
// ),
// ).Sub(sumAirdrop)
// fmt.Printf("community pool amount: %s\n", communityPoolExtra)
// distributionGenState.FeePool.CommunityPool = sdk.NewDecCoinsFromCoins(communityPoolExtra...)
// distributionGenStateBz, err := cdc.MarshalJSON(&distributionGenState)
// if err != nil {
// return fmt.Errorf("failed to marshal distribution genesis state: %w", err)
// }
// appState[distributiontypes.ModuleName] = distributionGenStateBz
// save entire genesis state to json
appStateJSON, err := json.Marshal(appState)
if err != nil {
return fmt.Errorf("failed to marshal application genesis state: %w", err)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment