Skip to content

Commit

Permalink
refactor: cover the case of early termination of a capped market
Browse files Browse the repository at this point in the history
  • Loading branch information
witgaw committed Sep 16, 2024
1 parent 9202db5 commit b291142
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions protocol/0016-PFUT-product_builtin_future.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ If `max_price` is specified, mark price candidates greater than `max_price` shou
If `max_price` is specified:

- When `binary_settlement` parameter is set to `false` any value `0 <= settlement_price <= max_price` should be accepted as a settlement price.
- When `binary_settlement` parameter is set to `true` only `settlement_price=0` or `settlement_price=max_price` should be accepted.
- When `binary_settlement` parameter is set to `true` AND the market has been [suspended with a governance vote](./0028-GOVE-governance.md#62-suspend-the-market) any value `0 <= settlement_price <= max_price` should be accepted as a settlement price. This is needed to allow community to close the markets which never reach their termination in orderly fashion, when a price that's considered "fair" may be neither `0` nor `max_price`.
- When `binary_settlement` parameter is set to `true` AND the trading termination was triggered only `settlement_price=0` or `settlement_price=max_price` should be accepted.
- Any other values get ignored and market does not settle, instead it still waits for subsequent values from the settlement oracle until a value which passes the above conditions arrives.

## 3. Binary options
Expand Down Expand Up @@ -118,7 +119,10 @@ Optional parameters:
1. When `max_price` is specified and the market is setup to use oracle based mark price and the value received from oracle is greater than `max_price` then it gets ignored and mark-to-market settlement doesn't occur until a mark price candidate within the `[0, max_price]` range arrives. (<a name="0016-PFUT-017" href="#0016-PFUT-017">0016-PFUT-017</a>)
1. When `max_price` is specified and `binary_settlement` flag is set to `false`, and the final settlement price candidate received from the oracle is less than or equal to `max_price` then it gets used as is and the final cashflows are calculated according to that price. (<a name="0016-PFUT-018" href="#0016-PFUT-018">0016-PFUT-018</a>)
1. When `max_price` is specified and the final settlement price candidate received from the oracle is greater than `max_price` the value gets ignored, next a value equal to `max_price` comes in from the settlement oracle and market settles correctly. The market behaves in this way irrespective of how `binary_settlement` flag is set. (<a name="0016-PFUT-019" href="#0016-PFUT-019">0016-PFUT-019</a>)
1. When `max_price` is specified, the `binary_settlement` flag is set to `true` and the final settlement price candidate received from the oracle is greater than `0` and less than `max_price` the value gets ignored, next a value of `0` comes in from the settlement oracle and market settles correctly. (<a name="0016-PFUT-020" href="#0016-PFUT-020">0016-PFUT-020</a>)
1. When `max_price` is specified, the `binary_settlement` flag is set to `true`, the trading termination trigger has been successfully received and the final settlement price candidate received from the oracle is greater than `0` and less than `max_price` the value gets ignored, next a value of `0` comes in from the settlement oracle and market settles correctly. (<a name="0016-PFUT-020" href="#0016-PFUT-020">0016-PFUT-020</a>)
1. When `max_price` is specified, the `binary_settlement` flag is set to `true`, the market has been suspended via governance and another governance vote proposes to terminate the market, the termination price which is greater than `0` and less than `max_price` gets accepted and the market settles correctly. (<a name="0016-PFUT-029" href="#0016-PFUT-029">0016-PFUT-029</a>)
1. When `max_price` is specified, the `binary_settlement` flag is set to `true`, the market has been suspended via governance and another governance vote proposes to terminate the market, the termination price which is equal to `0` gets accepted and the market settles correctly. (<a name="0016-PFUT-030" href="#0016-PFUT-030">0016-PFUT-030</a>)
1. When `max_price` is specified, the `binary_settlement` flag is set to `true`, the market has been suspended via governance and another governance vote proposes to terminate the market, the termination price which is equal to `max_price` gets accepted and the market settles correctly. (<a name="0016-PFUT-031" href="#0016-PFUT-031">0016-PFUT-031</a>)
1. When `max_price` is specified and the market is ran in a fully-collateralised mode and it has parties with open positions settling it at a price of `max_price` works correctly and the sum of all final settlement cashflows equals 0 (loss socialisation does not happen). Assuming general account balances of all parties were `0` after opening the positions and all of their funds were in the margin accounts: long parties end up with balances equal to `position size * max_price` and short parties end up with `0` balances. (<a name="0016-PFUT-021" href="#0016-PFUT-021">0016-PFUT-021</a>)
1. When `max_price` is specified and the market is ran in a fully-collateralised mode and it has parties with open positions settling it at a price of `0` works correctly and the sum of all final settlement cashflows equals 0 (loss socialisation does not happen). Assuming general account balances of all parties were `0` after opening the positions and all of their funds were in the margin accounts: short parties end up with balances equal to `abs(position size) * max_price` and long parties end up with `0` balances. (<a name="0016-PFUT-022" href="#0016-PFUT-022">0016-PFUT-022</a>)
1. When `max_price` is specified and the market is ran in a fully-collateralised mode and a party opens a long position at a `max_price`, no closeout happens when mark to market settlement is carried out at a price of `0`. (<a name="0016-PFUT-023" href="#0016-PFUT-023">0016-PFUT-023</a>)
Expand Down
12 changes: 10 additions & 2 deletions protocol/colosseo-features.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@
"0056-REWA-167"
]
},

"Spot stop orders": {
"milestone": "colosseo",
"acs": [
Expand Down Expand Up @@ -486,7 +485,8 @@
"acs": [
"0012-POSR-031",
"0012-POSR-032",
"0012-POSR-033"]
"0012-POSR-033"
]
},
"Order spam": {
"milestone": "colosseo_II",
Expand Down Expand Up @@ -636,6 +636,14 @@
"0094-PRAC-008"
]
},
"Misc": {
"milestone": "genbutemple",
"acs": [
"0016-PFUT-029",
"0016-PFUT-030",
"0016-PFUT-031"
]
},
"Unknown": {
"milestone": "unknown",
"acs": []
Expand Down

0 comments on commit b291142

Please sign in to comment.