-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added querying all pools for specified pair
- Loading branch information
1 parent
7aa093e
commit 55eeaa8
Showing
7 changed files
with
145 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ONE_ALPH, web3 } from '@alephium/web3' | ||
import { getSigner } from '@alephium/web3-test' | ||
import { Invariant } from '../src/invariant' | ||
import { Network } from '../src/network' | ||
import { getPool, initTokensXY } from '../src/testUtils' | ||
import { getBasicFeeTickSpacing } from '../src/snippets' | ||
import { newFeeTier, newPoolKey } from '../src/utils' | ||
|
||
web3.setCurrentNodeProvider('http://127.0.0.1:22973') | ||
|
||
describe('query on pair', () => { | ||
test('query on pools works', async () => { | ||
const initialFee = 0n | ||
const [fee] = getBasicFeeTickSpacing() | ||
const deployer = await getSigner(ONE_ALPH * 1000n, 0) | ||
const invariant = await Invariant.deploy(deployer, Network.Local, initialFee) | ||
const supply = 10n ** 10n | ||
const [tokenX, tokenY] = await initTokensXY(deployer, supply) | ||
|
||
const initSqrtPrice = 10n ** 24n | ||
const feeTier10TS = await newFeeTier(fee, 10n) | ||
const feeTier20TS = await newFeeTier(fee, 20n) | ||
|
||
await invariant.addFeeTier(deployer, feeTier10TS) | ||
await invariant.addFeeTier(deployer, feeTier20TS) | ||
|
||
const poolKey0 = await newPoolKey(tokenX.contractId, tokenY.contractId, feeTier10TS) | ||
const poolKey1 = await newPoolKey(tokenX.contractId, tokenY.contractId, feeTier20TS) | ||
|
||
await invariant.createPool( | ||
deployer, | ||
tokenX.contractId, | ||
tokenY.contractId, | ||
feeTier10TS, | ||
initSqrtPrice | ||
) | ||
|
||
await invariant.createPool( | ||
deployer, | ||
tokenX.contractId, | ||
tokenY.contractId, | ||
feeTier20TS, | ||
initSqrtPrice | ||
) | ||
|
||
const expectedPool0 = await invariant.getPool(poolKey0) | ||
const expectedPool1 = await invariant.getPool(poolKey1) | ||
console.log('expectedPool0', expectedPool0) | ||
console.log('expectedPool1', expectedPool1) | ||
const query = await invariant.getAllPoolsForPair(tokenX.contractId, tokenY.contractId) | ||
console.log(query) | ||
}) | ||
}) |