Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Got the error "InsufficientFunds" #32

Closed
fastQM opened this issue Oct 6, 2021 · 5 comments
Closed

Got the error "InsufficientFunds" #32

fastQM opened this issue Oct 6, 2021 · 5 comments

Comments

@fastQM
Copy link

fastQM commented Oct 6, 2021

I had successfully swap GNO to WETH from Cowswap, but I cannot swap the tokens from my scripts.

The paras I posted are like ( I need to swap 1GNO to WETH):

params: {"sellToken":"0x6810e776880c02933d47db1b9fc05908e5386b96","buyToken":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","sellAmount":"896936549560389504","buyAmount":"72349153448856840","validTo":1633511944,"appData":"0xf785fae7a7c5abc49f3cd6a61f6df1ff26433392b066ee9ff2240ff1eb7ab6e4","feeAmount":"103063450439610496","kind":"sell","partiallyFillable":false,"signature": $$$my signature,"signingScheme":"ethsign","sellTokenBalance":"erc20","buyTokenBalance":"erc20"}

The server returns:
{"errorType":"InsufficientFunds","description":"order owner must have funds worth at least x in his account"}
but I have definitely more than 1GNO

Any idea? Thanks!

@fleupold
Copy link
Contributor

fleupold commented Oct 6, 2021

You also must have approved the token prior to being able to place an order. We have a task pending for giving a better error message in this case.

@fastQM
Copy link
Author

fastQM commented Oct 6, 2021

Thanks for the reply.

But I believe this is not the case because I did approve the token and I had swapped them successfully from cowswap.

Should I need to approve WETH too? Will it be the problem about the signature?

Yes, more details about the error are quite necessary.

@fleupold
Copy link
Contributor

fleupold commented Oct 6, 2021

If you have approved GNO then likely something is wrong with the signature which will lead to our backend recovering a different signer address. To double check that, I'd advise to also add the optional from field in the json body (https://protocol-mainnet.gnosis.io/api/#/default/post_api_v1_orders)

This will throw a different error in case the address recovered from the signature doesn't match the one that the backend recovered.

@fastQM
Copy link
Author

fastQM commented Oct 7, 2021

It helps, thanks!

However, the problem is that I missed the parameter "receiver" when I placed the order.

I think the backend should report the parameters are incomplete and the tutorial (https://docs.gnosis.io/protocol/docs/tutorial-api-order/) should be updated.

@fleupold
Copy link
Contributor

fleupold commented Oct 7, 2021

Thanks for the feedback!

I updated the json blob in https://docs.cowswap.exchange/tutorials/how-to-submit-orders-via-the-api/5.-placing-the-order to contain the missing fields.

Note that receiver, buyTokenBalance and sellTokenBalance are optional fields in the API. We recently had a discussion about making them non-optional (which would have raised an error in your case) but decided against it for backwards compatibility: gnosis/gp-v2-services#1189

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants