From 399f71ef979d7020d2ab8db41a66ef745482f6e9 Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Mon, 9 May 2022 16:26:39 +0400 Subject: [PATCH] add BondAmount to Prism Farm --- protocols/prism/farm.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/protocols/prism/farm.go b/protocols/prism/farm.go index eb1ce7f..e315f1b 100644 --- a/protocols/prism/farm.go +++ b/protocols/prism/farm.go @@ -40,6 +40,23 @@ func (f *Farm) WithdrawableRewards(ctx context.Context, address cosmos.AccAddres return terra.PRISM.ValueFromTerra(r.Withdrawable), nil } +func (f *Farm) BondAmount(ctx context.Context, address cosmos.AccAddress) (decimal.Decimal, error) { + var q struct { + RewardInfo struct { + StakerAddr string `json:"staker_addr"` + } `json:"reward_info"` + } + q.RewardInfo.StakerAddr = address.String() + var r struct { + BondAmount decimal.Decimal `json:"bond_amount"` + } + err := f.QueryStore(ctx, q, &r) + if err != nil { + return decimal.Zero, errors.Wrap(err, "querying contract store") + } + return terra.YLUNA.ValueFromTerra(r.BondAmount), nil +} + func (f *Farm) NewBondMessage(sender cosmos.AccAddress, amount decimal.Decimal) (cosmos.Msg, error) { var q struct { Bond struct{} `json:"bond"`