Credit Loan
Credit Loan is the feature that enables protocols and developers to leverage liquidity in Iron Bank without collateralization.


Credit Loan allows protocols and developers to borrow assets without collateralization. The liquidity comes from the shared markets where normal users supply and borrow via website. That is, the same Interest Rate Model, Utilization Rate and Borrow APY apply to Credit Loan user. For more information about market stats, visit Iron Bank Market.
Currently, the Credit Loan feature is by permission. Iron Bank team reviews borrower's contracts and protocol model to come up with a risk assessment report, and the report is public to Iron Bank community. As mentioned, the Credit Loan user borrows from the shared markets where normal users supply. Therefore, it is necessary to evaluate the Credit Loan risk from all perspectives.

Risk Assessment

Besides contract security, Iron Bank team also reviews the protocol model to ensure two things:
  • The destination of fund is deterministic
  • Iron Bank is senior debt
The borrower must be a contract. The borrowing fund goes to where the contract predefines without exception, and Iron Bank must be the top priority for the contract to repay before the fund is distributed for other purposes. This is how we review the Credit Loan requests, and also how we ensure the funds go back to Iron Bank eventually.
For risk assessment example, visit Alpha Homora Risk Assessment (Optimism).

Credit Limit

By having the credit limit, a Credit Loan user can borrow to the limit from the designated market. It is decided by Iron Bank team, depending on the risk assessment report.
The credit limit can be adjusted anytime by admin multisig with a 2-hour timelock, and the change does not affect current borrowing but prevents Credit Loan user from borrowing more than the new limit.
In the time of emergency, the guardian can reduce credit limit to $1 for a specific account without timelock, preventing the account to borrow further without making it a non-credit-limit account.


Credit Loan is an advanced concept aimed at protocol developers. You must have a good understanding of EVM, programming, and smart contracts to be able to proceed.
GitHub - ibdotxyz/ib-creditloan-mix: A Brownie mix containing all you need to get started with developing credit borrowing on Iron Bank
It comes with everything you need to start developing on Iron Bank Credit Loans.

Installation and Setup

  1. 1.
    Install Brownie & Ganache-CLI, if you haven't already.
  2. 2.
    Sign up for Infura and generate an API key. Store it in the WEB3_INFURA_PROJECT_ID environment variable.
  • Optional Use network-config.yaml provided in the repo. NOTE: This will replace your network config globally
cp network-config.yaml ~/.brownie/
3. Sign up for Etherscan and generate an API key. This is required for fetching source codes of the mainnet contracts we will be interacting with. Store the API key in the ETHERSCAN_TOKEN environment variable.
export ETHERSCAN_TOKEN=YourApiToken
  • Optional Use .env file
    1. 1.
      Make a copy of .env.example
    2. 2.
      Add the values for ETHERSCAN_TOKEN or OPSCAN_TOKEN according to the network you are going to develop on.
4. Download the mix.
git clone [email protected]:ibdotxyz/ib-creditloan-mix.git

Basic Use

To perform a simple credit loan in a development environment:
1. Run scripts/ to create an officer for our credit borrower and launch the console. This automatically launches Ganache on a forked mainnet.
$ brownie run scripts/ --network mainnet-fork --interactive
2. Deploy the CreditBorrower.sol contract.
>>> token = credit_officer.borrowToken()
>>> credit_borrower = CreditBorrower.deploy(accounts[0], token, credit_officer, {"from": accounts[0]})
Transaction sent: 0xb173db83eeee9b35abe557f963543e0579bd3e79f710ece407e763428a0aeea1
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 6
CreditBorrower.constructor confirmed Block: 15547377 Gas used: 395321 (3.29%)
CreditBorrower deployed at: 0x9E4c14403d7d9A8A782044E86a93CAE09D7B2ac9
3. Set the borrower to the newly deployed contract. We must do this because we only approved borrower contract that has been reviewed.
>>> credit_officer.setBorrower(credit_borrower, {"from": ib_admin})
Transaction sent: 0xe1a4b986f14d62ad7c71e3528af8fce41eb6a4560af423ecb50db23e6e5f304c
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 3
CreditOfficer.setBorrower confirmed Block: 15547378 Gas used: 43452 (0.36%)
4. Borrow some DAI from Iron Bank.
>>> credit_borrower.borrow(100_000 * 10 ** 18, {"from": accounts[0]})
Transaction sent: 0xa24bed673ed9eb23ce1cecae261394c73cba518aeecb6aa3730f331d26111d2a
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 7
CreditBorrower.borrow confirmed Block: 15547379 Gas used: 346029 (2.88%)
5. Now we are ready to put our borrower into work!
>>>{"from": accounts[0]})
Transaction sent: 0x7c6bdd7f0b80547ca81583de4cdca92b240a2014b4732114140ddc074fe8b7ca
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 8 confirmed Block: 15547380 Gas used: 22115 (0.18%)

Implementing Credit Loan Logic

contracts/CreditBorrower.sol is where you implement your own logic for credit loans. In particular:
  • Fill in a way to calculate the total balance of the asset that are able to be repaid via CreditBorrower.totalBalance()
  • Unwind enough of your position to payback debt via CreditBorrower.askForRepay()
  • The destination of fund should be deterministic.
  • Iron Bank should be senior debt.
  • Decentralized oracle should be used to evaluate assets that are not the borrowed token.
  • All operations and roles will be reviewed by Iron Bank.
See the Iron Bank documentation on Credit Limit Assessment for more information.


To run the tests:
brownie test
The example tests provided in this mix start by deploying and approving your CreditBorrower.sol contract. This ensures that the loan executes succesfully without any custom logic. Once you have built your own logic, you should edit tests/
See the Brownie documentation for more detailed information on testing your project.

Debugging Failed Transactions

Use the --interactive flag to open a console immediatly after each failing test:
brownie test --interactive
Within the console, transaction data is available in the history container:
>>> history
[<Transaction '0x50f41e2a3c3f44e5d57ae294a8f872f7b97de0cb79b2a4f43cf9f2b6bac61fb4'>,
<Transaction '0xb05a87885790b579982983e7079d811c1e269b2c678d99ecb0a3a5104a666138'>]
Examine the TransactionReceipt for the failed test to determine what went wrong. For example, to view a traceback:
>>> tx = history[-1]
>>> tx.traceback()
To view a tree map of how the transaction executed:
>>> tx.call_trace()
See the Brownie documentation for more detailed information on debugging failed transactions.


You should write your own deployment script and verify on Etherscan. Submit the contract address to Iron Bank for review.


Copy link
On this page
Risk Assessment
Credit Limit
Installation and Setup
Basic Use
Implementing Credit Loan Logic
Debugging Failed Transactions