Skip to content

Commit

Permalink
Sunny/mainnet params (osmosis-labs#318)
Browse files Browse the repository at this point in the history
* multiple nativetokendenommetadata

* mainnet updates
  • Loading branch information
sunnya97 authored Jun 16, 2021
1 parent 0ea96d9 commit 15e7725
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 236 deletions.
54 changes: 38 additions & 16 deletions cmd/osmosisd/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,43 @@ Example:
}
defer ionJSON.Close()
byteValue2, _ := ioutil.ReadAll(ionJSON)
var ionAmounts map[string]int64
json.Unmarshal(byteValue2, &ionAmounts)
var ionAmts map[string]int64
json.Unmarshal(byteValue2, &ionAmts)
if err != nil {
return err
}

// get genesis params
genesisParams := MainnetGenesisParams()

nonAirdropAccs := make(map[string]sdk.Coins)

for _, acc := range genesisParams.StrategicReserveAccounts {
nonAirdropAccs[acc.Address] = acc.GetCoins()
}

for _, acc := range genesisParams.MintParams.WeightedDeveloperRewardsReceivers {
if _, ok := nonAirdropAccs[acc.Address]; !ok {
nonAirdropAccs[acc.Address] = sdk.NewCoins()
}

}

for addr, amt := range ionAmts {
setCosmosBech32Prefixes()
address, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return err
}
appparams.SetAddressPrefixes()

if val, ok := nonAirdropAccs[address.String()]; ok {
nonAirdropAccs[address.String()] = val.Add(sdk.NewCoin("uion", sdk.NewInt(amt).MulRaw(1_000_000)))
} else {
nonAirdropAccs[address.String()] = sdk.NewCoins(sdk.NewCoin("uion", sdk.NewInt(amt).MulRaw(1_000_000)))
}
}

// figure out normalizationFactor to normalize snapshot balances to desired airdrop supply
normalizationFactor := genesisParams.AirdropSupply.ToDec().QuoInt(snapshot.TotalOsmosAirdropAmount)
fmt.Printf("normalization factor: %s\n", normalizationFactor)
Expand Down Expand Up @@ -288,11 +316,11 @@ Example:
// initial liquid amounts
// We consistently round down to the nearest uosmo
liquidAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.2")).TruncateInt() // 20% of airdrop amount
liquidCoins := sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadata.Base, liquidAmount))
liquidCoins := sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, liquidAmount))

if ionAmt, ok := ionAmounts[acc.AtomAddress]; ok {
liquidCoins = liquidCoins.Add(sdk.NewCoin("uion", sdk.NewInt(ionAmt).MulRaw(1_000_000)))
delete(ionAmounts, acc.AtomAddress)
if coins, ok := nonAirdropAccs[address.String()]; ok {
liquidCoins = liquidCoins.Add(coins...)
delete(nonAirdropAccs, address.String())
}

liquidBalances = append(liquidBalances, banktypes.Balance{
Expand All @@ -305,7 +333,7 @@ Example:

claimRecords = append(claimRecords, claimtypes.ClaimRecord{
Address: address.String(),
InitialClaimableAmount: sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadata.Base, claimableAmount)),
InitialClaimableAmount: sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, claimableAmount)),
ActionCompleted: []bool{false, false, false, false},
})

Expand All @@ -320,22 +348,16 @@ Example:
}

// distribute remaining ions to accounts not in fairdrop
for addr, remainingIons := range ionAmounts {
// set atom bech32 prefixes
setCosmosBech32Prefixes()

for addr, remainingNonAirdrop := range nonAirdropAccs {
// read address from snapshot
address, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return err
}

// set osmo bech32 prefixes
appparams.SetAddressPrefixes()

liquidBalances = append(liquidBalances, banktypes.Balance{
Address: address.String(),
Coins: sdk.NewCoins(sdk.NewCoin("uion", sdk.NewInt(remainingIons).MulRaw(1_000_000))),
Coins: remainingNonAirdrop,
})

// Add the new account to the set of genesis accounts
Expand Down Expand Up @@ -369,7 +391,7 @@ Example:

// claim module genesis
claimGenState := claimtypes.GetGenesisStateFromAppState(depCdc, appState)
claimGenState.ModuleAccountBalance = sdk.NewCoin(genesisParams.NativeCoinMetadata.Base, claimModuleAccountBalance)
claimGenState.ModuleAccountBalance = sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, claimModuleAccountBalance)

claimGenState.ClaimRecords = claimRecords
claimGenStateBz, err := cdc.MarshalJSON(claimGenState)
Expand Down
Loading

0 comments on commit 15e7725

Please sign in to comment.