Skip to content

Commit

Permalink
fix: chain first wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiteshAgrawal committed May 14, 2024
1 parent 19fb3c6 commit 296b064
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const generateLMSeasonEnum = (numSeasons: number) => {
*/
const pointsSource = [
"stratosphere_enrollment",
"chain_first_wallet",
"dex_aggregator_swap",
"dex_aggregator_first_swap",
"dex_aggregator_1k_swaps",
Expand Down
18 changes: 16 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
BIGINT_ONE,
BIGINT_ZERO,
deployedBlockTimestamps,
pointsMap,
} from "./config/constants";
import axios from "axios";

Expand Down Expand Up @@ -61,15 +62,28 @@ export const handleChainFirstWallet = async (
context: Context,
chainId: number,
userAddressLowerCase: string,
userData: any
userData: any,
event: any
): Promise<UserHistory> => {
const { AllProtocols, UserHistory } = context.db;
const { AllProtocols, UserHistory, Points } = context.db;
let allProtocols = await AllProtocols.findUnique({ id: "protocols" });
if (!allProtocols) {
allProtocols = await AllProtocols.create({
id: "protocols",
data: { firstWallet: userAddressLowerCase },
});
await Points.create({
id: `${userAddressLowerCase}-chain-first-wallet`,
data: {
userDataId: `${userAddressLowerCase}-${chainId}`,
userHistoryId: `${userAddressLowerCase}-${chainId}`,
pointsSource: "chain_first_wallet",
points: pointsMap.ChainFirstWallet,
chainId: chainId,
timestamp: event?.block?.timestamp,
},
});

return await UserHistory.update({
id: `${userAddressLowerCase}-${chainId}`,
data: { chainFirstWallet: true },
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ ponder.on("LiquidMining:Deposit", async ({ event, context }) => {
context,
chainId,
userAddressLowerCase,
userData
userData,
event
);
let liquidMiningData = await LiquidMining.findUnique({
id: seasonId,
Expand Down Expand Up @@ -254,7 +255,8 @@ ponder.on("VapeStaking:Deposit", async ({ event, context }) => {
context,
chainId,
userAddressLowerCase,
userData
userData,
event
);

let vapeStakingData = await VapeStaking.findUnique({
Expand Down Expand Up @@ -346,7 +348,8 @@ ponder.on("DexAggregator:RouterSwap", async ({ event, context }) => {
context,
chainId,
userAddressLowerCase,
userData
userData,
event
);
// @dev: We are trying maxSteps till 3, which includes all the common paths
// For reference: https://github.com/VaporFi/dex-aggregator-v2/blob/cad6410a4cc429df532720bfee209852dbd97be4/src/facets/LegacyRouterFacet.sol#L332
Expand Down

0 comments on commit 296b064

Please sign in to comment.