Skip to content

Commit

Permalink
Merge pull request #309 from invariant-labs/add-fee-tiers
Browse files Browse the repository at this point in the history
Add new fee tiers
  • Loading branch information
wojciech-cichocki authored Nov 25, 2023
2 parents 39c7ef3 + 3d27cfe commit 96da726
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@invariant-labs/sdk",
"version": "0.9.60",
"version": "0.9.61",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,16 @@ export const FEE_TIERS: FeeTier[] = [
{ fee: fromFee(new BN(3)), tickSpacing: 1 },
{ fee: fromFee(new BN(5)), tickSpacing: 1 },
{ fee: fromFee(new BN(10)), tickSpacing: 1 },
{ fee: fromFee(new BN(20)), tickSpacing: 5 },
{ fee: fromFee(new BN(50)) },
{ fee: fromFee(new BN(100)) },
{ fee: fromFee(new BN(300)) },
{ fee: fromFee(new BN(500)), tickSpacing: 5 },
{ fee: fromFee(new BN(1000)) },
{ fee: fromFee(new BN(3000)), tickSpacing: 5 },
{ fee: fromFee(new BN(5000)), tickSpacing: 5 },
{ fee: fromFee(new BN(10000)), tickSpacing: 5 },
{ fee: fromFee(new BN(25000)), tickSpacing: 5 },
{ fee: fromFee(new BN(50000)), tickSpacing: 5 }
]

Expand Down
14 changes: 10 additions & 4 deletions tests/math.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ describe('Math', () => {
assert.ok(result.eq(new BN(24)))
})
it('returns the correct average for 5 numbers', () => {
const result = arithmeticalAvg(new BN(10), new BN(50), new BN(12), new BN(10024), new BN(11479))
const result = arithmeticalAvg(
new BN(10),
new BN(50),
new BN(12),
new BN(10024),
new BN(11479)
)
assert.ok(result.eq(new BN(4315)))
})
})
Expand Down Expand Up @@ -1024,7 +1030,7 @@ describe('Math', () => {

assert.ok(result.v.eq(expectedResult.v))
})
it('2', async () => { })
it('2', async () => {})
const price: Decimal = { v: PRICE_DENOMINATOR.mul(new BN('1')) }
const liquidity: Decimal = { v: LIQUIDITY_DENOMINATOR.mul(new BN('2')) }
const amount: BN = new BN('3')
Expand Down Expand Up @@ -1100,7 +1106,7 @@ describe('Math', () => {
}
assert.ok(result.v.eq(expectedResult.v))
})
it('2', async () => { })
it('2', async () => {})
const price: Decimal = { v: PRICE_DENOMINATOR.mul(new BN('1')) }
const liquidity: Decimal = { v: LIQUIDITY_DENOMINATOR.mul(new BN('2')) }
const amount: BN = new BN('3')
Expand Down Expand Up @@ -2052,7 +2058,7 @@ describe('Math', () => {
it('case 1', async () => {
const volume = 125000
const tokenXamount = new BN(1000000)
const feeTier = FEE_TIERS[6] // 0.3%
const feeTier = FEE_TIERS[7] // 0.3%

const result = dailyFactorPool(tokenXamount, volume, feeTier)
assert.equal(result, 0.00037125)
Expand Down

1 comment on commit 96da726

@vercel
Copy link

@vercel vercel bot commented on 96da726 Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.