Accounts
Get an account's balances
account = notional.getAccount(accountAddress)Fetch an account's positions in readable format
from datetime import datetime
# CurrencyId to Symbol Mapping
CURRENCY_ID_TO_SYMBOL = {
1: "ETH",
2: "DAI",
3: "USDC",
4: "WBTC",
5: "wstETH",
6: "FRAX",
7: "rETH",
8: "USDT",
}
# This function can be used to make an account's positions readable.
def getAccountPositions(address):
account = notional.getAccount(address)
dict = {}
dict['Account Address'] = address
dict['Free collateral (ETH)'] = notional.getFreeCollateral(address)[0] / 1e8
for i in account[1]:
if i[0] != 0:
symbol = CURRENCY_ID_TO_SYMBOL[i[0]]
dict[symbol] = {
'p{} Balance'.format(symbol): i[1]/1e8,
'n{} Balance'.format(symbol): i[2]/1e8}
for j in account[2]:
symbol = CURRENCY_ID_TO_SYMBOL[j[0]]
if j[2] == 1:
dict[symbol].update({'f{} {} {}'.format(symbol, j[1], datetime.fromtimestamp(j[1]).date()): j[3] / 1e8})
return dictGet an account's free collateral
Get an account's Leveraged Vaults positions
Last updated