Links

How to find Positions that can be liquidated on Market?

To make the process more accessible and easier for the reader, We have provided a script that makes it easy to find borrowers that might have a low health factor and can be liquidated.
So before we begin, let’s discuss the steps involved:
  1. 1.
    Creating a Repl.it Account
  2. 2.
    Forking the script onto your Account
  3. 3.
    Choosing the network on which to find these users (polygon and fantom)
  4. 4.
    Adding the RPC for the network chosen
  5. 5.
    Running the script and understanding results

Create a Replit Account

  • Creating a Replit account is an easy process that can be done in just a few steps. First, navigate to replit.com and locate the "Sign Up" button in the top right corner of the page. Once you have located the button, click it to begin the account creation process.
  • After you have clicked the "Sign Up" button, you will be directed to a page with a signup page. You can use social sign in with Google or Github, or you can even join with an email-id and password.
  • Once you have completed the form, click the "Create Account" button. You will then be asked to verify your email address by clicking a link that will be sent to your email inbox. Click the link to verify your email address and activate your account.
  • Now that you have created your account and verified your email address, you are ready to move on to the next step.

Forking the script onto your Account

  • To fork the script onto your account, first go to this link : Click here
  • You will be directed to the project where the script is located. Then, click on the "Fork" button in the top right corner of the page.
  • Click on “Fork Repl” button. This will create a copy of the project on your Repl.it account.

Choosing the network

  • Open up the replit code editor in the forked project. Click the file named [main.py] and you will find the following variable:
chain_id = 137
  • This variable allows you to switch the network. You can set the following values:
    1. 1.
      137 (for polygon)
    2. 2.
      250 (for fantom)
  • You can change the chain_id variable to one of the above networks and the script will run like that!

Adding the network RPC

Since finding users that can be liquidated, is a computationally expensive task, you’d need to get a dedicated RPC API key, and you can do so by signing up on one of the following websites:

Polygon

Fantom

  • Once you signup and get an RPC Url, you should edit the utils.py file and edit the following line:
rpcs = {137: "POLYGON_RPC_URL", 250: "FANTOM_RPC_URL"}
  • Update the RPC API values in this file and save it.

Running the Script

  • Open up [main.py] file and press the Run button in the middle of the top navigation bar.
  • This should startup a console window and your results will start coming there, it would end up looking something like this:
---------------------------------------------------------
Pool id: 0
Pool name: We're live on Polygon
total_borrowers: 191
close factor: 690000000000000000
liquidation incentive: 1080000000000000000
these are the following accounts that can be liquidated:
---------------------------------------------------------
---------------------------------------------------------
Pool id: 1
Pool name: StableCoin Pool
total_borrowers: 299
close factor: 500000000000000000
liquidation incentive: 1100000000000000000
these are the following accounts that can be liquidated:
---------------------------------------------------------
---------------------------------------------------------
Pool id: 5
Pool name: Green Leverage Locker
total_borrowers: 4736
close factor: 500000000000000000
liquidation incentive: 1100000000000000000
these are the following accounts that can be liquidated:
account(0) 0x404d846Cxxxxxxxxx ignored, as borrowed value is less than 0.005 eth
account(1) 0xF47c5589xxxx with collateralValue 119499466869035672 and borrowedValue 134698530260284237
Tokens: 2
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
underlying: 0x5F1b5714f30bAaC4Cb1ee95E1d0cF6d5694c2204
ctoken: 0x5E6d66fB148a19B04D9FFe1BbEe7081A0D8Bbe2e
borrow balance: 0
supply balance: 240096063673185198421
collateral factor: 800000000000000000
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
underlying: 0x4e3Decbb3645551B8A19f0eA1678079FCB33fB4c
ctoken: 0xDc55282A0BBC4822b6E58d9c8Bfc5ff885972A82
borrow balance: 229457274307605240445
supply balance: 0
collateral factor: 750000000000000000
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[...]
  • Now you can see all the positions and their corresponding values.