# Trade fCash (Borrow & Lend Fixed)

## Deposit and Lend Fixed

To lend fixed on Notional, users need to trade Prime Cash in exchange for fCash:

```
from helpers import get_balance_trade_action

# Deposit 10 DAI to Notional as Prime Dai and lend 5 fDAI fixed in the 3M maturity (marketIndex = 1). 
lendActionDai = get_balance_trade_action(2, "DepositUnderlying", [
    {"tradeActionType": "Lend", "marketIndex": 1, "notional": 5 * 1e8, "minSlippage": 0.03*1e9}
    ], depositActionAmount = 10e18)

tx = notional.batchBalanceAndTradeAction(account.address, [lendActionDai], {"from": account})
```

Note that the `minSlippage` limit sets the minimum fixed rate at which the user will lend. The transaction will revert if the trade implied fixed rate is lower than the minimum slippage limit.

The `depositActionAmount` uses the external currency precision. The `notional` amount precision is 1e8. The slippage limit rate precision is 1e9.

## Deposit and Lend Fixed in multiple maturities

Users can use the `batchBalanceAndTradeAction` method to lend across multiple maturities:

```
from helpers import get_balance_trade_action

# Deposit 10 DAI to Notional as Prime Dai, 
# Lend 5 fDAI fixed in the 3M maturity (marketIndex = 1), and 
# Lend 3 fDAI fixed in the 6M maturity (marketIndex = 2).
lendActionDai = get_balance_trade_action(2, "DepositUnderlying", [
        {"tradeActionType": "Lend", "marketIndex": 1, "notional": 5 * 1e8, "minSlippage": 0.03*1e9},
        {"tradeActionType": "Lend", "marketIndex": 2, "notional": 3 * 1e8, "minSlippage": 0.02*1e9}
        ], depositActionAmount = 10e18)

tx = notional.batchBalanceAndTradeAction(account.address, [lendActionDai], {"from": account})
```

## Deposit and Lend Fixed in multiple currencies

Users can use the `batchBalanceAndTradeAction` method to lend across multiple currencies:

```
from helpers import get_balance_trade_action

# Deposit 10 DAI to Notional as Prime DAI and lend 5 fDAI fixed in the 3M maturity (marketIndex = 1). 
# Deposit 100 USDC to Notional as Prime USDC and lend 100 fUSDC fixed in the 6M maturity (marketIndex = 2).
lendActionDai = get_balance_trade_action(2, "DepositUnderlying", [
        {"tradeActionType": "Lend", "marketIndex": 1, "notional": 5 * 1e8, "minSlippage": 0.03*1e9}
        ], depositActionAmount = 10e18)
lendActionUsdc = get_balance_trade_action(3, "DepositUnderlying", [
        {"tradeActionType": "Lend", "marketIndex": 2, "notional": 100 * 1e8, "minSlippage": 0.02*1e9}
        ], depositActionAmount = 100e6)

tx = notional.batchBalanceAndTradeAction(account.address, [lendActionDai, lendActionUsdc], {"from": account})
```

Note that when using batch functions the array of actions needs to be sorted by Currency Ids.

## Deposit, lend fixed in the 3M maturity and borrow in the 6M maturity

Users can use the `batchBalanceAndTradeAction` method to lend and borrow across different maturities:

```
from helpers import get_balance_trade_action

# Deposit 10 DAI to Notional as Prime Dai, 
# Lend 1,000 fDAI fixed in the 3M maturity (marketIndex = 1), and 
# Borrow 1,000 fDAI fixed in the 6M maturity (marketIndex = 2).
actionDai = get_balance_trade_action(2, "DepositUnderlying", [
        {"tradeActionType": "Lend," "marketIndex": 1, "notional": 1_000 * 1e8, "minSlippage": 0.03*1e9},
        {"tradeActionType": "Borrow", "marketIndex": 2, "notional": 1_000 * 1e8, "maxSlippage": 0.05*1e9}
        ], depositActionAmount = 10e18)

tx = notional.batchBalanceAndTradeAction(account.address, [actionDai], {"from": account})
```

Note that the maxSlippage limit sets the maximum fixed rate at which user will borrow. If the trade implied fixed rate is lower than the minimum slippage limit, the transaction will revert.

## Deposit Prime Cash in one currency and borrow fixed in another currency

Users can use the `batchBalanceAndTradeAction` method to borrow at a fixed rate:

```
from helpers import get_balance_trade_action

# Deposit 10 DAI to Notional as Prime Dai, 
# Borrow 5 fUSDC fixed in the 6M maturity (marketIndex = 2).
actionDai = get_balance_trade_action(2, "DepositUnderlying", [], depositActionAmount = 10e18)
actionUsdc = get_balance_trade_action(3, "None", [
        {"tradeActionType": "Borrow", "marketIndex": 2, "notional": 5 * 1e8, "maxSlippage": 0.05*1e9}
        ], withdrawEntireCashBalance=True)

tx = notional.batchBalanceAndTradeAction(account.address, [actionDai, actionUsdc], {"from": account})
```

Note that we can set `withdrawEntireCashBalance` to True in order to withdraw the borrowed USDC to the user's wallet.


---

# 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/trading-guide/trade-fcash-borrow-and-lend-fixed.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.
