feat: Solana State SDK — Jupiter, Drift, Kamino protocol wrappers#11
Open
skansal-rome wants to merge 8 commits into
Open
feat: Solana State SDK — Jupiter, Drift, Kamino protocol wrappers#11skansal-rome wants to merge 8 commits into
skansal-rome wants to merge 8 commits into
Conversation
…rough Add read_u16le, read_u128le, u16le to Convert library (read_i64le and read_i128le already existed, refactored read_i128le to use read_u128le). Add Jupiter v6 passthrough invoke helper and JupiterSwap convenience contract. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add full Drift v2 protocol wrappers: PDA derivation, account parsers (PerpMarket, SpotMarket, User positions), instruction builders (deposit, withdraw, place_perp_order, cancel_order), DriftOrderBuilder for market and limit orders, DriftController high-level contract, and DriftFactory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Kamino Lending wrappers: Reserve and Obligation parsers with health factor computation, PDA derivation, instruction builders (deposit, withdraw, borrow, repay), and KaminoLending high-level contract. Add Kamino Vault wrappers: Strategy parser, vault instruction builders, and KaminoVault contract for LP provision. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add protocol-agnostic interfaces: ISwap (Jupiter/Meteora), ILending (Kamino), IPerpetuals (Drift), ILiquidity (Kamino Vault). DeFiRouter implements all four interfaces and delegates to protocol-specific libraries. Enable viaIR in hardhat config for stack depth support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…innet Drift PerpMarket: All offsets shifted due to self-pubkey field at [8]. Corrected: oracle→40, base_asset_reserve→176, quote_asset_reserve→192, cumulative_funding_long→560, cumulative_funding_short→576, last_funding_rate_ts→792, market_index→1160, status→1162. Removed open_interest (not a real Drift field). Drift SpotMarket: oracle→40, mint→72, vault→104, deposit_balance→432, borrow_balance→448, cum_deposit_interest→464, cum_borrow_interest→480, decimals→680 (u32 low byte), market_index→684, status→688. Kamino Lending: Corrected program ID to KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD, RESERVE_MIN_LEN to 8624. Header offsets (25-225) validated. Collateral/config offsets (520, 700) marked as unverified pending USDC reserve validation. All 51 offset checks pass against live mainnet Solana accounts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deployed addresses: - JupiterSwap: 0x1f67cfdfe9545f79e4f2de7243f4350d8c044d84 - DriftFactory: 0x7e8d277ecc3da14718fda1a4066002e206aa0244 - KaminoLending: 0xad9432a6d2c52e540df1c81a44dac0b05998f985 - KaminoVault: 0x8dddf7d1b8ade2c8b3230a4fa4b626c8c7d0b03c - DeFiRouter: 0x893297525024de0dc3de44cde83b1b939a0db6bc Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DriftController reads live data: PerpMarket 0 (SOL-PERP) and 1 (ETH-PERP) return correct market_index, non-zero reserves, recent funding timestamps. SpotMarket 0 (USDC, decimals=6) and 1 (SOL, decimals=9) validated. DriftFactory: controller creation + duplicate prevention verified. KaminoLending/Vault: correctly revert (Kamino not on monti_spl Solana). DeFiRouter: all delegated functions tested, swap/cancel correctly revert. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_u16le,read_u128le,u16letocontracts/convert.sol. Refactored existingread_i128leto useread_u128le.JupiterLibexecute_route helper +JupiterSwapconvenience contract for forwarding pre-computed Jupiter API routes via CPI.DriftOrderBuilderfor market/limit orders,DriftController+DriftFactory.KaminoLendingcontract. Vault strategy parser +KaminoVaultcontract for LP provision.ISwap,ILending,IPerpetuals,ILiquidityprotocol-agnostic interfaces +DeFiRouterimplementing all four, delegating to protocol-specific libraries.viaIR: true+ optimizer for stack depth support in complex CPI account builders.Architecture
Test plan
npx hardhat compile— 49 files compile cleanly (solc 0.8.28, viaIR)🤖 Generated with Claude Code