async def validator_rewards(self, validator: ValAddress) -> ValidatorRewards: """Fetches the self-delegation reward data and available commission for a validator. Args: validator (ValAddress): validator operator address Returns: ValidatorRewards: validator rewards """ res = await self._c._get(f"/distribution/validators/{validator}") operator_address = res["operator_address"] if res["self_bond_rewards"]: self_bond_rewards = Coins.from_data(res["self_bond_rewards"]) else: self_bond_rewards = Coin.from_data({'denom': 'uakt', 'amount': 0}) if res["val_commission"]['commission']: val_commission = Coins.from_data( res["val_commission"]['commission']) else: val_commission = Coin.from_data({'denom': 'uakt', 'amount': 0}) return ValidatorRewards(self_bond_rewards, val_commission, operator_address)
async def pool(self) -> StakingPool: """Fetch current staking pool information. Returns: StakingPool: information about current staking pool """ res = await self._c._get("/staking/pool") return StakingPool( bonded_tokens=Coin("uakt", res["bonded_tokens"]), not_bonded_tokens=Coin("uakt", res["not_bonded_tokens"]), )
def from_data(cls, data: dict) -> Delegation: return cls( delegator_address=data['delegation']["delegator_address"], validator_address=data['delegation']["validator_address"], shares=data['delegation']["shares"], balance=Coin.from_data(data["balance"]), )
def from_data(cls, data: dict) -> MsgDelegate: data = data["value"] return cls( delegator_address=data["delegator_address"], validator_address=data["validator_address"], amount=Coin.from_data(data["amount"]), )
async def supply(self) -> Coin: """Fetches total supply of AKT. TODO: add in IBC coins. Returns: Coin: Total Supply of coinz """ res = await self._c._get(f"/cosmos/bank/v1beta1/supply/uakt", raw=True) return Coin.from_data(res['amount'])
def from_data(cls, data: dict) -> MsgCreateValidator: data = data["value"] return cls( description=Description.from_data(data["description"]), commission=CommissionRates.from_data(data["commission"]), min_self_delegation=int(data["min_self_delegation"]), delegator_address=data["delegator_address"], validator_address=data["validator_address"], pubkey=data["pubkey"], value=Coin.from_data(data["value"]), )