-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract calculation for testing purposes. save the invitationIssuer as an issuer in the contract exit contract when done. use trade() rathern than reallocate() some renaming
- Loading branch information
1 parent
f900449
commit 779b33b
Showing
3 changed files
with
188 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/zoe/test/unitTests/contracts/test-callSpread-calculation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import '@agoric/install-ses'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import test from 'ava'; | ||
import '../../../exported'; | ||
|
||
import { setup } from '../setupBasicMints'; | ||
import { calculateLongShare } from '../../../src/contracts/callSpread'; | ||
|
||
test('callSpread-calculation, at lower bound', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(20); | ||
const strike2 = moola(70); | ||
const price = moola(20); | ||
t.is(0, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, at upper bound', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(20); | ||
const strike2 = moola(55); | ||
const price = moola(55); | ||
t.is(100, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, below lower bound', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(15); | ||
const strike2 = moola(55); | ||
const price = moola(0); | ||
t.is(0, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, above upper bound', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(15); | ||
const strike2 = moola(55); | ||
const price = moola(60); | ||
t.is(100, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, mid-way', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(15); | ||
const strike2 = moola(45); | ||
const price = moola(40); | ||
t.is(83, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, zero', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(15); | ||
const strike2 = moola(45); | ||
const price = moola(0); | ||
t.is(0, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); | ||
|
||
test('callSpread-calculation, large', async t => { | ||
const { moola, amountMaths } = setup(); | ||
const moolaMath = amountMaths.get('moola'); | ||
|
||
const strike1 = moola(15); | ||
const strike2 = moola(45); | ||
const price = moola(10000000000); | ||
t.is(100, calculateLongShare(moolaMath, price, strike1, strike2)); | ||
}); |
Oops, something went wrong.