@merkl/api 0.20.90 → 0.20.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/api/.generated/edge.js +2 -2
- package/dist/database/api/.generated/index.js +2 -2
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/schema.prisma +1 -1
- package/dist/src/eden/index.d.ts +12 -12
- package/dist/src/engine/campaignTVL/factory.d.ts +1 -1
- package/dist/src/engine/campaignTVL/factory.js +5 -1
- package/dist/src/engine/campaignTVL/implementations/Ajna.d.ts +7 -0
- package/dist/src/engine/campaignTVL/implementations/Ajna.js +91 -0
- package/dist/src/index.d.ts +4 -4
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
- package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +3 -3
- package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +1 -1
- package/dist/src/modules/v4/dynamicData/dynamicData.service.js +79 -73
- package/dist/src/modules/v4/router.d.ts +4 -4
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -673,8 +673,8 @@ const config = {
|
|
673
673
|
}
|
674
674
|
}
|
675
675
|
},
|
676
|
-
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n binaryTargets = [\"native\", \"linux-arm64-openssl-1.1.x\", \"linux-musl-arm64-openssl-3.0.x\"]\n output = \".generated/\"\n previewFeatures = [\"fullTextSearchPostgres\", \"relationJoins\"]\n}\n\ngenerator drizzle {\n provider = \"drizzle-prisma-generator\"\n output = \".generated/drizzle/\" // Where to put generated Drizle tables\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_API_URL\")\n}\n\nmodel Campaign {\n id String @id\n ComputeChain Chain @relation(\"compute\", fields: [computeChainId], references: [id])\n computeChainId Int\n DistributionChain Chain @relation(\"distribution\", fields: [distributionChainId], references: [id])\n distributionChainId Int\n campaignId String\n type String\n distributionType DistributionType @default(DUTCH_AUCTION)\n subType Int?\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n startTimestamp BigInt\n endTimestamp BigInt\n params Json\n RewardBreakdown RewardBreakdown[]\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n Creator User @relation(fields: [creatorAddress], references: [address])\n creatorAddress String @db.Char(42)\n // Should probably be a 1 to 1 relation if we do not want to keep historic records\n CampaignStatus CampaignStatus[]\n CampaignEngineValues CampaignComputedValue[]\n UserComputedValue UserComputedValue[]\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n manualOverrides CampaignManualOverride[] @default([])\n\n createdAt DateTime @default(now())\n\n @@unique([distributionChainId, campaignId])\n @@index([opportunityId], type: Hash)\n}\n\n// SubTable of Campaigns that should be here as soon as the campaign is processed\nmodel CampaignStatus {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n computedUntil BigInt\n processingStarted BigInt\n status RunStatus @default(SUCCESS)\n error String @default(\"\")\n details Json @default(\"{}\")\n}\n\n// SubTable of Campaigns that will contain values populated by the Engine when it's running\nmodel CampaignComputedValue {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n averageBoost Float? // Average boost in case of boosting hook\n totalDistributedInUSD Float? // Used in case there is a distribution cap\n forfeitingBoost Float? // In case some rewards are forfeited, resulting boost for remaining users\n}\n\nmodel UserComputedValue {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n address String @db.Char(42)\n User User? @relation(fields: [address], references: [address])\n reason String\n boost Float?\n\n @@unique([campaignId, address, reason])\n}\n\nmodel Chain {\n id Int @id\n name String\n icon String\n // liveCampaigns Int @default(0)\n // dailyRewards Float @default(0)\n Explorer Explorer[]\n Campaigns Campaign[] @relation(\"compute\")\n Distribution Campaign[] @relation(\"distribution\")\n Token Token[]\n Opportunity Opportunity[]\n MerklRoot MerklRoot[]\n Blacklist Blacklist[]\n Dump Dump[]\n}\n\nmodel Explorer {\n id String @id\n type ExplorerType\n Chain Chain @relation(fields: [chainId], references: [id])\n url String\n chainId Int\n\n @@unique([type, chainId])\n}\n\nmodel Opportunity {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id]) // compute\n chainId Int // compute\n type String\n identifier String // eg. 0xUniswapPool - formerly mainParameter\n name String // Override\n depositUrl String? // Override\n explorerAddress String? // Override\n status Status\n action OpportunityAction // Override\n Tokens Token[]\n Campaigns Campaign[]\n Protocols Protocol[]\n MainProtocol Protocol? @relation(name: \"main\", fields: [mainProtocolId], references: [id])\n mainProtocolId String?\n tvl Float @default(0)\n TvlRecords TVLRecord[]\n apr Float @default(0)\n AprRecords AprRecord[]\n dailyRewards Float @default(0)\n DailyRewardsRecords DailyRewardsRecord[]\n tags String[] @default([])\n lastCampaignCreatedAt DateTime @default(now())\n manualOverrides OpportunityManualOverride[] @default([])\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n // manualOverrides OpportunityManualOverride[] @default([])\n\n @@unique([chainId, type, identifier])\n}\n\nmodel Protocol {\n id String @id\n tags String[] @default([])\n name String\n description String @default(\"\")\n url String\n icon String\n // liveCampaigns Int @default(0)\n // totalDailyRewards Float @default(0)\n MainOpportunities Opportunity[] @relation(name: \"main\")\n Opportunities Opportunity[]\n RewardBreakdown RewardBreakdown[]\n}\n\nmodel Token {\n id String @id()\n name String?\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n address String @db.Char(42)\n decimals Int\n symbol String\n displaySymbol String @default(\"\")\n icon String\n verified Boolean @default(false)\n isTest Boolean @default(false)\n isPoint Boolean @default(false)\n isNative Boolean @default(false)\n price Float?\n Opportunity Opportunity[]\n Campaigns Campaign[]\n Reward Reward[]\n DumpTo Dump[] @relation(\"to\")\n DumpFrom Dump[] @relation(\"from\")\n\n @@unique([chainId, address])\n @@index([chainId], type: Hash)\n @@index([symbol, address])\n}\n\nmodel AprRecord {\n id String @id\n timestamp BigInt\n cumulated Float\n AprBreakdown AprBreakdown[]\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel AprBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type AprType\n value Float\n AprRecord AprRecord @relation(fields: [aprRecordId], references: [id])\n aprRecordId String\n\n @@index([aprRecordId], type: Hash)\n}\n\nmodel TVLRecord {\n id String @id\n timestamp BigInt\n total Float\n TvlBreakdown TVLBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel TVLBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type TvlType\n value Float\n\n TvlRecord TVLRecord @relation(fields: [tvlRecordId], references: [id])\n tvlRecordId String\n\n @@index([tvlRecordId], type: Hash)\n}\n\nmodel DailyRewardsRecord {\n id String @id\n timestamp BigInt\n total Float\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel DailyRewardsBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n value Float\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n DailyRewardsRecord DailyRewardsRecord @relation(fields: [dailyRewardsRecordId], references: [id])\n dailyRewardsRecordId String\n\n @@index([dailyRewardsRecordId], type: Hash)\n}\n\nmodel User {\n address String @id @db.Char(42)\n Rewards Reward[]\n Blacklist Blacklist[]\n CampaignsCreated Campaign[]\n UserComputedValue UserComputedValue[]\n tags String[]\n\n Creator Creator? @relation(fields: [creatorId], references: [id])\n creatorId String?\n}\n\nmodel Creator {\n id String @id\n icon String?\n name String\n Users User[]\n}\n\nmodel Reward {\n id String @id\n MerklRoot MerklRoot @relation(fields: [root], references: [root])\n root String\n User User @relation(fields: [recipient], references: [address])\n recipient String @db.Char(42)\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String @default(\"0\")\n claimed String @default(\"0\")\n pending String @default(\"0\")\n proofs String[]\n Breakdown RewardBreakdown[]\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([root, recipient, rewardTokenId])\n @@index([root], type: Hash)\n @@index([recipient, rewardTokenId])\n}\n\nmodel RewardBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n Protocol Protocol? @relation(fields: [protocolId], references: [id])\n protocolId String?\n reason String\n amount String\n claimed String\n pending String\n Reward Reward @relation(fields: [rewardId], references: [id], onDelete: Cascade)\n rewardId String\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([rewardId, campaignId, reason])\n @@index([rewardId], type: Hash)\n @@index([campaignId], type: Hash)\n}\n\nmodel MerklRoot {\n root String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n epoch Int\n timestamp BigInt\n Rewards Reward[]\n\n @@index([chainId, root])\n}\n\nmodel PriceSource {\n id Int @id @default(autoincrement()) // This should hold in Int ids\n symbol String @unique() // Price Id\n method PriceSourceMethod\n args Json?\n}\n\n// priceId -> number\n\nmodel Blacklist {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n poolAddress String @db.Char(42)\n User User @relation(fields: [userAddress], references: [address])\n userAddress String @db.Char(42)\n arrestTimestamp BigInt\n arrestDetails Json\n\n @@unique([chainId, userAddress, poolAddress])\n @@index([userAddress], type: Hash)\n}\n\nmodel Dump {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n FromToken Token @relation(name: \"from\", fields: [fromTokenId], references: [id])\n fromTokenId String\n ToToken Token @relation(name: \"to\", fields: [toTokenId], references: [id])\n toTokenId String\n multisig String @db.Char(42)\n recipient String @db.Char(42)\n amountIn String @default(\"0\")\n amountOut String @default(\"0\")\n datetime DateTime\n timestamp Int\n\n @@unique([chainId, fromTokenId, toTokenId, timestamp])\n}\n\nmodel Logged {\n id String @id\n chainId Int\n type LoggedEntityType @default(UNKNOWN)\n address String? @db.Char(42)\n fetchAtBlock Int\n caughtFromAddress String @db.Char(42)\n entityData Json\n\n @@unique([chainId, address])\n}\n\n// enums\n\nenum LoggedEntityType {\n UNKNOWN\n EULER_VAULT\n UNISWAP_V4\n COMPOUND_v2\n}\n\nenum RunStatus {\n PROCESSING\n SUCCESS\n FAILED\n SKIPPED\n}\n\nenum OpportunityAction {\n POOL\n HOLD\n DROP\n LEND\n BORROW\n LONG\n SHORT\n SWAP\n INVALID\n}\n\nenum Status {\n NONE // This would mean that no campaigns was ever created for this opportunity\n PAST\n LIVE\n SOON\n}\n\nenum ExplorerType {\n ETHERSCAN\n BLOCKSCOUT\n}\n\nenum AprType {\n CAMPAIGN\n TOKEN\n PROTOCOL\n}\n\nenum TvlType {\n TOKEN\n PROTOCOL\n}\n\nenum PriceSourceMethod {\n COINGECKO\n CONSTANT\n EQUAL_TO\n ERC4626\n DEXSCREENER\n INDEXCOOP\n DEFILLAMA\n}\n\nenum CampaignManualOverride {\n opportunityId\n creatorAddress\n}\n\nenum OpportunityManualOverride {\n name\n depositUrl\n explorerAddress\n action\n}\n\nenum DistributionType {\n DUTCH_AUCTION\n FIX_REWARD_VALUE_PER_LIQUIDITY_VALUE // The fix reward value will lie in params.apr\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_VALUE\n FIX_REWARD_VALUE_PER_LIQUIDITY_AMOUNT\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_AMOUNT\n}\n",
|
677
|
-
"inlineSchemaHash": "
|
676
|
+
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n binaryTargets = [\"native\", \"linux-arm64-openssl-1.1.x\", \"linux-musl-arm64-openssl-3.0.x\"]\n output = \".generated/\"\n previewFeatures = [\"fullTextSearchPostgres\", \"relationJoins\"]\n}\n\ngenerator drizzle {\n provider = \"drizzle-prisma-generator\"\n output = \".generated/drizzle/\" // Where to put generated Drizle tables\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_API_URL\")\n}\n\nmodel Campaign {\n id String @id\n ComputeChain Chain @relation(\"compute\", fields: [computeChainId], references: [id])\n computeChainId Int\n DistributionChain Chain @relation(\"distribution\", fields: [distributionChainId], references: [id])\n distributionChainId Int\n campaignId String\n type String\n distributionType DistributionType @default(DUTCH_AUCTION)\n subType Int?\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n startTimestamp BigInt\n endTimestamp BigInt\n params Json\n RewardBreakdown RewardBreakdown[]\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n Creator User @relation(fields: [creatorAddress], references: [address])\n creatorAddress String @db.Char(42)\n // Should probably be a 1 to 1 relation if we do not want to keep historic records\n CampaignStatus CampaignStatus[]\n CampaignEngineValues CampaignComputedValue[]\n UserComputedValue UserComputedValue[]\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n manualOverrides CampaignManualOverride[] @default([])\n\n createdAt DateTime @default(now())\n\n @@unique([distributionChainId, campaignId])\n @@index([opportunityId], type: Hash)\n}\n\n// SubTable of Campaigns that should be here as soon as the campaign is processed\nmodel CampaignStatus {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n computedUntil BigInt\n processingStarted BigInt\n status RunStatus @default(SUCCESS)\n error String @default(\"\")\n details Json @default(\"{}\")\n}\n\n// SubTable of Campaigns that will contain values populated by the Engine when it's running\nmodel CampaignComputedValue {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n averageBoost Float? // Average boost in case of boosting hook\n totalDistributedInUSD Float? // Used in case there is a distribution cap\n forfeitingBoost Float? // In case some rewards are forfeited, resulting boost for remaining users\n}\n\nmodel UserComputedValue {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n address String @db.Char(42)\n User User? @relation(fields: [address], references: [address])\n reason String\n boost Float?\n\n @@unique([campaignId, address, reason])\n}\n\nmodel Chain {\n id Int @id\n name String\n icon String\n // liveCampaigns Int @default(0)\n // dailyRewards Float @default(0)\n Explorer Explorer[]\n Campaigns Campaign[] @relation(\"compute\")\n Distribution Campaign[] @relation(\"distribution\")\n Token Token[]\n Opportunity Opportunity[]\n MerklRoot MerklRoot[]\n Blacklist Blacklist[]\n Dump Dump[]\n}\n\nmodel Explorer {\n id String @id\n type ExplorerType\n Chain Chain @relation(fields: [chainId], references: [id])\n url String\n chainId Int\n\n @@unique([type, chainId])\n}\n\nmodel Opportunity {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id]) // compute\n chainId Int // compute\n type String\n identifier String // eg. 0xUniswapPool - formerly mainParameter\n name String // Override\n depositUrl String? // Override\n explorerAddress String? // Override\n status Status\n action OpportunityAction // Override\n Tokens Token[]\n Campaigns Campaign[]\n Protocols Protocol[]\n MainProtocol Protocol? @relation(name: \"main\", fields: [mainProtocolId], references: [id])\n mainProtocolId String?\n tvl Float @default(0)\n TvlRecords TVLRecord[]\n apr Float @default(0)\n AprRecords AprRecord[]\n dailyRewards Float @default(0)\n DailyRewardsRecords DailyRewardsRecord[]\n tags String[] @default([])\n lastCampaignCreatedAt DateTime @default(now())\n manualOverrides OpportunityManualOverride[] @default([])\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n // manualOverrides OpportunityManualOverride[] @default([])\n\n @@unique([chainId, type, identifier])\n}\n\nmodel Protocol {\n id String @id\n tags String[] @default([])\n name String\n description String @default(\"\")\n url String\n icon String\n // liveCampaigns Int @default(0)\n // totalDailyRewards Float @default(0)\n MainOpportunities Opportunity[] @relation(name: \"main\")\n Opportunities Opportunity[]\n RewardBreakdown RewardBreakdown[]\n}\n\nmodel Token {\n id String @id()\n name String?\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n address String @db.Char(42)\n decimals Int\n symbol String\n displaySymbol String @default(\"\")\n icon String\n verified Boolean @default(false)\n isTest Boolean @default(false)\n isPoint Boolean @default(false)\n isNative Boolean @default(false)\n price Float?\n Opportunity Opportunity[]\n Campaigns Campaign[]\n Reward Reward[]\n DumpTo Dump[] @relation(\"to\")\n DumpFrom Dump[] @relation(\"from\")\n\n @@unique([chainId, address])\n @@index([chainId], type: Hash)\n @@index([symbol, address])\n}\n\nmodel AprRecord {\n id String @id\n timestamp BigInt\n cumulated Float\n AprBreakdown AprBreakdown[]\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel AprBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type AprType\n value Float\n AprRecord AprRecord @relation(fields: [aprRecordId], references: [id])\n aprRecordId String\n\n @@index([aprRecordId], type: Hash)\n}\n\nmodel TVLRecord {\n id String @id\n timestamp BigInt\n total Float\n TvlBreakdown TVLBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel TVLBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type TvlType\n value Float // In case type is TOKEN, this is the raw amount of tokens\n\n TvlRecord TVLRecord @relation(fields: [tvlRecordId], references: [id])\n tvlRecordId String\n\n @@index([tvlRecordId], type: Hash)\n}\n\nmodel DailyRewardsRecord {\n id String @id\n timestamp BigInt\n total Float\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel DailyRewardsBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n value Float\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n DailyRewardsRecord DailyRewardsRecord @relation(fields: [dailyRewardsRecordId], references: [id])\n dailyRewardsRecordId String\n\n @@index([dailyRewardsRecordId], type: Hash)\n}\n\nmodel User {\n address String @id @db.Char(42)\n Rewards Reward[]\n Blacklist Blacklist[]\n CampaignsCreated Campaign[]\n UserComputedValue UserComputedValue[]\n tags String[]\n\n Creator Creator? @relation(fields: [creatorId], references: [id])\n creatorId String?\n}\n\nmodel Creator {\n id String @id\n icon String?\n name String\n Users User[]\n}\n\nmodel Reward {\n id String @id\n MerklRoot MerklRoot @relation(fields: [root], references: [root])\n root String\n User User @relation(fields: [recipient], references: [address])\n recipient String @db.Char(42)\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String @default(\"0\")\n claimed String @default(\"0\")\n pending String @default(\"0\")\n proofs String[]\n Breakdown RewardBreakdown[]\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([root, recipient, rewardTokenId])\n @@index([root], type: Hash)\n @@index([recipient, rewardTokenId])\n}\n\nmodel RewardBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n Protocol Protocol? @relation(fields: [protocolId], references: [id])\n protocolId String?\n reason String\n amount String\n claimed String\n pending String\n Reward Reward @relation(fields: [rewardId], references: [id], onDelete: Cascade)\n rewardId String\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([rewardId, campaignId, reason])\n @@index([rewardId], type: Hash)\n @@index([campaignId], type: Hash)\n}\n\nmodel MerklRoot {\n root String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n epoch Int\n timestamp BigInt\n Rewards Reward[]\n\n @@index([chainId, root])\n}\n\nmodel PriceSource {\n id Int @id @default(autoincrement()) // This should hold in Int ids\n symbol String @unique() // Price Id\n method PriceSourceMethod\n args Json?\n}\n\n// priceId -> number\n\nmodel Blacklist {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n poolAddress String @db.Char(42)\n User User @relation(fields: [userAddress], references: [address])\n userAddress String @db.Char(42)\n arrestTimestamp BigInt\n arrestDetails Json\n\n @@unique([chainId, userAddress, poolAddress])\n @@index([userAddress], type: Hash)\n}\n\nmodel Dump {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n FromToken Token @relation(name: \"from\", fields: [fromTokenId], references: [id])\n fromTokenId String\n ToToken Token @relation(name: \"to\", fields: [toTokenId], references: [id])\n toTokenId String\n multisig String @db.Char(42)\n recipient String @db.Char(42)\n amountIn String @default(\"0\")\n amountOut String @default(\"0\")\n datetime DateTime\n timestamp Int\n\n @@unique([chainId, fromTokenId, toTokenId, timestamp])\n}\n\nmodel Logged {\n id String @id\n chainId Int\n type LoggedEntityType @default(UNKNOWN)\n address String? @db.Char(42)\n fetchAtBlock Int\n caughtFromAddress String @db.Char(42)\n entityData Json\n\n @@unique([chainId, address])\n}\n\n// enums\n\nenum LoggedEntityType {\n UNKNOWN\n EULER_VAULT\n UNISWAP_V4\n COMPOUND_v2\n}\n\nenum RunStatus {\n PROCESSING\n SUCCESS\n FAILED\n SKIPPED\n}\n\nenum OpportunityAction {\n POOL\n HOLD\n DROP\n LEND\n BORROW\n LONG\n SHORT\n SWAP\n INVALID\n}\n\nenum Status {\n NONE // This would mean that no campaigns was ever created for this opportunity\n PAST\n LIVE\n SOON\n}\n\nenum ExplorerType {\n ETHERSCAN\n BLOCKSCOUT\n}\n\nenum AprType {\n CAMPAIGN\n TOKEN\n PROTOCOL\n}\n\nenum TvlType {\n TOKEN\n PROTOCOL\n}\n\nenum PriceSourceMethod {\n COINGECKO\n CONSTANT\n EQUAL_TO\n ERC4626\n DEXSCREENER\n INDEXCOOP\n DEFILLAMA\n}\n\nenum CampaignManualOverride {\n opportunityId\n creatorAddress\n}\n\nenum OpportunityManualOverride {\n name\n depositUrl\n explorerAddress\n action\n}\n\nenum DistributionType {\n DUTCH_AUCTION\n FIX_REWARD_VALUE_PER_LIQUIDITY_VALUE // The fix reward value will lie in params.apr\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_VALUE\n FIX_REWARD_VALUE_PER_LIQUIDITY_AMOUNT\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_AMOUNT\n}\n",
|
677
|
+
"inlineSchemaHash": "8d0a6358875760b281772470a9cfc8328ffb279d4cc301c423f71ea0ff3a996a",
|
678
678
|
"copyEngine": true
|
679
679
|
}
|
680
680
|
config.dirname = '/'
|
@@ -674,8 +674,8 @@ const config = {
|
|
674
674
|
}
|
675
675
|
}
|
676
676
|
},
|
677
|
-
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n binaryTargets = [\"native\", \"linux-arm64-openssl-1.1.x\", \"linux-musl-arm64-openssl-3.0.x\"]\n output = \".generated/\"\n previewFeatures = [\"fullTextSearchPostgres\", \"relationJoins\"]\n}\n\ngenerator drizzle {\n provider = \"drizzle-prisma-generator\"\n output = \".generated/drizzle/\" // Where to put generated Drizle tables\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_API_URL\")\n}\n\nmodel Campaign {\n id String @id\n ComputeChain Chain @relation(\"compute\", fields: [computeChainId], references: [id])\n computeChainId Int\n DistributionChain Chain @relation(\"distribution\", fields: [distributionChainId], references: [id])\n distributionChainId Int\n campaignId String\n type String\n distributionType DistributionType @default(DUTCH_AUCTION)\n subType Int?\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n startTimestamp BigInt\n endTimestamp BigInt\n params Json\n RewardBreakdown RewardBreakdown[]\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n Creator User @relation(fields: [creatorAddress], references: [address])\n creatorAddress String @db.Char(42)\n // Should probably be a 1 to 1 relation if we do not want to keep historic records\n CampaignStatus CampaignStatus[]\n CampaignEngineValues CampaignComputedValue[]\n UserComputedValue UserComputedValue[]\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n manualOverrides CampaignManualOverride[] @default([])\n\n createdAt DateTime @default(now())\n\n @@unique([distributionChainId, campaignId])\n @@index([opportunityId], type: Hash)\n}\n\n// SubTable of Campaigns that should be here as soon as the campaign is processed\nmodel CampaignStatus {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n computedUntil BigInt\n processingStarted BigInt\n status RunStatus @default(SUCCESS)\n error String @default(\"\")\n details Json @default(\"{}\")\n}\n\n// SubTable of Campaigns that will contain values populated by the Engine when it's running\nmodel CampaignComputedValue {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n averageBoost Float? // Average boost in case of boosting hook\n totalDistributedInUSD Float? // Used in case there is a distribution cap\n forfeitingBoost Float? // In case some rewards are forfeited, resulting boost for remaining users\n}\n\nmodel UserComputedValue {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n address String @db.Char(42)\n User User? @relation(fields: [address], references: [address])\n reason String\n boost Float?\n\n @@unique([campaignId, address, reason])\n}\n\nmodel Chain {\n id Int @id\n name String\n icon String\n // liveCampaigns Int @default(0)\n // dailyRewards Float @default(0)\n Explorer Explorer[]\n Campaigns Campaign[] @relation(\"compute\")\n Distribution Campaign[] @relation(\"distribution\")\n Token Token[]\n Opportunity Opportunity[]\n MerklRoot MerklRoot[]\n Blacklist Blacklist[]\n Dump Dump[]\n}\n\nmodel Explorer {\n id String @id\n type ExplorerType\n Chain Chain @relation(fields: [chainId], references: [id])\n url String\n chainId Int\n\n @@unique([type, chainId])\n}\n\nmodel Opportunity {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id]) // compute\n chainId Int // compute\n type String\n identifier String // eg. 0xUniswapPool - formerly mainParameter\n name String // Override\n depositUrl String? // Override\n explorerAddress String? // Override\n status Status\n action OpportunityAction // Override\n Tokens Token[]\n Campaigns Campaign[]\n Protocols Protocol[]\n MainProtocol Protocol? @relation(name: \"main\", fields: [mainProtocolId], references: [id])\n mainProtocolId String?\n tvl Float @default(0)\n TvlRecords TVLRecord[]\n apr Float @default(0)\n AprRecords AprRecord[]\n dailyRewards Float @default(0)\n DailyRewardsRecords DailyRewardsRecord[]\n tags String[] @default([])\n lastCampaignCreatedAt DateTime @default(now())\n manualOverrides OpportunityManualOverride[] @default([])\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n // manualOverrides OpportunityManualOverride[] @default([])\n\n @@unique([chainId, type, identifier])\n}\n\nmodel Protocol {\n id String @id\n tags String[] @default([])\n name String\n description String @default(\"\")\n url String\n icon String\n // liveCampaigns Int @default(0)\n // totalDailyRewards Float @default(0)\n MainOpportunities Opportunity[] @relation(name: \"main\")\n Opportunities Opportunity[]\n RewardBreakdown RewardBreakdown[]\n}\n\nmodel Token {\n id String @id()\n name String?\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n address String @db.Char(42)\n decimals Int\n symbol String\n displaySymbol String @default(\"\")\n icon String\n verified Boolean @default(false)\n isTest Boolean @default(false)\n isPoint Boolean @default(false)\n isNative Boolean @default(false)\n price Float?\n Opportunity Opportunity[]\n Campaigns Campaign[]\n Reward Reward[]\n DumpTo Dump[] @relation(\"to\")\n DumpFrom Dump[] @relation(\"from\")\n\n @@unique([chainId, address])\n @@index([chainId], type: Hash)\n @@index([symbol, address])\n}\n\nmodel AprRecord {\n id String @id\n timestamp BigInt\n cumulated Float\n AprBreakdown AprBreakdown[]\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel AprBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type AprType\n value Float\n AprRecord AprRecord @relation(fields: [aprRecordId], references: [id])\n aprRecordId String\n\n @@index([aprRecordId], type: Hash)\n}\n\nmodel TVLRecord {\n id String @id\n timestamp BigInt\n total Float\n TvlBreakdown TVLBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel TVLBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type TvlType\n value Float\n\n TvlRecord TVLRecord @relation(fields: [tvlRecordId], references: [id])\n tvlRecordId String\n\n @@index([tvlRecordId], type: Hash)\n}\n\nmodel DailyRewardsRecord {\n id String @id\n timestamp BigInt\n total Float\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel DailyRewardsBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n value Float\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n DailyRewardsRecord DailyRewardsRecord @relation(fields: [dailyRewardsRecordId], references: [id])\n dailyRewardsRecordId String\n\n @@index([dailyRewardsRecordId], type: Hash)\n}\n\nmodel User {\n address String @id @db.Char(42)\n Rewards Reward[]\n Blacklist Blacklist[]\n CampaignsCreated Campaign[]\n UserComputedValue UserComputedValue[]\n tags String[]\n\n Creator Creator? @relation(fields: [creatorId], references: [id])\n creatorId String?\n}\n\nmodel Creator {\n id String @id\n icon String?\n name String\n Users User[]\n}\n\nmodel Reward {\n id String @id\n MerklRoot MerklRoot @relation(fields: [root], references: [root])\n root String\n User User @relation(fields: [recipient], references: [address])\n recipient String @db.Char(42)\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String @default(\"0\")\n claimed String @default(\"0\")\n pending String @default(\"0\")\n proofs String[]\n Breakdown RewardBreakdown[]\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([root, recipient, rewardTokenId])\n @@index([root], type: Hash)\n @@index([recipient, rewardTokenId])\n}\n\nmodel RewardBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n Protocol Protocol? @relation(fields: [protocolId], references: [id])\n protocolId String?\n reason String\n amount String\n claimed String\n pending String\n Reward Reward @relation(fields: [rewardId], references: [id], onDelete: Cascade)\n rewardId String\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([rewardId, campaignId, reason])\n @@index([rewardId], type: Hash)\n @@index([campaignId], type: Hash)\n}\n\nmodel MerklRoot {\n root String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n epoch Int\n timestamp BigInt\n Rewards Reward[]\n\n @@index([chainId, root])\n}\n\nmodel PriceSource {\n id Int @id @default(autoincrement()) // This should hold in Int ids\n symbol String @unique() // Price Id\n method PriceSourceMethod\n args Json?\n}\n\n// priceId -> number\n\nmodel Blacklist {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n poolAddress String @db.Char(42)\n User User @relation(fields: [userAddress], references: [address])\n userAddress String @db.Char(42)\n arrestTimestamp BigInt\n arrestDetails Json\n\n @@unique([chainId, userAddress, poolAddress])\n @@index([userAddress], type: Hash)\n}\n\nmodel Dump {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n FromToken Token @relation(name: \"from\", fields: [fromTokenId], references: [id])\n fromTokenId String\n ToToken Token @relation(name: \"to\", fields: [toTokenId], references: [id])\n toTokenId String\n multisig String @db.Char(42)\n recipient String @db.Char(42)\n amountIn String @default(\"0\")\n amountOut String @default(\"0\")\n datetime DateTime\n timestamp Int\n\n @@unique([chainId, fromTokenId, toTokenId, timestamp])\n}\n\nmodel Logged {\n id String @id\n chainId Int\n type LoggedEntityType @default(UNKNOWN)\n address String? @db.Char(42)\n fetchAtBlock Int\n caughtFromAddress String @db.Char(42)\n entityData Json\n\n @@unique([chainId, address])\n}\n\n// enums\n\nenum LoggedEntityType {\n UNKNOWN\n EULER_VAULT\n UNISWAP_V4\n COMPOUND_v2\n}\n\nenum RunStatus {\n PROCESSING\n SUCCESS\n FAILED\n SKIPPED\n}\n\nenum OpportunityAction {\n POOL\n HOLD\n DROP\n LEND\n BORROW\n LONG\n SHORT\n SWAP\n INVALID\n}\n\nenum Status {\n NONE // This would mean that no campaigns was ever created for this opportunity\n PAST\n LIVE\n SOON\n}\n\nenum ExplorerType {\n ETHERSCAN\n BLOCKSCOUT\n}\n\nenum AprType {\n CAMPAIGN\n TOKEN\n PROTOCOL\n}\n\nenum TvlType {\n TOKEN\n PROTOCOL\n}\n\nenum PriceSourceMethod {\n COINGECKO\n CONSTANT\n EQUAL_TO\n ERC4626\n DEXSCREENER\n INDEXCOOP\n DEFILLAMA\n}\n\nenum CampaignManualOverride {\n opportunityId\n creatorAddress\n}\n\nenum OpportunityManualOverride {\n name\n depositUrl\n explorerAddress\n action\n}\n\nenum DistributionType {\n DUTCH_AUCTION\n FIX_REWARD_VALUE_PER_LIQUIDITY_VALUE // The fix reward value will lie in params.apr\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_VALUE\n FIX_REWARD_VALUE_PER_LIQUIDITY_AMOUNT\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_AMOUNT\n}\n",
|
678
|
-
"inlineSchemaHash": "
|
677
|
+
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n binaryTargets = [\"native\", \"linux-arm64-openssl-1.1.x\", \"linux-musl-arm64-openssl-3.0.x\"]\n output = \".generated/\"\n previewFeatures = [\"fullTextSearchPostgres\", \"relationJoins\"]\n}\n\ngenerator drizzle {\n provider = \"drizzle-prisma-generator\"\n output = \".generated/drizzle/\" // Where to put generated Drizle tables\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_API_URL\")\n}\n\nmodel Campaign {\n id String @id\n ComputeChain Chain @relation(\"compute\", fields: [computeChainId], references: [id])\n computeChainId Int\n DistributionChain Chain @relation(\"distribution\", fields: [distributionChainId], references: [id])\n distributionChainId Int\n campaignId String\n type String\n distributionType DistributionType @default(DUTCH_AUCTION)\n subType Int?\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n startTimestamp BigInt\n endTimestamp BigInt\n params Json\n RewardBreakdown RewardBreakdown[]\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n Creator User @relation(fields: [creatorAddress], references: [address])\n creatorAddress String @db.Char(42)\n // Should probably be a 1 to 1 relation if we do not want to keep historic records\n CampaignStatus CampaignStatus[]\n CampaignEngineValues CampaignComputedValue[]\n UserComputedValue UserComputedValue[]\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n manualOverrides CampaignManualOverride[] @default([])\n\n createdAt DateTime @default(now())\n\n @@unique([distributionChainId, campaignId])\n @@index([opportunityId], type: Hash)\n}\n\n// SubTable of Campaigns that should be here as soon as the campaign is processed\nmodel CampaignStatus {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n computedUntil BigInt\n processingStarted BigInt\n status RunStatus @default(SUCCESS)\n error String @default(\"\")\n details Json @default(\"{}\")\n}\n\n// SubTable of Campaigns that will contain values populated by the Engine when it's running\nmodel CampaignComputedValue {\n campaignId String @id\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n averageBoost Float? // Average boost in case of boosting hook\n totalDistributedInUSD Float? // Used in case there is a distribution cap\n forfeitingBoost Float? // In case some rewards are forfeited, resulting boost for remaining users\n}\n\nmodel UserComputedValue {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n address String @db.Char(42)\n User User? @relation(fields: [address], references: [address])\n reason String\n boost Float?\n\n @@unique([campaignId, address, reason])\n}\n\nmodel Chain {\n id Int @id\n name String\n icon String\n // liveCampaigns Int @default(0)\n // dailyRewards Float @default(0)\n Explorer Explorer[]\n Campaigns Campaign[] @relation(\"compute\")\n Distribution Campaign[] @relation(\"distribution\")\n Token Token[]\n Opportunity Opportunity[]\n MerklRoot MerklRoot[]\n Blacklist Blacklist[]\n Dump Dump[]\n}\n\nmodel Explorer {\n id String @id\n type ExplorerType\n Chain Chain @relation(fields: [chainId], references: [id])\n url String\n chainId Int\n\n @@unique([type, chainId])\n}\n\nmodel Opportunity {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id]) // compute\n chainId Int // compute\n type String\n identifier String // eg. 0xUniswapPool - formerly mainParameter\n name String // Override\n depositUrl String? // Override\n explorerAddress String? // Override\n status Status\n action OpportunityAction // Override\n Tokens Token[]\n Campaigns Campaign[]\n Protocols Protocol[]\n MainProtocol Protocol? @relation(name: \"main\", fields: [mainProtocolId], references: [id])\n mainProtocolId String?\n tvl Float @default(0)\n TvlRecords TVLRecord[]\n apr Float @default(0)\n AprRecords AprRecord[]\n dailyRewards Float @default(0)\n DailyRewardsRecords DailyRewardsRecord[]\n tags String[] @default([])\n lastCampaignCreatedAt DateTime @default(now())\n manualOverrides OpportunityManualOverride[] @default([])\n\n // Fields should be automatically parsable and overriden periodically UNLESS\n // they are manually overridden, in which case they should be kept as is\n // manualOverrides OpportunityManualOverride[] @default([])\n\n @@unique([chainId, type, identifier])\n}\n\nmodel Protocol {\n id String @id\n tags String[] @default([])\n name String\n description String @default(\"\")\n url String\n icon String\n // liveCampaigns Int @default(0)\n // totalDailyRewards Float @default(0)\n MainOpportunities Opportunity[] @relation(name: \"main\")\n Opportunities Opportunity[]\n RewardBreakdown RewardBreakdown[]\n}\n\nmodel Token {\n id String @id()\n name String?\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n address String @db.Char(42)\n decimals Int\n symbol String\n displaySymbol String @default(\"\")\n icon String\n verified Boolean @default(false)\n isTest Boolean @default(false)\n isPoint Boolean @default(false)\n isNative Boolean @default(false)\n price Float?\n Opportunity Opportunity[]\n Campaigns Campaign[]\n Reward Reward[]\n DumpTo Dump[] @relation(\"to\")\n DumpFrom Dump[] @relation(\"from\")\n\n @@unique([chainId, address])\n @@index([chainId], type: Hash)\n @@index([symbol, address])\n}\n\nmodel AprRecord {\n id String @id\n timestamp BigInt\n cumulated Float\n AprBreakdown AprBreakdown[]\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel AprBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type AprType\n value Float\n AprRecord AprRecord @relation(fields: [aprRecordId], references: [id])\n aprRecordId String\n\n @@index([aprRecordId], type: Hash)\n}\n\nmodel TVLRecord {\n id String @id\n timestamp BigInt\n total Float\n TvlBreakdown TVLBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel TVLBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n identifier String\n type TvlType\n value Float // In case type is TOKEN, this is the raw amount of tokens\n\n TvlRecord TVLRecord @relation(fields: [tvlRecordId], references: [id])\n tvlRecordId String\n\n @@index([tvlRecordId], type: Hash)\n}\n\nmodel DailyRewardsRecord {\n id String @id\n timestamp BigInt\n total Float\n DailyRewardsBreakdown DailyRewardsBreakdown[]\n\n Opportunity Opportunity @relation(fields: [opportunityId], references: [id])\n opportunityId String\n\n @@unique([opportunityId, timestamp])\n @@index([opportunityId, timestamp(sort: Desc)])\n}\n\nmodel DailyRewardsBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n value Float\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n DailyRewardsRecord DailyRewardsRecord @relation(fields: [dailyRewardsRecordId], references: [id])\n dailyRewardsRecordId String\n\n @@index([dailyRewardsRecordId], type: Hash)\n}\n\nmodel User {\n address String @id @db.Char(42)\n Rewards Reward[]\n Blacklist Blacklist[]\n CampaignsCreated Campaign[]\n UserComputedValue UserComputedValue[]\n tags String[]\n\n Creator Creator? @relation(fields: [creatorId], references: [id])\n creatorId String?\n}\n\nmodel Creator {\n id String @id\n icon String?\n name String\n Users User[]\n}\n\nmodel Reward {\n id String @id\n MerklRoot MerklRoot @relation(fields: [root], references: [root])\n root String\n User User @relation(fields: [recipient], references: [address])\n recipient String @db.Char(42)\n RewardToken Token @relation(fields: [rewardTokenId], references: [id])\n rewardTokenId String\n amount String @default(\"0\")\n claimed String @default(\"0\")\n pending String @default(\"0\")\n proofs String[]\n Breakdown RewardBreakdown[]\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([root, recipient, rewardTokenId])\n @@index([root], type: Hash)\n @@index([recipient, rewardTokenId])\n}\n\nmodel RewardBreakdown {\n id String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n Protocol Protocol? @relation(fields: [protocolId], references: [id])\n protocolId String?\n reason String\n amount String\n claimed String\n pending String\n Reward Reward @relation(fields: [rewardId], references: [id], onDelete: Cascade)\n rewardId String\n campaignId String\n Campaign Campaign @relation(fields: [campaignId], references: [id])\n // Hidden index on ((CAST(amount AS INTEGER) + CAST(pending AS INTEGER)));\n\n @@unique([rewardId, campaignId, reason])\n @@index([rewardId], type: Hash)\n @@index([campaignId], type: Hash)\n}\n\nmodel MerklRoot {\n root String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n epoch Int\n timestamp BigInt\n Rewards Reward[]\n\n @@index([chainId, root])\n}\n\nmodel PriceSource {\n id Int @id @default(autoincrement()) // This should hold in Int ids\n symbol String @unique() // Price Id\n method PriceSourceMethod\n args Json?\n}\n\n// priceId -> number\n\nmodel Blacklist {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n poolAddress String @db.Char(42)\n User User @relation(fields: [userAddress], references: [address])\n userAddress String @db.Char(42)\n arrestTimestamp BigInt\n arrestDetails Json\n\n @@unique([chainId, userAddress, poolAddress])\n @@index([userAddress], type: Hash)\n}\n\nmodel Dump {\n id String @id\n Chain Chain @relation(fields: [chainId], references: [id])\n chainId Int\n FromToken Token @relation(name: \"from\", fields: [fromTokenId], references: [id])\n fromTokenId String\n ToToken Token @relation(name: \"to\", fields: [toTokenId], references: [id])\n toTokenId String\n multisig String @db.Char(42)\n recipient String @db.Char(42)\n amountIn String @default(\"0\")\n amountOut String @default(\"0\")\n datetime DateTime\n timestamp Int\n\n @@unique([chainId, fromTokenId, toTokenId, timestamp])\n}\n\nmodel Logged {\n id String @id\n chainId Int\n type LoggedEntityType @default(UNKNOWN)\n address String? @db.Char(42)\n fetchAtBlock Int\n caughtFromAddress String @db.Char(42)\n entityData Json\n\n @@unique([chainId, address])\n}\n\n// enums\n\nenum LoggedEntityType {\n UNKNOWN\n EULER_VAULT\n UNISWAP_V4\n COMPOUND_v2\n}\n\nenum RunStatus {\n PROCESSING\n SUCCESS\n FAILED\n SKIPPED\n}\n\nenum OpportunityAction {\n POOL\n HOLD\n DROP\n LEND\n BORROW\n LONG\n SHORT\n SWAP\n INVALID\n}\n\nenum Status {\n NONE // This would mean that no campaigns was ever created for this opportunity\n PAST\n LIVE\n SOON\n}\n\nenum ExplorerType {\n ETHERSCAN\n BLOCKSCOUT\n}\n\nenum AprType {\n CAMPAIGN\n TOKEN\n PROTOCOL\n}\n\nenum TvlType {\n TOKEN\n PROTOCOL\n}\n\nenum PriceSourceMethod {\n COINGECKO\n CONSTANT\n EQUAL_TO\n ERC4626\n DEXSCREENER\n INDEXCOOP\n DEFILLAMA\n}\n\nenum CampaignManualOverride {\n opportunityId\n creatorAddress\n}\n\nenum OpportunityManualOverride {\n name\n depositUrl\n explorerAddress\n action\n}\n\nenum DistributionType {\n DUTCH_AUCTION\n FIX_REWARD_VALUE_PER_LIQUIDITY_VALUE // The fix reward value will lie in params.apr\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_VALUE\n FIX_REWARD_VALUE_PER_LIQUIDITY_AMOUNT\n FIX_REWARD_AMOUNT_PER_LIQUIDITY_AMOUNT\n}\n",
|
678
|
+
"inlineSchemaHash": "8d0a6358875760b281772470a9cfc8328ffb279d4cc301c423f71ea0ff3a996a",
|
679
679
|
"copyEngine": true
|
680
680
|
}
|
681
681
|
|
@@ -223,7 +223,7 @@ model TVLBreakdown {
|
|
223
223
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
224
224
|
identifier String
|
225
225
|
type TvlType
|
226
|
-
value Float
|
226
|
+
value Float // In case type is TOKEN, this is the raw amount of tokens
|
227
227
|
|
228
228
|
TvlRecord TVLRecord @relation(fields: [tvlRecordId], references: [id])
|
229
229
|
tvlRecordId String
|
package/dist/src/eden/index.d.ts
CHANGED
@@ -1123,7 +1123,7 @@ declare const eden: {
|
|
1123
1123
|
query?: Record<string, unknown> | undefined;
|
1124
1124
|
fetch?: RequestInit | undefined;
|
1125
1125
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
1126
|
-
200: unknown[]
|
1126
|
+
200: unknown[];
|
1127
1127
|
}>>;
|
1128
1128
|
};
|
1129
1129
|
}) & {
|
@@ -1526,7 +1526,7 @@ declare const eden: {
|
|
1526
1526
|
query?: Record<string, unknown> | undefined;
|
1527
1527
|
fetch?: RequestInit | undefined;
|
1528
1528
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
1529
|
-
200: unknown[]
|
1529
|
+
200: unknown[];
|
1530
1530
|
}>>;
|
1531
1531
|
};
|
1532
1532
|
}) & {
|
@@ -1539,7 +1539,7 @@ declare const eden: {
|
|
1539
1539
|
query?: Record<string, unknown> | undefined;
|
1540
1540
|
fetch?: RequestInit | undefined;
|
1541
1541
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
1542
|
-
200: unknown[]
|
1542
|
+
200: unknown[];
|
1543
1543
|
}>>;
|
1544
1544
|
};
|
1545
1545
|
post: (body: {
|
@@ -1562,7 +1562,7 @@ declare const eden: {
|
|
1562
1562
|
query?: Record<string, unknown> | undefined;
|
1563
1563
|
fetch?: RequestInit | undefined;
|
1564
1564
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
1565
|
-
200: unknown[]
|
1565
|
+
200: unknown[];
|
1566
1566
|
}>>;
|
1567
1567
|
};
|
1568
1568
|
metadata: {
|
@@ -6065,7 +6065,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6065
6065
|
authorization: string;
|
6066
6066
|
};
|
6067
6067
|
response: {
|
6068
|
-
200: unknown[]
|
6068
|
+
200: unknown[];
|
6069
6069
|
};
|
6070
6070
|
};
|
6071
6071
|
};
|
@@ -6632,7 +6632,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6632
6632
|
authorization: string;
|
6633
6633
|
};
|
6634
6634
|
response: {
|
6635
|
-
200: unknown[]
|
6635
|
+
200: unknown[];
|
6636
6636
|
};
|
6637
6637
|
};
|
6638
6638
|
};
|
@@ -6650,7 +6650,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6650
6650
|
authorization: string;
|
6651
6651
|
};
|
6652
6652
|
response: {
|
6653
|
-
200: unknown[]
|
6653
|
+
200: unknown[];
|
6654
6654
|
};
|
6655
6655
|
};
|
6656
6656
|
};
|
@@ -6680,7 +6680,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6680
6680
|
authorization: string;
|
6681
6681
|
};
|
6682
6682
|
response: {
|
6683
|
-
200: unknown[]
|
6683
|
+
200: unknown[];
|
6684
6684
|
};
|
6685
6685
|
};
|
6686
6686
|
};
|
@@ -11804,7 +11804,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
11804
11804
|
query?: Record<string, unknown> | undefined;
|
11805
11805
|
fetch?: RequestInit | undefined;
|
11806
11806
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
11807
|
-
200: unknown[]
|
11807
|
+
200: unknown[];
|
11808
11808
|
}>>;
|
11809
11809
|
};
|
11810
11810
|
}) & {
|
@@ -12207,7 +12207,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12207
12207
|
query?: Record<string, unknown> | undefined;
|
12208
12208
|
fetch?: RequestInit | undefined;
|
12209
12209
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
12210
|
-
200: unknown[]
|
12210
|
+
200: unknown[];
|
12211
12211
|
}>>;
|
12212
12212
|
};
|
12213
12213
|
}) & {
|
@@ -12220,7 +12220,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12220
12220
|
query?: Record<string, unknown> | undefined;
|
12221
12221
|
fetch?: RequestInit | undefined;
|
12222
12222
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
12223
|
-
200: unknown[]
|
12223
|
+
200: unknown[];
|
12224
12224
|
}>>;
|
12225
12225
|
};
|
12226
12226
|
post: (body: {
|
@@ -12243,7 +12243,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
12243
12243
|
query?: Record<string, unknown> | undefined;
|
12244
12244
|
fetch?: RequestInit | undefined;
|
12245
12245
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
12246
|
-
200: unknown[]
|
12246
|
+
200: unknown[];
|
12247
12247
|
}>>;
|
12248
12248
|
};
|
12249
12249
|
metadata: {
|
@@ -1,6 +1,10 @@
|
|
1
|
+
import { Campaign } from "@sdk";
|
2
|
+
import { AjnaCampaignTVLBuilder } from "./implementations/Ajna";
|
1
3
|
// @dev Casts are made to enforce type safety
|
2
4
|
// @dev A type error must be thrown if a new campaign type is added and the corresponding builder is not implemented
|
3
|
-
const map = {
|
5
|
+
const map = {
|
6
|
+
[Campaign.AJNA]: new AjnaCampaignTVLBuilder(),
|
7
|
+
};
|
4
8
|
export const campaignDynamicDataBuilderFactory = (campaignType) => {
|
5
9
|
if (!map[campaignType]) {
|
6
10
|
return null;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
|
2
|
+
import type { CampaignTVLBuilder, TVLData } from "../interface";
|
3
|
+
type campaignType = Campaign.AJNA;
|
4
|
+
export declare class AjnaCampaignTVLBuilder implements CampaignTVLBuilder<campaignType> {
|
5
|
+
build(chainId: MerklChainId, campaigns: CampaignParameters<campaignType>[]): Promise<TVLData>;
|
6
|
+
}
|
7
|
+
export {};
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import { TokenService } from "@/modules/v4/token/token.service";
|
2
|
+
import { providers } from "@/utils/providers";
|
3
|
+
import { TvlType } from "@db/api";
|
4
|
+
import { AjnaSubCampaignType, BN2Number, ChainInteractionService, ERC20Pool__factory, NETWORK_LABELS, PoolInfoUtilsInterface, } from "@sdk";
|
5
|
+
import { POOL_INFO_UTILS } from "@sdk";
|
6
|
+
import axios from "axios";
|
7
|
+
export class AjnaCampaignTVLBuilder {
|
8
|
+
async build(chainId, campaigns) {
|
9
|
+
const calls = [];
|
10
|
+
for (const campaign of campaigns) {
|
11
|
+
if (campaign.campaignParameters.subCampaignType === AjnaSubCampaignType.lend) {
|
12
|
+
calls.push({
|
13
|
+
allowFailure: true,
|
14
|
+
callData: PoolInfoUtilsInterface.encodeFunctionData("poolPricesInfo", [campaign.campaignParameters.poolId]),
|
15
|
+
target: POOL_INFO_UTILS[campaign.computeChainId],
|
16
|
+
});
|
17
|
+
}
|
18
|
+
}
|
19
|
+
const result = await ChainInteractionService(chainId).fetchState(calls);
|
20
|
+
let index = 0;
|
21
|
+
const tvls = [];
|
22
|
+
for (const campaign of campaigns) {
|
23
|
+
const res = await axios.get(`https://ajna-api.blockanalitica.com/v4/${NETWORK_LABELS[chainId].toLowerCase()}/pools/${campaign.campaignParameters.poolId.toLowerCase()}`);
|
24
|
+
let totalSupplyTargetToken = 0;
|
25
|
+
let totalComputedTargetToken = 0;
|
26
|
+
if (campaign.campaignParameters.subCampaignType === AjnaSubCampaignType.lend) {
|
27
|
+
totalSupplyTargetToken = res?.data.results?.quote_token_balance;
|
28
|
+
const htpIndex = PoolInfoUtilsInterface.decodeFunctionResult("poolPricesInfo", result[index].returnData)[3];
|
29
|
+
const lupIndex = PoolInfoUtilsInterface.decodeFunctionResult("poolPricesInfo", result[index].returnData)[5];
|
30
|
+
const threshold = BN2Number(lupIndex, 0) === 0 ? lupIndex : lupIndex.gt(htpIndex) ? lupIndex.add(22) : htpIndex.add(22);
|
31
|
+
const InterestEarningSupplyRes = await ERC20Pool__factory.connect(campaign.campaignParameters.poolId, providers[campaign.computeChainId]).depositUpToIndex(threshold);
|
32
|
+
totalComputedTargetToken = BN2Number(InterestEarningSupplyRes, 18);
|
33
|
+
index++;
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
totalSupplyTargetToken = res?.data.results?.debt;
|
37
|
+
}
|
38
|
+
totalComputedTargetToken =
|
39
|
+
campaign.campaignSubType === AjnaSubCampaignType.lend ? totalComputedTargetToken : totalSupplyTargetToken;
|
40
|
+
/** Handling blacklists */
|
41
|
+
if (campaign.campaignParameters.blacklist.length !== 0 && totalComputedTargetToken !== 0) {
|
42
|
+
let blacklistedSupply = 0;
|
43
|
+
let blacklistedPosition;
|
44
|
+
for (const blacklisted of campaign.campaignParameters.blacklist) {
|
45
|
+
const res = await axios.get(`https://ajna-api.blockanalitica.com/v4/${NETWORK_LABELS[chainId].toLowerCase()}/wallets/${blacklisted}/pools/?days_ago=1&order=-debt&p_size=50`);
|
46
|
+
let nextRoute = null;
|
47
|
+
if (!!res.data.next) {
|
48
|
+
nextRoute = `https://${res.data.next.slice(res.data.next.indexOf(":") + 1)}`;
|
49
|
+
}
|
50
|
+
blacklistedPosition = res.data.results.find((position) => position.pool_address === campaign.campaignParameters.poolId);
|
51
|
+
blacklistedSupply = !blacklistedPosition
|
52
|
+
? 0
|
53
|
+
: campaign.campaignSubType === AjnaSubCampaignType.lend
|
54
|
+
? Number(blacklistedPosition.supply)
|
55
|
+
: Number(blacklistedPosition.debt);
|
56
|
+
while (nextRoute !== null && blacklistedSupply !== 0) {
|
57
|
+
const res = await axios.get(nextRoute);
|
58
|
+
blacklistedPosition = res.data.results.find((position) => position.pool_address === campaign.campaignParameters.poolId);
|
59
|
+
blacklistedSupply = !blacklistedPosition
|
60
|
+
? 0
|
61
|
+
: campaign.campaignSubType === AjnaSubCampaignType.lend
|
62
|
+
? Number(blacklistedPosition.supply)
|
63
|
+
: Number(blacklistedPosition.debt);
|
64
|
+
if (!!res.data.next) {
|
65
|
+
nextRoute = `https://${res.data.next.slice(res.data.next.indexOf(":") + 1)}`;
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
nextRoute = null;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
totalComputedTargetToken -= blacklistedSupply;
|
73
|
+
}
|
74
|
+
tvls.push({
|
75
|
+
campaign,
|
76
|
+
tvl: Number(res?.data.results?.tvl),
|
77
|
+
tvlBreakdown: [
|
78
|
+
{
|
79
|
+
type: TvlType.TOKEN,
|
80
|
+
identifier: TokenService.hashId({
|
81
|
+
chainId: chainId,
|
82
|
+
address: campaign.rewardToken,
|
83
|
+
}),
|
84
|
+
value: totalComputedTargetToken,
|
85
|
+
},
|
86
|
+
],
|
87
|
+
});
|
88
|
+
}
|
89
|
+
return tvls;
|
90
|
+
}
|
91
|
+
}
|
package/dist/src/index.d.ts
CHANGED
@@ -1327,7 +1327,7 @@ declare const app: Elysia<"", false, {
|
|
1327
1327
|
authorization: string;
|
1328
1328
|
};
|
1329
1329
|
response: {
|
1330
|
-
200: unknown[]
|
1330
|
+
200: unknown[];
|
1331
1331
|
};
|
1332
1332
|
};
|
1333
1333
|
};
|
@@ -1894,7 +1894,7 @@ declare const app: Elysia<"", false, {
|
|
1894
1894
|
authorization: string;
|
1895
1895
|
};
|
1896
1896
|
response: {
|
1897
|
-
200: unknown[]
|
1897
|
+
200: unknown[];
|
1898
1898
|
};
|
1899
1899
|
};
|
1900
1900
|
};
|
@@ -1912,7 +1912,7 @@ declare const app: Elysia<"", false, {
|
|
1912
1912
|
authorization: string;
|
1913
1913
|
};
|
1914
1914
|
response: {
|
1915
|
-
200: unknown[]
|
1915
|
+
200: unknown[];
|
1916
1916
|
};
|
1917
1917
|
};
|
1918
1918
|
};
|
@@ -1942,7 +1942,7 @@ declare const app: Elysia<"", false, {
|
|
1942
1942
|
authorization: string;
|
1943
1943
|
};
|
1944
1944
|
response: {
|
1945
|
-
200: unknown[]
|
1945
|
+
200: unknown[];
|
1946
1946
|
};
|
1947
1947
|
};
|
1948
1948
|
};
|
@@ -26,7 +26,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
|
|
26
26
|
authorization: string;
|
27
27
|
};
|
28
28
|
response: {
|
29
|
-
200: unknown[]
|
29
|
+
200: unknown[];
|
30
30
|
};
|
31
31
|
};
|
32
32
|
};
|
@@ -44,7 +44,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
|
|
44
44
|
authorization: string;
|
45
45
|
};
|
46
46
|
response: {
|
47
|
-
200: unknown[]
|
47
|
+
200: unknown[];
|
48
48
|
};
|
49
49
|
};
|
50
50
|
};
|
@@ -74,7 +74,7 @@ export declare const CampaignTestController: Elysia<"/campaigns", false, {
|
|
74
74
|
authorization: string;
|
75
75
|
};
|
76
76
|
response: {
|
77
|
-
200: unknown[]
|
77
|
+
200: unknown[];
|
78
78
|
};
|
79
79
|
};
|
80
80
|
};
|
@@ -5,7 +5,7 @@ export declare class DynamicDataService {
|
|
5
5
|
*
|
6
6
|
* @dev The list must ONLY contain campaigns of the same type and the same computeChainId
|
7
7
|
*/
|
8
|
-
static update(chainId: ChainId, type: CampaignEnum, campaigns: CampaignParameters<CampaignEnum>[], dryRun?: boolean): Promise<unknown[]
|
8
|
+
static update(chainId: ChainId, type: CampaignEnum, campaigns: CampaignParameters<CampaignEnum>[], dryRun?: boolean): Promise<unknown[]>;
|
9
9
|
/**
|
10
10
|
* @dev Test function used to create mock ERC20 static campaigns and check tvl and metadata
|
11
11
|
*/
|