Skip to content

Commit

Permalink
GSW-1845 fix: if block range for emission inclus emission end height,…
Browse files Browse the repository at this point in the history
… mint until end height
  • Loading branch information
r3v4s committed Dec 20, 2024
1 parent 3588325 commit 4a54183
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions _deploy/r/gnoswap/gns/gns.gno
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func MintGns(address pusers.AddressOrName) uint64 {

// skip minting process if following conditions are met
// - if gns for current block is already minted
// - if emission has ended
if skipIfSameHeight(lastMintedHeight, currentHeight) || skipIfEmissionEnded(currentHeight) {
// - if last minted height is same as last height to mint ( 12 years passed )
if lastMintedHeight == currentHeight || lastMintedHeight == GetEndHeight() {
return 0
}

Expand Down Expand Up @@ -139,13 +139,15 @@ func checkErr(err error) {
}
}

// helper functions

// calculateAmountToMint calculates the amount of gns to mint
// It calculates the amount of gns to mint for each halving year for block range.
// It also handles the left emission amount if the current block range includes halving year end block.
func calculateAmountToMint(fromHeight, toHeight int64) uint64 {
fromYear := GetHalvingYearByHeight(fromHeight)

if toHeight > GetEndHeight() {
toHeight = GetEndHeight()
}
toYear := GetHalvingYearByHeight(toHeight)

totalAmountToMint := uint64(0)
Expand Down

0 comments on commit 4a54183

Please sign in to comment.