Skip to content

Commit

Permalink
docs: Clarify mintExtendedCoin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed May 21, 2024
1 parent 47e5b50 commit 1ad82ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions x/precisebank/keeper/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,26 @@ func (k Keeper) mintExtendedCoin(
) error {
moduleAddr := k.ak.GetModuleAddress(moduleName)

// Get current fractional amount - 0 if not found
// Get current module account fractional balance - 0 if not found
fractionalAmount := k.GetFractionalBalance(ctx, moduleAddr)

// Get mint amounts
// Get separated mint amounts
integerMintAmount := amt.Quo(types.ConversionFactor())
fractionalMintAmount := amt.Mod(types.ConversionFactor())

// Get new fractional balance
// Get new fractional balance after minting
newFractionalBalance := fractionalAmount.Add(fractionalMintAmount)

// If it carries over, add 1 to integer mint amount. In this case, it will
// always be 1 as two fractional amounts can only add up < 2
// always be 1:
// fractional amounts x and y
// where x < ConversionFactor and y < ConversionFactor
// x + y < (2 * ConversionFactor) - 2
// x + y < 2 integer amounts
if newFractionalBalance.GTE(types.ConversionFactor()) {
// carry over to integer mint amount
integerMintAmount = integerMintAmount.AddRaw(1)
// keep the fractional balance that was not carried over
newFractionalBalance = newFractionalBalance.Mod(types.ConversionFactor())
}

Expand Down

0 comments on commit 1ad82ef

Please sign in to comment.