keeper

package
v0.0.3-0...-8a3f181 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

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 NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

NewQueryServerImpl returns an implementation of the QueryServer 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 {
	Schema         collections.Schema
	Params         collections.Item[types.Params]
	MatchedBidsLen collections.Map[uint64, int64]
	AllowedBidder  collections.Map[collections.Pair[uint64, sdk.AccAddress], types.AllowedBidder]
	VestingQueue   collections.Map[collections.Pair[uint64, time.Time], types.VestingQueue]
	BidSeq         collections.Map[uint64, uint64]
	Bid            collections.Map[collections.Pair[uint64, uint64], types.Bid]
	AuctionSeq     collections.Sequence
	Auction        collections.Map[uint64, types.AuctionI]
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	addressCodec address.Codec,
	storeService store.KVStoreService,
	logger log.Logger,
	authority string,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	distrKeeper types.DistrKeeper,
) Keeper

func (Keeper) AddAllowedBidders

func (k Keeper) AddAllowedBidders(ctx context.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) AddressCodec

func (k Keeper) AddressCodec() address.Codec

AddressCodec returns the address codec.

func (Keeper) AfterBatchAuctionCreated

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

AfterBatchAuctionCreated - call hook if registered

func (Keeper) AfterFixedPriceAuctionCreated

func (k Keeper) AfterFixedPriceAuctionCreated(
	ctx context.Context,
	auctionID uint64,
	auctioneer string,
	startPrice math.LegacyDec,
	sellingCoin sdk.Coin,
	payingCoinDenom string,
	vestingSchedules []types.VestingSchedule,
	startTime time.Time,
	endTime time.Time,
) error

AfterFixedPriceAuctionCreated - call hook if registered

func (Keeper) AllocateSellingCoin

func (k Keeper) AllocateSellingCoin(ctx context.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) AllowedBidders

func (k Keeper) AllowedBidders(ctx context.Context) ([]types.AllowedBidder, error)

AllowedBidders returns all AllowedBidder.

func (Keeper) ApplyVestingSchedules

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

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

func (Keeper) Auctions

func (k Keeper) Auctions(ctx context.Context) ([]types.AuctionI, error)

Auctions returns all Actions.

func (Keeper) BeforeAllowedBidderUpdated

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

BeforeAllowedBidderUpdated - call hook if registered

func (Keeper) BeforeAllowedBiddersAdded

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

BeforeAllowedBiddersAdded - call hook if registered

func (Keeper) BeforeAuctionCanceled

func (k Keeper) BeforeAuctionCanceled(
	ctx context.Context,
	auctionID uint64,
	auctioneer string,
) error

BeforeAuctionCanceled - call hook if registered

func (Keeper) BeforeBatchAuctionCreated

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

BeforeBatchAuctionCreated - call hook if registered

func (Keeper) BeforeBidModified

func (k Keeper) BeforeBidModified(
	ctx context.Context,
	auctionID uint64,
	bidID uint64,
	bidder string,
	bidType types.BidType,
	price math.LegacyDec,
	coin sdk.Coin,
) error

BeforeBidModified - call hook if registered

func (Keeper) BeforeBidPlaced

func (k Keeper) BeforeBidPlaced(
	ctx context.Context,
	auctionID uint64,
	bidID uint64,
	bidder string,
	bidType types.BidType,
	price math.LegacyDec,
	coin sdk.Coin,
) error

BeforeBidPlaced - call hook if registered

func (Keeper) BeforeFixedPriceAuctionCreated

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

BeforeFixedPriceAuctionCreated - call hook if registered

func (Keeper) BeforeSellingCoinsAllocated

func (k Keeper) BeforeSellingCoinsAllocated(
	ctx context.Context,
	auctionID uint64,
	allocationMap map[string]math.Int,
	refundMap map[string]math.Int,
) error

BeforeSellingCoinsAllocated - call hook if registered

func (Keeper) BeginBlocker

func (k Keeper) BeginBlocker(ctx context.Context) error

func (Keeper) Bids

func (k Keeper) Bids(ctx context.Context) ([]types.Bid, error)

Bids returns all Bid.

func (Keeper) CalculateBatchAllocation

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

func (Keeper) CalculateFixedPriceAllocation

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

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

func (Keeper) CancelAuction

func (k Keeper) CancelAuction(ctx context.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 context.Context, auction types.AuctionI) error

CloseBatchAuction closes a batch auction.

func (Keeper) CloseFixedPriceAuction

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

CloseFixedPriceAuction closes a fixed price auction.

func (Keeper) CreateBatchAuction

func (k Keeper) CreateBatchAuction(ctx context.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 context.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 context.Context, auction types.AuctionI) error

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

func (Keeper) ExecuteStartedStatus

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

ExecuteStartedStatus executes operations depending on the auction type.

func (Keeper) ExecuteVestingStatus

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

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) ExtendRound

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

ExtendRound extends another round of ExtendedPeriod value for the auction.

func (Keeper) GetAllowedBidder

func (k Keeper) GetAllowedBidder(ctx context.Context, auctionID uint64, bidder sdk.AccAddress) (types.AllowedBidder, error)

GetAllowedBidder returns AllowedBidder by auction ID and bidder address.

func (Keeper) GetAllowedBiddersByAuction

func (k Keeper) GetAllowedBiddersByAuction(ctx context.Context, auctionID uint64) ([]types.AllowedBidder, error)

GetAllowedBiddersByAuction returns allowed bidders list for the auction.

func (Keeper) GetAuction

func (k Keeper) GetAuction(ctx context.Context, auctionID uint64) (types.AuctionI, error)

GetAuction returns Auction interface by auction ID.

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the module's authority.

func (Keeper) GetBid

func (k Keeper) GetBid(ctx context.Context, auctionID, bidID uint64) (types.Bid, error)

GetBid returns Bid by auction ID and bid ID.

func (Keeper) GetBidsByAuctionID

func (k Keeper) GetBidsByAuctionID(ctx context.Context, auctionID uint64) ([]types.Bid, error)

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

func (Keeper) GetBidsByBidder

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

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

func (Keeper) GetLastMatchedBidsLen

func (k Keeper) GetLastMatchedBidsLen(ctx context.Context, auctionID uint64) (int64, error)

func (Keeper) GetNextBidIDWithUpdate

func (k Keeper) GetNextBidIDWithUpdate(ctx context.Context, auctionID uint64) (uint64, error)

GetNextBidIDWithUpdate increments bid id by one and set it.

func (Keeper) GetVestingQueue

func (k Keeper) GetVestingQueue(ctx context.Context, auctionID uint64, releaseTime time.Time) (types.VestingQueue, error)

GetVestingQueue returns VestingQueue by auction ID and release time.

func (Keeper) GetVestingQueuesByAuctionID

func (k Keeper) GetVestingQueuesByAuctionID(ctx context.Context, auctionID uint64) ([]types.VestingQueue, error)

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

func (Keeper) Logger

func (k Keeper) Logger() log.Logger

Logger returns a module-specific logger.

func (Keeper) ModifyBid

func (k Keeper) ModifyBid(ctx context.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 context.Context, auctioneerAddr sdk.AccAddress) error

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

func (Keeper) PayPlaceBidFee

func (k Keeper) PayPlaceBidFee(ctx context.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 context.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 context.Context, auction types.AuctionI, mInfo MatchingInfo) error

RefundPayingCoin refunds paying coin to the corresponding bidders.

func (Keeper) RefundRemainingSellingCoin

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

RefundRemainingSellingCoin refunds the remaining selling coin to the auctioneer.

func (Keeper) ReleaseVestingPayingCoin

func (k Keeper) ReleaseVestingPayingCoin(ctx context.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 context.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 context.Context, auctionID uint64, auctioneerAddr sdk.AccAddress, sellingCoin sdk.Coin) error

ReserveSellingCoin reserves the selling coin to the selling reserve account.

func (*Keeper) SetHooks

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

SetHooks sets the fundraising hooks.

func (Keeper) SetMatchedBidsLen

func (k Keeper) SetMatchedBidsLen(ctx context.Context, auctionID uint64, matchedLen int64) error

func (Keeper) UpdateAllowedBidder

func (k Keeper) UpdateAllowedBidder(ctx context.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 context.Context, auction types.AuctionI, bid types.Bid) error

ValidateBatchManyBid validates a batch many bid type.

func (Keeper) ValidateBatchWorthBid

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

ValidateBatchWorthBid validates a batch worth bid type.

func (Keeper) ValidateFixedPriceBid

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

ValidateFixedPriceBid validates a fixed price bid type.

func (Keeper) VestingQueues

func (k Keeper) VestingQueues(ctx context.Context) ([]types.VestingQueue, error)

VestingQueues returns all VestingQueue.

type MatchingInfo

type MatchingInfo struct {
	MatchedLen         int64               // the length of matched bids
	MatchedPrice       math.LegacyDec      // 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.

Jump to

Keyboard shortcuts

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