Add base leg valuation for synthetic perp markets in Drift adapter#36
Add base leg valuation for synthetic perp markets in Drift adapter#36
Conversation
- Implemented manual reading of `last_oracle_price` from `PerpMarket` account data (offset 72). - Calculated USD value of base asset for markets without a spot mint (e.g., HYPE-PERP). - Added value to quote token (USDC) balance in TVL calculation. Co-authored-by: zknpr <96851588+zknpr@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
This PR addresses the issue where base leg valuation was skipped for perp markets lacking a spot mint (e.g., HYPE-PERP).
Changes:
projects/neutral-trade/utils/drift.js, withingetTvl, modified theperpPositionsprocessing loop.elseblock (wherebaseTokenMintis missing) to fetch thePerpMarketaccount info.last_oracle_pricefrom theHistoricalOracleDatastruct within thePerpMarketaccount (specifically at offset 72).(base_asset_amount * last_oracle_price) / 1e9. The division by1e9accounts for the base asset precision (1e9) and oracle price precision (1e6) to produce a result in USDC precision (1e6).api.add.This ensures that the TVL/Equity calculation correctly includes the value of positions in synthetic perp markets. Verified via a temporary test script mocking the buffer read and calculation.
PR created automatically by Jules for task 864869628374530130 started by @zknpr