Cardanoex.StakePool (cardanoex v0.6.3)

The stake pool module let's you manage stake pools.

Link to this section Summary

Functions

Estimate fee for joining or leaving a stake pool. Note that it is an estimation because a delegation induces a transaction for which coins have to be selected randomly within the wallet. Because of this randomness, fees can only be estimated.

Delegate all (current and future) addresses from the given wallet to the given stake pool.

List all known stake pools ordered by descending non_myopic_member_rewards. The non_myopic_member_rewards — and thus the ordering — depends on the stake parameter.

List stake-keys relevant to the wallet, and how much ada is associated with each.

Stop delegating completely. The wallet's stake will become inactive.

Performs maintenance actions on stake pools, such as triggering metadata garbage collection.

Returns the current status of the stake pools maintenance actions.

Link to this section Types

Link to this type

fee_estimation()

@type fee_estimation() :: %{
  estimated_min: %{quantity: non_neg_integer(), unit: String.t()},
  estimated_max: %{quantity: non_neg_integer(), unit: String.t()},
  minimum_coins: [%{quantity: non_neg_integer(), unit: String.t()}],
  deposit: %{quantity: non_neg_integer(), unit: String.t()}
}
@type stake_key() :: %{
  ours: [
    %{
      index: non_neg_integer(),
      key: String.t(),
      stake: %{quantity: non_neg_integer(), unit: String.t()},
      reward_balance: %{quantity: non_neg_integer(), unit: String.t()},
      delegation: %{
        active: %{status: String.t(), target: String.t()},
        next: [
          %{
            status: String.t(),
            target: String.t(),
            changes_at: %{
              epoch_number: non_neg_integer(),
              epoch_start_time: String.t()
            }
          }
        ]
      }
    }
  ],
  foreign: [
    %{
      key: String.t(),
      stake: %{quantity: non_neg_integer(), unit: String.t()},
      reward_balance: %{quantity: non_neg_integer(), unit: String.t()}
    }
  ],
  none: %{stake: %{quantity: non_neg_integer(), unit: String.t()}}
}
Link to this type

stake_pool()

@type stake_pool() :: %{
  id: String.t(),
  metrics: %{
    non_myopic_member_rewards: %{quantity: non_neg_integer(), unit: String.t()}
  },
  relative_stake: %{quantity: float(), unit: String.t()},
  saturation: float(),
  produced_blocks: %{quantity: non_neg_integer(), unit: String.t()},
  cost: %{quantity: non_neg_integer(), unit: String.t()},
  margin: %{quantity: float(), unit: String.t()},
  pledge: %{quantity: non_neg_integer(), unit: String.t()},
  metadata: %{
    ticker: String.t(),
    name: String.t(),
    description: String.t(),
    homepage: String.t()
  },
  retirement: %{epoch_number: non_neg_integer(), epoch_start_time: String.t()},
  flags: [String.t()]
}

Link to this section Functions

Link to this function

estimate_fee(wallet_id)

@spec estimate_fee(String.t()) :: {:error, String.t()} | {:ok, fee_estimation()}

Estimate fee for joining or leaving a stake pool. Note that it is an estimation because a delegation induces a transaction for which coins have to be selected randomly within the wallet. Because of this randomness, fees can only be estimated.

options

Options

  • wallet_id - hex based string. 40 characters
Link to this function

join(wallet_id, stake_pool_id, passphrase)

@spec join(String.t(), String.t(), String.t()) ::
  {:error, String.t()} | {:ok, Cardanoex.Transaction.transaction()}

Delegate all (current and future) addresses from the given wallet to the given stake pool.

Note: Bech32-encoded stake pool identifiers can vary in length.

options

Options

  • wallet_id - hex based string. 40 characters
  • stake_pool_id - hex|bech32 string
  • passphrase - Wallet passphrase
@spec list(non_neg_integer()) :: {:error, String.t()} | {:ok, [stake_pool()]}

List all known stake pools ordered by descending non_myopic_member_rewards. The non_myopic_member_rewards — and thus the ordering — depends on the stake parameter.

Some pools may also have metadata attached to them.

options

Options

  • stake - The stake the user intends to delegate in Lovelace. Required.
Link to this function

list_stake_keys(wallet_id)

@spec list_stake_keys(String.t()) :: {:error, String.t()} | {:ok, stake_key()}

List stake-keys relevant to the wallet, and how much ada is associated with each.

options

Options

  • wallet_id - hex based string. 40 characters
Link to this function

quit(wallet_id, passphrase)

@spec quit(String.t(), String.t()) ::
  {:error, String.t()} | {:ok, Cardanoex.Transaction.transaction()}

Stop delegating completely. The wallet's stake will become inactive.

options

Options

  • wallet_id - hex based string. 40 characters
  • passphrase - Wallet passphrase
Link to this function

trigger_maintenance_action(action)

@spec trigger_maintenance_action(String.t()) :: :ok | {:error, String.t()}

Performs maintenance actions on stake pools, such as triggering metadata garbage collection.

Actions may not be instantaneous.

Link to this function

view_maintenance_actions()

@spec view_maintenance_actions() ::
  {:error, String.t()}
  | {:ok, %{gc_stake_pools: %{status: String.t(), last_run: String.t()}}}

Returns the current status of the stake pools maintenance actions.