2021-09-24 20:19:45 +03:00
|
|
|
import { BigNumber } from '@ethersproject/bignumber'
|
2021-09-22 02:21:28 +03:00
|
|
|
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
|
|
|
|
import JSBI from 'jsbi'
|
|
|
|
|
2021-05-18 18:31:22 +03:00
|
|
|
import { ZERO_ADDRESS } from '../constants/misc'
|
2020-09-28 21:26:14 +03:00
|
|
|
import { computeUniCirculation } from './computeUniCirculation'
|
|
|
|
|
|
|
|
describe('computeUniCirculation', () => {
|
2021-05-20 19:21:40 +03:00
|
|
|
const token = new Token(4, ZERO_ADDRESS, 18)
|
2020-09-28 21:26:14 +03:00
|
|
|
|
|
|
|
function expandTo18Decimals(num: JSBI | string | number) {
|
|
|
|
return JSBI.multiply(JSBI.BigInt(num), JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(18)))
|
|
|
|
}
|
|
|
|
|
|
|
|
function tokenAmount(num: JSBI | string | number) {
|
2021-05-12 16:52:17 +03:00
|
|
|
return CurrencyAmount.fromRawAmount(token, expandTo18Decimals(num))
|
2020-09-28 21:26:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
it('before staking', () => {
|
|
|
|
expect(computeUniCirculation(token, BigNumber.from(0), undefined)).toEqual(tokenAmount(150_000_000))
|
|
|
|
expect(computeUniCirculation(token, BigNumber.from(1600387200), undefined)).toEqual(tokenAmount(150_000_000))
|
|
|
|
})
|
|
|
|
it('mid staking', () => {
|
|
|
|
expect(computeUniCirculation(token, BigNumber.from(1600387200 + 15 * 24 * 60 * 60), undefined)).toEqual(
|
|
|
|
tokenAmount(155_000_000)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
it('after staking and treasury vesting cliff', () => {
|
|
|
|
expect(computeUniCirculation(token, BigNumber.from(1600387200 + 60 * 24 * 60 * 60), undefined)).toEqual(
|
|
|
|
tokenAmount(224_575_341)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
it('subtracts unclaimed uni', () => {
|
|
|
|
expect(computeUniCirculation(token, BigNumber.from(1600387200 + 15 * 24 * 60 * 60), tokenAmount(1000))).toEqual(
|
|
|
|
tokenAmount(154_999_000)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|