@@ -10,9 +10,20 @@ import {
1010import {ComposableCoW} from "@composable-cow/ComposableCoW.sol " ;
1111
1212import {Trading} from "exchange/mixins/Trading.sol " ;
13+ import {OrderStatus} from "exchange/libraries/OrderStructs.sol " ;
1314
1415import {PolyswapOrder} from "./PolyswapOrder.sol " ;
1516
17+ // --- error strings
18+ string constant INVALID_HASH = "invalid hash " ;
19+ string constant CONDITION_NOT_MET = "condition not met " ;
20+ string constant POLYMARKET_ORDER_CANCELLED = "polymarket order cancelled " ;
21+
22+ /**
23+ * @title Polyswap Conditional Order
24+ * @dev This contract implements the logic for generating a tradeable order based on a Polyswap order.
25+ * It inherits from BaseConditionalOrder to work with the ComposableCoW framework.
26+ **/
1627contract Polyswap is BaseConditionalOrder {
1728 ComposableCoW public immutable composableCow;
1829 Trading public immutable polymarket;
@@ -41,5 +52,12 @@ contract Polyswap is BaseConditionalOrder {
4152 order = PolyswapOrder.orderFor (polyswapOrder, polymarket);
4253
4354 // check if the polymarket order is fulfilled
55+ OrderStatus memory status = polymarket.getOrderStatus (polyswapOrder.polymarketOrderHash);
56+ if (status.isFilledOrCancelled && status.remaining != 0 ) {
57+ revert IConditionalOrder.PollNever (POLYMARKET_ORDER_CANCELLED);
58+ }
59+ if (! (status.isFilledOrCancelled && status.remaining == 0 )) {
60+ revert IConditionalOrder.PollTryNextBlock (CONDITION_NOT_MET);
61+ }
4462 }
4563}
0 commit comments