Skip to content

Commit

Permalink
chore: renamed pricedCallSpread to drop 's'. declared option price
Browse files Browse the repository at this point in the history
Added the price of each option to the invitation details.

the pricedCallSpread was inexplicably in pricedCallSpreads.js. I
dropped the plural.
  • Loading branch information
Chris-Hibbert committed Nov 17, 2020
1 parent 68f3c40 commit c875fde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ const start = zcf => {
await depositToSeat(zcf, collateralSeat, spreadAmount, payment);
// AWAIT ////

const numerator =
(dir === Position.LONG) ? buyPercent : inverse(buyPercent);
const required = floorDivide(
multiply(terms.settlementAmount.value, numerator),
100,
);

/** @type {OfferHandler} */
const optionPosition = depositSeat => {
assertProposalShape(depositSeat, {
Expand All @@ -115,12 +122,6 @@ const start = zcf => {
} = depositSeat.getProposal();

// assert that this buyer offered the amount required
const numerator =
(dir === Position.LONG) ? buyPercent : inverse(buyPercent);
const required = floorDivide(
multiply(terms.settlementAmount.value, numerator),
100,
);
assert(
collateralMath.isEqual(newCollateral, collateralMath.make(required)),
details`Collateral required: ${required}`,
Expand All @@ -147,6 +148,7 @@ const start = zcf => {

return zcf.makeInvitation(optionPosition, `call spread ${dir}`, {
position: dir,
collateral: required,
option: spreadAmount.Option,
});
}
Expand Down
6 changes: 3 additions & 3 deletions packages/zoe/test/unitTests/contracts/test-callSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { assertPayoutDeposit, assertPayoutAmount } from '../../zoeTestHelpers';
import { makeFakePriceAuthority } from '../../../tools/fakePriceAuthority';

const fundedCallSpread = `${__dirname}/../../../src/contracts/callSpread/fundedCallSpread`;
const pricedCallSpread = `${__dirname}/../../../src/contracts/callSpread/pricedCallSpreads`;
const pricedCallSpread = `${__dirname}/../../../src/contracts/callSpread/pricedCallSpread`;
const simpleExchange = `${__dirname}/../../../src/contracts/simpleExchange`;

const makeTestPriceAuthority = (amountMaths, priceList, timer) =>
Expand Down Expand Up @@ -669,7 +669,7 @@ test('pricedCallSpread, mid-strike', async t => {
// Bob makes an offer for the long option
const bobProposal = harden({
want: { Option: longOption },
give: { Collateral: bucks(225) },
give: { Collateral: bucks(longOptionValue.collateral) },
});
const bobPurchaseSeat = await zoe.offer(await longInvitation, bobProposal, {
Collateral: bobBucksPayment,
Expand All @@ -693,7 +693,7 @@ test('pricedCallSpread, mid-strike', async t => {
// carol makes an offer for the short option
const carolProposal = harden({
want: { Option: shortOption },
give: { Collateral: bucks(75) },
give: { Collateral: bucks(shortOptionValue.collateral) },
});
const carolPurchaseSeat = await zoe.offer(
await shortInvitation,
Expand Down

0 comments on commit c875fde

Please sign in to comment.