State

State Objects

The x/incentives module keeps the following objects in state:

State Object
Description
Key
Value
Store

Incentive

Incentive bytecode

[]byte{1} + []byte(contract)

[]byte{incentive}

KV

GasMeter

Incentive id bytecode by erc20 contract bytes

[]byte{2} + []byte(contract) + []byte(participant)

[]byte{gasMeter}

KV

AllocationMeter

Total allocation bytes by denom bytes

[]byte{3} + []byte(denom)

[]byte{sdk.Dec}

KV

Incentive

An instance that organizes distribution conditions for a given smart contract.

type Incentive struct {
	// contract address
	Contract string `protobuf:"bytes,1,opt,name=contract,proto3" json:"contract,omitempty"`
	// denoms and percentage of rewards to be allocated
	Allocations github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=allocations,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"allocations"`
	// number of remaining epochs
	Epochs uint32 `protobuf:"varint,3,opt,name=epochs,proto3" json:"epochs,omitempty"`
	// distribution start time
	StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"`
	// cumulative gas spent by all gasmeters of the incentive during the epoch
	TotalGas uint64 `protobuf:"varint,5,opt,name=total_gas,json=totalGas,proto3" json:"total_gas,omitempty"`
}

As long as an incentive has remaining epochs, it distributes rewards according to its allocations. The allocations are stored as sdk.DecCoins where each containing sdk.DecCoin arrow-up-rightdescribes the percentage of rewards (Amount) that are allocated to the contract for a given coin denomination (Denom). An incentive can contain several allocations, resulting in users to receive rewards in form of several different denominations.

GasMeter

Tracks the cumulative gas spent in a contract per participant during one epoch.

AllocationMeter

An allocation meter stores the sum of all registered incentives’ allocations for a given denomination and is used to limit the amount of registered incentives.

Say, there are several incentives that have registered an allocation for the $BCX coin and the allocation meter for $BCX is at 97%. Then a new incentive proposal can only include an $BCX allocation at up to 3%, claiming the last remaining allocation capacity from the $BCX rewards in the inflation pool.

Genesis State

The x/incentives module's GenesisState defines the state necessary for initializing the chain from a previously exported height. It contains the module parameters and the list of active incentives and their corresponding gas meters: