Skip to content

feat: script for aave poc#13

Open
carlos-cow wants to merge 5 commits intocarlos/gnosisfrom
carlos/aave_poc
Open

feat: script for aave poc#13
carlos-cow wants to merge 5 commits intocarlos/gnosisfrom
carlos/aave_poc

Conversation

@carlos-cow
Copy link
Collaborator

@carlos-cow carlos-cow commented Sep 11, 2025

GIST

This is a very hardcoded script to create a limit order to test the flashloan logic e2e.
This is not supposed to be merged.

This script will send an order to gnosis staging.

HOWTO RUN

Setup your wallet/position

Use your deployer wallet to test.

You will need to hold 20 aWXDAI in gnosis chain.
You can use Cowswap!

Once you get your collateral, get some debt.
Go to aave: https://app.aave.com/reserve-overview/?underlyingAsset=0x9c58bacc331c9aa871afd802db6379a98e80cedb&marketName=proto_gnosis_v3
and borrow 0.01 GNO.

Screenshot 2025-08-12 at 1 52 14 PM

Borrowing tokens in aave will lock your full collateral to be moved.

Create an .env file with:

RPC_URL_100=<your gnosis chain rpc url>
PRIVATE_KEY=0x0

Modify the script to use a valid VALID_FOR

Since the deterministic contract depends on VALID_FOR it's better to hardcode a value to avoid approving a contract over and over again. Get a value in the future from https://www.epochconverter.com/
I usually do 4hs. I think the backend has an error when it's too many days ahead in the future.

Run with the script

You will need to have node and dependencies and you can run with:

yarn dev

It will ask you to approve the token to the deterministic helper address for the order parameters.
You should do this only once per order.

NOTE: The order creation will fail. The error you will get is the following:

400, body: {"errorType":"InsufficientBalance","description":"order owner must have funds worth at least x in his account"}

This is a bug in the backend and needs to be fixed.
To continue testing without the fix, transfer 1 wei of your sell token into the helper contract.

Go here:
https://gnosisscan.io/address/0xc6B7AcA6DE8a6044E0e32d0c841a89244A10D284#writeProxyContract#F10
and do something like this after connecting your wallet:

Screenshot 2025-08-18 at 10 26 22 PM

Re-run the script and you will see a 201. The order should be created but I am not seeing the order reaching solvers.


Copy link
Owner

@anxolin anxolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get is why you opted out of the SDKs. The code should be way simpler (for appData generation, posting orders, etc.

Ideally, AAVE uses the SDK. If there's any issue with the SDK we can easily address. For example, if the hint is not there in the appData project, there's ways to still use the SDK and add it (I showed how in the PR used to kickstart your PoC).

This is a PoC so, its not like I care a lot, but if we don't dogfood the SDK, we migh make it harder for others to us too. AAVE uses it in the ui, and the code it generates is safer and accounts many of the pitfalls we observed over time.

I didn't see you getting a quote. Wouldn't it be important to test it too? If you use the SDK for this, you will be end-to-end testing with the right slippage tolerances, and would be getting things as close as it gets to production. This takes me to the next point, why BARN? (can we test it in PROD?)

Also, is the EOA signature mocked? How can that work?

@carlos-cow
Copy link
Collaborator Author

carlos-cow commented Sep 25, 2025

@anxolin

For example, if the hint is not there in the appData project, there's ways to still use the SDK and add it (I showed how in the PR used to kickstart your PoC).

// @ts-ignore The flash-loan hint is still not added officially to https://github.com/cowprotocol/app-data

This didn't work for me. SDK rejected the order creation.
Also SDK needs this:

  1. There is no way to force an specific validTo cowprotocol/cow-sdk#376
    Without being able to specify an specific timestamp it's imposible to keep order deterministic.
  2. Create e2e test for 1271 orders cowprotocol/cow-sdk#377
    1271 apparently doesn't work.

I didn't see you getting a quote. Wouldn't it be important to test it too?

Using quote directly means different parameters which changed the deterministic address. I went with limit order to make the order creation reproducible.

This takes me to the next point, why BARN? (can we test it in PROD?)

Backend change is not in prod yet.

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

Successfully merging this pull request may close these issues.

3 participants

Comments