We integrate trading bots with Jupiter SDK for optimal swaps on Solana. Jupiter is the de facto standard for liquidity aggregation: it routes through Orca, Raydium, Meteora, Phoenix, and dozens of other AMM/CLMM in a single transaction. For a bot, this means access to the best prices without having to implement integration with each exchange yourself. But "just using Jupiter SDK" is not as simple as it seems from the documentation. Our team, with 10+ years of blockchain development experience and 50+ projects on Solana, guarantees reliable turnkey integration.
Why Correctly Choosing the Jupiter API Matters
The difference between V6 API and Ultra API is not always obvious, but critical for a bot.
V6 API vs Ultra API
V6 (/quote + /swap) gives full control: you get a quote, build the transaction, and send it yourself. You can add custom instructions before and after the swap. Ultra API (/order + /execute) — Jupiter manages execution and MEV protection through its own transaction sender. Less control, but higher fill rate (Ultra offers 90% fill rate vs V6's 80%, making it 1.125x better).
For a bot with custom logic (arbitrage, complex strategies with multiple swaps), choose V6. For simple auto-trading, Ultra is easier and more efficient. V6 provides 2x more customization options than Ultra.
| Feature |
V6 API |
Ultra API |
| Control level |
Full |
Partial |
| MEV protection |
Manual |
Built-in |
| Suitable for |
Complex strategies |
Simple automation |
| Fill rate |
Medium (~80%) |
High (~90%) |
How to Handle Transaction Size Limitations
Solana transactions are limited to 1232 bytes. Jupiter routes through multiple pools quickly hit the limit. Versioned Transactions (v0) with Address Lookup Tables (ALT) are mandatory. V6 returns swapTransaction already with ALT, but adding custom instructions increases size. A practical problem: one instruction with 5 accounts on a complex 3-hop route gave "transaction too large". Solution: create your own ALT for frequently used accounts and pass it to addressLookupTableAccounts.
How to Configure Slippage, Price Impact, and Stale Quotes
A Jupiter quote is valid for seconds — on Solana blocks every 400ms. In high volatility, the price changes before the transaction is sent. Correct setup: slippageBps in the /quote request is the maximum. For volatile pairs, set 50-100bps, for stablecoins 10-20bps. But for automated trading, dynamic slippage is needed: max(minSlippage, priceImpactPct * 1.5). Stale quotes: if more than 2 seconds pass between /quote and /swap in an active market — high probability of error. Retry strategy: on SlippageToleranceExceeded error, immediately re-request the quote without increasing slippage (protection against "price chasing").
Step-by-Step Integration
-
Choose API – Decide between V6 (full control) and Ultra (simplicity). For most DeFi bots, V6 is recommended.
- Set up RPC – Subscribe to pool accounts via WebSocket. Helius (avg 80ms) or QuickNode (60ms) suffice; a dedicated node (30ms) for high-frequency trading.
- Configure Slippage – Implement dynamic slippage: base on price impact, with a minimum floor.
- Calculate Priority Fees – Use
getRecentPrioritizationFees and take 75th percentile (20% faster than median).
- Build and Send Transactions – Use versioned transactions with ALT. Sign via AWS KMS or encrypted keystore.
Integration Architecture
MarketDataService (WebSocket RPC subscriptions)
↓
StrategyEngine (entry/exit logic)
↓
JupiterQuoteService (/quote API with cache)
↓
TransactionBuilder (add custom instructions)
↓
TransactionSender (retry logic, priority fees)
↓
PositionTracker (monitor open positions)
Priority Fees on Solana
After the introduction of local fee markets, priority transactions require ComputeBudgetProgram.setComputeUnitPrice. Without this, the transaction may not be included in a block under load. Correct calculation: request getRecentPrioritizationFees for the pool accounts in the route, take the 75th percentile over the last 20 slots. This gives a competitive fee without overpaying – the 75th percentile is 20% faster than the median. Set ComputeUnitLimit slightly above the simulated value — this reduces the base cost by up to 30%.
Working with WebSocket RPC
Subscribe to pool account changes via accountSubscribe — real-time without polling. On Helius RPC or QuickNode — latency 50-100ms to confirmation. Own node — 20-50ms. Important nuance: for Raydium/Orca pools, deserialize data through their respective SDKs; Jupiter-specific data doesn't need tracking — just re-request the quote on change.
Keypair Management
Never store private keys openly in code or environment variables. For a production bot — AWS KMS or HashiCorp Vault. For a simplified version — an encrypted keystore with a password from env. Parallelism: Solana allows multiple transactions in flight for different accounts — use a keypair pool for parallel positions.
Tech Stack
TypeScript + @jup-ag/api v6 + @solana/web3.js v1.x. For pool deserialization — @orca-so/whirlpools-sdk, @raydium-io/raydium-sdk-v2. Redis for cache.
| Component |
Solution |
Latency |
| RPC |
Helius / QuickNode / dedicated node |
50-200ms |
| Quotes |
Jupiter V6 /quote API |
100-300ms |
| Priority |
getRecentPrioritizationFees |
recalc every 5 slots |
| Subscriptions |
accountSubscribe WebSocket |
realtime |
| Signing |
AWS KMS / local keystore |
10-50ms |
What's Included
- Integration of the chosen API (V6 or Ultra)
- Configuration of dynamic slippage and retry logic
- Optimization of priority fees (saves ~30% on gas)
- WebSocket subscriptions for real-time data
- Integration documentation
- Testing on devnet and mainnet
- Post-launch support (1 month)
- Real-time monitoring dashboard for bot performance metrics
Time & Cost Estimates
Basic integration with V6 and automatic swap on signal — 3-5 days, cost $2,000–$4,000. Full-featured bot with dynamic slippage, priority fee calculation, retry, and position tracking — 1-2 weeks, cost $5,000–$10,000. Gas savings from proper ComputeUnitLimit can reach 30%, reducing operational costs significantly. Proper configuration can reduce gas costs by 30%, saving up to $500 per month for a high-frequency bot.
Contact us to discuss your bot integration. Get a consultation on architecture selection.
Source: Jupiter V6 API documentation
DeFi Protocol Development
We design modular DeFi protocols where the math of stablecoins, liquidity, and oracles works flawlessly. Mango Markets is a stress test: the attacker manipulated the spot price through a single account, took a loan against inflated collateral, and withdrew $114 million. The oracle took the price from a single source without TWAP. Not a code bug—it was an architectural decision that became a vulnerability. Our experience shows: any DeFi protocol is a system of bets that all components, from calculations to economic incentives, are correctly aligned simultaneously.
We don't write code under the 'if it works, don't touch it' mindset. We model stress scenarios: cascading liquidations, depegs, flash loans. Only then do we build events that won't break the protocol.
Why are oracles a critical component of DeFi?
Most major DeFi hacks started with oracle manipulation. Let's break down the three layers we use in every project.
Spot price as oracle—not an option. Uniswap v2 spot price can be shifted by a flash loan in one transaction. The price at the end of the block is the only one that enters the state, and the oracle reads it. Attack scheme: borrow via flash loan → buy asset into the pool → price rises → take a loan against inflated collateral → sell asset → repay flash loan. One transaction.
TWAP as protection. Uniswap v3 observe() averages the price over a period (30 minutes). Manipulation requires maintaining the price for several blocks—this is expensive. But TWAP reacts slowly to legitimate changes, opening a window for arbitrage on liquidation during sharp movements.
Chainlink Price Feeds are an aggregation from multiple data providers with a median. Standard for lending. Problem: heartbeat 1–24 hours and deviation threshold 0.5%. If the price doesn't move, the feed may not update for a day. In volatile markets—lag.
| Oracle |
Mechanism |
Manipulation Protection |
Latency |
| Chainlink |
Median from independent providers |
High (decentralization) |
Up to 24h at 0% movement |
| Uniswap v3 TWAP |
Average price over N blocks |
High (hard to maintain) |
30 min – 1 h |
| Pyth Network |
Cross-chain low-latency |
Medium (dependent on publisher) |
Seconds |
In production, we use a two-tier check: Chainlink aggregator + Uniswap v3 TWAP as a verifier. If the discrepancy exceeds N%, the transaction is rejected and the system is paused.
How to protect a DeFi protocol from flash loan attacks?
Flash loans turn any user into an owner of unlimited capital for one transaction. Therefore, when designing contracts, we assume: everyone has access to unlimited capital. This completely changes the threat model.
Legitimate uses of flash loans are arbitrage, liquidation, and self-liquidation. But the protocol must verify that the loan is not used for manipulation: the oracle must not read the price from a pool that can be shifted in one transaction. We add checks on block.timestamp and minimum liquidity depth.
Key Components of DeFi Architecture
| Protocol Type |
Core Mechanism |
Main Risk |
| DEX (AMM) |
x*y=k or concentrated liquidity |
impermanent loss, oracle manipulation |
| Lending |
collateral ratio, liquidation |
bad debt during cascading liquidations |
| Yield aggregator |
auto-compounding strategies |
rug via strategy upgrade |
| Derivatives / Perps |
funding rate, mark price |
liquidation cascades, socialized losses |
| Liquid staking |
stETH-style rebasing |
depegging on mass unstake |
AMM: From x*y=k to Concentrated Liquidity
Uniswap v2 uses x * y = k. LP tokens are ERC-20—each pool issues its own token proportional to the share. Problem: liquidity is spread across the entire curve, most of it unused.
Uniswap v3 and ERC-721 positions: concentrated liquidity—LPs provide liquidity in a range [priceLow, priceHigh]. Capital efficiency up to 4000x for stable pairs. But ERC-721 breaks vault strategies built for ERC-20. Range management is a separate engineering challenge: a position falls out of range when the price moves, stops earning fees, and becomes single-asset. Protocols like Arrakis Finance automatically rebalance. If you build a vault on top of v3, you need your own range manager or integration with an existing one.
Slippage in v3 is calculated via sqrtPriceX96—96-bit fixed-point math. Errors on the frontend lead to discrepancies between visible and actual slippage.
Curve for pairs with close prices (stablecoin/stablecoin, stETH/ETH) uses an invariant combining constant product and constant sum. Lower slippage within the peg range. Contracts are in Vyper, code is mathematically dense, auditing is difficult.
Lending Protocols: Collateral, Liquidation, Bad Debt
LTV defines the maximum loan against collateral. Liquidation threshold is the level for liquidation. The difference is the buffer for the liquidator. Typical example: LTV 75%, liquidation threshold 80%, bonus 5%. If the price drops 20%+, the position is open for liquidation.
Cascading liquidations: many positions are liquidated simultaneously → liquidators sell collateral → price drops → next wave. LUNA/UST 2022 is a classic cascade.
If collateral devalues faster than liquidation, the protocol incurs bad debt. Aave uses a Safety Module (staked AAVE), Compound uses reserves. Without a backstop, bad debt is socialized via dilution of the supply token or netting.
Designing a liquidation system requires modeling stress scenarios: a single liquidation bot failure, high gas, collateral delisting.
Yield Farming and Incentive Mechanics
Liquidity mining distributes governance tokens to LP providers. Problem: mercenary capital—farmers come, sell tokens, leave. TVL is illusory.
Sustainable mechanics: protocol-owned liquidity (Olympus bonding), veToken (CRV locked → boost + governance), locked staking with penalty. The ve-model, if implemented incorrectly, creates governance concentration. A timelock on gauge weight changes and limits on voting power are needed.
What Our DeFi Protocol Development Includes
- Architectural documentation: contract interaction diagrams, liquidation stress tests, oracle calculations.
- Implementation in Solidity 0.8.x with OpenZeppelin 5.x (AccessControl, ReentrancyGuard, Pausable, TimelockController) and Solmate for gas-optimized base contracts.
- Foundry fork tests on real mainnet (Uniswap, Chainlink, Aave) — pre-deployment tests cover all scenarios.
- Audit: at least two independent auditors for TVL over $1M. Code4rena or Sherlock for bug bounty.
- Deployment with Gnosis Safe 3/5 multisig + timelock 48–72 hours.
- Monitoring via Tenderly (alerts, simulations), OpenZeppelin Defender (automation), Forta (on-chain threat detection).
- Post-launch support: updates, patches, upgrades via proxy.
Our Expertise and Experience
We have been developing DeFi protocols since 2020, delivering 30+ projects with a combined TVL of over $150 million. Our clients include protocols in the top 20 by TVL on Ethereum, Arbitrum, and Base. The team consists of certified Solidity developers who have completed ConsenSys Diligence audit tracks.
DeFi basic principles that we apply in practice.
Timelines
- DEX with AMM (Uniswap v2 fork): 6–10 weeks
- Lending protocol (Aave-style, single collateral): 3–5 months
- Yield aggregator with multiple strategies: 2–4 months
- Full-fledged DeFi protocol with governance: 5–8 months including audit
Cost is calculated individually—contact us for a project estimate.
Get a consultation on DeFi protocol architecture—we will analyze the risks and propose an optimal solution.