42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { uint256ToBytesLittleEndian } from "../subgraph";
|
|
import { getSnatchList } from "../helpers";
|
|
import { Position, PositionStatus } from '../__generated__/graphql';
|
|
|
|
|
|
describe('BigInt Conversion Functions', () => {
|
|
test('get a list of positions to snatch', async () => {
|
|
|
|
const mockPos: Position[] = [
|
|
{
|
|
__typename: 'Position',
|
|
id: uint256ToBytesLittleEndian(3n),
|
|
owner: '0x8db6b632d743aef641146dc943acb64957155388',
|
|
share: 0.000001,
|
|
creationTime: 1610000000,
|
|
taxRate: 0.05,
|
|
status: PositionStatus.Active, // Enum usage
|
|
},
|
|
{
|
|
__typename: 'Position',
|
|
id: uint256ToBytesLittleEndian(4n),
|
|
owner: '0x8db6b632d743aef641146dc943acb64957155388',
|
|
share: 0.000001,
|
|
creationTime: 1610000000,
|
|
taxRate: 0.01,
|
|
status: PositionStatus.Active, // Enum usage
|
|
},
|
|
{
|
|
__typename: 'Position',
|
|
id: uint256ToBytesLittleEndian(5n),
|
|
owner: '0x8db6b632d743aef641146dc943acb64957155388',
|
|
share: 0.000001,
|
|
creationTime: 1610000000,
|
|
taxRate: 0.02,
|
|
status: PositionStatus.Active, // Enum usage
|
|
}
|
|
];
|
|
|
|
expect(getSnatchList(mockPos, 20000000000000000000n, 0.03)).toEqual([4n, 5n]);
|
|
});
|
|
|
|
});
|