Skip to content

Commit

Permalink
Merge pull request #21 from Cardinal-Cryptography/dont-check-mem
Browse files Browse the repository at this point in the history
Don't check pool existence for volume
  • Loading branch information
deuszx authored May 24, 2024
2 parents cb74e17 + 59aef4a commit 20fa2f3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/servers/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ export async function poolsSwapVolume(app: express.Express, pools: Pools) {
res.status(400).send("Invalid pool address");
return;
}
let pool = pools.pools.get(req.params.poolId);
if (pool === undefined) {
res.status(404).send("Pool not found");
return;
}
let poolId = req.params.poolId;
let fromQuery = req.query.from;
let toQuery = req.query.to;
if (fromQuery === undefined || toQuery === undefined) {
Expand All @@ -97,17 +93,17 @@ export async function poolsSwapVolume(app: express.Express, pools: Pools) {
res.status(400).send("from and to query parameters must be positive");
return;
}
const volume = await pools.poolSwapVolume(pool.id, fromMillis, toMillis);
const volume = await pools.poolSwapVolume(poolId, fromMillis, toMillis);
if (!volume) {
res.status(404).send("Pool not found");
return;
}
if (volume.pool !== pool.id) {
if (volume.pool !== poolId) {
res.status(404).send("Pool not found");
}

res.send({
pool: pool.id,
pool: poolId,
fromMillis: fromQuery,
toMillis: toQuery,
amount0_in: volume.amount0_in,
Expand Down

0 comments on commit 20fa2f3

Please sign in to comment.