logo
pub trait Auction: StorageProvider + RuntimeProvider + MintProvider + AccountProvider + Sized {
    fn get_era_validators(&mut self) -> Result<EraValidators, Error> { ... }
    fn read_seigniorage_recipients(
        &mut self
    ) -> Result<SeigniorageRecipients, Error> { ... } fn add_bid(
        &mut self,
        public_key: PublicKey,
        delegation_rate: DelegationRate,
        amount: U512
    ) -> Result<U512, ApiError> { ... } fn withdraw_bid(
        &mut self,
        public_key: PublicKey,
        amount: U512
    ) -> Result<U512, Error> { ... } fn delegate(
        &mut self,
        delegator_public_key: PublicKey,
        validator_public_key: PublicKey,
        amount: U512,
        max_delegator_size_limit: usize,
        minimum_delegation_amount: u64
    ) -> Result<U512, ApiError> { ... } fn undelegate(
        &mut self,
        delegator_public_key: PublicKey,
        validator_public_key: PublicKey,
        amount: U512
    ) -> Result<U512, Error> { ... } fn slash(
        &mut self,
        validator_public_keys: Vec<PublicKey>
    ) -> Result<(), Error> { ... } fn run_auction(
        &mut self,
        era_end_timestamp_millis: u64,
        evicted_validators: Vec<PublicKey>
    ) -> Result<(), Error> { ... } fn distribute(
        &mut self,
        reward_factors: BTreeMap<PublicKey, u64>
    ) -> Result<(), Error> { ... } fn read_era_id(&mut self) -> Result<EraId, Error> { ... } fn activate_bid(
        &mut self,
        validator_public_key: PublicKey
    ) -> Result<(), Error> { ... } }
Expand description

Bonding auction contract interface

Provided methods

Returns active validators and auction winners for a number of future eras determined by the configured auction_delay.

Returns validators in era_validators, mapped to their bids or founding stakes, delegation rates and lists of delegators together with their delegated quantities from delegators. This function is publicly accessible, but intended for system use by the Handle Payment contract, because this data is necessary for distributing seigniorage.

This entry point adds or modifies an entry in the Key::Bid section of the global state and creates (or tops off) a bid purse. Post genesis, any new call on this entry point causes a non-founding validator in the system to exist.

The logic works for both founding and non-founding validators, making it possible to adjust their delegation rate and increase their stakes.

A validator with its bid inactive due to slashing can activate its bid again by increasing its stake.

Validators cannot create a bid with 0 amount, and the delegation rate can’t exceed DELEGATION_RATE_DENOMINATOR.

Returns a U512 value indicating total amount of tokens staked for given public_key.

For a non-founder validator, this method simply decreases a stake.

For a founding validator, this function first checks whether they are released and fails if they are not.

When a validator’s stake reaches 0 all the delegators that bid their tokens to it are automatically unbonded with their total staked amount and the bid is deactivated. A bid can be activated again by staking tokens.

You can’t withdraw higher amount than its currently staked. Withdrawing zero is allowed, although it does not change the state of the auction.

The function returns the new amount of motes remaining in the bid. If the target bid does not exist, the function call returns an error.

Adds a new delegator to delegators or increases its current stake. If the target validator is missing, the function call returns an error and does nothing.

The function transfers motes from the source purse to the delegator’s bonding purse.

This entry point returns the number of tokens currently delegated to a given validator.

Removes specified amount of motes (or the value from the collection altogether, if the remaining amount is 0) from the entry in delegators map for given validator and creates a new unbonding request to the queue.

The arguments are the delegator’s key, the validator’s key, and the amount.

Returns the remaining bid amount after the stake was decreased.

Slashes each validator.

This can be only invoked through a system call.

Takes active_bids and delegators to construct a list of validators’ total bids (their own added to their delegators’) ordered by size from largest to smallest, then takes the top N (number of auction slots) bidders and replaces era_validators with these.

Accessed by: node

Mint and distribute seigniorage rewards to validators and their delegators, according to reward_factors returned by the consensus component.

Reads current era id.

Activates a given validator’s bid. To be used when a validator has been marked as inactive by consensus (aka “evicted”).

Implementors