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

Reset trader approval #724

Merged
merged 2 commits into from
Nov 4, 2022
Merged

Reset trader approval #724

merged 2 commits into from
Nov 4, 2022

Conversation

nlordell
Copy link
Contributor

@nlordell nlordell commented Nov 4, 2022

Fixes an issue with trade simulations and the Tether USD token for accounts with some approval to the CoW Protocol vault relayer.

Specifically, Tether requires an approval reset before setting a new one, so make sure to do that in the Trader.sol impersonator.

Test Plan

Run the orderbook without this change and perform the following quote:

% curl -s http://localhost:8080/api/v1/quote -X POST -H 'content-type: application/json' --data '@-' <<JSON | jq
{
  "from": "0xf17afe5237d982868b8a97424dd79a4a50c36412",
  "sellToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "buyToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
  "kind": "sell",
  "sellAmountBeforeFee": "1000000000"
}
JSON

Note that before this change, we get an error because of a failed simulation:

{
  "errorType": "InternalServerError",
  "description": ""
}

After, we have great success!

{
  "quote": {
    "sellToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "buyToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
    "receiver": null,
    "sellAmount": "993229180",
    "buyAmount": "993230905247068340318",
    "validTo": 1667581593,
    "appData": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "feeAmount": "6770820",
    "kind": "sell",
    "partiallyFillable": false,
    "sellTokenBalance": "erc20",
    "buyTokenBalance": "erc20",
    "signingScheme": "eip712"
  },
  "from": "0xf17afe5237d982868b8a97424dd79a4a50c36412",
  "expiration": "2022-11-04T16:37:33.530731Z",
  "id": 3
}

@nlordell nlordell requested a review from a team as a code owner November 4, 2022 16:38
@nlordell nlordell enabled auto-merge (squash) November 4, 2022 16:39
@nlordell nlordell merged commit 6be87b2 into main Nov 4, 2022
@nlordell nlordell deleted the reset-approval-for-trader branch November 4, 2022 17:08
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants