To get a list of Notional users, one can use this or use this .
Get an account's balances
account = notional.getAccount(accountAddress)
Fetch an account's positions in readable format
The following function can be used to make an account's balances more readable. This is especially useful when comparing an account's state before and after trading.
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 dict
Get an account's free collateral
If a user's free collateral is negative, then the user is eligible to get liquidated. If the user's free collateral figure is positive the account is sufficiently collateralized.
notional.getFreeCollateral(accountAddress)
Get an account's Leveraged Vaults positions
Users can use the getVaultAccount methord to fetch an account's leveraged vault positions: