---
# System prepended metadata

title: Australis Lending Pool

---

Australis Dev Docs

[TOC]

# Australis Lending Pool
Main point of interaction with an Australis protocol's market. Users can:
  - Deposit
  - Withdraw
  - Borrow
  - Repay
  - Swap their loans between variable and stable rate
  - Enable/disable their deposits as collateral rebalance stable rate borrow positions
  - Liquidate positions
  - Execute Flash Loans

All admin functions are callable by the LendingPoolConfigurator contract defined also in the LendingPoolAddressesProvider.


## Deposit

Deposits an `amount` of underlying asset into the reserve, receiving in return overlying astTokens.
- E.g. User deposits 100 DAI and gets in return 100 astDAI.
```solidity
function deposit(
  address asset,
  uint256 amount,
  address onBehalfOf,
  uint16 referralCode)
```
| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset to deposit |
| amount | uint256 | The amount to be deposited |
| onBehalfOf | address | The address that will receive the aTokens, same as msg.sender if the user   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens   is a different wallet |
| referralCode | uint16 | Code used to register the integrator originating the operation, for potential rewards.   0 if the action is executed directly by the user, without any middle-man |

### Deposit Event
```solidity
event Deposit(
  address reserve,
  address user,
  address onBehalfOf,
  uint256 amount,
  uint16 referral)
```

Emitted on `deposit()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The address initiating the deposit |
| onBehalfOf | address | The beneficiary of the deposit, receiving the aTokens |
| amount | uint256 | The amount deposited |
| referral | uint16 | The referral code used |

## Withdraw

```solidity
function withdraw(
  address asset,
  uint256 amount,
  address to) returns (uint256)
```

Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
E.g. User has 100 astUSDC, calls withdraw() and receives 100 USDC, burning the 100 astUSDC

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset to withdraw |
| amount | uint256 | The underlying amount to be withdrawn   - Send the value type(uint256).max in order to withdraw the whole aToken balance |
| to | address | Address that will receive the underlying, same as msg.sender if the user   wants to receive it on his own wallet, or a different address if the beneficiary is a   different wallet |

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | uint256 | The final amount withdrawn |

### Withdraw Event

```solidity
event Withdraw(
  address reserve,
  address user,
  address to,
  uint256 amount)
```

Emitted on `withdraw()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlyng asset being withdrawn |
| user | address | The address initiating the withdrawal, owner of aTokens |
| to | address | Address that will receive the underlying |
| amount | uint256 | The amount to be withdrawn |


## Borrow

```solidity
function borrow(
  address asset,
  uint256 amount,
  uint256 interestRateMode,
  uint16 referralCode,
  address onBehalfOf)
```

Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower
already deposited enough collateral, or he was given enough allowance by a credit delegator on the
corresponding debt token (StableDebtToken or VariableDebtToken)
- E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet
  and 100 stable/variable debt tokens, depending on the `interestRateMode`.

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset to borrow |
| amount | uint256 | The amount to be borrowed |
| interestRateMode | uint256 | The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable |
| referralCode | uint16 | Code used to register the integrator originating the operation, for potential rewards.   0 if the action is executed directly by the user, without any middle-man |
| onBehalfOf | address | Address of the user who will receive the debt. Should be the address of the borrower itself calling the function if he wants to borrow against his own collateral, or the address of the credit delegator if he has been given credit delegation allowance |

### Borrow Event

```solidity
event Borrow(
  address reserve,
  address user,
  address onBehalfOf,
  uint256 amount,
  uint256 borrowRateMode,
  uint256 borrowRate,
  uint16 referral)
```

Emitted on `borrow()` and `flashLoan()` when debt needs to be opened.

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset being borrowed |
| user | address | The address of the user initiating the `borrow()`, receiving the funds on `borrow()` or just initiator of the transaction on `flashLoan()` |
| onBehalfOf | address | The address that will be getting the debt |
| amount | uint256 | The amount borrowed out |
| borrowRateMode | uint256 | The rate mode: 1 for Stable, 2 for Variable |
| borrowRate | uint256 | The numeric rate at which the user has borrowed |
| referral | uint16 | The referral code used |


## Repay

```solidity
function repay(
  address asset,
  uint256 amount,
  uint256 rateMode,
  address onBehalfOf) returns (uint256)
```

Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned
- E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address.

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the borrowed underlying asset previously borrowed |
| amount | uint256 | The amount to repay - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` |
| rateMode | uint256 | The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable |
| onBehalfOf | address | Address of the user who will get his debt reduced/removed. Should be the address of the user calling the function if he wants to reduce/remove his own debt, or the address of any other other borrower whose debt should be removed |

| Name | Type | Description |
| ---- | ---- | ----------- |
| [0] | uint256 | The final amount repaid |

### Repay Event

```solidity
event Repay(
  address reserve,
  address user,
  address repayer,
  uint256 amount)
```

Emitted on `repay()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The beneficiary of the repayment, getting his debt reduced |
| repayer | address | The address of the user initiating the `repay()`, providing the funds |
| amount | uint256 | The amount repaid |

## Swap Borrow Rate Mode

```solidity
function swapBorrowRateMode(address asset, uint256 rateMode)
```

Allows a borrower to swap his debt between stable and variable mode, or viceversa.

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset borrowed |
| rateMode | uint256 | The rate mode that the user wants to swap to |

### Swap Event

```solidity
event Swap(address reserve, address user, uint256 rateMode)
```

Emitted on `swapBorrowRateMode()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The address of the user swapping his rate mode |
| rateMode | uint256 | The rate mode that the user wants to swap to |

## Rebalance Stable Borrow Rate

```solidity
function rebalanceStableBorrowRate(address asset, address user)
```

Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.  Users can be rebalanced if the following conditions are satisfied:
  - Usage ratio is above 95%
  - the current deposit APY is below `REBALANCE_UP_THRESHOLD` * `maxVariableBorrowRate`, which means that too much has been borrowed at a stable rate and depositors are not earning enough.

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset borrowed |
| user | address | The address of the user to be rebalanced |


### Rebalance Stable Borrow Rate

```solidity
event RebalanceStableBorrowRate(address reserve, address user)
```

Emitted on `rebalanceStableBorrowRate()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The address of the user for which the rebalance has been executed |

## Set User Use Reserve As Collateral

```solidity
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
```

Allows depositors to enable/disable a specific deposited asset as collateral

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset deposited |
| useAsCollateral | bool | `true` if the user wants to use the deposit as collateral, `false` otherwise |

### Reserve Used As Collateral Enabled

```solidity
event ReserveUsedAsCollateralEnabled(address reserve, address user)
```

Emitted on `setUserUseReserveAsCollateral()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The address of the user enabling the usage as collateral |

### Reserve Used As Collateral Disabled

```solidity
event ReserveUsedAsCollateralDisabled(address reserve, address user)
```

Emitted on `setUserUseReserveAsCollateral()`

| Name | Type | Description |
| ---- | ---- | ----------- |
| reserve | address | The address of the underlying asset of the reserve |
| user | address | The address of the user enabling the usage as collateral |

## Liquidation Call

```solidity
function liquidationCall(
  address collateralAsset,
  address debtAsset,
  address user,
  uint256 debtToCover,
  bool receiveAToken)
```

Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1
- The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives
  a proportionally amount of the `collateralAsset` plus a bonus to cover market risk

| Name | Type | Description |
| ---- | ---- | ----------- |
| collateralAsset | address | The address of the underlying asset used as collateral, to receive as result of the liquidation |
| debtAsset | address | The address of the underlying borrowed asset to be repaid with the liquidation |
| user | address | The address of the borrower getting liquidated |
| debtToCover | uint256 | The debt amount of borrowed `asset` the liquidator wants to cover |
| receiveAToken | bool | `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants to receive the underlying collateral asset directly |

### LiquidationCall Event

```solidity
event LiquidationCall(
  address collateralAsset,
  address debtAsset,
  address user,
  uint256 debtToCover,
  uint256 liquidatedCollateralAmount,
  address liquidator,
  bool receiveAToken)
```

Emitted when a borrower is liquidated. This event is emitted by the LendingPool via
LendingPoolCollateral manager using a `DELEGATECALL`
This allows to have the events in the generated ABI for LendingPool.

| Name | Type | Description |
| ---- | ---- | ----------- |
| collateralAsset | address | The address of the underlying asset used as collateral, to receive as result of the liquidation |
| debtAsset | address | The address of the underlying borrowed asset to be repaid with the liquidation |
| user | address | The address of the borrower getting liquidated |
| debtToCover | uint256 | The debt amount of borrowed `asset` the liquidator wants to cover |
| liquidatedCollateralAmount | uint256 | The amount of collateral received by the liiquidator |
| liquidator | address | The address of the liquidator |
| receiveAToken | bool | `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants to receive the underlying collateral asset directly |

## FlashLoan

```solidity
struct FlashLoanLocalVars {
  contract IFlashLoanReceiver receiver;
  address oracle;
  uint256 i;
  address currentAsset;
  address currentATokenAddress;
  uint256 currentAmount;
  uint256 currentPremium;
  uint256 currentAmountPlusPremium;
  address debtToken;
}
```

```solidity
function flashLoan(
  address receiverAddress,
  address[] assets,
  uint256[] amounts,
  uint256[] modes,
  address onBehalfOf,
  bytes params,
  uint16 referralCode)
```

Allows smartcontracts to access the liquidity of the pool within one transaction,
as long as the amount taken plus a fee is returned. There are security concerns for developers of flashloan receiver contracts that must be kept into consideration.

| Name | Type | Description |
| ---- | ---- | ----------- |
| receiverAddress | address | The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface |
| assets | address[] | The addresses of the assets being flash-borrowed |
| amounts | uint256[] | The amounts amounts being flash-borrowed |
| modes | uint256[] | Types of the debt to open if the flash loan is not returned:   0 -> Don't open any debt, just revert if funds can't be transferred from the receiver   1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address   2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address |
| onBehalfOf | address | The address  that will receive the debt in the case of using on `modes` 1 or 2 |
| params | bytes | Variadic packed params to pass to the receiver as extra information |
| referralCode | uint16 | Code used to register the integrator originating the operation, for potential rewards.   0 if the action is executed directly by the user, without any middle-man |

# Lending Pool Configurator


Implements the configuration methods for the Australis protocol

## Batch Init Reserve
```
struct InitReserveInput {
    address aTokenImpl;
    address stableDebtTokenImpl;
    address variableDebtTokenImpl;
    uint8 underlyingAssetDecimals;
    address interestRateStrategyAddress;
    address underlyingAsset;
    address treasury;
    address incentivesController;
    string underlyingAssetName;
    string aTokenName;
    string aTokenSymbol;
    string variableDebtTokenName;
    string variableDebtTokenSymbol;
    string stableDebtTokenName;
    string stableDebtTokenSymbol;
    bytes params;
  }
```

```solidity
function batchInitReserve(
  struct InitReserveInput[] input) external
```

Initializes reserves in batch

### Reserve Initialized Event

```solidity
event ReserveInitialized(
  address asset,
  address astToken,
  address stableDebtToken,
  address variableDebtToken,
  address interestRateStrategyAddress)
```

Emitted when a reserve is initialized.

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset of the reserve |
| astToken | address | The address of the associated aToken contract |
| stableDebtToken | address | The address of the associated stable rate debt token |
| variableDebtToken | address | The address of the associated variable rate debt token |
| interestRateStrategyAddress | address | The address of the interest rate strategy for the reserve |

## Update astToken

```solidity
struct UpdateDebtTokenInput {
  address asset;
  address incentivesController;
  string name;
  string symbol;
  address implementation;
  bytes params;
}
```

```solidity
function updateAstToken(struct UpdateATokenInput input) external
```

Updates the astToken implementation for the reserve

### AstTokenUpgraded Event

```solidity
event AstTokenUpgraded(address asset, address proxy, address implementation)
```

Emitted when an aToken implementation is upgraded

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset of the reserve |
| proxy | address | The aToken proxy address |
| implementation | address | The new aToken implementation |

## Update Stable Debt Token


```solidity
struct UpdateDebtTokenInput {
  address asset;
  address incentivesController;
  string name;
  string symbol;
  address implementation;
  bytes params;
}
```

```solidity
function updateStableDebtToken(struct UpdateDebtTokenInput input) external
```

Updates the stable debt token implementation for the reserve

### Stable Debt Token Upgraded Event

```solidity
event StableDebtTokenUpgraded(
  address asset,
  address proxy,
  address implementation)
```

Emitted when the implementation of a stable debt token is upgraded

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset of the reserve |
| proxy | address | The stable debt token proxy address |
| implementation | address | The new astToken implementation |

## Update Variable Debt Token

```solidity
function updateVariableDebtToken(struct UpdateDebtTokenInput input) external
```

Updates the variable debt token implementation for the asset

### Variable Debt Token Upgraded Event

```solidity
event VariableDebtTokenUpgraded(
  address asset,
  address proxy,
  address implementation)
```

Emitted when the implementation of a variable debt token is upgraded

| Name | Type | Description |
| ---- | ---- | ----------- |
| asset | address | The address of the underlying asset of the reserve |
| proxy | address | The variable debt token proxy address |
| implementation | address | The new astToken implementation |

# Australis Oracle


Proxy smart contract to get the price of an asset from a price source, with Flux Protocol smart contracts as primary option.
- If the returned price by a Flux aggregator is <= 0, the call is forwarded to a fallbackOracle
- Owned by the Australis governance system, allowed to add sources for assets, replace them
  and change the fallbackOracle.

## Base Currency

```solidity
function BASE_CURRENCY() external view returns (address)
```

## Base Currency Unit

```solidity
function BASE_CURRENCY_UNIT() external view returns (uint256)
```

## Get Asset Price

```solidity
function getAssetPrice(address asset) external view returns (uint256)
```

## Set Asset Sources

```solidity
function setAssetSources(address[] assets, address[] sources) external
```

External function called by the Australis governance to set or replace sources of assets

| Name | Type | Description |
| ---- | ---- | ----------- |
| assets | address[] | The addresses of the assets |
| sources | address[] | The address of the source of each asset |

### AssetSourceUpdated Event

```solidity
event AssetSourceUpdated(address asset, address source)
```

## Set Fallback Oracle

```solidity
function setFallbackOracle(address fallbackOracle) external
```

Sets the fallbackOracle
- Callable only by the Australis governance

| Name | Type | Description |
| ---- | ---- | ----------- |
| fallbackOracle | address | The address of the fallbackOracle |

### FallbackOracleUpdated Event

```solidity
event FallbackOracleUpdated(address fallbackOracle)
```
