Skip to content

Commit

Permalink
feat: handle empty input curve for TradeType
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhwu committed Nov 26, 2024
1 parent cb0fd03 commit ec81bcf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/entities/HardQuoteRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ export class HardQuoteRequest {
}
else if (this.order instanceof UnsignedV3DutchOrder) {
const startAmount = this.order.info.input.startAmount;
return startAmount.eq(V3DutchOrderBuilder.getMinAmountOut(startAmount, this.order.info.input.curve.relativeAmounts))
? TradeType.EXACT_INPUT
: TradeType.EXACT_OUTPUT
// If curve doesn't exist OR startAmount equals minAmountOut, then it's EXACT_INPUT
return !this.order.info.input.curve ||
startAmount.eq(V3DutchOrderBuilder.getMinAmountOut(startAmount, this.order.info.input.curve.relativeAmounts))
? TradeType.EXACT_INPUT
: TradeType.EXACT_OUTPUT;
}
else {
throw new Error('Unsupported order type');
Expand Down

0 comments on commit ec81bcf

Please sign in to comment.