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/specify contract taker in LimitOrders #164

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions src/methods/limitOrders/helpers/buildOrderData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export interface BuildOrderDataInput {
makerAmount: string;
takerAmount: string;
maker: Address;
// OrderData.taker must be Augustus for p2p limitOrders to involve swap through Augustus
// this is the actual user taker which will go into nonceAndMeta
// OrderData.taker must be Augustus (or other Executor) for p2p limitOrders to involve swap through Augustus
/** @description actual user taker which will go into nonceAndMeta */
taker?: Address;
/** @description contract executor (Augustus or similar) that is allowed to execute the order, gois in Order.taker */
contractTaker?: Address;

AugustusAddress: Address;
}

Expand Down Expand Up @@ -65,6 +68,8 @@ export function buildOrderData({
// if taker is specified -- p2p order for that taker only to fill through Augustus -- taker = Augustus, takerInNonce = _taker
// if taker is not specified -- limitOrder for anyone to fill through Augustus or not -- taker = Zero, takerInNonce = Zero
taker: takerInNonce = ZERO_ADDRESS,
// if given, overrides the above choices made based on `taker`
contractTaker,
}: BuildOrderDataInput): SignableOrderData {
// first 160 bits is taker address (for p2p orders),
// or 0 for limitOrders, so that anyone can be the taker of the Order
Expand All @@ -75,7 +80,9 @@ export function buildOrderData({

// no takerInNonce -> not p2p order -> allow anyone to fill (not only Augustus)
// otherwise p2p order -> fill through Augustus only
const taker = takerInNonce === ZERO_ADDRESS ? ZERO_ADDRESS : AugustusAddress;
const taker =
contractTaker ||
(takerInNonce === ZERO_ADDRESS ? ZERO_ADDRESS : AugustusAddress);

const order: OrderData = {
nonceAndMeta,
Expand Down
Loading