fix(twap): approve prod vault relayer regardless of environment#7695
Conversation
TWAP orders are always settled against the production CoW Protocol settlement contract, but the spender override was using the environment-aware COW_PROTOCOL_VAULT_RELAYER_ADDRESS from @cowprotocol/common-utils, which resolves to the staging vault relayer on the barn backend env. As a result, allowances granted on the barn-deployed app targeted the staging relayer and TWAP orders were unfillable on Safe due to insufficient allowance against the prod relayer. Add a prod-only re-export, COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD, in @cowprotocol/common-utils and use it for the TWAP spender override, so TWAP allowances always target the production relayer regardless of the current environment. Closes cowprotocol#7690
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a production-only vault relayer constant in common utils and switches TWAP allowance wiring to use it for ChangesTWAP prod vault relayer address fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // Use this when allowances must always target the production relayer | ||
| // regardless of the current environment (e.g. TWAP, which is always | ||
| // settled against the production settlement contract). | ||
| export const COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD: AddressPerChain = |
There was a problem hiding this comment.
Nitpick: we have 2 names for the same variable, let's keep using COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD, get rid of COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD_SDK. Did you do this because of the type casting to AddressPerChain?
Addresses @kernelwhisperer's feedback on cowprotocol#7695 — rename the SDK import alias to an internal underscore-prefixed name so COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD is the only PROD-named export. The cast to AddressPerChain is still needed because the SDK's type differs from AddressPerChain.
|
@kernelwhisperer updated in e81f214 — renamed the SDK import alias to |
|
Cloudflare Pages preview mirror Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7695 Source fork branch:
|
…lowance-prod-relayer
…lowance-prod-relayer
Drop the duplicate prod relayer identifier. Define COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PROD once (the AddressPerChain cast target) and reuse it for the env-aware export, so the SDK import is now plain raw plumbing referenced a single time. Addresses @kernelwhisperer's review feedback.
|
@kernelwhisperer good catch — yes, the second identifier only existed to apply the |
I think it's worth looking into the the sdk type is not |
Summary
Closes #7690.
TWAP orders are always settled against the production CoW Protocol settlement contract, regardless of which environment (
prod/barn) the frontend is configured against. The TWAP spender override, however, was using the environment-awareCOW_PROTOCOL_VAULT_RELAYER_ADDRESSfrom@cowprotocol/common-utils, which resolves to the staging vault relayer when running on the barn backend env.As a result, on the barn-deployed app, allowances granted from the TWAP page targeted the staging vault relayer, while the TWAP order itself was created against the production ComposableCoW / settlement — leaving the order unfillable due to insufficient allowance against the production relayer.
Fix
COW_PROTOCOL_VAULT_RELAYER_ADDRESS_PRODin@cowprotocol/common-utilsfor the explicit "always-prod" case.apps/cowswap-frontend/src/modules/twap/updaters/index.tsx) to use this prod-only constant, so TWAP allowances always target the production relayer regardless of the current environment. This also matches the existing intent already documented in the inline comment above the spender computation.No other consumers of the environment-aware constant are touched — only the TWAP flow is bound to the production settlement contract.
Test plan
Summary by CodeRabbit