# 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:&#x20;

```
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

<pre><code>from brownie.network.state import Chain
chain = Chain()

<strong>primeFactors = notional.getPrimeFactors(currencyId, chain.time())
</strong><strong>
</strong># Prime Cash Supply Rate
oracleSupplyRate = primeFactors["primeRate"]["oracleSupplyRate"]/1e9

# Prime Cash Borrow Rate
TODO after contract upgrade

</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.notional.finance/v3-technical-docs/contract-interaction-guides/prime-cash-markets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
