Skip to content

Commit

Permalink
Add sdai to balances (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Jan 9, 2025
1 parent 82307dc commit b81a3f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions prediction_market_agent_tooling/tools/balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
from prediction_market_agent_tooling.gtypes import ChecksumAddress, xDai
from prediction_market_agent_tooling.markets.omen.omen_contracts import (
WrappedxDaiContract,
sDaiContract,
)
from prediction_market_agent_tooling.tools.web3_utils import wei_to_xdai


class Balances(BaseModel):
xdai: xDai
wxdai: xDai
sdai: xDai

@property
def total(self) -> xDai:
return xDai(self.xdai + self.wxdai)
return xDai(self.xdai + self.wxdai + self.sdai)


def get_balances(address: ChecksumAddress, web3: Web3 | None = None) -> Balances:
Expand All @@ -24,4 +26,5 @@ def get_balances(address: ChecksumAddress, web3: Web3 | None = None) -> Balances
xdai_balance = Wei(web3.eth.get_balance(address))
xdai = wei_to_xdai(xdai_balance)
wxdai = wei_to_xdai(WrappedxDaiContract().balanceOf(address, web3=web3))
return Balances(xdai=xdai, wxdai=wxdai)
sdai = wei_to_xdai(sDaiContract().balanceOf(address, web3=web3))
return Balances(xdai=xdai, wxdai=wxdai, sdai=sdai)

0 comments on commit b81a3f7

Please sign in to comment.