Skip to content

feat: resolve flashloan fee on-chain via ACLManager - #2972

Merged
mgrabina merged 8 commits into
mainfrom
feat/flashloan-fee-acl-check
May 11, 2026
Merged

feat: resolve flashloan fee on-chain via ACLManager#2972
mgrabina merged 8 commits into
mainfrom
feat/flashloan-fee-acl-check

Conversation

@mgrabina

@mgrabina mgrabina commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the hardcoded 5 bps flashloan fee in CoW and Paraswap swap flows with a per-flow on-chain check against ACLManager.isFlashBorrower(target). When governance grants the FLASH_BORROWER role to the relevant adapter / factory, the UI auto-detects and drops the fee to 0 without a code change. Falls back to the existing 5 bps constant on pending, error, or unsupported chains, so we never under-quote.

Target address per flow

  • CoW (CollateralSwap, DebtSwap, RepayCollateral) → ADAPTER_FACTORY[chainId] (single 0xdeCC46…F192 across chains)
  • Paraswap (CollateralSwap, RepayWithCollateral, DebtSwap, WithdrawAndSwap) → per-flow per-market adapter from currentMarketData.addresses

How it flows

  1. useFlashLoanFeeBps({ provider, swapType, marketData }) — new hook resolves the target, calls isFlashBorrower via Tanstack useQuery + ethers Contract, returns 0 only when the role is granted.
  2. useSwapOrderAmounts calls the hook and writes the resolved bps to state.flashLoanFeeBps.
  3. The 4 non-React readers (cow adapters.helpers.ts, 3 cow action files, paraswap flashloan.helpers.ts) now read state.flashLoanFeeBps ?? <fallback constant>.

Verified live: queried isFlashBorrower against all 11 V3 markets × 4 candidate addresses on mainnet/Arb/Base/Polygon/Optimism/Avalanche/Sonic/Gnosis/BNB — all false today, so behavior is unchanged at ship time. Once governance whitelists, the UI flips to 0 bps automatically.

Test plan

  • After governance grants FLASH_BORROWER to the target address on a chain, confirm CoW and Paraswap flows on that chain show 0 bps fee (UI cost rows hide automatically when fee is 0).
  • Confirm flows on a non-whitelisted chain still show 5 bps.

@vercel

vercel Bot commented May 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
interface Ready Ready Preview, Comment May 8, 2026 5:17pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21b2292124

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/transactions/Swap/helpers/cow/adapters.helpers.ts Outdated
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@mgrabina
mgrabina merged commit e55b2b0 into main May 11, 2026
20 of 21 checks passed
@mgrabina
mgrabina deleted the feat/flashloan-fee-acl-check branch May 11, 2026 14:45
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.

3 participants