fix: Liquidator MCR target, API key header, loop position re-fetch#376
fix: Liquidator MCR target, API key header, loop position re-fetch#376vitaliybezz merged 2 commits intodevfrom
Conversation
📝 WalkthroughSummaryThis PR addresses three distinct concerns in the liquidator service: 1. Environment Variable StandardizationRenamed generic environment variables to NEAR-specific naming:
Updates applied across configuration files (.env.example), shell scripts, config.rs, and service.rs. 2. RPC API Key Header SupportAdded optional API key authentication for RPC calls:
3. Liquidation Logic Refinements
Critical Review Points
WalkthroughThe PR renames generic env/CLI vars to NEAR-specific names (NEAR_NETWORK, NEAR_RPC_URL, NEAR_API_KEY), adds optional RPC API-key support, introduces position re-fetching in the liquidation loop, and adds a MarketScanner method to fetch a single borrow position. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@service/liquidator/scripts/intent-swap.sh`:
- Line 53: The NEAR_RPC_URL variable in intent-swap.sh is declared but unused;
either remove NEAR_RPC_URL or update all near CLI invocations (e.g., the near
contract call-function / near call commands in this script) to pass the custom
RPC endpoint by adding the --rpc-url flag and referencing NEAR_RPC_URL alongside
the existing NETWORK usage so the CLI actually uses the custom endpoint.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
service/liquidator/.env.exampleservice/liquidator/scripts/intent-swap.shservice/liquidator/scripts/run-mainnet.shservice/liquidator/scripts/run-testnet.shservice/liquidator/src/config.rsservice/liquidator/src/liquidator.rsservice/liquidator/src/main.rsservice/liquidator/src/scanner.rsservice/liquidator/src/service.rs
💤 Files with no reviewable changes (1)
- service/liquidator/src/main.rs
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
service/liquidator/src/config.rs (1)
430-458: 🧹 Nitpick | 🔵 TrivialConsider adding test coverage for
near_api_key.The test verifies
near_rpc_urlpropagation but doesn't testnear_api_key. Adding an assertion ensures the API key is correctly passed through toServiceConfig.💡 Proposed test enhancement
fn test_build_config() { let mut args = create_test_args(); args.near_rpc_url = Some("https://custom.rpc.url".to_string()); + args.near_api_key = Some("test_api_key".to_string()); args.transaction_timeout = 90; // ... existing setup ... let config = args.build_config(); // ... existing assertions ... assert_eq!( config.near_rpc_url, Some("https://custom.rpc.url".to_string()) ); + assert_eq!( + config.near_api_key, + Some("test_api_key".to_string()) + );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@service/liquidator/src/config.rs` around lines 430 - 458, The test function test_build_config currently checks near_rpc_url but omits near_api_key; update the test (in test_build_config using create_test_args / args.build_config) to set args.near_api_key = Some("<expected_key>".to_string()) and add an assertion that config.near_api_key equals that Some value so the ServiceConfig propagation is verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@service/liquidator/src/config.rs`:
- Around line 430-458: The test function test_build_config currently checks
near_rpc_url but omits near_api_key; update the test (in test_build_config using
create_test_args / args.build_config) to set args.near_api_key =
Some("<expected_key>".to_string()) and add an assertion that config.near_api_key
equals that Some value so the ServiceConfig propagation is verified.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| let liquidatable_collateral = position.liquidatable_collateral( | ||
| &price_pair, | ||
| self.market_config.borrow_mcr_liquidation, | ||
| self.market_config.borrow_mcr_maintenance, |
There was a problem hiding this comment.
cool. this is the key change
This change is