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

feat(uniswapx-sdk): Implement Dutch V3 #84

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ec6cb33
feat: V3DutchOrder
alanhwu Sep 3, 2024
5ea0ce8
feat, test: create orders from JSON
alanhwu Sep 3, 2024
89cbd0e
feat, test: cosigning v3 orders
alanhwu Sep 3, 2024
c409254
fix: linting
alanhwu Sep 3, 2024
fdd909e
fix: more linting
alanhwu Sep 3, 2024
612d1bf
refactor: update relativeAmounts name
alanhwu Sep 3, 2024
7222b53
feat, test: resolve & decay with math tests
alanhwu Sep 5, 2024
080d616
test: extra resolve v3 test, comments
alanhwu Sep 6, 2024
cebaa8a
feat, test: MVP v3 OrderBuilder
alanhwu Sep 6, 2024
f8430de
refactor: clean reuse of v2 for v3
alanhwu Sep 6, 2024
f50e745
feat, test: robust testing, helpers for v3 cosignerData building
alanhwu Sep 6, 2024
4138f2c
feat, test: v3 buildPartial
alanhwu Sep 6, 2024
4a93058
feat, test: v3 builder fromOrder
alanhwu Sep 6, 2024
e221b4a
feat, test: v3 orderTrade
alanhwu Sep 6, 2024
73db687
fix: cosigned order detection
alanhwu Sep 6, 2024
54888da
fix: tiny, linting
alanhwu Sep 11, 2024
8ef21c7
refactor: rename CosignerData types
alanhwu Sep 11, 2024
adae9f2
refactor: move order amount helper to utils
alanhwu Sep 11, 2024
d21c580
refactor: relativeBlocks decoding for clarity
alanhwu Sep 11, 2024
69fa516
refactor: update v3 curve type name to new name in contract
alanhwu Sep 11, 2024
81710ab
style: linting
alanhwu Sep 11, 2024
d63c65e
fix, test: dutchBlockDecay rounding math
alanhwu Sep 11, 2024
5af9cf1
feat, test: support negative relativeAmounts with BigInt
alanhwu Sep 12, 2024
e58c9ee
fix: BigInt -> bigint
alanhwu Sep 12, 2024
d63c629
test: dutchBlockDecay
alanhwu Sep 12, 2024
ed7ad9c
fix: fully serialize V3 JSONs
alanhwu Sep 12, 2024
e85054c
feat: relax V3 upward decay restraint
alanhwu Sep 12, 2024
3c8690e
style: linting
alanhwu Sep 12, 2024
ad14a17
refactor: cleaner type & reuse
alanhwu Sep 12, 2024
64f8d35
feat: align dutchBlockDecay with updated contract
alanhwu Sep 12, 2024
4382181
fix, test: stricter calculation of minOut maxIn
alanhwu Sep 12, 2024
10516d7
style: linting
alanhwu Sep 12, 2024
fcf99b4
feat: generic for checking cosigned status
alanhwu Sep 13, 2024
efecbc0
feat, test: V3 decay curve validity invariants
alanhwu Sep 13, 2024
0cec87d
style: linting
alanhwu Sep 13, 2024
7c8d8c4
refactor: clean invariants
alanhwu Sep 13, 2024
361f559
feat, test: Cosigned toJSON, fromJSON
alanhwu Sep 16, 2024
0ca5a19
refactor: use length to decode relativeBlocks
alanhwu Sep 19, 2024
e18e677
refactor: clean determination of cosigned status
alanhwu Sep 19, 2024
a8759dc
fix: test description typos
alanhwu Sep 19, 2024
40d17f0
feat: helper for getting maxAmountOut from V3 curve
alanhwu Sep 19, 2024
3657f09
Merge branch 'main' into v3-dutch-sdk
alanhwu Sep 19, 2024
c4a5acf
Merge branch 'main' into v3-dutch-sdk
alanhwu Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdks/uniswapx-sdk/src/builder/V2DutchOrderBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ describe("V2DutchOrderBuilder", () => {
.outputOverrides([OUTPUT_START_AMOUNT.mul(102).div(100)])
.build()
).toThrow(
"Invariant failed: inputOverride not set or larger than original input"
"Invariant failed: inputOverride larger than original input"
);
});

Expand Down Expand Up @@ -574,7 +574,7 @@ describe("V2DutchOrderBuilder", () => {
});

describe("partial order tests", () => {
it("builds an unsigned partial order with default cosignerData values", () => {
it("builds an unsigned partial order with default cosignerData values", () => { //TODO: partial orders don't have cosignerData...
alanhwu marked this conversation as resolved.
Show resolved Hide resolved
const deadline = Math.floor(Date.now() / 1000) + 1000;
const order = builder
.cosigner(constants.AddressZero)
Expand Down
14 changes: 4 additions & 10 deletions sdks/uniswapx-sdk/src/builder/V2DutchOrderBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
UnsignedV2DutchOrder,
} from "../order";
import { ValidationInfo } from "../order/validation";
import { getPermit2, getReactor } from "../utils";
import { getPermit2, getReactor, isCosignedV2 } from "../utils";

import { OrderBuilder } from "./OrderBuilder";

Expand Down Expand Up @@ -40,7 +40,7 @@ export class V2DutchOrderBuilder extends OrderBuilder {
builder.output(output);
}

if (isCosigned(order)) {
if (isCosignedV2(order)) {
builder.cosignature(order.info.cosignature);
builder.decayEndTime(order.info.cosignerData.decayEndTime);
builder.decayStartTime(order.info.cosignerData.decayStartTime);
Expand Down Expand Up @@ -287,9 +287,9 @@ export class V2DutchOrderBuilder extends OrderBuilder {
"exclusivityOverrideBps not set"
);
invariant(
this.info.cosignerData.inputOverride !== undefined &&
this.info.cosignerData.inputOverride !== undefined && // inputOverride is defaulted to 0 because enforced to be of type BigNumber
alanhwu marked this conversation as resolved.
Show resolved Hide resolved
this.info.cosignerData.inputOverride.lte(this.info.input.startAmount),
"inputOverride not set or larger than original input"
"inputOverride larger than original input"
);
invariant(
this.info.cosignerData.outputOverrides.length > 0,
Expand Down Expand Up @@ -339,9 +339,3 @@ export class V2DutchOrderBuilder extends OrderBuilder {
};
}
}

function isCosigned(
order: UnsignedV2DutchOrder | CosignedV2DutchOrder
): order is CosignedV2DutchOrder {
return (order as CosignedV2DutchOrder).info.cosignature !== undefined;
}
Loading
Loading