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

add hard quote logic #271

Merged
merged 2 commits into from
Feb 29, 2024
Merged

add hard quote logic #271

merged 2 commits into from
Feb 29, 2024

Conversation

marktoda
Copy link
Collaborator

@marktoda marktoda commented Feb 27, 2024

This PR adds the internal logic for hard quotes! Effectively:

  • Parse the unsigned order passed in
  • run a secondary auction round
  • validate the auction result
  • create cosignerData using auction result and updated timings
  • cosign the full order
  • post the full order to gouda service
  • return encoded full order

Still remaining TODOs:

  • use AWS KMS signer instead of a local wallet for cosigner
  • integ tests

parse order, run secondary quote, and cosign order
@marktoda marktoda requested a review from zhongeric February 27, 2024 02:15
Copy link
Collaborator

@zhongeric zhongeric left a comment

Choose a reason for hiding this comment

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

looks good! just a few questions

@@ -76,16 +80,24 @@ export class HardQuoteRequest {
return utils.getAddress(this.order.info.baseOutputs[0].token);
}

public get totalOutputAmountStart(): BigNumber {
let amount = BigNumber.from(0);
for (const output of this.order.info.baseOutputs) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this assumes all outputs are same token which is not necessarily true right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Assumed true anyways for now in main rfq flownsince quoters can only be for one token

const outputAmounts = request.order.info.baseOutputs.map(() => BigNumber.from(0));

// if the quote is better, then increase amounts by the difference
if (request.type === TradeType.EXACT_INPUT) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the expected behavior if less outputs are required for EXACT_INPUT but more input is required? Apply the output adjustment but not the input? Wonder if we should explicitly throw / error on this case if its undesired behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm interesting, I think the api contract should disallow changing the EXACT_X side in any case yea

@marktoda marktoda merged commit 36948b4 into main Feb 29, 2024
5 checks passed
@marktoda marktoda deleted the add-hard-quote-logic branch February 29, 2024 02:48
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.

2 participants