@nftx/subgraph
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.1.0](https://github.com/NFTX-project/nftxjs/compare/v2.0.2...v2.1.0) (2024-04-18) | ||
### Features | ||
* upgrade nftx amm subgraph to the new uniswap subgraph ([a9912b3](https://github.com/NFTX-project/nftxjs/commit/a9912b3ab61b317f0162838da5b86f01be26107d)) | ||
## [2.0.2](https://github.com/NFTX-project/nftxjs/compare/v2.0.1...v2.0.2) (2024-03-20) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@nftx/subgraph", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -32,10 +32,10 @@ "homepage": "https://github.com/NFTX-project/nftxjs#readme", | ||
"dependencies": { | ||
"@nftx/config": "^2.0.2", | ||
"@nftx/constants": "^2.0.2", | ||
"@nftx/config": "^2.1.0", | ||
"@nftx/constants": "^2.1.0", | ||
"@nftx/errors": "^2.0.0", | ||
"@nftx/utils": "^2.0.2" | ||
"@nftx/utils": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@nftx/types": "^2.0.2" | ||
"@nftx/types": "^2.1.0" | ||
} | ||
} |
@@ -12,3 +12,3 @@ import 'isomorphic-fetch'; | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPool | ||
const query = g.pool | ||
.id('0x1768ccc3fc3a40522fcd3296633ae8c00434b3b6') | ||
@@ -19,3 +19,3 @@ .select((s) => [s.id]); | ||
const expected = `{ | ||
liquidityPool(id: "0x1768ccc3fc3a40522fcd3296633ae8c00434b3b6") { | ||
pool(id: "0x1768ccc3fc3a40522fcd3296633ae8c00434b3b6") { | ||
id | ||
@@ -30,7 +30,7 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [s.id]); | ||
const query = g.pools.select((s) => [s.id]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
id | ||
@@ -45,7 +45,7 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.as('foo').select((s) => [s.id]); | ||
const query = g.pools.as('foo').select((s) => [s.id]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
foo: liquidityPools { | ||
foo: pools { | ||
id | ||
@@ -60,5 +60,5 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools | ||
const query = g.pools | ||
.first(10) | ||
.orderBy('activeLiquidity') | ||
.orderBy('liquidity') | ||
.orderDirection('desc') | ||
@@ -69,5 +69,5 @@ .select((s) => [s.id]); | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
first: 10 | ||
orderBy: activeLiquidity | ||
orderBy: liquidity | ||
orderDirection: desc | ||
@@ -85,4 +85,4 @@ ) { | ||
const query = g.liquidityPools | ||
.where((w) => [w.createdTimestamp('0')]) | ||
const query = g.pools | ||
.where((w) => [w.createdAtTimestamp('0')]) | ||
.select((s) => [s.id]); | ||
@@ -92,5 +92,5 @@ | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
where: { | ||
createdTimestamp: "0" | ||
createdAtTimestamp: "0" | ||
} | ||
@@ -108,8 +108,11 @@ ) { | ||
const query = g.liquidityPools | ||
const query = g.pools | ||
.where((w) => [ | ||
w.createdTimestamp(undefined), | ||
w.totalLiquidity(null), | ||
w.activeLiquidity.in(undefined), | ||
w.protocol((w) => [w.id.in(null), w.pools((w) => [w.id.is(undefined)])]), | ||
w.createdAtTimestamp(undefined), | ||
w.liquidity(null), | ||
w.balanceOfBlock.in(undefined), | ||
w.collects((collect) => [ | ||
collect.id.in(null), | ||
collect.owner((owner) => [owner.id.is(undefined)]), | ||
]), | ||
]) | ||
@@ -120,3 +123,3 @@ .select((s) => [s.id]); | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
id | ||
@@ -131,4 +134,4 @@ } | ||
const q = createQuery<Query>(); | ||
const query = q.withdraws | ||
.where((w) => [w.inputTokens.contains(['0x1234'])]) | ||
const query = q.pools | ||
.where((w) => [w.burns.contains(['0x1234'])]) | ||
.select((s) => [s.id]); | ||
@@ -138,5 +141,5 @@ | ||
const expected = `{ | ||
withdraws( | ||
pools( | ||
where: { | ||
inputTokens_contains: ["0x1234"] | ||
burns_contains: ["0x1234"] | ||
} | ||
@@ -151,21 +154,22 @@ ) { | ||
it('filters by an exact array match', () => { | ||
const q = createQuery<Query>(); | ||
const query = q.withdraws | ||
.where((w) => [w.inputTokenAmounts.isNot(['0', '0'])]) | ||
.select((s) => [s.id]); | ||
// Pretty sure we no longer have a use case for this in our schemas | ||
// it('filters by an exact array match', () => { | ||
// const q = createQuery<Query>(); | ||
// const query = q.pools | ||
// .where((w) => [w.feesUSD.isNot(['0', '0'])]) | ||
// .select((s) => [s.id]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
withdraws( | ||
where: { | ||
inputTokenAmounts_not: ["0", "0"] | ||
} | ||
) { | ||
id | ||
} | ||
}`; | ||
// const actual = query.toString(); | ||
// const expected = `{ | ||
// withdraws( | ||
// where: { | ||
// inputTokenAmounts_not: ["0", "0"] | ||
// } | ||
// ) { | ||
// id | ||
// } | ||
// }`; | ||
expect(ignoreWs(actual)).toBe(ignoreWs(expected)); | ||
}); | ||
// expect(ignoreWs(actual)).toBe(ignoreWs(expected)); | ||
// }); | ||
@@ -175,3 +179,3 @@ // For now we're just saying bigint fields should be stringified | ||
// const g = createQuery<Query>(); | ||
// const query = g.liquidityPools | ||
// const query = g.pools | ||
// .where((w) => w.activeLiquidity.is(0n)) | ||
@@ -182,3 +186,3 @@ // .select((s) => [s.id]); | ||
// const expected = `{ | ||
// liquidityPools( | ||
// pools( | ||
// where: { | ||
@@ -197,9 +201,9 @@ // activeLiquidity: 0 | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools | ||
const query = g.pools | ||
.where((w) => [ | ||
w.activeLiquidity.gt('0'), | ||
w.activeLiquidity.gte('1'), | ||
w.activeLiquidity.isNot('2'), | ||
w.activeLiquidity.lt('100000000000'), | ||
w.activeLiquidity.lte('9999999999'), | ||
w.liquidity.gt('0'), | ||
w.liquidity.gte('1'), | ||
w.liquidity.isNot('2'), | ||
w.liquidity.lt('100000000000'), | ||
w.liquidity.lte('9999999999'), | ||
]) | ||
@@ -210,9 +214,9 @@ .select((s) => [s.id]); | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
where: { | ||
activeLiquidity_gt: "0", | ||
activeLiquidity_gte: "1", | ||
activeLiquidity_ne: "2", | ||
activeLiquidity_lt: "100000000000", | ||
activeLiquidity_lte: "9999999999" | ||
liquidity_gt: "0", | ||
liquidity_gte: "1", | ||
liquidity_ne: "2", | ||
liquidity_lt: "100000000000", | ||
liquidity_lte: "9999999999" | ||
} | ||
@@ -230,12 +234,15 @@ ) { | ||
const query = g.liquidityPools | ||
.where((w) => [w.inputTokens((w) => [w.id('0x00000'), w.decimals(18)])]) | ||
const query = g.pools | ||
// .where((w) => [w.inputTokens((w) => [w.id('0x00000'), w.decimals(18)])]) | ||
.where((w) => [ | ||
w.fees((fee) => [fee.id('0x00000'), fee.feePercentage('0.01')]), | ||
]) | ||
.select((s) => [s.id]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
where: { | ||
inputTokens_: { | ||
fees_: { | ||
id: "0x00000", | ||
decimals: 18 | ||
feePercentage: "0.01" | ||
} | ||
@@ -251,7 +258,9 @@ } | ||
it.todo('allows for OR queries'); | ||
it("searches by a child entity's ID", () => { | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools | ||
.where((w) => w.protocol.is('0x000')) | ||
const query = g.pools | ||
.where((w) => w.token1.is('0x000')) | ||
.select((s) => [s.id]); | ||
@@ -261,5 +270,5 @@ | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
where: { | ||
protocol: "0x000" | ||
token1: "0x000" | ||
} | ||
@@ -276,6 +285,6 @@ ) { | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [ | ||
const query = g.pools.select((s) => [ | ||
s.id, | ||
s.activeLiquidity, | ||
s.createdTimestamp, | ||
s.liquidity, | ||
s.createdAtTimestamp, | ||
]); | ||
@@ -285,6 +294,6 @@ | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
id | ||
activeLiquidity | ||
createdTimestamp | ||
liquidity | ||
createdAtTimestamp | ||
} | ||
@@ -298,8 +307,9 @@ }`; | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [s.positions((s) => [s.id])]); | ||
// const query = g.pools.select((s) => [s.positions((s) => [s.id])]); | ||
const query = g.positions.select((s) => [s.pool((pool) => [pool.id])]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
liquidityPools { | ||
positions { | ||
positions { | ||
pool { | ||
id | ||
@@ -315,4 +325,4 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [ | ||
s.positions((s) => [s.pool((s) => [s.id])]), | ||
const query = g.positions.select((s) => [ | ||
s.pool((pool) => [pool.mints((mint) => [mint.id])]), | ||
]); | ||
@@ -322,5 +332,5 @@ | ||
const expected = `{ | ||
liquidityPools { | ||
positions { | ||
pool { | ||
positions { | ||
pool { | ||
mints { | ||
id | ||
@@ -337,7 +347,7 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [s.id]); | ||
const query = g.pools.select((s) => [s.id]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
id | ||
@@ -352,6 +362,4 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select(() => [ | ||
g.positions | ||
.where((w) => w.account.is('0x0')) | ||
.select((s) => [s.depositCount]), | ||
const query = g.pools.select(() => [ | ||
g.positions.where((w) => w.owner.is('0x0')).select((s) => [s.nfpmAddress]), | ||
]); | ||
@@ -361,9 +369,9 @@ | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
positions( | ||
where: { | ||
account: "0x0" | ||
owner: "0x0" | ||
} | ||
) { | ||
depositCount | ||
nfpmAddress | ||
} | ||
@@ -379,20 +387,21 @@ } | ||
const query = q.liquidityPools.select((s) => [ | ||
s.hourlySnapshots( | ||
q.liquidityPoolHourlySnapshots | ||
const query = q.pools.select((s) => [ | ||
s.poolHourData( | ||
q.poolHourDatas | ||
.first(24) | ||
.orderBy('hour') | ||
.orderBy('periodStartUnix') | ||
.orderDirection('desc') | ||
.select((s) => [s.hourlyVolumeUSD, s.id]) | ||
.select((s) => [s.volumeUSD, s.id]) | ||
), | ||
]); | ||
const actual = query.toString(); | ||
const expected = `{ | ||
liquidityPools { | ||
hourlySnapshots( | ||
pools { | ||
poolHourData( | ||
first: 24 | ||
orderBy: hour | ||
orderBy: periodStartUnix | ||
orderDirection: desc | ||
) { | ||
hourlyVolumeUSD | ||
volumeUSD | ||
id | ||
@@ -409,10 +418,10 @@ } | ||
const query = q.liquidityPools.select((s) => [ | ||
const query = q.pools.select((s) => [ | ||
s.on('Foo', (s) => [ | ||
s.hourlySnapshots( | ||
q.liquidityPoolHourlySnapshots | ||
s.poolHourData( | ||
q.poolHourDatas | ||
.first(24) | ||
.orderBy('hour') | ||
.orderBy('periodStartUnix') | ||
.orderDirection('desc') | ||
.select((s) => [s.hourlyVolumeUSD, s.id]) | ||
.select((s) => [s.volumeUSD, s.id]) | ||
), | ||
@@ -424,10 +433,10 @@ ]), | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
... on Foo { | ||
hourlySnapshots( | ||
poolHourData( | ||
first: 24 | ||
orderBy: hour | ||
orderBy: periodStartUnix | ||
orderDirection: desc | ||
) { | ||
hourlyVolumeUSD | ||
volumeUSD | ||
id | ||
@@ -460,13 +469,10 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools | ||
.where((w) => [ | ||
w.activeLiquidity.gt('0'), | ||
w.inputTokens((w) => [w.id('0xAB')]), | ||
]) | ||
const query = g.pools | ||
.where((w) => [w.liquidity.gt('0'), w.token0((w) => [w.id('0xAB')])]) | ||
.select((s) => [ | ||
s.activeLiquidity, | ||
s.liquidity, | ||
s.fees((s) => [s.id, s.feeType, s.feePercentage]), | ||
g.positions | ||
.where((w) => [w.account.is('0x0')]) | ||
.select((s) => [s.id, s.account((s) => [s.id])]), | ||
.where((w) => [w.owner.is('0x0')]) | ||
.select((s) => [s.id, s.owner((s) => [s.id])]), | ||
]); | ||
@@ -476,6 +482,6 @@ | ||
const expected = `{ | ||
liquidityPools( | ||
pools( | ||
where: { | ||
activeLiquidity_gt: "0", | ||
inputTokens_: { | ||
liquidity_gt: "0", | ||
token0_: { | ||
id: "0xab" | ||
@@ -485,3 +491,3 @@ } | ||
) { | ||
activeLiquidity | ||
liquidity | ||
fees { | ||
@@ -494,7 +500,7 @@ id | ||
where: { | ||
account: "0x0" | ||
owner: "0x0" | ||
} | ||
) { | ||
id | ||
account { | ||
owner { | ||
id | ||
@@ -510,6 +516,6 @@ } | ||
it('aliases fields', () => { | ||
const query = createQuery<Query>().liquidityPools.select((s) => [ | ||
s.activeLiquidity.as('liquidityActive'), | ||
s.deposits((s) => [s.blockNumber]).as('x'), | ||
s.positions((s) => [s.withdrawCount.as('totalWithdrawals')]).as('y'), | ||
const query = createQuery<Query>().pools.select((s) => [ | ||
s.liquidity.as('w'), | ||
s.mints((s) => [s.timestamp]).as('x'), | ||
s.burns((s) => [s.timestamp.as('z')]).as('y'), | ||
]); | ||
@@ -519,9 +525,9 @@ | ||
const expected = `{ | ||
liquidityPools { | ||
liquidityActive: activeLiquidity | ||
x: deposits { | ||
blockNumber | ||
pools { | ||
w: liquidity | ||
x: mints { | ||
timestamp | ||
} | ||
y: positions { | ||
totalWithdrawals: withdrawCount | ||
y: burns { | ||
z: timestamp | ||
} | ||
@@ -576,3 +582,3 @@ } | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools; | ||
const query = g.pools; | ||
@@ -584,3 +590,3 @@ expect(() => query.toString()).toThrow(); | ||
it('sends a query to the subgraph', async () => { | ||
const response = { data: { liquidityPools: [] } }; | ||
const response = { data: { pools: [] } }; | ||
const fetch = jest.fn().mockResolvedValue({ | ||
@@ -593,3 +599,3 @@ ok: true, | ||
const g = createQuery<Query>(); | ||
const query = g.liquidityPools.select((s) => [s.id]).first(1); | ||
const query = g.pools.select((s) => [s.id]).first(1); | ||
@@ -603,3 +609,3 @@ const result = await querySubgraph({ | ||
expect(fetch).toBeCalled(); | ||
expect(fetch.mock.calls[0][1].body).toContain('liquidityPools'); | ||
expect(fetch.mock.calls[0][1].body).toContain('pools'); | ||
expect(fetch.mock.calls[0][1].body).toContain('first: 1'); | ||
@@ -611,3 +617,3 @@ expect(fetch.mock.calls[0][1].body).toContain('id'); | ||
it('combines multiple queries into a single query request', async () => { | ||
const response = { data: { liquidityPools: [] } }; | ||
const response = { data: { pools: [] } }; | ||
const fetch = jest.fn().mockResolvedValue({ | ||
@@ -620,3 +626,3 @@ ok: true, | ||
const g = createQuery<Query>(); | ||
const q1 = g.liquidityPools.select((s) => [s.id]); | ||
const q1 = g.pools.select((s) => [s.id]); | ||
const q2 = g.positions.select((s) => [s.id]); | ||
@@ -628,3 +634,3 @@ const q3 = g.accounts.select((s) => [s.id]); | ||
const expected = `{ | ||
liquidityPools { | ||
pools { | ||
id | ||
@@ -647,4 +653,4 @@ } | ||
expect(ignoreWs(actual)).toBe(ignoreWs(expected)); | ||
expect(fetch.mock.calls[0][1].body).toContain('liquidityPools'); | ||
expect(fetch.mock.calls[0][1].body).toContain('pools'); | ||
expect(fetch.mock.calls[0][1].body).toContain('positions'); | ||
}); |
2772
89186
Updated@nftx/config@^2.1.0
Updated@nftx/constants@^2.1.0
Updated@nftx/utils@^2.1.0