Skip to content

Commit

Permalink
chore: state tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed Oct 22, 2023
1 parent 4c871dc commit 54480eb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/swap/src/helpers/prices/getPriceAfterFee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,30 @@ describe('getPriceAfterFee', () => {
const expected = new BigNumber(0)
expect(result).toStrictEqual(expected)
})

// NOTE: it means that if the price is missing the fee wont consider the batcher fee
it('should return not add the feeInSellTerm when pt sell side is 0', () => {
const pool = {
tokenA: {quantity: '143983812522', tokenId: 'tokenA'},
tokenB: {quantity: '2050476716943', tokenId: 'tokenB'},
ptPriceTokenA: '0',
ptPriceTokenB: '1',
fee: '0.3', // 0.3%
provider: 'minswap',
batcherFee: {quantity: '1900000', tokenId: ''},
deposit: {quantity: '1', tokenId: ''},
poolId: '0',
lpToken: {
quantity: '0',
tokenId: '0',
},
} as Swap.Pool
const tokenAAmount = '10000000000'
const tokenBAmount = '1000'
const tokenId = 'tokenA'
const result = getPriceAfterFee(pool, tokenAAmount, tokenBAmount, tokenId)
const expected = new BigNumber(10000000)
expect(result).toStrictEqual(expected)
})

})
2 changes: 1 addition & 1 deletion packages/swap/src/translators/reactjs/state/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('State Actions', () => {
})

describe('SelectedPoolChanged', () => {
describe('market', () => {
describe('market', () => {
it('should ignore', () => {
const action: SwapCreateOrderAction = {
type: SwapCreateOrderActionType.SelectedPoolChanged,
Expand Down

0 comments on commit 54480eb

Please sign in to comment.