@@ -14,6 +14,7 @@ import {
1414 fetchPositionsInWhirlpool ,
1515} from "../src/position" ;
1616import { rpc , signer } from "./utils/mockRpc" ;
17+ import { getFullRangeTickIndexes } from "@orca-so/whirlpools-core" ;
1718
1819describe ( "Fetch Position" , ( ) => {
1920 let mintA : Address ;
@@ -29,28 +30,48 @@ describe("Fetch Position", () => {
2930 pool = await setupWhirlpool ( mintA , mintB , 128 ) ;
3031 splashPool = await setupWhirlpool ( mintA , mintB , SPLASH_POOL_TICK_SPACING ) ;
3132 await setupPosition ( pool ) ;
32- await setupPosition ( splashPool ) ;
33+ const splashFullRange = getFullRangeTickIndexes ( SPLASH_POOL_TICK_SPACING ) ;
34+ await setupPosition ( splashPool , {
35+ tickLower : splashFullRange . tickLowerIndex ,
36+ tickUpper : splashFullRange . tickUpperIndex ,
37+ } ) ;
3338 await setupTEPosition ( pool ) ;
34- await setupPositionBundle ( pool ) ;
35- await setupPositionBundle ( splashPool , [ { } , { } ] ) ;
39+
40+ // bundle with 1 position, 2 positions
41+ await setupPositionBundle ( pool , [ { tickLower : - 100 , tickUpper : 100 } ] ) ;
42+ await setupPositionBundle ( splashPool , [
43+ {
44+ tickLower : splashFullRange . tickLowerIndex ,
45+ tickUpper : splashFullRange . tickUpperIndex ,
46+ } ,
47+ {
48+ tickLower : splashFullRange . tickLowerIndex ,
49+ tickUpper : splashFullRange . tickUpperIndex ,
50+ } ,
51+ ] ) ;
3652 } ) ;
3753
38- // TODO: enable this when solana-bankrun supports gpa
39- it . skip ( "Should fetch all positions for an address" , async ( ) => {
54+ it ( "Should fetch all positions for an address" , async ( ) => {
4055 const positions = await fetchPositionsForOwner ( rpc , signer . address ) ;
41- assert . strictEqual ( positions . length , 5 ) ;
56+
57+ // 3 positions: 1 regular on pool, 1 full-range on splashPool, 1 TE on pool
58+ const standalone = positions . filter ( ( p ) => ! p . isPositionBundle ) ;
59+ assert . strictEqual ( standalone . length , 3 ) ;
60+
61+ const bundles = positions . filter ( ( p ) => p . isPositionBundle ) ;
62+ assert . strictEqual ( bundles . length , 2 ) ;
63+ assert . deepEqual ( bundles . map ( ( b ) => b . positions . length ) . sort ( ) , [ 1 , 2 ] ) ;
4264 } ) ;
4365
44- // TODO: enable this when solana-bankrun supports gpa
45- it . skip ( "Should fetch no positions for a different address" , async ( ) => {
66+ it ( "Should fetch no positions for a different address" , async ( ) => {
4667 const other = await generateKeyPairSigner ( ) ;
4768 const positions = await fetchPositionsForOwner ( rpc , other . address ) ;
4869 assert . strictEqual ( positions . length , 0 ) ;
4970 } ) ;
5071
51- // TODO: enable this when solana-bankrun supports gpa
52- it . skip ( "Should fetch positions for a whirlpool" , async ( ) => {
72+ it ( "Should fetch positions for a whirlpool" , async ( ) => {
5373 const positions = await fetchPositionsInWhirlpool ( rpc , pool ) ;
74+ // 3 positions in pool: 1 regular + 1 TE + 1 bundled
5475 assert . strictEqual ( positions . length , 3 ) ;
5576 } ) ;
5677} ) ;
0 commit comments