Skip to content

Commit

Permalink
feat: add aggregatorv2 address and update pointsSource enum
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed May 14, 2024
1 parent 9c8ed8b commit 19fb3c6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
15 changes: 9 additions & 6 deletions ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ export default createConfig({
abi: DexAggregatorAbi,
network: {
avalanche: {
address: addresses.DexAggregator?.avalanche,
startBlock: 20308160,
address: [
addresses.DexAggregator?.avalanche!,
addresses.DexAggregatorV2?.avalanche!,
],
startBlock: 43508160,
maxBlockRange,
},
},
Expand All @@ -40,7 +43,7 @@ export default createConfig({
network: {
avalanche: {
address: addresses.Stratosphere?.avalanche,
startBlock: 20310567,
startBlock: 43508160,
maxBlockRange,
},
},
Expand All @@ -51,7 +54,7 @@ export default createConfig({
network: {
avalanche: {
address: addresses.LiquidMining?.avalanche,
startBlock: 32271032,
startBlock: 43508160,
maxBlockRange,
},
},
Expand All @@ -62,7 +65,7 @@ export default createConfig({
network: {
avalanche: {
address: addresses.VapeStaking?.avalanche,
startBlock: 33291048,
startBlock: 43508160,
maxBlockRange,
},
},
Expand All @@ -73,7 +76,7 @@ export default createConfig({
network: {
avalanche: {
address: addresses.RewardsController?.avalanche,
startBlock: 43805790, // TODO: Update this
startBlock: 43508160, // TODO: Update this
maxBlockRange,
},
},
Expand Down
1 change: 1 addition & 0 deletions ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const generateLMSeasonEnum = (numSeasons: number) => {
const pointsSource = [
"stratosphere_enrollment",
"dex_aggregator_swap",
"dex_aggregator_first_swap",
"dex_aggregator_1k_swaps",
"dex_aggregator_10k_swaps",
"dex_aggregator_100k_swaps",
Expand Down
3 changes: 3 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export const addresses: AddressMap = {
DexAggregator: {
[Chains.AVALANCHE]: "0xDef9ee39FD82ee57a1b789Bc877E2Cbd88fd5caE",
},
DexAggregatorV2: {
[Chains.AVALANCHE]: "0x55477d8537ede381784b448876AfAa98aa450E63",
},
LiquidMining: {
[Chains.AVALANCHE]: "0xAe950fdd0CC79DDE64d3Fffd40fabec3f7ba368B",
},
Expand Down
38 changes: 19 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,30 +364,30 @@ ponder.on("DexAggregator:RouterSwap", async ({ event, context }) => {
},
});

if (!userData.firstSwap) {
userData = await UserHistory.update({
id: `${userAddressLowerCase}-${chainId}`,
data: { firstSwap: true },
});

await Points.create({
id: `${hash}-dex-aggregator-first-swap`,
data: {
userDataId: `${userAddressLowerCase}-${chainId}`,
userHistoryId: `${userAddressLowerCase}-${chainId}`,
pointsSource: "dex_aggregator_first_swap",
points: pointsMap.FirstSwap,
chainId: chainId,
timestamp: timestamp,
},
});
}

await getOrUpdateTokenIdData(context, tokenId, timestamp, {
pointsEarned: usdValueOfTrade,
});
}

if (!userData.firstSwap) {
userData = await UserHistory.update({
id: `${userAddressLowerCase}-${chainId}`,
data: { firstSwap: true },
});

await Points.create({
id: `${hash}-dex-aggregator-first-swap`,
data: {
userDataId: `${userAddressLowerCase}-${chainId}`,
userHistoryId: `${userAddressLowerCase}-${chainId}`,
pointsSource: "dex_aggregator_first_swap",
points: pointsMap.FirstSwap,
chainId: chainId,
timestamp: timestamp,
},
});
}

// Update total swaps and total USD value of swaps
userData = await UserHistory.update({
id: `${userAddressLowerCase}-${chainId}`,
Expand Down

0 comments on commit 19fb3c6

Please sign in to comment.