-
Notifications
You must be signed in to change notification settings - Fork 67
/
vault.maths.test.ts
53 lines (44 loc) · 1.68 KB
/
vault.maths.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import BigNumber from 'bignumber.js'
import { zero } from 'helpers/zero'
import { buildPosition, collateralPriceAtRatio } from './vault.maths'
//TODO: [Mocha -> Jest] Rewrite in Jest compatible format.
describe.skip('vault maths', () => {
describe('collateralPriceAtRatioThreshold', () => {
it('converts', () => {
const colRatioPriceUsd = collateralPriceAtRatio({
colRatio: new BigNumber(1.5),
vaultDebt: new BigNumber(100),
collateral: new BigNumber(1000),
})
expect(colRatioPriceUsd.toString()).toBe('0.15')
})
it('handles zero collateral', () => {
const colRatioPriceUsd = collateralPriceAtRatio({
colRatio: new BigNumber(1.5),
vaultDebt: new BigNumber(100),
collateral: zero,
})
expect(colRatioPriceUsd.toString()).toBe('0')
})
})
describe('daiYieldFromLockedCollateral', () => {
it('accounts for the origination fee and min active col ratio in daiYieldFromLockedCollateral', () => {
const args = {
debtScalingFactor: new BigNumber(1),
stabilityFee: new BigNumber(1),
liquidationRatio: new BigNumber(1),
ilkDebtAvailable: new BigNumber(1000),
collateralizationDangerThreshold: new BigNumber(1),
collateralizationWarningThreshold: new BigNumber(1),
collateral: new BigNumber(150),
currentPrice: new BigNumber(1),
nextPrice: new BigNumber(2),
normalizedDebt: new BigNumber('49.5'),
minActiveColRatio: new BigNumber('1.5'),
originationFee: new BigNumber('0.01'),
}
const result = buildPosition(args)
expect(result.daiYieldFromLockedCollateral.toString()).toBe('50')
})
})
})