Skip to content

Commit 32ef95f

Browse files
committed
refactored code
1 parent 27be4f9 commit 32ef95f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

research/zkLend_liquidation_research.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To verify if a position was liquidated in zkLend, the following steps were taken
4242

4343
Upon checking the portfolio of the deployed Spotnet contract, it was found that there is a balance of **1.744172753867558899 zSTRK Token**. This corresponds with `LiquidityLooped` event that showed the user (through spotnet contract) was able to achieve a collateral of **1.744172753867558898 STRK** from an initial deposit amount of **1 STRK**.
4444

45-
`LiquidityLooped` event also showed that **0.473917 USDC** was borrowed with the 1.744 STRK collateral. The Read function `get_user_debt_for_token(user, token)`, with USDC address as token, on zkLend Market contract returned 0.475401 USDC, 0.475529 USDC at a later time. and currently 0.476299. Checked the `balanceOf(account)` of our contract on zkLend: zSTRK Token contract, which returned 1.744438892223882014. Due to an abscence of a `Liquidation` event for our contract on zkLend, these state (small) changes must be due to market activity, interest on debts or rewards for providing liquidity/collateral.
45+
`LiquidityLooped` event also showed that **0.473917 USDC** was borrowed with the 1.744 STRK collateral. The Read function `get_user_debt_for_token(user, token)`, with USDC address as token, on zkLend Market contract returned 0.475401 USDC, 0.475529 USDC at a later time, and currently 0.476299. Checked the `balanceOf(account)` of our contract on zkLend: zSTRK Token contract, which returned 1.744438892223882014. Due to an abscence of a `Liquidation` event for our contract on zkLend, these state (small) changes must be due to market activity, interest on debts or rewards for providing liquidity/collateral.
4646

4747
## Result/Discussion
4848

@@ -79,7 +79,7 @@ From analysis of [all Starknet Liquidations](https://dune.com/caravanserai/stark
7979

8080
The zkLend liquidation process is unique compared to other lending protocols, such as Aave. Unlike these protocols, zkLend does not allow liquidators to fully liquidate a position, regardless of how low the health factor is. Instead, the current design permits liquidators to partially liquidate undercollateralized positions, ensuring that the user remains undercollateralized after the liquidation.
8181

82-
The deployed Spotnet contract is yet to be liquidized by zkLend as evident by:
82+
The deployed Spotnet contract is yet to be liquidated by zkLend as evident by:
8383
1. lack of `Liquidation` event from zkLend Events.
8484
2. collateral balance remains the same.
8585

research/zklend_liquidation_position.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from starknet_py.net.full_node_client import FullNodeClient
1212

1313
# Load environment variables
14-
node_url = "https://starknet-mainnet.public.blastapi.io/rpc/v0_7"
14+
NODE_URL = "https://starknet-mainnet.public.blastapi.io/rpc/v0_7"
1515
ZKLEND_CONTRACT_ADDRESS = (
1616
"0x04c0a5193d58f74fbace4b74dcf65481e734ed1714121bdc571da345540efa05"
1717
)
@@ -21,7 +21,7 @@
2121

2222

2323
# Initialize the StarkNet client
24-
client = FullNodeClient(node_url=node_url)
24+
client = FullNodeClient(node_url=NODE_URL)
2525

2626
DEPOSIT_SELECTOR = "0xfa3f9acdb7b24dcf6d40d77ff2f87a87bca64a830a2169aebc9173db23ff41"
2727

@@ -71,9 +71,6 @@ async def check_liquidation_proof(liquidatee_address: str) -> None:
7171

7272
# Process events for the specific user
7373
for event in events:
74-
# logger.info(f"Event Data: {event}")
75-
# logger.info(f"Event Data: {event.data}")
76-
7774
# Unpack event.data object
7875
# sample at
7976
# https://starkscan.co/event/0x0204f9e81102c2e2f1af181e9a931580da5fa9a80abd21e15116a6175e00b736_10
@@ -103,9 +100,9 @@ async def check_liquidation_proof(liquidatee_address: str) -> None:
103100

104101
# Print all liquidation results after processing all events
105102
if liquid_results:
106-
print("Liquidation Results:", liquid_results)
103+
logger.info(f"Liquidation Results: {liquid_results}")
107104
else:
108-
print(f"No liquidation events found for user {liquidatee_address}.")
105+
logger.info(f"No liquidation events found for user {liquidatee_address}.")
109106

110107

111108
if __name__ == "__main__":

0 commit comments

Comments
 (0)