1

have been building a little front end app to execute trades back and forth between ETH and USDC, partly to learn and partly to build a tool I want to exist.

I have all the quotes and stuff working OK, I am testing on goerli network and can successfully purchase goerli USDC using the goerli 0x contract, great.

but I cannot get the trade to go the opposite way, trying to sell USDC for eth fails every time despite sending what seems to be valid transaction data returned by 0xapi.

this is a sample transaction https://goerli.etherscan.io/tx/0x18c66dc0f2a49a01475a8e5eac2f7718918024b09bf0195a950ea67ff596323f

mostly i get: Fail with error 'ERC20: transfer amount exceeds allowance'

what I don't understand is my USDC approval transactions seem to work: https://goerli.etherscan.io/tx/0xa24b133ee0694578a96a3aed444e98a93af3b4e498ab38900e0b37ee4d21e44d

but I still get transfer amount exceeds allowance? what am i doing wrong? I have a feeling that perhaps I am approving against the wrong contract address, but everything is working ok trading eth for usdc, just not usdc for eth.

using these addresses:

const ZERO_EX_PROXY_GOERLI = "0xF91bB752490473B8342a3E964E855b9f9a2A668e"; //chain 5

const USDC_GOERLI = "0x07865c6e87b9f70255377e024ace6630c1eaa37f"; //chain 5

example transaction data:

{ "chainId": 5, "price": "93127.57", "guaranteedPrice": "94058.85", "estimatedPriceImpact": "38.2635", "to": "0xf91bb752490473b8342a3e964e855b9f9a2a668e", "data": "0x415565b000000000000000000000000007865c6e87b9f70255377e024ace6630c1eaa37f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000008f85bd00000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000007865c6e87b9f70255377e024ace6630c1eaa37f000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d600000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000005af3107a40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000025375736869537761700000000000000000000000000000000000000000000000000000000000000000000000008f85bd00000000000000000000000000000000000000000000000000005af3107a4000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b479975060000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007865c6e87b9f70255377e024ace6630c1eaa37f000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d6000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000007865c6e87b9f70255377e024ace6630c1eaa37f0000000000000000000000000000000000000000000000000000000000000000869584cd00000000000000000000000010000000000000000000000000000000000000110000000000000000000000000000000000000000000000b1e8885a9d639a5f4b", "value": "0x0", "gas": "0x1b198", "estimatedGas": "111000", "from": "0xff7ec211ec3476db90f2a499e05f844585dcb382", "gasPrice": "0x162010", "protocolFee": "0", "minimumProtocolFee": "0", "buyTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "sellTokenAddress": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "buyAmount": "100000000000000", "sellAmount": "9312757", "sources": [ { "name": "0x", "proportion": "0" }, { "name": "SushiSwap", "proportion": "1" }, { "name": "Uniswap", "proportion": "0" }, { "name": "Uniswap_V2", "proportion": "0" }, { "name": "Uniswap_V3", "proportion": "0" }, { "name": "MultiHop", "proportion": "0" } ], "orders": [ { "type": 0, "source": "SushiSwap", "makerToken": "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6", "takerToken": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "makerAmount": "100000000000000", "takerAmount": "9312757", "fillData": { "tokenAddressPath": [ "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6" ], "router": "0x1b02da8cb0d097eb8d57a175b88c7d8b47997506" }, "fill": { "input": "100000000000000", "output": "9312757", "adjustedOutput": "9312757", "gas": 90000 }, "sourcePathId": "0x95608ef079f532439a0b73a53672e11900fd38d3f96159963325c9971a25744e" } ], "allowanceTarget": "0xf91bb752490473b8342a3e964e855b9f9a2a668e", "decodedUniqueId": "b1e8885a9d-1671061323", "sellTokenToEthRate": "57493.704479", "buyTokenToEthRate": "1", "expectedSlippage": null }

thanks in advance for any hints or guidance, i feel like ive tried every combination of everything and still getting allowance errors.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.