Skip to content

Commit

Permalink
fix: use migrate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Nov 30, 2023
1 parent b793dfa commit 910eb39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-server/package.staging.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-server-staging",
"version": "1.0.35",
"version": "1.0.36",
"main": "dist/index.js",
"bin": "dist/index.js",
"license": "MIT",
Expand Down
14 changes: 7 additions & 7 deletions packages/oraidex-sync/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class OraiDexSync {
console.time("timer-updateLatestPairInfos");
const pairInfos = await getAllPairInfos();
const allPools = await this.duckDb.getPools();
if (allPools.length > 0 && pairInfos.length === allPools.length) return;
if (allPools.length > 0 && pairInfos.length === allPools.length) return false;
await this.duckDb.insertPairInfos(
pairInfos.map((pair) => {
const symbols = getSymbolFromAsset(pair.asset_infos);
Expand All @@ -86,18 +86,18 @@ class OraiDexSync {
})
);
console.timeEnd("timer-updateLatestPairInfos");
return true;
} catch (error) {
console.log("error in updateLatestPairInfos: ", error);
}
}

private async updateLatestLpAmountHistory(currentHeight: number) {
private async updateLatestLpAmountHistory(currentHeight: number, isNewPool: boolean) {
try {
console.time("timer-updateLatestLpAmountHistory");
const countLpAmounts = await this.duckDb.getLpAmountHistory();
if (countLpAmounts > 0) return;
const pairInfos = await this.duckDb.getPools();

if (countLpAmounts > 0 && !isNewPool && !process.env.IS_MIGRATE_POOL) return;
const pairInfos = await this.duckDb.getPools(); // 13 pools
const poolInfos = await getPoolInfos(
pairInfos.map((pair) => pair.pairAddr),
currentHeight
Expand Down Expand Up @@ -181,10 +181,10 @@ class OraiDexSync {
}
console.log("current ind: ", currentInd);

await this.updateLatestPairInfos();
const isNewPool = await this.updateLatestPairInfos();

// update offer & ask, total share of pool history in the first time
await this.updateLatestLpAmountHistory(currentInd);
await this.updateLatestLpAmountHistory(currentInd, isNewPool);

// NOTE: need to updateLatestLpAmountHistory before update apr in the first time
// to get the offerAmount, askAmount from lp amount history table.
Expand Down

0 comments on commit 910eb39

Please sign in to comment.