You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`--markets`: A list of markets to monitor for liquidations (e.g., templar-market1.testnet).
43
+
-`--registries`: A list of registries to query markets from which will be monitored for liquidations (e.g., templar-registry1.testnet).
43
44
-`--signer-key`: The private key of the signer account used to sign transactions.
44
45
-`--signer-account`: The NEAR account that will perform the liquidations (e.g., templar-liquidator.testnet).
45
46
-`--asset`: The asset to liquidate NEP-141 token account used for repayments (e.g., usdc.testnet).
@@ -48,10 +49,12 @@ Arguments:
48
49
-`--timeout`: The timeout for RPC calls in seconds (default is 60 seconds).
49
50
-`--concurrency`: The number of concurrent liquidation attempts (default is 10).
50
51
-`--interval`: The interval in seconds for the service to check for liquidatable positions (default is 600 seconds).
52
+
-`--registry-refresh-interval`: The interval in seconds for the service to check for new markets on the registries (default is 3600 seconds - 1 hour).
51
53
52
54
How it works:
53
55
54
-
1. The bot initializes a Liquidator object for each market specified in the `--markets` argument.
56
+
1. The bot fetches all deployments for each registry specified in the `--registryes` argument.
57
+
1. The bot initializes a Liquidator object for each market fetched.
55
58
1. It continuously checks the status of borrowers in each market.
56
59
1. If a borrower is found to be liquidatable, it calculates the liquidation amount based on the borrower's collateral and debt.
57
60
1. It sends an `ft_transfer_call` RPC call to the smart contract to trigger the liquidation process.
@@ -66,7 +69,7 @@ Liquidation Logic:
66
69
The liquidation logic is encapsulated within the `Liquidator` object, which is responsible for:
67
70
68
71
- Checking a borrower's status to determine if they are below the required collateralization ratio.
69
-
- Calculating the liquidation amount based on the borrower's collateral and debt. (This calculation should be implemented by the liquidator according to their specific strategy or requirements.)
72
+
- Calculating the liquidation amount based on the borrower's collateral and debt.
70
73
71
74
```rust
72
75
#[instrument(skip(self), level ="debug")]
@@ -76,17 +79,7 @@ async fn liquidation_amount(
76
79
oracle_response:&OracleResponse,
77
80
configuration:MarketConfiguration,
78
81
) ->LiquidatorResult<(U128, U128)> {
79
-
// TODO: Calculate optimal liquidation amount
80
-
// For purposes of this example implementation we will just use the minimum acceptable
81
-
// liquidation amount.
82
-
// Costs to take into account here are:
83
-
// - Gas fees
84
-
// - Price impact
85
-
// - Slippage
86
-
// All of this would be used in calculating both the optimal liquidation amount and wether to
- Deciding on whether the liquidation should happen or not (This calculation should be implemented by the liquidator according to their specific strategy or requirements.)
112
+
113
+
```rust
114
+
#[instrument(skip(self), level ="debug")]
115
+
pubasyncfnshould_liquidate(
116
+
&self,
117
+
swap_amount:U128,
118
+
liquidation_amount:U128,
119
+
) ->LiquidatorResult<bool> {
120
+
// TODO: Calculate optimal liquidation amount
121
+
// For purposes of this example implementation we will just use the minimum acceptable
122
+
// liquidation amount.
123
+
// Costs to take into account here are:
124
+
// - Gas fees
125
+
// - Price impact
126
+
// - Slippage
127
+
// All of this would be used in calculating both the optimal liquidation amount and wether to
128
+
// perform full or partial liquidation
129
+
Ok(true)
130
+
}
131
+
```
132
+
128
133
- Sending the `ft_transfer_call` RPC call to the borrow asset contract to trigger liquidation.
129
134
- Handling errors and retries for failed liquidation attempts.
130
135
- Logging the results of each liquidation attempt for monitoring and debugging purposes.
@@ -172,6 +177,67 @@ async fn get_oracle_prices(
172
177
173
178
The liquidator will fetch the price data from the oracle contract in order to execute the liquidation and gauge whether the liquidation is profitable.
0 commit comments