Skip to content

Commit a2cc336

Browse files
committed
Update stop-limit spec to recommend using makerFeeAssetData
1 parent 4f7c3d1 commit a2cc336

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

order-types/stop-limit.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,37 @@ To create a stop-limit 0x order, we need:
2626
- The price range in which we'd like the order to be executed. Note that the value returned by Chainlink reference contracts is the price multiplied by 100000000 ([source](https://docs.chain.link/docs/using-chainlink-reference-contracts#section-live-reference-data-contracts-ethereum-mainnet)).
2727

2828
The contract addresses and parameters must be encoded as StaticCall asset data and included in one of the order's asset data fields.
29-
For example, consider an order selling ZRX for ETH. Normally, the `makerAssetData` of this order would be the ERC20 asset data encoding of the ZRX token address.
29+
For example, consider an order selling ZRX for ETH.
30+
31+
### Option 1: makerFeeAssetData
32+
33+
If the `makerFeeAssetData` would otherwise be unused, we can simply set it to be the stop-limit StaticCall asset data.
34+
During order settlement, the Exchange will dispatch the StaticCall proxy to call the stop-limit contract.
35+
36+
In TypeScript, this would look something like the following:
37+
```typescript
38+
import { encodeStopLimitStaticCallData } from '@0x/contracts-integrations';
39+
import { assetDataUtils } from '@0x/order-utils';
40+
41+
const makerFeeAssetData = encodeStopLimitStaticCallData(
42+
chainlinkStopLimit.address,
43+
chainLinkZrxEthAggregator.address,
44+
minPrice,
45+
maxPrice,
46+
);
47+
48+
```
49+
50+
In order to avoid unexpected behavior caused by rounding and overflow, we recommend setting the `makerFee` amount to equal the `makerAssetAmount` (in this case, the amount of ZRX being sold).
51+
Note that despite the non-zero `makerFee`, the maker will not be transferring any assets for the "transfer", we are simply repurposing the field to perform the stop-limit check.
52+
As such, the `feeRecipientAddress` can be set to an arbitrary address or the null address.
53+
54+
### Option 2: Multi-asset makerAssetData
55+
56+
Option 1 is the preferred way to create stop-limit orders for easy discoverability via [0x Mesh](https://github.com/0xProject/0x-mesh).
57+
However, if the maker would in fact like to use the maker fee field to transfer assets to a fee recipient, we can instead add the stop-limit check to the `makerAssetData`.
58+
59+
Normally, the `makerAssetData` of a ZRX-ETH sell order would be the ERC20 asset data encoding of the ZRX token address.
3060
But to turn this into a stop-limit sell order, we can instead use [MultiAsset](https://github.com/0xProject/0x-protocol-specification/blob/master/asset-proxy/multi-asset-proxy.md) asset data, where the nested assets are ZRX and the stop-limit check (encoded as StaticCall asset data).
3161
During order settlement, the MultiAsset proxy will dispatch the ERC20 proxy to perform the ZRX transfer and then dispatch the StaticCall proxy to call the stop-limit contract.
3262

0 commit comments

Comments
 (0)