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

Solver crate forwards flashloans back to driver #3283

Merged
merged 4 commits into from
Feb 19, 2025

Conversation

sunce86
Copy link
Contributor

@sunce86 sunce86 commented Feb 18, 2025

Description

Expands Order/Solution objects in solvers-dto crate, needed for e2e tests for flashloans to work.

Changes

  • crates::solvers-dto expanded with flashloans
  • solvers crate returns back the flashloans to driver if driver sent the hints

How to test

Existing tests.

@sunce86 sunce86 self-assigned this Feb 18, 2025
@sunce86 sunce86 requested a review from a team as a code owner February 18, 2025 14:05
Copy link

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams (at least Frontend team and SAFE team).
  • You provide proper versioning and migration mechanisms.

Caused by:

@@ -161,7 +162,16 @@ impl Auction {
),
app_data: AppDataHash(order.app_data.hash().0.into()),
flashloan_hint: flashloans_enabled
.then(|| order.app_data.flashloan().cloned().map(Into::into))
.then(|| {
order.app_data.flashloan().map(|flashloan| FlashloanHint {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if filling in these default values makes more sense in the component that fetches the app data in the first place. 🤔
No strong opinion, though since I can see why one would want to have access to the pure unaltered appdata.

Copy link
Contributor Author

@sunce86 sunce86 Feb 19, 2025

Choose a reason for hiding this comment

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

True. For now, flashloan hints in their final shape are not needed/used in the driver domain. But we can move this logic out to driver domain when the need comes.

@@ -684,6 +688,11 @@ fn default_simulation_bad_token_max_age() -> Duration {
Duration::from_secs(600)
}

// SKY lending DAI token
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I wasn't aware that the contract @fedgiac used in the e2e test for the contract only worked with Dai. I'm fine to make this the default for the start where it's only relevant for the e2e test but we should have at least 1 supported general purpose flashloan lender.
Also this could indicate that we might need a module or component that suggests a good lending provider based on the token that needs to be borrowed. Should happen later, though (if at all).

Copy link
Contributor Author

@sunce86 sunce86 Feb 19, 2025

Choose a reason for hiding this comment

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

Agree. There are A LOT of assumptions made at the moment, but I have them in my list. Before going live, these will have to be addressed and some kind of validation for flashloan hints will be implemented to avoid weird cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

In principle there are wrappers for incompatible flash-loan lenders (some examples here from this EIP discussion).
But for the e2e test I wanted to avoid the extra mental overhead of the wrapper and I used a protocol that natively supports the standard (but unfortunately only for DAI).
Another assumption in the e2e test is that the flash-loan lender pulls back the token from the borrower by executing transferFrom, but this isn't necessarily the case for other protocols, some other expect the tokens to be transferred back and check that the balance at the end is as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we will have to implement a lender specific encoding once we finish this first version that works only with Sky.

@@ -34,6 +34,7 @@ impl Auction {
fee_handler: FeeHandler,
solver_native_token: ManageNativeToken,
flashloans_enabled: bool,
flashloan_default_lender: eth::Address,
Copy link
Contributor

Choose a reason for hiding this comment

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

By now this constructor has quite a few arguments that will not change during the runtime of the driver.
Might be useful to have a builder component for those pieces of information. 🤔
(follow up task if at all)

Copy link
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.

LGTM

@sunce86 sunce86 merged commit 280fdba into main Feb 19, 2025
11 checks passed
@sunce86 sunce86 deleted the flashloans-to-solvers-dto branch February 19, 2025 12:22
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 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.

6 participants