github.com/ava-labs/avalanchego@v1.11.11/vms/platformvm/reward/example_test.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package reward 5 6 import ( 7 "fmt" 8 "time" 9 10 "github.com/ava-labs/avalanchego/utils/units" 11 ) 12 13 func ExampleNewCalculator() { 14 const ( 15 day = 24 * time.Hour 16 week = 7 * day 17 stakingDuration = 4 * week 18 19 stakeAmount = 100_000 * units.Avax // 100k AVAX 20 21 // The current supply can be fetched with the platform.getCurrentSupply API 22 currentSupply = 447_903_489_576_595_361 * units.NanoAvax // ~448m AVAX 23 ) 24 var ( 25 mainnetRewardConfig = Config{ 26 MaxConsumptionRate: .12 * PercentDenominator, 27 MinConsumptionRate: .10 * PercentDenominator, 28 MintingPeriod: 365 * 24 * time.Hour, 29 SupplyCap: 720 * units.MegaAvax, 30 } 31 mainnetCalculator = NewCalculator(mainnetRewardConfig) 32 ) 33 34 potentialReward := mainnetCalculator.Calculate(stakingDuration, stakeAmount, currentSupply) 35 36 fmt.Printf("Staking %d nAVAX for %s with the current supply of %d nAVAX would have a potential reward of %d nAVAX", 37 stakeAmount, 38 stakingDuration, 39 currentSupply, 40 potentialReward, 41 ) 42 // Output: Staking 100000000000000 nAVAX for 672h0m0s with the current supply of 447903489576595361 nAVAX would have a potential reward of 473168956104 nAVAX 43 }