When [ (Case (Deposit (Role "Party") (Role "Party") (Token "" "") (ConstantParam "Amount paid by party") ) (When [ (Case (Deposit (Role "Counterparty") (Role "Counterparty") (Token "" "") (ConstantParam "Amount paid by counterparty") ) (When [] (TimeParam "First window beginning") (When [ (Case (Choice (ChoiceId "Price in first window" (Role "Oracle") ) [ (Bound 0 1000000000)]) (When [] (TimeParam "Second window beginning") (When [ (Case (Choice (ChoiceId "Price in second window" (Role "Oracle") ) [ (Bound 0 1000000000)]) (If (ValueGT (ChoiceValue (ChoiceId "Price in first window" (Role "Oracle") ) ) (ChoiceValue (ChoiceId "Price in second window" (Role "Oracle") ) ) ) (Let "Decrease in price" (SubValue (ChoiceValue (ChoiceId "Price in first window" (Role "Oracle") ) ) (ChoiceValue (ChoiceId "Price in second window" (Role "Oracle") ) ) ) (Pay (Role "Counterparty") (Account (Role "Party") ) (Token "" "") (Cond (ValueLT (UseValue "Decrease in price") (ConstantParam "Amount paid by counterparty") ) (UseValue "Decrease in price") (ConstantParam "Amount paid by counterparty") ) Close) ) (If (ValueLT (ChoiceValue (ChoiceId "Price in first window" (Role "Oracle") ) ) (ChoiceValue (ChoiceId "Price in second window" (Role "Oracle") ) ) ) (Let "Increase in price" (SubValue (ChoiceValue (ChoiceId "Price in second window" (Role "Oracle") ) ) (ChoiceValue (ChoiceId "Price in first window" (Role "Oracle") ) ) ) (Pay (Role "Party") (Account (Role "Counterparty") ) (Token "" "") (Cond (ValueLT (UseValue "Increase in price") (ConstantParam "Amount paid by party") ) (UseValue "Increase in price") (ConstantParam "Amount paid by party") ) Close) ) Close) ) )] (TimeParam "Second window deadline") Close) ) )] (TimeParam "First window deadline") Close) ) )] (TimeParam "Counterparty deposit deadline") Close) )] (TimeParam "Party deposit deadline") Close