Skip to content

[simplex, sdk]: add Uniswap V4 and Aerodrome funding venues#731

Merged
seunlanlege merged 41 commits into
mainfrom
roy/defi-strategies
Mar 27, 2026
Merged

[simplex, sdk]: add Uniswap V4 and Aerodrome funding venues#731
seunlanlege merged 41 commits into
mainfrom
roy/defi-strategies

Conversation

@royvardhan

Copy link
Copy Markdown
Collaborator

Closes #700

@royvardhan royvardhan changed the title [simplex]: add Aerodrome funding in fx strategy [simplex, sdk]: add Uniswap V4 and Aerodrome funding venues Mar 25, 2026
@royvardhan royvardhan force-pushed the roy/defi-strategies branch from 43b0b5d to 17bca16 Compare March 25, 2026 07:50
@royvardhan royvardhan requested a review from seunlanlege March 25, 2026 08:13
@royvardhan royvardhan marked this pull request as ready for review March 25, 2026 08:13
@royvardhan royvardhan requested a review from Wizdave97 March 25, 2026 08:13
Comment thread sdk/packages/sdk/src/protocols/intents/GasEstimator.ts
@Wizdave97

Copy link
Copy Markdown
Member

@royvardhan Let's update the docs in this PR

@royvardhan

Copy link
Copy Markdown
Collaborator Author

@royvardhan Let's update the docs in this PR

Done ser.

@seunlanlege seunlanlege left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observation: Overshoot buffer doesn't fully cover slippage tolerance (Uniswap V4)

In UniswapV4FundingPlanner.ts, the withdrawal adds a 0.05% (5 bps) overshoot buffer to the target amount:

const bufferedRemaining = remaining + (remaining * 5n) / 10_000n

But the slippage tolerance is set to 0.10% (10 bps):

const SLIPPAGE_TOLERANCE = new Percent(10, 10_000) // 0.10%

This means in the worst case:

  • Need 100 tokens
  • Withdraw 100.05 (buffered)
  • Slippage hits the full 0.10% → receive ~99.95
  • Transaction succeeds but you're 0.05 short of what's actually needed

The buffer doesn't fully cover the slippage tolerance. If slippage exceeds 0.05%, the withdrawal succeeds but the subsequent fill could fail due to insufficient funds.

Consider either increasing the buffer to match or exceed the slippage tolerance, or reducing the slippage tolerance to match the buffer.

@royvardhan

Copy link
Copy Markdown
Collaborator Author

Observation: Overshoot buffer doesn't fully cover slippage tolerance (Uniswap V4)

In UniswapV4FundingPlanner.ts, the withdrawal adds a 0.05% (5 bps) overshoot buffer to the target amount:

const bufferedRemaining = remaining + (remaining * 5n) / 10_000n

But the slippage tolerance is set to 0.10% (10 bps):

const SLIPPAGE_TOLERANCE = new Percent(10, 10_000) // 0.10%

This means in the worst case:

  • Need 100 tokens
  • Withdraw 100.05 (buffered)
  • Slippage hits the full 0.10% → receive ~99.95
  • Transaction succeeds but you're 0.05 short of what's actually needed

The buffer doesn't fully cover the slippage tolerance. If slippage exceeds 0.05%, the withdrawal succeeds but the subsequent fill could fail due to insufficient funds.

Consider either increasing the buffer to match or exceed the slippage tolerance, or reducing the slippage tolerance to match the buffer.

Thanks for this.

@royvardhan royvardhan force-pushed the roy/defi-strategies branch from 65086f7 to 95c635d Compare March 26, 2026 08:54
Comment thread sdk/packages/simplex/src/funding/uniswapV4/UniswapV4FundingPlanner.ts Outdated
royvardhan and others added 8 commits March 27, 2026 14:52
…rify startup validation requirements for bid/ask curves and introduce optional spread configuration. Update pricing logic to prioritize Uniswap V4 rates exclusively when configured, and improve error handling for pricing sources.
…ing, approvals

- Increase slippage tolerance from 0.10% to 0.50% in both Aerodrome and V4
- Buffer withdrawal targets by slippage so credited tokens cover the fill
- Replace 6s price polling with on-demand async getExoticTokenPrice
- Store venue prices per-chain to fix multi-token mispricing
- Add consume() tracking to prevent double-booking liquidity across concurrent plans
- Batch LP approvals via ERC-7821 in Aerodrome initialise
- Use order.deadline (blocks → timestamp via viem blockTime) for tx deadlines
- Deduplicate tick decode helpers (import from ABI module)
- Aerodrome getExoticTokenPrice returns null instead of throwing
- Downgrade hot-path logs from info to debug
- Remove ASCII chart banner from CLI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the pre-fetched price map with a single getVenuePrice() helper
that queries on-demand. Prices are fetched once per chain per order
evaluation, not stored as class state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
royvardhan and others added 22 commits March 27, 2026 11:57
…rify startup validation requirements for bid/ask curves and introduce optional spread configuration. Update pricing logic to prioritize Uniswap V4 rates exclusively when configured, and improve error handling for pricing sources.
…ing, approvals

- Increase slippage tolerance from 0.10% to 0.50% in both Aerodrome and V4
- Buffer withdrawal targets by slippage so credited tokens cover the fill
- Replace 6s price polling with on-demand async getExoticTokenPrice
- Store venue prices per-chain to fix multi-token mispricing
- Add consume() tracking to prevent double-booking liquidity across concurrent plans
- Batch LP approvals via ERC-7821 in Aerodrome initialise
- Use order.deadline (blocks → timestamp via viem blockTime) for tx deadlines
- Deduplicate tick decode helpers (import from ABI module)
- Aerodrome getExoticTokenPrice returns null instead of throwing
- Downgrade hot-path logs from info to debug
- Remove ASCII chart banner from CLI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the pre-fetched price map with a single getVenuePrice() helper
that queries on-demand. Prices are fetched once per chain per order
evaluation, not stored as class state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mprove transaction handling

- Re-enable the test for USDC to cNGN LP NFT minting with V4 funding.
- Integrate DelegationService for delegation setup and ensure successful delegation.
- Add waitForTxPoolDrained function to manage transaction pool state and prevent in-flight transaction issues.
- Enhance event log decoding for ERC-721 Transfer events to ensure proper mint receipt validation.
- Re-enable the test for placing USDC to cNGN orders on Base mainnet.
- Introduce the use of CurrencyAmount for token amounts.
- Add detailed logging for pool parameters and order placement.
- Ensure the test correctly handles expected outcomes and transaction flow.
@seunlanlege seunlanlege merged commit 62f36f5 into main Mar 27, 2026
1 check failed
@seunlanlege seunlanlege deleted the roy/defi-strategies branch March 27, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[simplex]: Defi Strategies

3 participants