Skip to content

Commit

Permalink
reinstating provider incentives (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell authored Dec 3, 2022
2 parents 0ccd040 + bc66133 commit 434298c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func NewJackalApp(
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
// storagemoduletypes.ModuleName,
storagemoduletypes.ModuleName,
)
mintModule := mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper)

Expand Down
6 changes: 3 additions & 3 deletions x/jklmint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type (
stakingKeeper types.StakingKeeper
bankKeeper types.BankKeeper
feeCollectorName string
// miningName string
miningName string
}
)

Expand All @@ -33,7 +33,7 @@ func NewKeeper(
ak types.AccountKeeper,
bk types.BankKeeper,
feeCollectorName string,
// miningName string,
miningName string,
) Keeper {
// ensure mint module account is set
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
Expand All @@ -52,7 +52,7 @@ func NewKeeper(
stakingKeeper: sk,
bankKeeper: bk,
feeCollectorName: feeCollectorName,
// miningName: miningName,
miningName: miningName,
}
}

Expand Down
25 changes: 13 additions & 12 deletions x/jklmint/keeper/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,42 @@ import (
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/jackalLabs/canine-chain/x/jklmint/types"
storeTypes "github.com/jackalLabs/canine-chain/x/storage/types"
)

func (k Keeper) BlockMint(ctx sdk.Context) {
var validatorRatio int64 = 4
// var providerRatio int64 = 6
var providerRatio int64 = 6

denom := k.GetParams(ctx).MintDenom

totalCoin := sdk.NewCoin(denom, sdk.NewInt((validatorRatio)*1000000))
totalCoin := sdk.NewCoin(denom, sdk.NewInt((validatorRatio+providerRatio)*1000000))

// mint coins, update supply
mintedCoin := sdk.NewCoin(denom, sdk.NewInt(validatorRatio*1000000))
mintedCoins := sdk.NewCoins(mintedCoin)

// mint coins, update supply
providerCoin := sdk.NewCoin(denom, sdk.NewInt(providerRatio*1000000))
providerCoins := sdk.NewCoins(providerCoin)

err := k.MintCoins(ctx, sdk.NewCoins(totalCoin))
if err != nil {
panic(err)
}

err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, storeTypes.ModuleName, providerCoins)
if err != nil {
panic(err)
}

// send the minted coins to the fee collector account
err = k.AddCollectedFees(ctx, mintedCoins)
if err != nil {
panic(err)
}

// mint coins, update supply
// providerCoin := sdk.NewCoin(denom, sdk.NewInt(providerRatio*1000000))
// providerCoins := sdk.NewCoins(providerCoin)

// err = k.SendToProviders(ctx, providerCoins)
// if err != nil {
// panic(err)
// }

if mintedCoin.Amount.IsInt64() {
if totalCoin.Amount.IsInt64() {
defer telemetry.ModuleSetGauge(types.ModuleName, float32(totalCoin.Amount.Int64()), "minted_tokens")
}

Expand Down
5 changes: 3 additions & 2 deletions x/jklmint/keeper/mint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ func (suite *MintTestSuite) TestBlockMint() {
Address: feeAccount.GetAddress().String(),
Denom: denom,
})

suite.Require().NoError(err)
suite.Require().Equal(sdk.NewInt(4000000), feeBalanceAfter.Balance.Amount)
supplyAfter, err := app.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &types.QueryTotalSupplyRequest{})
suite.Require().NoError(err)
suite.Require().Equal(1, len(supplyAfter.Supply))
suite.Require().Equal(sdk.NewInt(4000000), supplyAfter.Supply.AmountOf(denom))
// After BlockMint we now have exactly 4JKL in the fee collector account
suite.Require().Equal(sdk.NewInt(10000000), supplyAfter.Supply.AmountOf(denom))
// After BlockMint we now have exactly 10JKL in the fee collector account
}

0 comments on commit 434298c

Please sign in to comment.