V3 Technical Docs
  • Deployed Contracts
    • Notional V3
      • Ethereum Mainnet
      • Arbitrum
  • Security
    • Audits
    • Bug Bounty
  • Currency Ids & Precision
    • Currency Ids
    • Market Indexes
    • Notional Internal Precision
  • Contract interaction guides
    • Intro
    • Trading guide
      • Deposit (Prime Lend)
      • Trade fCash (Borrow & Lend Fixed)
      • Add liquidity (Mint nTokens)
      • Withdraw liquidity (Redeem nTokens)
      • Withdraw (Prime Cash)
      • Settle Account
      • Enter Leveraged Vaults
      • Exit Leveraged Vaults
    • Accounts
    • Prime Cash Markets
    • fCash Markets
    • nTokens
    • Leveraged Vaults
    • Oracles
    • Governance parameters
  • Subgraph guides
    • Notional V3 Subgraphs
      • Fetch Notional Accounts
      • Fetch Notional's reserves
      • Fetch Notional nToken accounts
      • Fetch Historical Trades
      • Fetch an Account's P&L
      • Fetch current fCash and Prime Cash Rates
      • Fetch Historical Prime Cash & Prime Debt Exchange Rates
      • Fetch Prime Cash Market Balances
      • Fetch fCash Market Balances
      • Fetch Outstanding Debt
      • Fetch Historical nToken Exchange Rates
      • Fetch ETH Oracle Exchange Rates
      • Fetch Annual Incentive Rates
      • Fetch Interest Rate Models
      • Fetch Governance Parameters
  • Dune Dashboard
  • Notional Risk Docs
  • Notional V3 Docs
  • Notional Blog
Powered by GitBook
On this page
  • Fetch Prime Cash and Prime Debt Addresses
  • Fetch a market's total pCash and total pDebt supply
  • Get a market's pCash and pDebt Supply in Underlying
  • Calculate a Prime Cash Market's utilization
  • Fetch Prime Cash markets Supply Rates and Borrowing Rates
  1. Contract interaction guides

Prime Cash Markets

Fetch Prime Cash and Prime Debt Addresses

# Fetch the Prime Cash and Prime debt addresses for a given currencyId

pCashAddress = notional.pCashAddress(currrencyId)
pDebtAddress = notional.pDebtAddress(currrencyId)

Fetch a market's total pCash and total pDebt supply

from brownie.network.state import Chain
chain = Chain()

primeFactors = notional.getPrimeFactorsStored(currencyId, chain.time())
totalPrimeSupply = primeFactors['factors']["totalPrimeSupply"]/1e8
totalPrimeDebt = primeFactors['factors']["totalPrimeDebt"]/1e8

Get a market's pCash and pDebt Supply in Underlying

In order to convert Prime Cash to underlying we need to use the underlyingScalar and the supplyScalar. To convert Prime Debt to underlying we need to use the underlyingScalar and the debtScalar:

from brownie.network.state import Chain
chain = Chain()

primeFactors = notional.getPrimeFactorsStored(currencyId, chain.time())
totalPrimeSupply = primeFactors['factors']["totalPrimeSupply"]/1e8
totalPrimeDebt = primeFactors['factors']["totalPrimeDebt"]/1e8

supplyScalar = primeFactors["factors"]["supplyScalar"]/1e18
debtScalar = primeFactors["factors"]["debtScalar"]/1e18
underlyingScalar = primeFactors["factors"]["underlyingScalar"]/1e18

# Total Prime Supply in underlying 
totalPrimeSupplyInUnderlying = totalPrimeSupply * underlyingScalar * supplyScalar
totalPrimeDebtInUnderlying = totalPrimeDebt * underlyingScalar * debtScalar 

Calculate a Prime Cash Market's utilization

Prime Cash Market utilization is defined as a market's debt / supply in underlying terms:

from brownie.network.state import Chain
chain = Chain()

primeFactors = notional.getPrimeFactorsStored(currencyId, chain.time())
totalPrimeSupply = primeFactors["factors"]["totalPrimeSupply"]
totalPrimeDebt = primeFactors["factors"]["totalPrimeDebt"]
supplyScalar = primeFactors["factors"]["supplyScalar"]
debtScalar = primeFactors["factors"]["debtScalar"]


# Utilization is calculated in underlying terms.
# Utilization = accruedDebtUnderlying / accruedSupplyUnderlying
# Utilization = (totalPrimeDebt * underlyingScalar * debtScalar) / (totalPrimeSupply * underlyingScalar * supplyScalar)
# Note that the underlyingScalar cancels out in both numerator and denominator
utilization = (totalPrimeDebt * debtScalar) / (totalPrimeSupply * supplyScalar) 

Fetch Prime Cash markets Supply Rates and Borrowing Rates

from brownie.network.state import Chain
chain = Chain()

primeFactors = notional.getPrimeFactors(currencyId, chain.time())

# Prime Cash Supply Rate
oracleSupplyRate = primeFactors["primeRate"]["oracleSupplyRate"]/1e9

# Prime Cash Borrow Rate
TODO after contract upgrade
PreviousAccountsNextfCash Markets

Last updated 5 months ago