@merkl/api 0.10.129 → 0.10.130
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database/api/.generated/default.js +1 -0
- package/dist/database/api/.generated/edge.js +609 -0
- package/dist/database/api/.generated/index-browser.js +586 -0
- package/dist/database/api/.generated/index.js +638 -0
- package/dist/database/api/.generated/runtime/edge-esm.js +31 -0
- package/dist/database/api/.generated/runtime/edge.js +31 -0
- package/dist/database/api/.generated/runtime/index-browser.js +13 -0
- package/dist/database/api/.generated/runtime/library.js +143 -0
- package/dist/database/api/.generated/runtime/react-native.js +80 -0
- package/dist/database/api/.generated/runtime/wasm.js +32 -0
- package/dist/database/api/.generated/wasm.js +586 -0
- package/dist/database/api/seeder/resources/protocol.js +341 -0
- package/dist/database/engine/.generated/default.js +1 -0
- package/dist/database/engine/.generated/edge.js +438 -0
- package/dist/database/engine/.generated/index-browser.js +415 -0
- package/dist/database/engine/.generated/index.js +467 -0
- package/dist/database/engine/.generated/runtime/edge-esm.js +31 -0
- package/dist/database/engine/.generated/runtime/edge.js +31 -0
- package/dist/database/engine/.generated/runtime/index-browser.js +13 -0
- package/dist/database/engine/.generated/runtime/library.js +143 -0
- package/dist/database/engine/.generated/runtime/react-native.js +80 -0
- package/dist/database/engine/.generated/runtime/wasm.js +32 -0
- package/dist/database/engine/.generated/wasm.js +415 -0
- package/dist/node_modules/@elysiajs/eden/eden/LICENSE +7 -0
- package/dist/node_modules/@elysiajs/eden/eden/README.md +46 -0
- package/dist/node_modules/@elysiajs/eden/eden/bunfig.toml +2 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-2IHGLN7W.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-7WO4HTSU.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-XYW4OUFN.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/chunk-YAG46HFR.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/errors.d.ts +5 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch/index.d.ts +4 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch/types.d.ts +44 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.d.mts +48 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.d.ts +48 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.global.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/fetch.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/index.d.mts +5 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/index.d.ts +5 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/index.global.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/index.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/index.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/index.d.ts +17 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/types.d.ts +99 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty/utils.d.ts +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.d.mts +114 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.d.ts +114 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.global.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/index.d.ts +5 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/types.d.ts +86 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2/ws.d.ts +14 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.d.mts +103 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.d.ts +103 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.global.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.js +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/treaty2.mjs +1 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/types-C41kuZ-K.d.mts +44 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/types-C41kuZ-K.d.ts +44 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/types.d.ts +39 -0
- package/dist/node_modules/@elysiajs/eden/eden/dist/utils/parsingUtils.d.ts +6 -0
- package/dist/node_modules/@elysiajs/eden/eden/package.json +85 -0
- package/dist/package.json +2 -2
- package/dist/src/backgroundJobs/index.js +44 -0
- package/dist/src/backgroundJobs/jobs/campaignsCacheUpdater.js +160 -0
- package/dist/src/backgroundJobs/jobs/health.js +15 -0
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +63 -0
- package/dist/src/backgroundJobs/jobs/priceUpdater.js +16 -0
- package/dist/src/backgroundJobs/jobs/sync.js +33 -0
- package/dist/src/cache/declaration.js +146 -0
- package/dist/src/cache/index.js +152 -0
- package/dist/src/cache/redis.js +49 -0
- package/dist/src/constants.js +119 -0
- package/dist/src/entities/campaign.js +134 -0
- package/dist/src/entities/opportunity.js +549 -0
- package/dist/src/errors/BadRequest.error.js +7 -0
- package/dist/src/errors/Conflict.error.js +7 -0
- package/dist/src/errors/HttpError.js +11 -0
- package/dist/src/errors/NotFound.error.js +7 -0
- package/dist/src/errors/Opportunity.error.js +11 -0
- package/dist/src/errors/Unauthorized.error.js +7 -0
- package/dist/src/errors/index.js +5 -0
- package/dist/src/guards/BackOffice.guard.js +10 -0
- package/dist/src/guards/Engine.guard.js +10 -0
- package/dist/src/guards/TokenAuth.guard.js +10 -0
- package/dist/src/hooks/checkQueryAddressValidity.js +7 -0
- package/dist/src/hooks/checkQueryChainIdValidity.js +7 -0
- package/dist/src/index.js +79 -0
- package/dist/src/internal/controllers/endingCampaigns.js +41 -0
- package/dist/src/internal/controllers/unclaimed.js +36 -0
- package/dist/src/internal/index.js +30 -0
- package/dist/src/libs/campaigns/campaignTypes/AjnaDynamicData.js +111 -0
- package/dist/src/libs/campaigns/campaignTypes/BadgerDynamicData.js +93 -0
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +942 -0
- package/dist/src/libs/campaigns/campaignTypes/CompoundDynamicData.js +90 -0
- package/dist/src/libs/campaigns/campaignTypes/DolomiteDynamicData.js +60 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +162 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicDataRefacto.js +159 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/eulerVaultNames.js +13 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/factoryFinder.js +29 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/getBlacklistedSupply.js +22 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/metamorphoTvl.js +35 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/spliceTVL.js +21 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +106 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AaveProcessor.js +26 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AssetProcessor.js +47 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.js +103 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerGaugeProcessor.js +83 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BalancerPoolProcessor.js +99 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/BeefyProcessor.js +51 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/CompoundProcessor.js +36 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EnzymeProcessor.js +51 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerBorrowProcessor.js +46 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/EulerLendProcessor.js +47 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/FluidProcessor.js +36 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/FraxProcessor.js +41 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GearboxProcessor.js +44 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +239 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/MetamorphoProcessor.js +43 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleProcessor.js +31 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RadiantProcessor.js +58 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/RfxProcessor.js +64 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/SpliceProcessor.js +35 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/SturdySiloProcessor.js +37 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/TemplateProcessor.js +40 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/TorosProcessor.js +33 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/UniswapProcessor.js +48 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/WoofiProcessor.js +40 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/curveProcessor.js +68 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +77 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPrices.js +583 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPricesRefactoFinal.js +24 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +1209 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.js +194 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.js +645 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2RefactoFinal.js +22 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3.js +392 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3RefactoFinal.js +22 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4.js +323 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4RefactoFinal.js +22 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20_SNAPSHOTDynamicData.js +38 -0
- package/dist/src/libs/campaigns/campaignTypes/EulerDynamicData.js +165 -0
- package/dist/src/libs/campaigns/campaignTypes/JSON_AIRDROPDynamicData.js +19 -0
- package/dist/src/libs/campaigns/campaignTypes/MORPHODynamicData.js +120 -0
- package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.js +112 -0
- package/dist/src/libs/campaigns/campaignTypes/SILODynamicData.js +113 -0
- package/dist/src/libs/campaigns/campaignsDynamicData.js +83 -0
- package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.js +78 -0
- package/dist/src/libs/campaigns/getCampaigns.js +18 -0
- package/dist/src/libs/campaigns/utils/fetchA51Strategies.js +44 -0
- package/dist/src/libs/campaigns/utils/fetchClamInfo.js +27 -0
- package/dist/src/libs/campaigns/utils/fetchLogs.js +91 -0
- package/dist/src/libs/campaigns/utils/getCompV2ForksVaults.js +122 -0
- package/dist/src/libs/campaigns/utils/getContractCreationBlock.js +44 -0
- package/dist/src/libs/campaigns/utils/getDolomiteMarkets.js +50 -0
- package/dist/src/libs/campaigns/utils/getEulerV2Vaults.js +87 -0
- package/dist/src/libs/campaigns/utils/getLastEligibilityRatio.js +56 -0
- package/dist/src/libs/computeFee.js +34 -0
- package/dist/src/libs/custom/twtParticipants.js +54 -0
- package/dist/src/libs/deprecated-merklv3/index.js +184 -0
- package/dist/src/libs/getTokensList.js +37 -0
- package/dist/src/libs/merklChainData.js +129 -0
- package/dist/src/libs/parse/marketsWithCache.js +8 -0
- package/dist/src/libs/positions/ajna/index.js +107 -0
- package/dist/src/libs/positions/badger/index.js +79 -0
- package/dist/src/libs/positions/clamm/index.js +419 -0
- package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.js +35 -0
- package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.js +35 -0
- package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.js +44 -0
- package/dist/src/libs/positions/clamm/thegraph/index.js +162 -0
- package/dist/src/libs/positions/compound/index.js +93 -0
- package/dist/src/libs/positions/dolomite/index.js +49 -0
- package/dist/src/libs/positions/erc20/index.js +55 -0
- package/dist/src/libs/positions/euler/index.js +57 -0
- package/dist/src/libs/positions/index.js +48 -0
- package/dist/src/libs/positions/morpho/index.js +177 -0
- package/dist/src/libs/positions/prepareFetch.js +339 -0
- package/dist/src/libs/positions/silo/index.js +67 -0
- package/dist/src/libs/positions/types.js +1 -0
- package/dist/src/libs/reports/campaignReport.js +37 -0
- package/dist/src/libs/reports/mainParameterRewards.js +48 -0
- package/dist/src/libs/rewards/userRewards.js +154 -0
- package/dist/src/libs/staticCampaigns.js +10 -0
- package/dist/src/libs/tokens/balances.js +126 -0
- package/dist/src/libs/tokens/tokenInfo.js +22 -0
- package/dist/src/modules/v4/accounting/accounting.controller.js +66 -0
- package/dist/src/modules/v4/accounting/accounting.model.js +32 -0
- package/dist/src/modules/v4/accounting/accounting.repository.js +100 -0
- package/dist/src/modules/v4/accounting/accounting.service.js +78 -0
- package/dist/src/modules/v4/accounting/index.js +3 -0
- package/dist/src/modules/v4/apr/apr.controller.js +1 -0
- package/dist/src/modules/v4/apr/apr.model.js +1 -0
- package/dist/src/modules/v4/apr/apr.repository.js +1 -0
- package/dist/src/modules/v4/apr/apr.service.js +40 -0
- package/dist/src/modules/v4/apr/index.js +2 -0
- package/dist/src/modules/v4/blacklist/blacklist.controller.js +45 -0
- package/dist/src/modules/v4/blacklist/blacklist.model.js +13 -0
- package/dist/src/modules/v4/blacklist/blacklist.repository.js +56 -0
- package/dist/src/modules/v4/blacklist/blacklist.service.js +24 -0
- package/dist/src/modules/v4/blacklist/index.js +3 -0
- package/dist/src/modules/v4/cache/cache.model.js +14 -0
- package/dist/src/modules/v4/cache/cache.repository.js +10 -0
- package/dist/src/modules/v4/cache/cache.service.js +44 -0
- package/dist/src/modules/v4/cache/index.js +1 -0
- package/dist/src/modules/v4/campaign/campaign.controller.js +56 -0
- package/dist/src/modules/v4/campaign/campaign.model.js +54 -0
- package/dist/src/modules/v4/campaign/campaign.repository.js +346 -0
- package/dist/src/modules/v4/campaign/campaign.service.js +203 -0
- package/dist/src/modules/v4/campaign/index.js +3 -0
- package/dist/src/modules/v4/chain/chain.controller.js +40 -0
- package/dist/src/modules/v4/chain/chain.model.js +17 -0
- package/dist/src/modules/v4/chain/chain.repository.js +64 -0
- package/dist/src/modules/v4/chain/chain.service.js +42 -0
- package/dist/src/modules/v4/chain/index.js +3 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +19 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.model.js +6 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.repository.js +1 -0
- package/dist/src/modules/v4/dynamicData/dynamicData.service.js +49 -0
- package/dist/src/modules/v4/dynamicData/index.js +3 -0
- package/dist/src/modules/v4/enso/enso.model.js +108 -0
- package/dist/src/modules/v4/enso/enso.service.js +46 -0
- package/dist/src/modules/v4/explorer/explorer.model.js +2 -0
- package/dist/src/modules/v4/explorer/explorer.repository.js +23 -0
- package/dist/src/modules/v4/explorer/explorer.service.js +24 -0
- package/dist/src/modules/v4/explorer/index.js +1 -0
- package/dist/src/modules/v4/index.js +4 -0
- package/dist/src/modules/v4/merklRoot/index.js +3 -0
- package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +19 -0
- package/dist/src/modules/v4/merklRoot/merklRoot.model.js +6 -0
- package/dist/src/modules/v4/merklRoot/merklRoot.repository.js +31 -0
- package/dist/src/modules/v4/merklRoot/merklRoot.service.js +38 -0
- package/dist/src/modules/v4/opportunity/index.js +3 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +69 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.js +36 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +14 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +217 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +0 -15
- package/dist/src/modules/v4/opportunity/opportunity.service.js +180 -0
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +50 -0
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +23 -0
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +33 -0
- package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.js +18 -0
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +15 -0
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +63 -0
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +8 -0
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +30 -0
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +36 -0
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +19 -0
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +9 -0
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +13 -0
- package/dist/src/modules/v4/opportunity/transform-id.pipe.js +6 -0
- package/dist/src/modules/v4/opportunity/validate-id.pipe.js +12 -0
- package/dist/src/modules/v4/participate/participate.controller.js +66 -0
- package/dist/src/modules/v4/participate/participate.model.js +24 -0
- package/dist/src/modules/v4/participate/participate.service.js +33 -0
- package/dist/src/modules/v4/price/index.js +3 -0
- package/dist/src/modules/v4/price/price.controller.js +62 -0
- package/dist/src/modules/v4/price/price.model.js +12 -0
- package/dist/src/modules/v4/price/price.repository.js +18 -0
- package/dist/src/modules/v4/price/price.service.js +44 -0
- package/dist/src/modules/v4/prisma/index.js +1 -0
- package/dist/src/modules/v4/protocol/index.js +3 -0
- package/dist/src/modules/v4/protocol/protocol.controller.js +23 -0
- package/dist/src/modules/v4/protocol/protocol.model.js +68 -0
- package/dist/src/modules/v4/protocol/protocol.repository.js +37 -0
- package/dist/src/modules/v4/protocol/protocol.service.js +77 -0
- package/dist/src/modules/v4/reward/index.js +3 -0
- package/dist/src/modules/v4/reward/reward.controller.js +52 -0
- package/dist/src/modules/v4/reward/reward.model.js +104 -0
- package/dist/src/modules/v4/reward/reward.repository.js +237 -0
- package/dist/src/modules/v4/reward/reward.service.js +283 -0
- package/dist/src/modules/v4/reward/rewardConvertor.service.js +136 -0
- package/dist/src/modules/v4/router.js +57 -0
- package/dist/src/modules/v4/status/index.js +3 -0
- package/dist/src/modules/v4/status/status.controller.js +48 -0
- package/dist/src/modules/v4/status/status.model.js +24 -0
- package/dist/src/modules/v4/status/status.repository.js +88 -0
- package/dist/src/modules/v4/status/status.service.js +60 -0
- package/dist/src/modules/v4/token/index.js +3 -0
- package/dist/src/modules/v4/token/token.controller.js +32 -0
- package/dist/src/modules/v4/token/token.model.js +23 -0
- package/dist/src/modules/v4/token/token.repository.js +128 -0
- package/dist/src/modules/v4/token/token.service.js +268 -0
- package/dist/src/modules/v4/tvl/index.js +2 -0
- package/dist/src/modules/v4/tvl/tvl.controller.js +1 -0
- package/dist/src/modules/v4/tvl/tvl.model.js +1 -0
- package/dist/src/modules/v4/tvl/tvl.repository.js +1 -0
- package/dist/src/modules/v4/tvl/tvl.service.js +49 -0
- package/dist/src/modules/v4/uniswapV4/index.js +4 -0
- package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.js +11 -0
- package/dist/src/modules/v4/uniswapV4/uniswapV4.model.js +17 -0
- package/dist/src/modules/v4/uniswapV4/uniswapV4.repository.js +2 -0
- package/dist/src/modules/v4/uniswapV4/uniswapV4.service.js +73 -0
- package/dist/src/modules/v4/user/index.js +3 -0
- package/dist/src/modules/v4/user/user.controller.js +69 -0
- package/dist/src/modules/v4/user/user.model.js +18 -0
- package/dist/src/modules/v4/user/user.repository.js +38 -0
- package/dist/src/modules/v4/user/user.service.js +50 -0
- package/dist/src/plugins/error-handling.plugin.js +28 -0
- package/dist/src/plugins/logger.plugin.js +22 -0
- package/dist/src/routes/v1/allowances.js +115 -0
- package/dist/src/routes/v1/balances.js +25 -0
- package/dist/src/routes/v1/prices.js +11 -0
- package/dist/src/routes/v1/tokens.js +17 -0
- package/dist/src/routes/v2/merkl.js +13 -0
- package/dist/src/routes/v3/ERC20Campaigns.js +63 -0
- package/dist/src/routes/v3/app.js +18 -0
- package/dist/src/routes/v3/blacklist.js +18 -0
- package/dist/src/routes/v3/campaign/delay.js +78 -0
- package/dist/src/routes/v3/campaignClaims.js +24 -0
- package/dist/src/routes/v3/campaignReport.js +22 -0
- package/dist/src/routes/v3/campaignUnclaimed.js +28 -0
- package/dist/src/routes/v3/campaigns.js +101 -0
- package/dist/src/routes/v3/campaignsForMainParameter.js +19 -0
- package/dist/src/routes/v3/campaignsInfo.js +54 -0
- package/dist/src/routes/v3/campaignsRewardsReport.js +47 -0
- package/dist/src/routes/v3/claims.js +45 -0
- package/dist/src/routes/v3/compoundV2.js +9 -0
- package/dist/src/routes/v3/createCampaign.js +66 -0
- package/dist/src/routes/v3/dolomite.js +9 -0
- package/dist/src/routes/v3/euler.js +9 -0
- package/dist/src/routes/v3/exports/campaigns.js +28 -0
- package/dist/src/routes/v3/fetch.js +27 -0
- package/dist/src/routes/v3/health.js +13 -0
- package/dist/src/routes/v3/lostyield.js +98 -0
- package/dist/src/routes/v3/merkl.js +119 -0
- package/dist/src/routes/v3/morphoMarkets.js +27 -0
- package/dist/src/routes/v3/morphoVaults.js +22 -0
- package/dist/src/routes/v3/multiChainPositions.js +69 -0
- package/dist/src/routes/v3/opportunity.js +63 -0
- package/dist/src/routes/v3/overview.js +73 -0
- package/dist/src/routes/v3/parse.js +23 -0
- package/dist/src/routes/v3/payload.js +40 -0
- package/dist/src/routes/v3/poolInfo.js +88 -0
- package/dist/src/routes/v3/positions.js +62 -0
- package/dist/src/routes/v3/radiant.js +26 -0
- package/dist/src/routes/v3/recipients.js +20 -0
- package/dist/src/routes/v3/rewards.js +33 -0
- package/dist/src/routes/v3/rewardsReport.js +51 -0
- package/dist/src/routes/v3/rootForTimestamp.js +47 -0
- package/dist/src/routes/v3/silo.js +20 -0
- package/dist/src/routes/v3/token.js +24 -0
- package/dist/src/routes/v3/tokenUnclaimed.js +24 -0
- package/dist/src/routes/v3/twt/participants.js +11 -0
- package/dist/src/routes/v3/updates.js +47 -0
- package/dist/src/routes/v3/userRewards.js +59 -0
- package/dist/src/types/index.js +6 -0
- package/dist/src/types/parameters/Action.js +11 -0
- package/dist/src/types/parameters/Chain.js +13 -0
- package/dist/src/types/parameters/ChainCampaignId.js +13 -0
- package/dist/src/types/parameters/MainParameter.js +19 -0
- package/dist/src/types/parameters/OpportunityId.js +14 -0
- package/dist/src/types/parameters/Timestamp.js +16 -0
- package/dist/src/types/parameters/Type.js +15 -0
- package/dist/src/types/parameters/index.js +17 -0
- package/dist/src/types/returnTypes.js +1 -0
- package/dist/src/types/utils.js +1 -0
- package/dist/src/utils/addString.js +6 -0
- package/dist/src/utils/bigintToString.js +20 -0
- package/dist/src/utils/crypto.js +4 -0
- package/dist/src/utils/decodeCalls.js +170 -0
- package/dist/src/utils/encodeCalls.js +240 -0
- package/dist/src/utils/error.js +90 -0
- package/dist/src/utils/execute.js +41 -0
- package/dist/src/utils/generateCardName.js +89 -0
- package/dist/src/utils/generic.js +117 -0
- package/dist/src/utils/hashArray.js +4 -0
- package/dist/src/utils/lastBlockBefore.js +78 -0
- package/dist/src/utils/logger.js +52 -0
- package/dist/src/utils/pricer.js +180 -0
- package/dist/src/utils/prices/chainlinkRead.js +8 -0
- package/dist/src/utils/prices/curveVirtualPrice.js +7 -0
- package/dist/src/utils/prices/getDQUICK.js +8 -0
- package/dist/src/utils/prices/priceFetcherFactory.js +29 -0
- package/dist/src/utils/prices/priceService.js +328 -0
- package/dist/src/utils/prices/services/coinGeckoService.js +53 -0
- package/dist/src/utils/prices/services/defillamaService.js +53 -0
- package/dist/src/utils/prices/services/dexScreenerService.js +62 -0
- package/dist/src/utils/prices/services/erc4626Service.js +30 -0
- package/dist/src/utils/prices/services/getERC4626.js +11 -0
- package/dist/src/utils/prices/services/indexCoopService.js +55 -0
- package/dist/src/utils/prices/services/priceFetcher.js +1 -0
- package/dist/src/utils/prices/uniV2Price.js +40 -0
- package/dist/src/utils/prisma.js +12 -0
- package/dist/src/utils/providers.js +30 -0
- package/dist/src/utils/queries/activeCampaigns.js +22 -0
- package/dist/src/utils/queries/allCampaigns.js +51 -0
- package/dist/src/utils/queries/campaignsForMainParameter.js +23 -0
- package/dist/src/utils/queries/claimsOverTime.js +111 -0
- package/dist/src/utils/queries/endingCampaigns.js +21 -0
- package/dist/src/utils/queries/futureCampaigns.js +19 -0
- package/dist/src/utils/queries/mainParameterCampaigns.js +11 -0
- package/dist/src/utils/queries/rewardsAmount.js +106 -0
- package/dist/src/utils/queries/unclaimed.js +81 -0
- package/dist/src/utils/rateLimit.js +13 -0
- package/dist/src/utils/stryke.js +4 -0
- package/dist/src/utils/throw.js +27 -0
- package/dist/src/utils/validation.js +20 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +2 -2
@@ -0,0 +1,91 @@
|
|
1
|
+
import { log } from "../../../utils/logger";
|
2
|
+
import { providers } from "../../../utils/providers";
|
3
|
+
import axios from "axios";
|
4
|
+
async function fetchLogs(chainId, topics, addresses, fromBlock, toBlock) {
|
5
|
+
const url = providers[chainId].connection.url;
|
6
|
+
if (fromBlock === undefined || fromBlock === null || !toBlock) {
|
7
|
+
throw new Error("fromBlock and toBlock are required");
|
8
|
+
}
|
9
|
+
const headers = {
|
10
|
+
accept: "application/json",
|
11
|
+
"content-type": "application/json",
|
12
|
+
};
|
13
|
+
let tempFromBlock = fromBlock;
|
14
|
+
let tempToBlock = toBlock;
|
15
|
+
log.local(`fetching logs between blocks ${fromBlock} and ${toBlock}`);
|
16
|
+
let step = tempToBlock - tempFromBlock;
|
17
|
+
// Binary search to fetch logs and avoid errors
|
18
|
+
let logs = [];
|
19
|
+
let isRateLimitingError = false;
|
20
|
+
while (true) {
|
21
|
+
try {
|
22
|
+
const data = {
|
23
|
+
id: 1,
|
24
|
+
jsonrpc: "2.0",
|
25
|
+
method: "eth_getLogs",
|
26
|
+
params: [
|
27
|
+
{
|
28
|
+
address: [...addresses],
|
29
|
+
topics: topics,
|
30
|
+
fromBlock: `0x${(tempFromBlock + 1).toString(16)}`, // fromBlock is included
|
31
|
+
toBlock: `0x${tempToBlock.toString(16)}`, // toBlock is included
|
32
|
+
},
|
33
|
+
],
|
34
|
+
};
|
35
|
+
try {
|
36
|
+
const res = await axios.post(url, data, { headers });
|
37
|
+
if (res?.data?.error?.code === -32602)
|
38
|
+
throw new Error("Log size exceeded");
|
39
|
+
if (res.data.error?.code === 429) {
|
40
|
+
isRateLimitingError = true;
|
41
|
+
throw new Error("Rate Limiting");
|
42
|
+
}
|
43
|
+
if (res.data.error?.code === 413) {
|
44
|
+
throw new Error("Request entity too large");
|
45
|
+
}
|
46
|
+
if (res.data.result?.length === 10000)
|
47
|
+
throw new Error("Log size exceeded");
|
48
|
+
logs = logs.concat(...res.data.result);
|
49
|
+
log.local(`fetched ${res.data.result.length} logs between blocks ${tempFromBlock} and ${tempToBlock}`);
|
50
|
+
}
|
51
|
+
catch (e) {
|
52
|
+
if (e.toString() === "Error: Request failed with status code 429") {
|
53
|
+
isRateLimitingError = true;
|
54
|
+
}
|
55
|
+
if (isRateLimitingError) {
|
56
|
+
/** Sleeping to reduce the chances of being rate limited */
|
57
|
+
await new Promise(resolve => setTimeout(resolve, 10_000));
|
58
|
+
throw new Error("Rate Limiting");
|
59
|
+
}
|
60
|
+
const message = `error making POST request: ${e}`;
|
61
|
+
log.error("fetchLogs", message);
|
62
|
+
throw message;
|
63
|
+
}
|
64
|
+
if (tempToBlock === toBlock)
|
65
|
+
break;
|
66
|
+
tempFromBlock = Math.min(tempFromBlock + step, toBlock);
|
67
|
+
tempToBlock = Math.min(tempToBlock + step, toBlock);
|
68
|
+
}
|
69
|
+
catch {
|
70
|
+
if (!isRateLimitingError) {
|
71
|
+
step = Math.floor(step / 2);
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
isRateLimitingError = false;
|
75
|
+
}
|
76
|
+
if (step === 0) {
|
77
|
+
log.error("fetchLogs", `error fetching logs for ${addresses}`);
|
78
|
+
return { logs, block: tempFromBlock };
|
79
|
+
}
|
80
|
+
tempToBlock = tempFromBlock + step;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return { logs, block: toBlock };
|
84
|
+
}
|
85
|
+
export async function safeFetchLogs(chainId, topics, addresses, fromBlock, toBlock) {
|
86
|
+
const { logs, block } = await fetchLogs(chainId, topics, addresses, fromBlock, toBlock);
|
87
|
+
if (block !== toBlock) {
|
88
|
+
throw new Error(`error fetching logs for ${addresses}`);
|
89
|
+
}
|
90
|
+
return logs;
|
91
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
import { Redis } from "../../../cache";
|
2
|
+
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
3
|
+
import { providers } from "../../../utils/providers";
|
4
|
+
import { CTokenInterface, ChainId, CompFork, Comptrollers, ERC20Interface, NULL_ADDRESS, } from "@sdk";
|
5
|
+
import { defaultAbiCoder } from "ethers/lib/utils";
|
6
|
+
import { safeFetchLogs } from "./fetchLogs";
|
7
|
+
import { getContractCreationBlock } from "./getContractCreationBlock";
|
8
|
+
const MARKET_SUPPORTED_EVENT_HASH = "0xaf16ad15f9e29d5140e8e81a30a92a755aa8edff3d301053c84392b70c0d09a3"; // For the case of Venus
|
9
|
+
const MARKET_LISTED_EVENT_HASH = "0xcf583bb0c569eb967f806b11601c4cb93c10310485c67add5f8362c2f212321f";
|
10
|
+
async function getCompoundV2ForksVaults() {
|
11
|
+
const compoundVaults = {};
|
12
|
+
//TODO can be optimized by looking to the same event over all forks for the same chain, then filtering out for each fork
|
13
|
+
for (const compFork of Object.keys(Comptrollers).map(compFork => Number(compFork))) {
|
14
|
+
for (const chainId of Object.keys(Comptrollers[compFork]).map(compFork => Number(compFork))) {
|
15
|
+
if ([ChainId.LINEA].includes(chainId)) {
|
16
|
+
continue;
|
17
|
+
}
|
18
|
+
const toBlock = await providers[chainId].getBlockNumber();
|
19
|
+
const comptrollerAddress = Comptrollers[compFork][chainId];
|
20
|
+
if (!comptrollerAddress) {
|
21
|
+
continue;
|
22
|
+
}
|
23
|
+
const creationBlock = (await getContractCreationBlock(comptrollerAddress, providers[chainId])) ?? 0;
|
24
|
+
let logs = [];
|
25
|
+
const topic = compFork === CompFork.Venus ? MARKET_SUPPORTED_EVENT_HASH : MARKET_LISTED_EVENT_HASH;
|
26
|
+
logs = await safeFetchLogs(chainId, [topic], [comptrollerAddress], creationBlock, toBlock);
|
27
|
+
if (compFork === CompFork.Ionic && chainId === ChainId.MODE) {
|
28
|
+
const isolatedIonicMarketUnitroller = "0x8Fb3D4a94D0aA5D6EDaAC3Ed82B59a27f56d923a";
|
29
|
+
const creationBlock = (await getContractCreationBlock(isolatedIonicMarketUnitroller, providers[chainId])) ?? 0;
|
30
|
+
const isolatedMarketLogs = await safeFetchLogs(chainId, [topic], [isolatedIonicMarketUnitroller], creationBlock, toBlock);
|
31
|
+
logs = logs.concat(isolatedMarketLogs);
|
32
|
+
}
|
33
|
+
const vaults = Object.keys(logs.reduce((acc, transfer) => {
|
34
|
+
const [cToken] = defaultAbiCoder.decode(["address"], transfer.data);
|
35
|
+
if (!!cToken) {
|
36
|
+
acc[cToken] = true;
|
37
|
+
}
|
38
|
+
return acc;
|
39
|
+
}, {}));
|
40
|
+
// Ensure that the entry in compoundVaults for the current chainId and compFork exists
|
41
|
+
const key = `${String(chainId)}_${String(compFork)}`;
|
42
|
+
if (!compoundVaults[key]) {
|
43
|
+
compoundVaults[key] = [];
|
44
|
+
}
|
45
|
+
const callsUnderlying = [];
|
46
|
+
vaults.forEach(vaultAddress => {
|
47
|
+
callsUnderlying.push({
|
48
|
+
allowFailure: true,
|
49
|
+
callData: CTokenInterface.encodeFunctionData("underlying"),
|
50
|
+
target: vaultAddress,
|
51
|
+
});
|
52
|
+
});
|
53
|
+
const resUnderlying = await batchMulticallCallWithRetry(chainId, {
|
54
|
+
calls: callsUnderlying,
|
55
|
+
});
|
56
|
+
const calls = [];
|
57
|
+
for (const [index, vaultAddress] of vaults.entries()) {
|
58
|
+
let underlying = NULL_ADDRESS;
|
59
|
+
if (!resUnderlying[index].success || resUnderlying[index].returnData === "0x") {
|
60
|
+
// const message = `Failed to fetch underlying of ${vaultAddress}`;
|
61
|
+
// log.warn(message);
|
62
|
+
}
|
63
|
+
else {
|
64
|
+
underlying = CTokenInterface.decodeFunctionResult("underlying", resUnderlying[index].returnData)[0];
|
65
|
+
}
|
66
|
+
calls.push({
|
67
|
+
allowFailure: true,
|
68
|
+
callData: CTokenInterface.encodeFunctionData("symbol"),
|
69
|
+
target: vaultAddress,
|
70
|
+
}, {
|
71
|
+
allowFailure: true,
|
72
|
+
callData: CTokenInterface.encodeFunctionData("decimals"),
|
73
|
+
target: vaultAddress,
|
74
|
+
}, {
|
75
|
+
allowFailure: true,
|
76
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
77
|
+
target: underlying,
|
78
|
+
}, {
|
79
|
+
allowFailure: true,
|
80
|
+
callData: ERC20Interface.encodeFunctionData("decimals"),
|
81
|
+
target: underlying,
|
82
|
+
});
|
83
|
+
}
|
84
|
+
const res = await batchMulticallCallWithRetry(chainId, {
|
85
|
+
calls,
|
86
|
+
});
|
87
|
+
// Add the found vaults to the compoundVaults object
|
88
|
+
let index = 0;
|
89
|
+
for (const [vaultIndex, vaultAddress] of vaults.entries()) {
|
90
|
+
let underlying = NULL_ADDRESS;
|
91
|
+
let symbolUnderlying = "ETH";
|
92
|
+
let decimalsUnderlying = 18;
|
93
|
+
if (!resUnderlying[vaultIndex].success || resUnderlying[vaultIndex].returnData === "0x") {
|
94
|
+
// const message = `Failed to fetch underlying of ${vaultAddress}`;
|
95
|
+
// log.warn(message);
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
underlying = CTokenInterface.decodeFunctionResult("underlying", resUnderlying[vaultIndex].returnData)[0];
|
99
|
+
}
|
100
|
+
if (res[index + 2].returnData !== "0x") {
|
101
|
+
symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", res[index + 2].returnData)[0];
|
102
|
+
}
|
103
|
+
if (res[index + 3].returnData !== "0x") {
|
104
|
+
decimalsUnderlying = ERC20Interface.decodeFunctionResult("decimals", res[index + 3].returnData)[0];
|
105
|
+
}
|
106
|
+
const symbolCToken = CTokenInterface.decodeFunctionResult("symbol", res[index].returnData)[0];
|
107
|
+
const decimalsCToken = CTokenInterface.decodeFunctionResult("decimals", res[index + 1].returnData)[0];
|
108
|
+
compoundVaults[key].push({
|
109
|
+
address: vaultAddress,
|
110
|
+
symbolCToken: symbolCToken,
|
111
|
+
underlying: underlying,
|
112
|
+
decimalsCToken: decimalsCToken,
|
113
|
+
symbolUnderlying: symbolUnderlying,
|
114
|
+
decimalsUnderlying: decimalsUnderlying,
|
115
|
+
});
|
116
|
+
index += 4;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
return compoundVaults;
|
121
|
+
}
|
122
|
+
export const getCompoundV2ForksVaultsWithCache = async () => await Redis.getOrSet("CompoundV2ForksVaults", getCompoundV2ForksVaults);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { log } from "../../../utils/logger";
|
2
|
+
// Connect to network
|
3
|
+
// Binary search to find the block where the contract code was first deployed
|
4
|
+
async function binarySearchContractCreation(provider, contractAddress, startBlock, endBlock) {
|
5
|
+
while (startBlock <= endBlock) {
|
6
|
+
const midBlock = Math.floor((startBlock + endBlock) / 2);
|
7
|
+
let code;
|
8
|
+
try {
|
9
|
+
code = await provider.getCode(contractAddress, midBlock);
|
10
|
+
}
|
11
|
+
catch {
|
12
|
+
log.warn("There was an issue with this chain");
|
13
|
+
break;
|
14
|
+
}
|
15
|
+
if (code === "0x") {
|
16
|
+
// Contract doesn't exist yet, search the later half
|
17
|
+
startBlock = midBlock + 1;
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
// Contract exists, search the earlier half
|
21
|
+
endBlock = midBlock - 1;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
// `startBlock` will be the first block where the contract code exists
|
25
|
+
return startBlock - 1;
|
26
|
+
}
|
27
|
+
// Function to find the contract creation transaction
|
28
|
+
export async function getContractCreationBlock(contractAddress, provider) {
|
29
|
+
// Get the contract code at the given address
|
30
|
+
const code = await provider.getCode(contractAddress);
|
31
|
+
// If the contract code is empty, it's not a contract
|
32
|
+
if (code === "0x") {
|
33
|
+
log.warn("This address is not a contract.");
|
34
|
+
throw new Error(`the address providers (${contractAddress}) is not a contract`);
|
35
|
+
}
|
36
|
+
// Binary search for the first block where the contract code exists
|
37
|
+
const currentBlock = await provider.getBlockNumber(); // Latest block
|
38
|
+
const contractCreationBlock = await binarySearchContractCreation(provider, contractAddress, 0, currentBlock);
|
39
|
+
if (contractCreationBlock) {
|
40
|
+
// log.info(`Contract was created in block: ${contractCreationBlock}`);
|
41
|
+
return contractCreationBlock;
|
42
|
+
}
|
43
|
+
log.warn("Contract creation block not found.");
|
44
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Redis } from "../../../cache";
|
2
|
+
import { DOLOMITE_CHAINID, DOLOMITE_MARGIN, DolomiteInterface, DolomiteMargin__factory, ERC20Interface } from "@sdk";
|
3
|
+
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
4
|
+
import { providers } from "../../../utils/providers";
|
5
|
+
export const getDomiteMarkets = async () => {
|
6
|
+
const dolomiteMarginContract = await DolomiteMargin__factory.connect(DOLOMITE_MARGIN, providers[DOLOMITE_CHAINID]);
|
7
|
+
const numMarkets = (await dolomiteMarginContract.getNumMarkets()).toNumber();
|
8
|
+
const calls = [];
|
9
|
+
for (let index = 0; index < numMarkets; index++) {
|
10
|
+
calls.push({
|
11
|
+
allowFailure: true,
|
12
|
+
callData: DolomiteInterface.encodeFunctionData("getMarket", [index]),
|
13
|
+
target: DOLOMITE_MARGIN,
|
14
|
+
});
|
15
|
+
}
|
16
|
+
const res = await batchMulticallCallWithRetry(DOLOMITE_CHAINID, {
|
17
|
+
calls,
|
18
|
+
});
|
19
|
+
if (!res.every(r => r.success)) {
|
20
|
+
throw "Failed to fetch market data for Dolomite";
|
21
|
+
}
|
22
|
+
const markets = [];
|
23
|
+
const secondCalls = [];
|
24
|
+
for (let index = 0; index < numMarkets; index++) {
|
25
|
+
const token = DolomiteInterface.decodeFunctionResult("getMarket", res[index].returnData)[0].token;
|
26
|
+
secondCalls.push({
|
27
|
+
allowFailure: true,
|
28
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
29
|
+
target: token,
|
30
|
+
});
|
31
|
+
}
|
32
|
+
const secondRes = await batchMulticallCallWithRetry(DOLOMITE_CHAINID, {
|
33
|
+
calls: secondCalls,
|
34
|
+
});
|
35
|
+
for (let index = 0; index < numMarkets; index++) {
|
36
|
+
const token = DolomiteInterface.decodeFunctionResult("getMarket", res[index].returnData)[0].token;
|
37
|
+
let symbol = "";
|
38
|
+
try {
|
39
|
+
symbol = ERC20Interface.decodeFunctionResult("symbol", secondRes[index].returnData)[0];
|
40
|
+
}
|
41
|
+
catch { }
|
42
|
+
markets.push({
|
43
|
+
index,
|
44
|
+
token,
|
45
|
+
symbol,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
return markets;
|
49
|
+
};
|
50
|
+
export const getDolomiteMarketWithCache = async () => await Redis.getOrSet("DolomiteMarkets", getDomiteMarkets);
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { Redis } from "../../../cache";
|
2
|
+
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
3
|
+
import { log } from "../../../utils/logger";
|
4
|
+
import { providers } from "../../../utils/providers";
|
5
|
+
import { ChainId, ERC20Interface, EulerEVKInterface, EulerVaultLensInterface, EulerVault__factory, } from "@sdk";
|
6
|
+
import { getAddress } from "ethers/lib/utils";
|
7
|
+
import { fetchEulerVaultName } from "../campaignTypes/ERC20SubTypes/helpers/eulerVaultNames";
|
8
|
+
import { safeFetchLogs } from "./fetchLogs";
|
9
|
+
const VAULT_LENS_ADDRESS = { [ChainId.MAINNET]: "0x57904B4DF131F00DEE9BB75a8FA1D27744035c90" };
|
10
|
+
async function getEulerV2Vaults() {
|
11
|
+
const chainId = ChainId.MAINNET;
|
12
|
+
const fromBlock = 20529207; // EVC contract creation block
|
13
|
+
const toBlock = await providers[chainId].getBlockNumber();
|
14
|
+
const logs = await safeFetchLogs(chainId, [EulerEVKInterface.getEventTopic("EVaultCreated")], [], fromBlock, toBlock);
|
15
|
+
const decodedVaults = await Promise.all(logs.map(async (log) => {
|
16
|
+
const aux = EulerEVKInterface.decodeEventLog("EVaultCreated", log.data, log.topics);
|
17
|
+
const name = (await EulerVault__factory.connect(log.address, providers[chainId]).name()).split(" ");
|
18
|
+
const vaultName = (await fetchEulerVaultName(getAddress(log.address), chainId)) ?? name[name.length - 1];
|
19
|
+
/** Respect the previous typing */
|
20
|
+
return {
|
21
|
+
address: log.address.toString(),
|
22
|
+
asset: aux[1].toString(),
|
23
|
+
chainId: chainId,
|
24
|
+
debtTokenAddress: aux[2].toString(),
|
25
|
+
name: vaultName,
|
26
|
+
};
|
27
|
+
}));
|
28
|
+
log.local(`fetched ${decodedVaults.length} vaults(s) between blocks ${fromBlock} and ${toBlock}`);
|
29
|
+
log.local(`fetched ${decodedVaults.length} vaults(s) between blocks ${fromBlock} and ${toBlock}`);
|
30
|
+
/** Extra calls batch to get the collateral addresses */
|
31
|
+
const resCollat = await batchMulticallCallWithRetry(chainId, {
|
32
|
+
calls: decodedVaults.map(vault => {
|
33
|
+
return {
|
34
|
+
allowFailure: true,
|
35
|
+
callData: EulerVaultLensInterface.encodeFunctionData("getRecognizedCollateralsLTVInfo", [vault.address]),
|
36
|
+
target: VAULT_LENS_ADDRESS[ChainId.MAINNET],
|
37
|
+
};
|
38
|
+
}),
|
39
|
+
});
|
40
|
+
const callsCollatUnderlying = [];
|
41
|
+
const callsCollatUnderlyingSymbol = [];
|
42
|
+
for (const [index, _] of decodedVaults.entries()) {
|
43
|
+
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
44
|
+
for (const collat of collatArray) {
|
45
|
+
callsCollatUnderlying.push({
|
46
|
+
allowFailure: true,
|
47
|
+
callData: EulerEVKInterface.encodeFunctionData("asset"),
|
48
|
+
target: collat.collateral,
|
49
|
+
}, {
|
50
|
+
allowFailure: true,
|
51
|
+
callData: EulerEVKInterface.encodeFunctionData("symbol"),
|
52
|
+
target: collat.collateral,
|
53
|
+
});
|
54
|
+
}
|
55
|
+
}
|
56
|
+
const resCollatUnderlying = await batchMulticallCallWithRetry(ChainId.MAINNET, {
|
57
|
+
calls: callsCollatUnderlying,
|
58
|
+
});
|
59
|
+
for (let i = 0; i < resCollatUnderlying.length; i = i + 2) {
|
60
|
+
const underlyingToken = EulerEVKInterface.decodeFunctionResult("asset", resCollatUnderlying[i].returnData)[0];
|
61
|
+
callsCollatUnderlyingSymbol.push({
|
62
|
+
allowFailure: true,
|
63
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
64
|
+
target: underlyingToken,
|
65
|
+
});
|
66
|
+
}
|
67
|
+
const resCollatUnderlyingSymbol = await batchMulticallCallWithRetry(ChainId.MAINNET, {
|
68
|
+
calls: callsCollatUnderlyingSymbol,
|
69
|
+
});
|
70
|
+
const vaults = (await Promise.all(decodedVaults.map(async (decodedVault, index) => {
|
71
|
+
const collatArray = EulerVaultLensInterface.decodeFunctionResult("getRecognizedCollateralsLTVInfo", resCollat[index].returnData)[0];
|
72
|
+
const collaterals = [];
|
73
|
+
for (const [_index, collat] of collatArray.entries()) {
|
74
|
+
const symbolUnderlying = ERC20Interface.decodeFunctionResult("symbol", resCollatUnderlyingSymbol[_index].returnData)[0];
|
75
|
+
collaterals.push({
|
76
|
+
address: collat.collateral,
|
77
|
+
symbolCollateral: EulerEVKInterface.decodeFunctionResult("symbol", resCollatUnderlying[2 * _index + 1].returnData)[0],
|
78
|
+
symbolUnderlying,
|
79
|
+
borrowLTV: collat.borrowLTV.toString(),
|
80
|
+
nameCollateral: (await fetchEulerVaultName(collat.collateral, chainId)) ?? symbolUnderlying,
|
81
|
+
});
|
82
|
+
}
|
83
|
+
return { ...decodedVault, collaterals };
|
84
|
+
})));
|
85
|
+
return vaults;
|
86
|
+
}
|
87
|
+
export const getEulerV2VaultsWithCache = async () => await Redis.getOrSet("EulerV2Vaults", getEulerV2Vaults);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { engineDbClient } from "../../../utils/prisma";
|
2
|
+
import { apiDbClient } from "src/utils/prisma";
|
3
|
+
export const getLastEligibilityRatio = async (campaign, chainId, currentRoot, backupCampaignIds) => {
|
4
|
+
if (campaign.campaignId === "0x6acb7a8cd2646f18e6e438658273bbee1ed6d664c19779d144cc339decf240ca") {
|
5
|
+
return 2;
|
6
|
+
}
|
7
|
+
let lastEligibilityRatio = 1; // By default it's 1
|
8
|
+
try {
|
9
|
+
const auxLastEligibilityRatioString = (await apiDbClient.rewardBreakdown.findFirst({
|
10
|
+
select: {
|
11
|
+
auxiliaryData1: true,
|
12
|
+
},
|
13
|
+
where: {
|
14
|
+
Reward: {
|
15
|
+
RewardToken: {
|
16
|
+
chainId,
|
17
|
+
},
|
18
|
+
root: currentRoot,
|
19
|
+
},
|
20
|
+
campaignId: campaign.campaignId,
|
21
|
+
},
|
22
|
+
orderBy: {
|
23
|
+
amount: "desc",
|
24
|
+
},
|
25
|
+
}))?.auxiliaryData1;
|
26
|
+
let auxLastEligibilityRatio = !!auxLastEligibilityRatioString
|
27
|
+
? Number.parseFloat(auxLastEligibilityRatioString)
|
28
|
+
: null;
|
29
|
+
// If the last eligibility ratio is 0 it means the campaign do not use eligibility
|
30
|
+
if (auxLastEligibilityRatio === undefined || auxLastEligibilityRatio === null) {
|
31
|
+
// Otherwise we search in the backup campaigns
|
32
|
+
for (const campaignId of backupCampaignIds) {
|
33
|
+
auxLastEligibilityRatio = (await engineDbClient.leaves.findFirst({
|
34
|
+
select: {
|
35
|
+
auxiliaryData1: true,
|
36
|
+
},
|
37
|
+
where: {
|
38
|
+
chainId: chainId,
|
39
|
+
campaignId,
|
40
|
+
root: currentRoot,
|
41
|
+
},
|
42
|
+
}))?.auxiliaryData1?.toNumber();
|
43
|
+
if (!!auxLastEligibilityRatio)
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (!!auxLastEligibilityRatio) {
|
48
|
+
lastEligibilityRatio = auxLastEligibilityRatio * 100;
|
49
|
+
}
|
50
|
+
else if (auxLastEligibilityRatio === 0) {
|
51
|
+
lastEligibilityRatio = 1;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
catch { }
|
55
|
+
return lastEligibilityRatio;
|
56
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { BASE_9, DistributionCreatorInterface, registry, } from "@sdk";
|
2
|
+
import { BigNumber } from "ethers";
|
3
|
+
import { batchMulticallCallWithRetry } from "../utils/generic";
|
4
|
+
export const computeFee = async (chainId, config) => {
|
5
|
+
if (!config.creator) {
|
6
|
+
throw new Error("Creator is required");
|
7
|
+
}
|
8
|
+
const distributionCreator = registry(chainId)?.Merkl?.DistributionCreator;
|
9
|
+
const calls = [
|
10
|
+
{
|
11
|
+
allowFailure: true,
|
12
|
+
target: distributionCreator,
|
13
|
+
callData: DistributionCreatorInterface.encodeFunctionData("campaignSpecificFees", [config.campaignType]),
|
14
|
+
},
|
15
|
+
{
|
16
|
+
allowFailure: true,
|
17
|
+
target: distributionCreator,
|
18
|
+
callData: DistributionCreatorInterface.encodeFunctionData("feeRebate", [config.creator]),
|
19
|
+
},
|
20
|
+
];
|
21
|
+
const result = await batchMulticallCallWithRetry(chainId, {
|
22
|
+
calls,
|
23
|
+
});
|
24
|
+
const campaignSpecificFees = BigNumber.from(DistributionCreatorInterface.decodeFunctionResult("campaignSpecificFees", result[0].returnData)[0]);
|
25
|
+
const feeRebate = BigNumber.from(DistributionCreatorInterface.decodeFunctionResult("feeRebate", result[1].returnData)[0]);
|
26
|
+
const baseFeesValue = campaignSpecificFees.eq("1")
|
27
|
+
? BigNumber.from(0)
|
28
|
+
: campaignSpecificFees.eq("0")
|
29
|
+
? BigNumber.from(30000000)
|
30
|
+
: campaignSpecificFees;
|
31
|
+
return {
|
32
|
+
fee: baseFeesValue.mul(BASE_9.sub(feeRebate)).div(BASE_9).toString(),
|
33
|
+
};
|
34
|
+
};
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { Redis } from "../../cache";
|
2
|
+
import { batchMulticallCallWithRetry } from "../../utils/generic";
|
3
|
+
import { Interface } from "@ethersproject/abi";
|
4
|
+
import { BN2Number, ChainId, ERC20Interface } from "@sdk";
|
5
|
+
import { log } from "../../utils/logger";
|
6
|
+
const stTwtABI = [
|
7
|
+
{
|
8
|
+
constant: true,
|
9
|
+
inputs: [],
|
10
|
+
name: "participantNumber",
|
11
|
+
outputs: [
|
12
|
+
{
|
13
|
+
name: "",
|
14
|
+
type: "uint256",
|
15
|
+
},
|
16
|
+
],
|
17
|
+
payable: false,
|
18
|
+
stateMutability: "view",
|
19
|
+
type: "function",
|
20
|
+
},
|
21
|
+
];
|
22
|
+
const stTwtAddresses = {
|
23
|
+
[ChainId.BSC]: "0x5029f49585D57ed770D2194841B5A0bE06BFc2ED",
|
24
|
+
};
|
25
|
+
const stTwtInterface = new Interface(stTwtABI);
|
26
|
+
export async function getTwtParticipants(chainId) {
|
27
|
+
const tokenAddress = stTwtAddresses[chainId];
|
28
|
+
const calls = [
|
29
|
+
{
|
30
|
+
allowFailure: true,
|
31
|
+
callData: stTwtInterface.encodeFunctionData("participantNumber", []),
|
32
|
+
target: tokenAddress,
|
33
|
+
},
|
34
|
+
{
|
35
|
+
allowFailure: true,
|
36
|
+
callData: ERC20Interface.encodeFunctionData("totalSupply"),
|
37
|
+
target: tokenAddress,
|
38
|
+
},
|
39
|
+
];
|
40
|
+
const result = await batchMulticallCallWithRetry(chainId, { calls });
|
41
|
+
const res = {
|
42
|
+
participants: 0,
|
43
|
+
totalSupply: 0,
|
44
|
+
};
|
45
|
+
try {
|
46
|
+
res.participants = stTwtInterface.decodeFunctionResult("participantNumber", result[0].returnData)[0].toNumber();
|
47
|
+
res.totalSupply = BN2Number(ERC20Interface.decodeFunctionResult("totalSupply", result[1].returnData)[0], 18);
|
48
|
+
}
|
49
|
+
catch (_error) {
|
50
|
+
log.local(`❌ Failed to call participantNumber for ${tokenAddress} on ${chainId}`);
|
51
|
+
}
|
52
|
+
return res;
|
53
|
+
}
|
54
|
+
export const getTwtParticipantsWithCache = async (chainId) => await Redis.getOrSet(`TwtParticipants_${chainId}`, getTwtParticipants, chainId);
|