Skip to content

Add flashloans docs#451

Merged
mateo-mro merged 43 commits intomainfrom
flashloans
Mar 24, 2025
Merged

Add flashloans docs#451
mateo-mro merged 43 commits intomainfrom
flashloans

Conversation

@mateo-mro
Copy link
Copy Markdown
Contributor

Description

It adds the flashloans documentation

Changes

  • Added flashloans documentation
  • Added flashloans example
  • Added periphery contract

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Mar 24, 2025 1:38pm


Once an order is placed within the CoW Protocol, it enters an auction batch. When a solution is found, the following steps occur:

1. The winning solver calls the Flashloan Settlement Wrapper contract.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be nice to add a simulation of an example transaction here once we have that.

Copy link
Copy Markdown
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

I would split the documentation between solvers and integrators (as they will care about different things).

One general advice in md files is to use one sentence per line. This makes it later easier to change parts without getting into annoying merge conflicts (if e.g. an entire paragraph is on the same line)


1. The winning solver calls the Flashloan Settlement Wrapper contract.
2. The 2101 USDC gets transferred to the Flashloan Settlement Wrapper contract.
3. In the pre-hook:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we include all pre-hooks here I would add which ones are solver added and which ones are user defined. Note that one pre hook is one pre-interaction (and here we are listing multiple)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But if this is a tutorial for users to use the flashloans, why would be relevant the solver's pre-interactions? 🤔

mateo-mro and others added 3 commits March 3, 2025 08:19
Co-authored-by: Felix Leupold <felixleupold90@gmail.com>
Co-authored-by: Felix Leupold <felixleupold90@gmail.com>
@mateo-mro
Copy link
Copy Markdown
Contributor Author

I would split the documentation between solvers and integrators (as they will care about different things).

One general advice in md files is to use one sentence per line. This makes it later easier to change parts without getting into annoying merge conflicts (if e.g. an entire paragraph is on the same line)

@fleupold thanks! 🙏 how would you split it, within the same section (one chapter for integrators and another for solver)? or to move the solver part to the section where the driver/solver is explained?

Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

Will do another round or two later. Too much info to digest.

sidebar_position: 6
---

# Repay debt with collateral using flash loans
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't the order type section be titled just 'Flash Loans,' with debt repayment described inside as the common use case? Or do we consider flash loans in CoW to be used only for this specific purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file is to describe this particular use case. Ideally we will have more cases in the future.

### Flash loans

The user is able to create a flash loan order's hint by attaching to the `appData` the specified metadata. The autopilot reads the order and cuts it into a [batch auction](../../../concepts/introduction/batch-auctions). Then the driver fetches the `appData` by calling the orderbook with `GET /v1/app_data/<app_data_hash>` for every order and caches them in memory. The driver should include the flash loan information into the batch auction's order before sending it to the solver(s).

Copy link
Copy Markdown
Contributor

@mrnaveira mrnaveira Mar 13, 2025

Choose a reason for hiding this comment

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

It would be nice to mention how flash loan orders impact the solution score, if at all. I assume they don’t, but it would be good to have a brief confirmation somewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hm I am not so sure. I believe it can alter the score if the solver is able to make a favorable deal. But I don't think flash loans are relevant to the score calculation per se.

- **token:** the token that needs to get borrowed.
- **amount:** how many atoms of the token need to get borrowed (e.g., 1 `WETH` would be 10¹⁸).

If optional values were not provided the solver will choose sensible defaults.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO it would be helpful to expand the sensible defaults part a bit more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is totally up to the solver.

mateo-mro and others added 2 commits March 14, 2025 08:16
Co-authored-by: ilya <squad.gazzz@gmail.com>
Co-authored-by: ilya <squad.gazzz@gmail.com>
Co-authored-by: Felix Leupold <felixleupold90@gmail.com>
@squadgazzz
Copy link
Copy Markdown
Contributor

Do we need to mention anywhere in the doc that currently only AAVE and Maker are supported?

Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

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

Looks like a reasonable first version of the docs. Although there are probably still a few improvements we can make in follow up PRs.

mateo-mro and others added 3 commits March 24, 2025 14:34
Co-authored-by: Martin Magnus <martin.beckmann@protonmail.com>
Co-authored-by: Martin Magnus <martin.beckmann@protonmail.com>
Co-authored-by: Martin Magnus <martin.beckmann@protonmail.com>
@mateo-mro mateo-mro merged commit 4aa7a6b into main Mar 24, 2025
4 checks passed
@mateo-mro mateo-mro deleted the flashloans branch March 24, 2025 13:54
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2025
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.

8 participants