Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rfq] Do not approve to both synapse_cctp and token messenger #2405

Open
trajan0x opened this issue Mar 30, 2024 · 1 comment
Open

[rfq] Do not approve to both synapse_cctp and token messenger #2405

trajan0x opened this issue Mar 30, 2024 · 1 comment

Comments

@trajan0x
Copy link
Contributor

Currently, we approve to both, so if one is not set we get a revert on 0 addresses.

image

Also should not try to approve at all to 0 address

@trajan0x trajan0x added the small label Jun 24, 2024
@trajan0x trajan0x reopened this Jun 24, 2024
@trajan0x trajan0x removed the small label Jun 24, 2024
Copy link

greptile-apps bot commented Jun 24, 2024

To resolve the issue of approving to both synapse_cctp and token messenger, follow these steps:

  1. Update approveToken function in /packages/synapse-interface/utils/approveToken.tsx:

    • Add a check to ensure address and tokenAddress are not zero addresses before calling approveErc20Token.
    if (address === zeroAddress || tokenAddress === zeroAddress) {
      throw new Error('Cannot approve to zero address');
    }
  2. Update approveErc20Token function in /packages/synapse-interface/actions/approveErc20Token.ts:

    • Add a check to ensure spender and tokenAddress are not zero addresses before proceeding with the approval.
    if (spender === zeroAddress || tokenAddress === zeroAddress) {
      throw new Error('Cannot approve to zero address');
    }
  3. Update approve function in /packages/synapse-interface/utils/actions/approveAndDeposit.tsx and /packages/synapse-interface/utils/actions/approveAndWithdraw.tsx:

    • Add a check to ensure poolAddress and tokenToApprove are not zero addresses before calling approveToken.
    if (poolAddress === zeroAddress || tokenToApprove === zeroAddress) {
      throw new Error('Cannot approve to zero address');
    }

These changes will prevent approvals to zero addresses and avoid reverts.

References

/packages/synapse-interface/utils/approveToken.tsx
/packages/synapse-interface/actions/approveErc20Token.ts
/packages/synapse-interface/utils/actions/approveAndDeposit.tsx
/packages/synapse-interface/utils/actions/approveAndWithdraw.tsx

Ask Greptile

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

No branches or pull requests

1 participant