Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 2.94 KB

File metadata and controls

74 lines (52 loc) · 2.94 KB

Sundaeswap Orders

Similarly to other Plutus v1 DEXes, Sundaeswap Orders also require an embedded datum (see Minswap).

Order Datum Type

Note

Since Sundaeswap's source code is not open source, we will only highlight certain typescript types that can be used to construct an order datum.

The order datum type is called IOrderDatum which is defined as following:

export interface IOrderDatum extends Encodable {
  poolIdentifier: string;
  orderAddress: IOrderAddress;
  scooperFee: BigInt;
  action: IOrderAction;
}

export interface IOrderAddress extends Encodable {
  destination: IOrderDestination;
  /** Hex encoded public key hash that can cancel order in case destination is script */
  pubKeyHash?: string;
}

export interface IOrderDestination extends Encodable {
  /** Bech32 encoded destination address */
  address: string;
  datumHash?: string;
}

export type IOrderAction = ISwapAction | IOrderWithdraw | IOrderDeposit;

The poolIdentifier is used by off-chain batchers to identify what token pair a specific order corresponds to. An orderAddress defines the destination of the swapped token and may be represented as simple wallet address or a script address (including a datum hash). The scooperFee is the amount of lovelace paid to order batchers. Last but not least, action defines what a user intends to do, whereby the ISwapAction & IOrderWithdraw is currently only implemented.

Order Redeemer Type

Similarly to Minswap, there are two redeemers. One, OrderScoop which is the redeemer used by Sundaeswap's off-chain batcher (scooper) to execute the swap transaction that interacts with a liquidity pool. Second, the OrderCancel redeemer which can be used by the owner of the order to cancel the swap before the batcher processed it.

export type IOrderRedeemerType = 'OrderScoop' | 'OrderCancel';

Type Reference

Datum Builders

Datum Decoders

Redeemer Builders

Redeemer Decoders