Skip to content

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

Open
mgrabina wants to merge 8 commits intomainfrom
feat/flashloan-fee-acl-check
Open

feat: resolve flashloan fee on-chain via ACLManager#2972
mgrabina wants to merge 8 commits intomainfrom
feat/flashloan-fee-acl-check

Conversation

@mgrabina
Copy link
Copy Markdown
Contributor

@mgrabina mgrabina commented May 8, 2026

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
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

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

Copy link
Copy Markdown

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

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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📦 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! 🙌

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.

2 participants