keeper

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// EnableAddAllowedBidder indicates whether msgServer accepts MsgAddAllowedBidder or not.
	// Never set this to true in production environment. Doing that will expose serious attack vector.
	// Default is false, which means AddAllowedBidder can't be executed through message level.
	EnableAddAllowedBidder = false
)

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the fundraising module.

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

func PayingPoolReserveAmountInvariant

func PayingPoolReserveAmountInvariant(k Keeper) sdk.Invariant

PayingPoolReserveAmountInvariant checks an invariant that the total bid amount must equal or greater than the paying reserve account balance.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all fundraising invariants.

func SellingPoolReserveAmountInvariant

func SellingPoolReserveAmountInvariant(k Keeper) sdk.Invariant

SellingPoolReserveAmountInvariant checks an invariant that the total amount of selling coin for an auction must equal or greater than the selling reserve account balance.

func VestingPoolReserveAmountInvariant

func VestingPoolReserveAmountInvariant(k Keeper) sdk.Invariant

VestingPoolReserveAmountInvariant checks an invariant that the total vesting amount must be equal or greater than the vesting reserve account balance.

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	key storetypes.StoreKey,
	memKey storetypes.StoreKey,
	paramSpace paramtypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	distrKeeper types.DistrKeeper,
) Keeper

func (Keeper) AddAllowedBidders

func (k Keeper) AddAllowedBidders(ctx sdk.Context, auctionId uint64, allowedBidders []types.AllowedBidder) error

AddAllowedBidders is a function that is implemented for an external module. An external module uses this function to add allowed bidders in the auction's allowed bidders list. It doesn't look up the bidder's previous maximum bid amount. Instead, it overlaps. It doesn't have any auctioneer's verification logic because the module is fundamentally designed to delegate full authorization to an external module. It is up to an external module to freely add necessary verification and operations depending on their use cases.

func (Keeper) AfterBatchAuctionCreated

func (k Keeper) AfterBatchAuctionCreated(
	ctx sdk.Context,
	auctionId uint64,
	auctioneer string,
	startPrice sdk.Dec,
	minBidPrice sdk.Dec,
	sellingCoin sdk.Coin,
	payingCoinDenom string,
	vestingSchedules []types.VestingSchedule,
	maxExtendedRound uint32,
	extendedRoundRate sdk.Dec,
	startTime time.Time,
	endTime time.Time,
)

AfterBatchAuctionCreated - call hook if registered

func (Keeper) AfterFixedPriceAuctionCreated

func (k Keeper) AfterFixedPriceAuctionCreated(
	ctx sdk.Context,
	auctionId uint64,
	auctioneer string,
	startPrice sdk.Dec,
	sellingCoin sdk.Coin,
	payingCoinDenom string,
	vestingSchedules []types.VestingSchedule,
	startTime time.Time,
	endTime time.Time,
)

AfterFixedPriceAuctionCreated - call hook if registered

func (Keeper) AllocateSellingCoin

func (k Keeper) AllocateSellingCoin(ctx sdk.Context, auction types.AuctionI, mInfo MatchingInfo) error

AllocateSellingCoin allocates allocated selling coin for all matched bids in MatchingInfo and releases them from the selling reserve account.

func (Keeper) ApplyVestingSchedules

func (k Keeper) ApplyVestingSchedules(ctx sdk.Context, auction types.AuctionI) error

ApplyVestingSchedules stores vesting queues based on the vesting schedules of the auction and sets status to vesting.

func (Keeper) BeforeAllowedBidderUpdated

func (k Keeper) BeforeAllowedBidderUpdated(
	ctx sdk.Context,
	auctionId uint64,
	bidder sdk.AccAddress,
	maxBidAmount math.Int,
)

BeforeAllowedBidderUpdated - call hook if registered

func (Keeper) BeforeAllowedBiddersAdded

func (k Keeper) BeforeAllowedBiddersAdded(
	ctx sdk.Context,
	allowedBidders []types.AllowedBidder,
)

BeforeAllowedBiddersAdded - call hook if registered

func (Keeper) BeforeAuctionCanceled

func (k Keeper) BeforeAuctionCanceled(
	ctx sdk.Context,
	auctionId uint64,
	auctioneer string,
)

BeforeAuctionCanceled - call hook if registered

func (Keeper) BeforeBatchAuctionCreated

func (k Keeper) BeforeBatchAuctionCreated(
	ctx sdk.Context,
	auctioneer string,
	startPrice sdk.Dec,
	minBidPrice sdk.Dec,
	sellingCoin sdk.Coin,
	payingCoinDenom string,
	vestingSchedules []types.VestingSchedule,
	maxExtendedRound uint32,
	extendedRoundRate sdk.Dec,
	startTime time.Time,
	endTime time.Time,
)

BeforeBatchAuctionCreated - call hook if registered

func (Keeper) BeforeBidModified

func (k Keeper) BeforeBidModified(
	ctx sdk.Context,
	auctionId uint64,
	bidId uint64,
	bidder string,
	bidType types.BidType,
	price sdk.Dec,
	coin sdk.Coin,
)

BeforeBidModified - call hook if registered

func (Keeper) BeforeBidPlaced

func (k Keeper) BeforeBidPlaced(
	ctx sdk.Context,
	auctionId uint64,
	bidId uint64,
	bidder string,
	bidType types.BidType,
	price sdk.Dec,
	coin sdk.Coin,
)

BeforeBidPlaced - call hook if registered

func (Keeper) BeforeFixedPriceAuctionCreated

func (k Keeper) BeforeFixedPriceAuctionCreated(
	ctx sdk.Context,
	auctioneer string,
	startPrice sdk.Dec,
	sellingCoin sdk.Coin,
	payingCoinDenom string,
	vestingSchedules []types.VestingSchedule,
	startTime time.Time,
	endTime time.Time,
)

BeforeFixedPriceAuctionCreated - call hook if registered

func (Keeper) BeforeSellingCoinsAllocated

func (k Keeper) BeforeSellingCoinsAllocated(
	ctx sdk.Context,
	auctionId uint64,
	allocationMap map[string]math.Int,
	refundMap map[string]math.Int,
)

BeforeSellingCoinsAllocated - call hook if registered

func (Keeper) CalculateBatchAllocation

func (k Keeper) CalculateBatchAllocation(ctx sdk.Context, auction types.AuctionI) MatchingInfo

func (Keeper) CalculateFixedPriceAllocation

func (k Keeper) CalculateFixedPriceAllocation(ctx sdk.Context, auction types.AuctionI) MatchingInfo

CalculateFixedPriceAllocation loops through all bids for the auction and calculate matching information.

func (Keeper) CancelAuction

func (k Keeper) CancelAuction(ctx sdk.Context, msg *types.MsgCancelAuction) error

CancelAuction handles types.MsgCancelAuction and cancels the auction. An auction can only be canceled when it is not started yet.

func (Keeper) CloseBatchAuction

func (k Keeper) CloseBatchAuction(ctx sdk.Context, auction types.AuctionI)

CloseBatchAuction closes a batch auction.

func (Keeper) CloseFixedPriceAuction

func (k Keeper) CloseFixedPriceAuction(ctx sdk.Context, auction types.AuctionI)

CloseFixedPriceAuction closes a fixed price auction.

func (Keeper) CreateBatchAuction

func (k Keeper) CreateBatchAuction(ctx sdk.Context, msg *types.MsgCreateBatchAuction) (types.AuctionI, error)

CreateBatchAuction handles types.MsgCreateBatchAuction and create a batch auction. Note that the module is designed to delegate authorization to an external module to add allowed bidders for the auction.

func (Keeper) CreateFixedPriceAuction

func (k Keeper) CreateFixedPriceAuction(ctx sdk.Context, msg *types.MsgCreateFixedPriceAuction) (types.AuctionI, error)

CreateFixedPriceAuction handles types.MsgCreateFixedPriceAuction and create a fixed price auction. Note that the module is designed to delegate authorization to an external module to add allowed bidders for the auction.

func (Keeper) ExecuteStandByStatus

func (k Keeper) ExecuteStandByStatus(ctx sdk.Context, auction types.AuctionI)

ExecuteStandByStatus simply updates the auction status to AuctionStatusStarted if the auction is ready to get started.

func (Keeper) ExecuteStartedStatus

func (k Keeper) ExecuteStartedStatus(ctx sdk.Context, auction types.AuctionI)

ExecuteStartedStatus executes operations depending on the auction type.

func (Keeper) ExecuteVestingStatus

func (k Keeper) ExecuteVestingStatus(ctx sdk.Context, auction types.AuctionI)

ExecuteVestingStatus first gets all vesting queues in the store and look up the release time of each vesting queue to see if the module needs to distribute the paying coin to the auctioneer.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis returns the module's exported genesis state.

func (Keeper) ExtendRound

func (k Keeper) ExtendRound(ctx sdk.Context, ba *types.BatchAuction)

ExtendRound extends another round of ExtendedPeriod value for the auction.

func (Keeper) GetAllowedBidder

func (k Keeper) GetAllowedBidder(ctx sdk.Context, auctionId uint64, bidderAddr sdk.AccAddress) (allowedBidder types.AllowedBidder, found bool)

GetAllowedBidder returns an allowed bidder object for the given auction id and bidder address.

func (Keeper) GetAllowedBiddersByAuction

func (k Keeper) GetAllowedBiddersByAuction(ctx sdk.Context, auctionId uint64) (allowedBidders []types.AllowedBidder)

GetAllowedBiddersByAuction returns allowed bidders list for the auction.

func (Keeper) GetAuction

func (k Keeper) GetAuction(ctx sdk.Context, id uint64) (auction types.AuctionI, found bool)

GetAuction returns an auction interface from the given auction id.

func (Keeper) GetAuctions

func (k Keeper) GetAuctions(ctx sdk.Context) (auctions []types.AuctionI)

GetAuctions returns all auctions in the store.

func (Keeper) GetBid

func (k Keeper) GetBid(ctx sdk.Context, auctionId uint64, bidId uint64) (bid types.Bid, found bool)

GetBid returns a bid for the given auction id and bid id. A bidder can have as many bids as they want, so bid id is required to get the bid.

func (Keeper) GetBids

func (k Keeper) GetBids(ctx sdk.Context) []types.Bid

GetBids returns all bids registered in the store.

func (Keeper) GetBidsByAuctionId

func (k Keeper) GetBidsByAuctionId(ctx sdk.Context, auctionId uint64) []types.Bid

GetBidsByAuctionId returns all bids associated with the auction id that are registered in the store.

func (Keeper) GetBidsByBidder

func (k Keeper) GetBidsByBidder(ctx sdk.Context, bidderAddr sdk.AccAddress) []types.Bid

GetBidsByBidder returns all bids associated with the bidder that are registered in the store.

func (Keeper) GetLastAuctionId

func (k Keeper) GetLastAuctionId(ctx sdk.Context) uint64

GetLastAuctionId returns the last auction id.

func (Keeper) GetLastBidId

func (k Keeper) GetLastBidId(ctx sdk.Context, auctionId uint64) uint64

GetLastBidId returns the last bid id for the bid.

func (Keeper) GetLastMatchedBidsLen

func (k Keeper) GetLastMatchedBidsLen(ctx sdk.Context, auctionId uint64) int64

func (Keeper) GetNextAuctionIdWithUpdate

func (k Keeper) GetNextAuctionIdWithUpdate(ctx sdk.Context) uint64

GetNextAuctionIdWithUpdate increments auction id by one and store it.

func (Keeper) GetNextBidIdWithUpdate

func (k Keeper) GetNextBidIdWithUpdate(ctx sdk.Context, auctionId uint64) uint64

GetNextBidId increments bid id by one and set it.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams returns the parameters for the fundraising module.

func (Keeper) GetVestingQueue

func (k Keeper) GetVestingQueue(ctx sdk.Context, auctionId uint64, releaseTime time.Time) types.VestingQueue

GetVestingQueue returns a slice of vesting queues that the auction is complete and waiting in a queue to release the vesting amount of coin at the respective release time.

func (Keeper) GetVestingQueues

func (k Keeper) GetVestingQueues(ctx sdk.Context) []types.VestingQueue

GetVestingQueues returns all vesting queues registered in the store.

func (Keeper) GetVestingQueuesByAuctionId

func (k Keeper) GetVestingQueuesByAuctionId(ctx sdk.Context, auctionId uint64) []types.VestingQueue

GetVestingQueuesByAuctionId returns all vesting queues associated with the auction id that are registered in the store.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)

InitGenesis initializes the module's state from a provided genesis state.

func (Keeper) IterateAllowedBiddersByAuction

func (k Keeper) IterateAllowedBiddersByAuction(ctx sdk.Context, auctionId uint64, cb func(ab types.AllowedBidder) (stop bool, err error)) error

IterateAllowedBiddersByAuction iterates through all the allowed bidder for the auction and call cb for each allowed bidder.

func (Keeper) IterateAuctions

func (k Keeper) IterateAuctions(ctx sdk.Context, cb func(auction types.AuctionI) (stop bool))

IterateAuctions iterates over all the stored auctions and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateBids

func (k Keeper) IterateBids(ctx sdk.Context, cb func(bid types.Bid) (stop bool))

IterateBids iterates through all bids stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateBidsByAuctionId

func (k Keeper) IterateBidsByAuctionId(ctx sdk.Context, auctionId uint64, cb func(bid types.Bid) (stop bool))

IterateBidsByAuctionId iterates through all bids associated with the auction id stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateBidsByBidder

func (k Keeper) IterateBidsByBidder(ctx sdk.Context, bidderAddr sdk.AccAddress, cb func(bid types.Bid) (stop bool))

IterateBidsByBidder iterates through all bids associated with the bidder stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateVestingQueues

func (k Keeper) IterateVestingQueues(ctx sdk.Context, cb func(queue types.VestingQueue) (stop bool))

IterateVestingQueues iterates through all VestingQueues and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) IterateVestingQueuesByAuctionId

func (k Keeper) IterateVestingQueuesByAuctionId(ctx sdk.Context, auctionId uint64, cb func(queue types.VestingQueue) (stop bool))

IterateVestingQueuesByAuctionId iterates through all VestingQueues associated with the auction id stored in the store and invokes callback function for each item. Stops the iteration when the callback function returns true.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) ModifyBid

func (k Keeper) ModifyBid(ctx sdk.Context, msg *types.MsgModifyBid) error

ModifyBid handles types.MsgModifyBid and stores the modified bid. A bidder must provide either greater bid price or coin amount. They are not permitted to modify with less bid price or coin amount.

func (Keeper) PayCreationFee

func (k Keeper) PayCreationFee(ctx sdk.Context, auctioneerAddr sdk.AccAddress) error

PayCreationFee sends the auction creation fee to the fee collector account.

func (Keeper) PayPlaceBidFee

func (k Keeper) PayPlaceBidFee(ctx sdk.Context, bidderAddr sdk.AccAddress) error

PayPlaceBidFee sends the fee when placing a bid for an auction to the fee collector account.

func (Keeper) PlaceBid

func (k Keeper) PlaceBid(ctx sdk.Context, msg *types.MsgPlaceBid) (types.Bid, error)

PlaceBid places a bid for the selling coin of the auction.

func (Keeper) RefundPayingCoin

func (k Keeper) RefundPayingCoin(ctx sdk.Context, auction types.AuctionI, mInfo MatchingInfo) error

RefundPayingCoin refunds paying coin to the corresponding bidders.

func (Keeper) RefundRemainingSellingCoin

func (k Keeper) RefundRemainingSellingCoin(ctx sdk.Context, auction types.AuctionI) error

RefundRemainingSellingCoin refunds the remaining selling coin to the auctioneer.

func (Keeper) ReleaseVestingPayingCoin

func (k Keeper) ReleaseVestingPayingCoin(ctx sdk.Context, auction types.AuctionI) error

ReleaseVestingPayingCoin releases the vested selling coin to the auctioneer from the vesting reserve account.

func (Keeper) ReservePayingCoin

func (k Keeper) ReservePayingCoin(ctx sdk.Context, auctionId uint64, bidderAddr sdk.AccAddress, payingCoin sdk.Coin) error

ReservePayingCoin reserves paying coin to the paying reserve account.

func (Keeper) ReserveSellingCoin

func (k Keeper) ReserveSellingCoin(ctx sdk.Context, auctionId uint64, auctioneerAddr sdk.AccAddress, sellingCoin sdk.Coin) error

ReserveSellingCoin reserves the selling coin to the selling reserve account.

func (Keeper) SetAllowedBidder

func (k Keeper) SetAllowedBidder(ctx sdk.Context, auctionId uint64, allowedBidder types.AllowedBidder)

SetAllowedBidder stores an allowed bidder object for the auction.

func (Keeper) SetAuction

func (k Keeper) SetAuction(ctx sdk.Context, auction types.AuctionI)

SetAuction sets an auction with the given auction id.

func (Keeper) SetAuctionId

func (k Keeper) SetAuctionId(ctx sdk.Context, id uint64)

SetAuctionId stores the last auction id.

func (Keeper) SetBid

func (k Keeper) SetBid(ctx sdk.Context, bid types.Bid)

SetBid sets a bid with the given arguments.

func (Keeper) SetBidId

func (k Keeper) SetBidId(ctx sdk.Context, auctionId uint64, bidId uint64)

SetBidId sets the bid id for the auction.

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(fk types.FundraisingHooks) *Keeper

SetHooks sets the fundraising hooks.

func (Keeper) SetMatchedBidsLen

func (k Keeper) SetMatchedBidsLen(ctx sdk.Context, auctionId uint64, matchedLen int64)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the parameters for the fundraising module.

func (Keeper) SetVestingQueue

func (k Keeper) SetVestingQueue(ctx sdk.Context, queue types.VestingQueue)

SetVestingQueue sets vesting queue into with the given release time and auction id.

func (Keeper) UpdateAllowedBidder

func (k Keeper) UpdateAllowedBidder(ctx sdk.Context, auctionId uint64, bidder sdk.AccAddress, maxBidAmount math.Int) error

UpdateAllowedBidder is a function that is implemented for an external module. An external module uses this function to update maximum bid amount of particular allowed bidder in the auction. It doesn't have any auctioneer's verification logic because the module is fundamentally designed to delegate full authorization to an external module. It is up to an external module to freely add necessary verification and operations depending on their use cases.

func (Keeper) ValidateBatchManyBid

func (k Keeper) ValidateBatchManyBid(ctx sdk.Context, auction types.AuctionI, bid types.Bid) error

ValidateBatchManyBid validates a batch many bid type.

func (Keeper) ValidateBatchWorthBid

func (k Keeper) ValidateBatchWorthBid(ctx sdk.Context, auction types.AuctionI, bid types.Bid) error

ValidateBatchWorthBid validates a batch worth bid type.

func (Keeper) ValidateFixedPriceBid

func (k Keeper) ValidateFixedPriceBid(ctx sdk.Context, auction types.AuctionI, bid types.Bid) error

ValidateFixedPriceBid validates a fixed price bid type.

type MatchingInfo

type MatchingInfo struct {
	MatchedLen         int64               // the length of matched bids
	MatchedPrice       sdk.Dec             // the final matched price
	TotalMatchedAmount math.Int            // the total sold amount
	AllocationMap      map[string]math.Int // the map that holds allocate amount information for each bidder
	ReservedMatchedMap map[string]math.Int // the map that holds each bidder's matched amount out of their total reserved amount
	RefundMap          map[string]math.Int // the map that holds refund amount information for each bidder
}

MatchingInfo holds information about an auction matching information.

type Querier

type Querier struct {
	Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper.

func (Querier) AllowedBidder

AllowedBidder queries the specific allowed bidder information.

func (Querier) AllowedBidders

AllowedBidders queries all allowed bidders for the auction.

func (Querier) Auction

Auction queries the specific auction.

func (Querier) Auctions

Auctions queries all auctions.

func (Querier) Bid

Bid queries the specific bid from the auction id and bid id.

func (Querier) Bids

Bids queries all bids for the auction.

func (Querier) Params

Params queries the parameters of the fundraising module.

func (Querier) Vestings

Vestings queries all vesting queues for the auction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL