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

Update SolverEngine API docs #2192

Merged
merged 9 commits into from
Dec 21, 2023
Merged

Update SolverEngine API docs #2192

merged 9 commits into from
Dec 21, 2023

Conversation

fleupold
Copy link
Contributor

@fleupold fleupold commented Dec 19, 2023

Description

Docs were slightly out of date

Changes

  • Updates all fields and structs on the existing endpoint
  • Remove pre-interactions for jit orders (for some reason we didn't populate post interactions and since those orders aren't really used in practice anyways, it seemed simpler to remove pre interactions instead of adding post interactions).
  • Flatten notification type to make it consistent with the way we encode enums elsewhere in the new API (cf. Liquidity)
  • Flatten Score enum to make it consistent
  • Document notify endpoint

How to test

Past into https://editor.swagger.io/ and compare line by line with the rust structs

Related Issues

Fixes #2182

@fleupold fleupold requested a review from a team as a code owner December 19, 2023 21:41
crates/solvers/openapi.yml Outdated Show resolved Hide resolved
@@ -67,16 +67,6 @@ impl Solutions {
buy_token_balance: BuyTokenBalance::Erc20,
signing_scheme,
signature,
pre_interactions: trade
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove pre-interactions for jit orders (for some reason we didn't populate post interactions...

I don't remember if it was a conscious decision to not populate post interactions for JIT orders but they are not strictly necessary, right?. The solver is the one that builds and uses a JIT order. With that information they should be able to execute anything that would make sense as a post-interaction as part of the regular interactions in the middle.
This is not the case for pre-interactions, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but I don't think this nuanced reasoning justifies this inconsistency (technically a self-hosted driver could also execute whatever call they want before settle).

Practically, no one is using this order type (and for sure not with pre-interactions), so I still think it's in the spirit of #simplification to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

technically a self-hosted driver could also execute whatever call they want before settle

How would they ensure that their interaction happens in the same block as their settlement?
Wouldn't they need tight block builder integration for that?

I'm fine with removing it. Just wanted to point possible reasons for why it is like it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's not trivial (sending bundles can work) or using a Safe or the like as the msg.sender for the settle call and atomically do other calls (in a multicall)

Comment on lines 607 to 609
"sellToken" for sell orders, and "buyToken" for buy orders.
allOf:
- $ref: "#/components/schemas/TokenAmount"
Copy link
Contributor

Choose a reason for hiding this comment

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

The executedAmount also appears to be outdated.
It's actually part of JitTrade and Fulfillment and should probably not be listed on the Trade. Also it's not a TokenAmount but a simple U256.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since JitTrade and Fulfillment are flattened this actually checks out (cf the example responses)
image

Will still put it on each type. TokenAmount is just a placeholder for U256 though.

@squadgazzz
Copy link
Contributor

Leaving a comment here not to forget to port the changes into https://github.com/cowprotocol/solvers

@fleupold
Copy link
Contributor Author

Leaving a comment here not to forget to port the changes into https://github.com/cowprotocol/solvers

😩 ugh, I don't know why we actually have the API documentation in the solvers crate and not in the driver (who kind of defines it). Also, the better long term solution is probably to switch to something like utoipa to have this automatically generated.

@squadgazzz
Copy link
Contributor

Also, the better long term solution is probably to switch to something like utoipa to have this automatically generated.

Ok, I can probably integrate it into the solvers repo and then remove the openapi.yml file.

@fleupold fleupold enabled auto-merge (squash) December 21, 2023 14:42
@fleupold fleupold merged commit 3f89dc2 into main Dec 21, 2023
8 checks passed
@fleupold fleupold deleted the update_solver_engine_api branch December 21, 2023 14:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
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.

chore: update openapi.yml for solver-driver communication
3 participants