Phantazm
  • Intro
    • What is Phantazm?
  • V2
    • TVL & Emission Sustainability
    • Two Token Model
    • Supplying assets into LPs
    • Staking Mechanism(Soon)
  • The Core Protocol
    • Protocol Overview
    • LendingPool
      • ILendingPool
    • Addresses Provider
      • ILendingPoolAddressesProvider
    • Addresses Provider Registry
      • ILendingPoolAddressesProviderRegistry
    • Protocol Data Provider
      • IProtocolDataProvider
    • aTokens (TBD)
      • IAToken
    • Debt Tokens
      • IStableDebtToken
      • IVariableDebtToken
    • Phantazm Token (TBD)
    • Price Oracle
      • IPriceOracle
  • Deployed Contracts
    • Main market (TBD)
  • Getting Started
    • SDKs
    • Subgraph data (GraphQL)
    • Gas Limits
  • Guides
    • APY and APR
    • Liquidity Mining
    • Flash Loans
      • IFlashLoanReceiver
    • Liquidations
    • Troubleshooting Errors
  • Security & Audits
  • Glossary
  • Socials
Powered by GitBook
On this page
  • Methods
  • deposit()
  • withdraw()
  • borrow()
  • repay()
  • swapBorrowRateMode()
  • setUserUseReserveAsCollateral()
  • liquidationCall()
  • flashLoan()
  • View Methods
  • getReserveData()
  • getUserAccountData**()**
  • getConfiguration**()**
  • getUserConfiguration**()**
  • getReserveNormalizedIncome**()**
  • getReserveNormalizedVariableDebt**()**
  • paused**()**
  • getReservesList**()**
  • getAddressesProvider**()**
  • Error Codes
  • ABI
  1. The Core Protocol

LendingPool

PreviousProtocol OverviewNextILendingPool

Last updated 1 year ago

The LendingPool contract is the main contract of the protocol. It exposes all the user-oriented actions that can be invoked using either Solidity or web3 libraries.

LendingPool methods**deposit, borrow, withdraw and repay**are only for ERC20, if you want to deposit, borrow, withdraw or repay using native ETH (or native MATIC incase of Polygon), use instead.

Methods

deposit()

function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)

Deposits a certain amount of an asset into the protocol, minting the same amount of corresponding aTokens, and transferring them to the onBehalfOf address.

The referral program is currently in active and you can pass0 as thereferralCode.

In future for referral code to be active again, a governance proposal, with the list of unique referral codes for various integration must be passed via governance.

When depositing, the LendingPool contract must have**allowance()to spend funds on behalf ofmsg.sender** for at-least**amount** for the asset being deposited. This can be done via the standard ERC20 approve() method.

Parameter Name
Type
Description

asset

address

amount

uint256

amount deposited, expressed in wei units

onBehalfOf

address

address whom will receive the aTokens. Use msg.sender when the aTokens should be sent to the caller.

referralCode

uint16

withdraw()

function withdraw(address asset, uint256 amount, address to)

Withdraws amount of the underlying asset, i.e. redeems the underlying token and burns the aTokens.

When withdrawing toanother address,**msg.sender**should haveaTokenthat will be burned by lendingPool .

Parameter Name
Type
Description

asset

address

amount

uint256

amount deposited, expressed in wei units. Use type(uint).max to withdraw the entire balance.

to

address

address that will receive the asset

borrow()

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

Borrows amount of asset with interestRateMode, sending the amount to msg.sender, with the debt being incurred by onBehalfOf.

Parameter Name
Type
Description

asset

address

amount

uint256

amount to be borrowed, expressed in wei units

interestRateMode

uint256

the type of borrow debt.

Stable: 1, Variable: 2

referralCode

uint16

onBehalfOf

address

address of user who will incur the debt.

Use msg.sender when not calling on behalf of a different user.

repay()

function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf)

Repays onBehalfOf's debt amount of asset which has a rateMode.

Parameter Name
Type
Description

asset

address

amount

uint256

amount to be borrowed, expressed in wei units.

Use uint(-1) to repay the entire debt, ONLY when the repayment is not executed on behalf of a 3rd party.

In case of repayments on behalf of another user, it's recommended to send an _amount slightly higher than the current borrowed amount.

rateMode

uint256

the type of borrow debt.

Stable: 1, Variable: 2

onBehalfOf

address

address of user who will incur the debt.

Use msg.sender when not calling on behalf of a different user.

swapBorrowRateMode()

function swapBorrowRateMode(address asset, uint256 rateMode)

Swaps the msg.sender's borrow rate modes between stable and variable.

Parameter Name
Type
Description

asset

address

rateMode

uint256

the rate mode the user is swapping to.

Stable: 1, Variable: 2

setUserUseReserveAsCollateral()

function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)

Sets the asset of msg.sender to be used as collateral or not.

Parameter Name
Type
Description

asset

address

useAsCollateral

bool

true if the asset should be used as collateral

liquidationCall()

function liquidationCall(address collateral, address debt, address user, uint256 debtToCover, bool receiveAToken)

When the health factor of a position is below 1, liquidators repay part or all of the outstanding borrowed amount on behalf of the borrower, while receiving a discounted amount of collateral in return (also known as a liquidation 'bonus"). Liquidators can decide if they want to receive an equivalent amount of collateral aTokens, or the underlying asset directly. When the liquidation is completed successfully, the health factor of the position is increased, bringing the health factor above 1.

Liquidators can only close a certain amount of collateral defined by a close factor. Currently the close factor is 0.5. In other words, liquidators can only liquidate a maximum of 50% of the amount pending to be repaid in a position. The liquidation discount applies to this amount.

Liquidators must approve() the LendingPool contract to use debtToCover of the underlying ERC20 of theasset used for the liquidation.

NOTES

  • In most scenarios, profitable liquidators will choose to liquidate as much as they can (50% of the user position).

  • debtToCover parameter can be set to uint(-1) and the protocol will proceed with the highest possible liquidation allowed by the close factor.

Parameter Name
Type
Description

collateral

address

address of the collateral reserve

debt

address

address of the debt reserve

user

address

address of the borrower

debtToCover

uint256

amount of asset debt that the liquidator will repay

receiveAToken

bool

if true, the user receives the aTokens equivalent of the purchased collateral. If false, the user receives the underlying asset directly.

flashLoan()

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

Sends the requested amounts of assets to the receiverAddress contract, passing the included params.

If the flash loaned amounts + fee is not returned by the end of the transaction, then the transaction will either:

  • revert if the associated mode is 0,

  • onBehalfOf incurs a stable debt if mode is 1, or

  • onBehalfOf incurs a variable debt if mode is 2.

Parameter Name
Type
Description

receiverAddress

address

address of the contract receiving the funds.

Must implement the IFlashLoanReceiver interface.

assets

address[]

addresses of the reserves to flashloan

amounts

uint256[]

amounts of assets to flashloan.

This needs to contain the same number of elements as assets.

modes

uint256[]

the types of debt to open if the flashloan is not returned.

0: Don't open any debt, just revert

1: stable mode debt

2: variable mode debt

onBehalfOf

address

if the associated mode is not0 then the incurred debt will be applied to the onBehalfOf address.

params

bytes

bytes-encoded parameters to be used by the receiverAddress contract

referralCode

uint16

View Methods

getReserveData()

function getReserveData(address asset)

Returns the state and configuration of the reserve

Parameter Name
Type
Description

asset

address

address of the reserve

Return values

Parameter Name
Type
Description

configuration

uint256

See the whitepaper for details on why a bitmask was used.

bit 0-15: LTV

bit 16-31: Liq. threshold

bit 32-47: Liq. bonus

bit 48-55: Decimals

bit 56: reserve is active

bit 57: reserve is frozen

bit 58: borrowing is enabled

bit 59: stable rate borrowing enabled

bit 60-63: reserved

bit 64-79: reserve factor

** All % are 1e4 i.e. percentage plus two decimals

** Decimals is 1e2

** Caveat on Liquidation bonus 105% Liq Bonus = 100% principal + 5% bonus

liquidityIndex

uint128

liquidity index in ray

variableBorrowIndex

uint128

variable borrow index in ray

currentLiquidityRate

uint128

current supply / liquidity / deposit rate in ray

currentVariableBorrowRate

uint128

current variable borrow rate in ray

currentStableBorrowRate

uint128

current stable borrow rate in ray

lastUpdateTimestamp

uint40

timestamp of when reserve data was last updated

aTokenAddress

address

address of associated aToken (tokenised deposit)

stableDebtTokenAddress

address

address of associated stable debt token

variableDebtTokenAddress

address

address of associated variable debt token

interestRateStrategyAddress

address

address of interest rate strategy.

id

uint8

the position in the list of active reserves

getUserAccountData**()**

function getUserAccountData(address user)

Returns the user account data across all the reserves

Parameter Name
Type
Description

user

address

address of the user

Return values

Parameter Name
Type
Description

totalCollateralETH

uint256

total collateral in ETH of the use (wei decimal unit)

totalDebtETH

uint256

total debt in ETH of the user (wei decimal unit)

availableBorrowsETH

uint256

borrowing power left of the user (wei decimal unit)

currentLiquidationThreshold

uint256

liquidation threshold of the user (1e4 format => percentage plus two decimals)

ltv

uint256

Loan To Value of the user (1e4 format => percentage plus two decimals)

healthFactor

uint256

current health factor of the user.

getConfiguration**()**

function getConfiguration(address asset)

Returns the configuration of the reserve

Parameter Name
Type
Description

asset

address

address of the reserve

Return values

Return Type
Description

uint256

See the whitepaper for details on why a bitmask was used.

bit 0-15: LTV

bit 16-31: Liq. threshold

bit 32-47: Liq. bonus

bit 48-55: Decimals

bit 56: reserve is active

bit 57: reserve is frozen

bit 58: borrowing is enabled

bit 59: stable rate borrowing enabled

bit 60-63: reserved

bit 64-79: reserve factor

getUserConfiguration**()**

function getUserConfiguration(address user)

Returns the configuration of the user across all the reserves.

Parameter Name
Type
Description

user

address

address of the user

Return values

Return Type
Description

uint256

See the whitepaper for details on why a bitmask was used.

The bitmask is divided into pairs of bits, one pair for each asset.

In short, if a user is using WETH as collateral and has borrowed DAI, then the value returned would be 0x40020 (in hex) or 262176 (in decimal).

getReserveNormalizedIncome**()**

function getReserveNormalizedIncome(address asset)

Returns the normalized income per unit of asset.

A return value of 1e271e271e27 indicates no income. As time passes, the income is accrued. A value of 2∗1e272 * 1e272∗1e27 indicates that for each unit of asset, two units of income have been accrued.

Parameter Name
Type
Description

asset

address

address of the reserve

getReserveNormalizedVariableDebt**()**

function getReserveNormalizedVariableDebt(address asset)

Returns the normalized variable debt per unit of asset.

A return value of 1e271e271e27 indicates no debt. As time passes, the debt is accrued. A value of 2∗1e272 * 1e272∗1e27 indicates that for each unit of asset, two units of debt have been accrued.

Parameter Name
Type
Description

asset

address

address of the reserve

paused**()**

function paused()

Returns true if the LendingPool is paused.

getReservesList**()**

function getReservesList()

Returns the list of initialized reserves.

getAddressesProvider**()**

function getAddressesProvider()

Returns the addresses provider.

Error Codes

ABI

LendingPool ABI
[
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "borrowRateMode",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "borrowRate",
              "type": "uint256"
          },
          {
              "indexed": true,
              "internalType": "uint16",
              "name": "referral",
              "type": "uint16"
          }
      ],
      "name": "Borrow",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "indexed": true,
              "internalType": "uint16",
              "name": "referral",
              "type": "uint16"
          }
      ],
      "name": "Deposit",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "target",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "initiator",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "premium",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint16",
              "name": "referralCode",
              "type": "uint16"
          }
      ],
      "name": "FlashLoan",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "collateralAsset",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "debtAsset",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "debtToCover",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "liquidatedCollateralAmount",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "address",
              "name": "liquidator",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "bool",
              "name": "receiveAToken",
              "type": "bool"
          }
      ],
      "name": "LiquidationCall",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [],
      "name": "Paused",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "RebalanceStableBorrowRate",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "repayer",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          }
      ],
      "name": "Repay",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "liquidityRate",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "stableBorrowRate",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "variableBorrowRate",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "liquidityIndex",
              "type": "uint256"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "variableBorrowIndex",
              "type": "uint256"
          }
      ],
      "name": "ReserveDataUpdated",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "ReserveUsedAsCollateralDisabled",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "ReserveUsedAsCollateralEnabled",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "rateMode",
              "type": "uint256"
          }
      ],
      "name": "Swap",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [],
      "name": "Unpaused",
      "type": "event"
  },
  {
      "anonymous": false,
      "inputs": [
          {
              "indexed": true,
              "internalType": "address",
              "name": "reserve",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "indexed": true,
              "internalType": "address",
              "name": "to",
              "type": "address"
          },
          {
              "indexed": false,
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          }
      ],
      "name": "Withdraw",
      "type": "event"
  },
  {
      "inputs": [],
      "name": "FLASHLOAN_PREMIUM_TOTAL",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "LENDINGPOOL_REVISION",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "MAX_NUMBER_RESERVES",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "MAX_STABLE_RATE_BORROW_SIZE_PERCENT",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "interestRateMode",
              "type": "uint256"
          },
          {
              "internalType": "uint16",
              "name": "referralCode",
              "type": "uint16"
          },
          {
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          }
      ],
      "name": "borrow",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          },
          {
              "internalType": "uint16",
              "name": "referralCode",
              "type": "uint16"
          }
      ],
      "name": "deposit",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "from",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "to",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "balanceFromBefore",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "balanceToBefore",
              "type": "uint256"
          }
      ],
      "name": "finalizeTransfer",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "receiverAddress",
              "type": "address"
          },
          {
              "internalType": "address[]",
              "name": "assets",
              "type": "address[]"
          },
          {
              "internalType": "uint256[]",
              "name": "amounts",
              "type": "uint256[]"
          },
          {
              "internalType": "uint256[]",
              "name": "modes",
              "type": "uint256[]"
          },
          {
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          },
          {
              "internalType": "bytes",
              "name": "params",
              "type": "bytes"
          },
          {
              "internalType": "uint16",
              "name": "referralCode",
              "type": "uint16"
          }
      ],
      "name": "flashLoan",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "getAddressesProvider",
      "outputs": [
          {
              "internalType": "contract ILendingPoolAddressesProvider",
              "name": "",
              "type": "address"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          }
      ],
      "name": "getConfiguration",
      "outputs": [
          {
              "components": [
                  {
                      "internalType": "uint256",
                      "name": "data",
                      "type": "uint256"
                  }
              ],
              "internalType": "struct DataTypes.ReserveConfigurationMap",
              "name": "",
              "type": "tuple"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          }
      ],
      "name": "getReserveData",
      "outputs": [
          {
              "components": [
                  {
                      "components": [
                          {
                              "internalType": "uint256",
                              "name": "data",
                              "type": "uint256"
                          }
                      ],
                      "internalType": "struct DataTypes.ReserveConfigurationMap",
                      "name": "configuration",
                      "type": "tuple"
                  },
                  {
                      "internalType": "uint128",
                      "name": "liquidityIndex",
                      "type": "uint128"
                  },
                  {
                      "internalType": "uint128",
                      "name": "variableBorrowIndex",
                      "type": "uint128"
                  },
                  {
                      "internalType": "uint128",
                      "name": "currentLiquidityRate",
                      "type": "uint128"
                  },
                  {
                      "internalType": "uint128",
                      "name": "currentVariableBorrowRate",
                      "type": "uint128"
                  },
                  {
                      "internalType": "uint128",
                      "name": "currentStableBorrowRate",
                      "type": "uint128"
                  },
                  {
                      "internalType": "uint40",
                      "name": "lastUpdateTimestamp",
                      "type": "uint40"
                  },
                  {
                      "internalType": "address",
                      "name": "aTokenAddress",
                      "type": "address"
                  },
                  {
                      "internalType": "address",
                      "name": "stableDebtTokenAddress",
                      "type": "address"
                  },
                  {
                      "internalType": "address",
                      "name": "variableDebtTokenAddress",
                      "type": "address"
                  },
                  {
                      "internalType": "address",
                      "name": "interestRateStrategyAddress",
                      "type": "address"
                  },
                  {
                      "internalType": "uint8",
                      "name": "id",
                      "type": "uint8"
                  }
              ],
              "internalType": "struct DataTypes.ReserveData",
              "name": "",
              "type": "tuple"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          }
      ],
      "name": "getReserveNormalizedIncome",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          }
      ],
      "name": "getReserveNormalizedVariableDebt",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "getReservesList",
      "outputs": [
          {
              "internalType": "address[]",
              "name": "",
              "type": "address[]"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "getUserAccountData",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "totalCollateralETH",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "totalDebtETH",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "availableBorrowsETH",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "currentLiquidationThreshold",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "ltv",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "healthFactor",
              "type": "uint256"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "getUserConfiguration",
      "outputs": [
          {
              "components": [
                  {
                      "internalType": "uint256",
                      "name": "data",
                      "type": "uint256"
                  }
              ],
              "internalType": "struct DataTypes.UserConfigurationMap",
              "name": "",
              "type": "tuple"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "aTokenAddress",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "stableDebtAddress",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "variableDebtAddress",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "interestRateStrategyAddress",
              "type": "address"
          }
      ],
      "name": "initReserve",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "contract ILendingPoolAddressesProvider",
              "name": "provider",
              "type": "address"
          }
      ],
      "name": "initialize",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "collateralAsset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "debtAsset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "user",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "debtToCover",
              "type": "uint256"
          },
          {
              "internalType": "bool",
              "name": "receiveAToken",
              "type": "bool"
          }
      ],
      "name": "liquidationCall",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [],
      "name": "paused",
      "outputs": [
          {
              "internalType": "bool",
              "name": "",
              "type": "bool"
          }
      ],
      "stateMutability": "view",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "user",
              "type": "address"
          }
      ],
      "name": "rebalanceStableBorrowRate",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "internalType": "uint256",
              "name": "rateMode",
              "type": "uint256"
          },
          {
              "internalType": "address",
              "name": "onBehalfOf",
              "type": "address"
          }
      ],
      "name": "repay",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "configuration",
              "type": "uint256"
          }
      ],
      "name": "setConfiguration",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "bool",
              "name": "val",
              "type": "bool"
          }
      ],
      "name": "setPause",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "address",
              "name": "rateStrategyAddress",
              "type": "address"
          }
      ],
      "name": "setReserveInterestRateStrategyAddress",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "bool",
              "name": "useAsCollateral",
              "type": "bool"
          }
      ],
      "name": "setUserUseReserveAsCollateral",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "rateMode",
              "type": "uint256"
          }
      ],
      "name": "swapBorrowRateMode",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
  },
  {
      "inputs": [
          {
              "internalType": "address",
              "name": "asset",
              "type": "address"
          },
          {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
          },
          {
              "internalType": "address",
              "name": "to",
              "type": "address"
          }
      ],
      "name": "withdraw",
      "outputs": [
          {
              "internalType": "uint256",
              "name": "",
              "type": "uint256"
          }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
  }
]

address of the

referral code for our . Use 0 for no referral.

address of the , not the aToken

Note: onBehalfOf must have enough collateral via or have delegated credit to msg.sender via . See the Credit Delegation guide for more details.

address of the

referral code for our . Use 0 for no referral code.

address of the

address of the

address of the

Liquidate positions with a health factor below 1. Also see our .

To check a user's health factor, use .

Your contract which receives the flash loaned amounts must conform to the interface. For more, see the .

Note: onBehalfOf must already have sufficient borrow allowance of the associated asset to msg.sender

referral code for our

Also see

The first bit of the pair indicates if it is being used as collateral by the user, the second bit indicates if it is being borrowed. The corresponding assets are in the same position as For example, if the hex value returned is 0x40020, which represents a decimal value of 262176, then in binary it is 1000000000000100000. If we format the binary value into pairs, starting from the right, we get 1 00 00 00 00 00 00 10 00 00.

If we start from the right and move left in the above binary pairs, the third pair is 10. The third reserve listed in is WETH. Therefore the 1 indicates that WETH is used as collateral, and 0 indicates that WETH has not been borrowed by this user.

If we continue to go to the end of the binary pairs (furthest left), we have 1 which can also be represented as 01. This is the 10th pair, which in is DAI. Therefore the 0 indicates that DAI is not used as collateral, and the 1 indicates that it is being borrowed by this user.

In order to reduce gas usage and code size, Phantazm contracts return numbered errors. If you are making calls to the protocol and receive numbered errors, you can use our to know what the error number means. Alternatively, you can also find what the numbers represent by checking the Errors.sol

WETHGateway
Liquidations guide
IFlashLoanReceiver
flash loan guides
getUserAccountData()
referral program
referral program
referral program
liquidationCall()
getReservesList()
getReserveList()
getReserveList()
deposit()
approveDelegation()
approved
error code reference guide
underlying asset
underlying asset
underlying asset
underlying asset
underlying asset
underlying asset