Class: Coinbase::StakingBalance
- Inherits:
-
Object
- Object
- Coinbase::StakingBalance
- Defined in:
- lib/coinbase/staking_balance.rb
Overview
A representation of a staking balance on a network for a given asset.
Class Method Summary collapse
-
.list(network, asset_id, address_id, start_time: DateTime.now.prev_month(1), end_time: DateTime.now) ⇒ Enumerable<Coinbase::StakingBalance>
Returns a list of StakingBalance for the provided network, asset, and addresses.
Instance Method Summary collapse
-
#address ⇒ Time
Returns the onchain address of the StakingBalance.
-
#bonded_stake ⇒ Balance
Returns the bonded stake as a Balance.
-
#date ⇒ Time
Returns the date of the StakingBalance.
-
#initialize(model) ⇒ StakingBalance
constructor
Returns a new StakingBalance object.
-
#inspect ⇒ String
Same as to_s.
-
#participant_type ⇒ String
Returns the participant type of the StakingBalance.
-
#to_s ⇒ String
Returns a string representation of the StakingBalance.
-
#unbonded_balance ⇒ Balance
Returns the unbonded balance as a Balance.
Constructor Details
#initialize(model) ⇒ StakingBalance
Returns a new StakingBalance object.
27 28 29 |
# File 'lib/coinbase/staking_balance.rb', line 27 def initialize(model) @model = model end |
Class Method Details
.list(network, asset_id, address_id, start_time: DateTime.now.prev_month(1), end_time: DateTime.now) ⇒ Enumerable<Coinbase::StakingBalance>
Returns a list of StakingBalance for the provided network, asset, and addresses.
15 16 17 18 19 20 21 22 23 |
# File 'lib/coinbase/staking_balance.rb', line 15 def self.list(network, asset_id, address_id, start_time: DateTime.now.prev_month(1), end_time: DateTime.now) network = Coinbase::Network.from_id(network) Coinbase::Pagination.enumerate( ->(page) { list_page(network, asset_id, address_id, start_time, end_time, page) } ) do |staking_balance| new(staking_balance) end end |
Instance Method Details
#address ⇒ Time
Returns the onchain address of the StakingBalance.
39 40 41 |
# File 'lib/coinbase/staking_balance.rb', line 39 def address @model.address end |
#bonded_stake ⇒ Balance
Returns the bonded stake as a Balance
45 46 47 |
# File 'lib/coinbase/staking_balance.rb', line 45 def bonded_stake @bonded_stake ||= Balance.from_model(@model.bonded_stake) end |
#date ⇒ Time
Returns the date of the StakingBalance.
33 34 35 |
# File 'lib/coinbase/staking_balance.rb', line 33 def date @model.date end |
#inspect ⇒ String
Same as to_s.
69 70 71 |
# File 'lib/coinbase/staking_balance.rb', line 69 def inspect to_s end |
#participant_type ⇒ String
Returns the participant type of the StakingBalance.
57 58 59 |
# File 'lib/coinbase/staking_balance.rb', line 57 def participant_type @model.participant_type end |
#to_s ⇒ String
Returns a string representation of the StakingBalance.
63 64 65 |
# File 'lib/coinbase/staking_balance.rb', line 63 def to_s "Coinbase::StakingBalance{date: '#{date}' address: '#{address}'}" end |
#unbonded_balance ⇒ Balance
Returns the unbonded balance as a Balance
51 52 53 |
# File 'lib/coinbase/staking_balance.rb', line 51 def unbonded_balance @unbonded_balance ||= Balance.from_model(@model.unbonded_balance) end |