@merkl/api 0.10.128 → 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,184 @@
|
|
1
|
+
import { Redis } from "../../cache";
|
2
|
+
import { RewardConvertorService } from "../../modules/v4/reward/rewardConvertor.service";
|
3
|
+
import { AMM, ANGLE_NETWORKS, Campaign, NETWORK_LABELS, } from "@sdk";
|
4
|
+
import Big from "big.js";
|
5
|
+
import { utils } from "ethers";
|
6
|
+
import { log } from "../../utils/logger";
|
7
|
+
const fetchCachedData = async (chainIds, onlyLive) => {
|
8
|
+
if (onlyLive === undefined) {
|
9
|
+
onlyLive = false;
|
10
|
+
}
|
11
|
+
const cacheKeys = chainIds.map(chainId => onlyLive ? `LiveCampaignsOldFormat_${chainId}` : `CampaignsOldFormat_${chainId}`);
|
12
|
+
return await Redis.getMany(cacheKeys);
|
13
|
+
};
|
14
|
+
export async function getClamsInfo(chainIds, AMMs, user, onlyLive) {
|
15
|
+
if (!chainIds && !user && !AMMs) {
|
16
|
+
const cachedData = await fetchCachedData(ANGLE_NETWORKS.merkl);
|
17
|
+
const result = ANGLE_NETWORKS.merkl.reduce((acc, chainId, index) => {
|
18
|
+
if (!cachedData[index]) {
|
19
|
+
log.error("Merkl cache", `Data for ${NETWORK_LABELS[chainId]} not found in cache`);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
acc[chainId] = cachedData[index];
|
23
|
+
}
|
24
|
+
return acc;
|
25
|
+
}, {});
|
26
|
+
return result;
|
27
|
+
}
|
28
|
+
if (!chainIds) {
|
29
|
+
chainIds = ANGLE_NETWORKS.merkl;
|
30
|
+
}
|
31
|
+
if (onlyLive === undefined) {
|
32
|
+
onlyLive = false;
|
33
|
+
}
|
34
|
+
const cachedData = await fetchCachedData(chainIds, onlyLive);
|
35
|
+
let chainData = [];
|
36
|
+
if (!!user) {
|
37
|
+
chainData = await Redis.getMany(chainIds.map(chainId => `MerklChainData_${chainId}`));
|
38
|
+
}
|
39
|
+
/** Parallel computation of data for each chain */
|
40
|
+
const result = {};
|
41
|
+
const promises = chainIds.map((chainId, index) => (async () => {
|
42
|
+
if (!cachedData[index]) {
|
43
|
+
log.error("Merkl cache", `Data for ${NETWORK_LABELS[chainId]} not found in cache`);
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
log.local(`Redis: ${Object.keys(cachedData[index]?.pools ?? {}).length} pools found on ${NETWORK_LABELS[chainId]}`);
|
47
|
+
/** Filter pools if an AMM filter is required */
|
48
|
+
const filteredPools = {};
|
49
|
+
for (const key of Object.keys(cachedData[index]?.pools ?? {})) {
|
50
|
+
if (!!AMMs &&
|
51
|
+
AMMs.length > 0 &&
|
52
|
+
!!AMM[cachedData[index].pools[key].amm] &&
|
53
|
+
AMMs.indexOf(AMM[cachedData[index].pools[key].amm].toLowerCase()) === -1) {
|
54
|
+
continue;
|
55
|
+
}
|
56
|
+
filteredPools[key] = cachedData[index].pools[key];
|
57
|
+
}
|
58
|
+
cachedData[index].pools = filteredPools;
|
59
|
+
/** Fetch user specific data */
|
60
|
+
if (!!user &&
|
61
|
+
utils.isAddress(user) &&
|
62
|
+
utils.getAddress(user) !== "0xeeeeeEAaAeEEeEEeEeEEEeEEeEeEEEeeeEeeeEee" &&
|
63
|
+
!!cachedData[index].merkleRoot) {
|
64
|
+
cachedData[index] = await RewardConvertorService.convertV4toMerklV2(user, chainId, cachedData[index]);
|
65
|
+
log.local(`Merkl: ${Object.keys(cachedData[index]?.pools ?? {}).filter(k => cachedData[index].pools[k].userBalanceToken0 > 0 ||
|
66
|
+
cachedData[index].pools[k].userBalanceToken1 > 0).length} pool with a user position found on ${NETWORK_LABELS[chainId]}`);
|
67
|
+
}
|
68
|
+
/** Fill result */
|
69
|
+
result[chainId] = cachedData[index];
|
70
|
+
})());
|
71
|
+
await Promise.all(promises);
|
72
|
+
return result;
|
73
|
+
}
|
74
|
+
export function campaignsToOldFormat(campaignData, merklChainData) {
|
75
|
+
const res = {};
|
76
|
+
res.merkleRoot = merklChainData.merkleRoot;
|
77
|
+
res.message = merklChainData.message;
|
78
|
+
res.validRewardTokens = merklChainData.validRewardTokens;
|
79
|
+
res.pools = {};
|
80
|
+
const pools = {};
|
81
|
+
for (const [type_mainParameter, campaigns] of Object.entries(campaignData)) {
|
82
|
+
// if not a CLAMM campaign, skip
|
83
|
+
if (!type_mainParameter.startsWith("2_")) {
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
const mainParameter = type_mainParameter.split("_")[1];
|
87
|
+
for (const campaign of Object.values(campaigns)) {
|
88
|
+
if (campaign.campaignType !== Campaign.CLAMM) {
|
89
|
+
continue;
|
90
|
+
}
|
91
|
+
if (!pools[mainParameter]) {
|
92
|
+
pools[mainParameter] = {
|
93
|
+
alm: campaign.forwarders?.reduce((prev, curr) => {
|
94
|
+
if (!prev[utils.getAddress(curr.almAddress)]) {
|
95
|
+
prev[utils.getAddress(curr.almAddress)] = {
|
96
|
+
...curr,
|
97
|
+
almAddress: utils.getAddress(curr.almAddress),
|
98
|
+
};
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
prev[utils.getAddress(curr.almAddress)].almAPR =
|
102
|
+
(!!prev[utils.getAddress(curr.almAddress)].almAPR
|
103
|
+
? prev[utils.getAddress(curr.almAddress)].almAPR
|
104
|
+
: 0) + (curr.almAPR ?? 0);
|
105
|
+
}
|
106
|
+
return prev;
|
107
|
+
}, {}),
|
108
|
+
amm: campaign.amm,
|
109
|
+
ammAlgo: campaign.ammAlgo,
|
110
|
+
ammAlgoName: campaign.ammAlgoName,
|
111
|
+
ammName: campaign.ammName,
|
112
|
+
aprs: campaign.aprs,
|
113
|
+
chainId: campaign.chainId,
|
114
|
+
decimalsToken0: campaign.campaignParameters.decimalsToken0,
|
115
|
+
decimalsToken1: campaign.campaignParameters.decimalsToken1,
|
116
|
+
disputeLive: merklChainData.disputeLive,
|
117
|
+
distributionData: [],
|
118
|
+
endOfDisputePeriod: merklChainData.endOfDisputePeriod,
|
119
|
+
meanAPR: campaign.apr,
|
120
|
+
pool: campaign.campaignParameters.poolAddress,
|
121
|
+
poolBalanceToken0: campaign.poolBalanceToken0,
|
122
|
+
poolBalanceToken1: campaign.poolBalanceToken1,
|
123
|
+
poolFee: Number.parseFloat(campaign.campaignParameters.poolFee),
|
124
|
+
poolTotalLiquidity: campaign.poolTotalLiquidity,
|
125
|
+
rewardsPerToken: {},
|
126
|
+
symbolToken0: campaign.campaignParameters.symbolToken0,
|
127
|
+
symbolToken1: campaign.campaignParameters.symbolToken1,
|
128
|
+
tick: campaign.tick,
|
129
|
+
token0: campaign.campaignParameters.token0,
|
130
|
+
token1: campaign.campaignParameters.token1,
|
131
|
+
tvl: campaign.tvl,
|
132
|
+
};
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
pools[mainParameter].meanAPR += campaign.apr;
|
136
|
+
if (!!campaign.aprs) {
|
137
|
+
for (const [key, value] of Object.entries(campaign.aprs)) {
|
138
|
+
pools[mainParameter].aprs[key] =
|
139
|
+
(!!pools[mainParameter].aprs[key] ? pools[mainParameter].aprs[key] : 0) + (value ?? 0);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
if (!!campaign.forwarders) {
|
143
|
+
for (const almDetails of campaign.forwarders) {
|
144
|
+
if (!pools[mainParameter]?.alm?.[utils.getAddress(almDetails.almAddress)]) {
|
145
|
+
pools[mainParameter].alm[utils.getAddress(almDetails.almAddress)] = almDetails;
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
pools[mainParameter].alm[utils.getAddress(almDetails.almAddress)].almAPR =
|
149
|
+
(!!pools[mainParameter].alm[utils.getAddress(almDetails.almAddress)].almAPR
|
150
|
+
? pools[mainParameter].alm[utils.getAddress(almDetails.almAddress)].almAPR
|
151
|
+
: 0) + (almDetails.almAPR ?? 0);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
const amountDecimal = Number.parseFloat(new Big(campaign.amount).div(new Big(10).pow(campaign.campaignParameters.decimalsRewardToken)).toString());
|
157
|
+
pools[mainParameter].distributionData.push({
|
158
|
+
amount: amountDecimal,
|
159
|
+
apr: campaign?.apr,
|
160
|
+
blacklist: campaign.campaignParameters.blacklist,
|
161
|
+
blacklistedBalance0: campaign.blacklistedBalance0,
|
162
|
+
blacklistedBalance1: campaign.blacklistedBalance1,
|
163
|
+
blacklistedLiquidity: campaign.blacklistedLiquidity,
|
164
|
+
breakdown: {},
|
165
|
+
decimalsRewardToken: campaign.campaignParameters.decimalsRewardToken,
|
166
|
+
endTimestamp: campaign.endTimestamp,
|
167
|
+
id: campaign.campaignId,
|
168
|
+
isLive: campaign.isLive,
|
169
|
+
isMock: campaign.isMock,
|
170
|
+
isOutOfRangeIncentivized: campaign.campaignParameters.isOutOfRangeIncentivized,
|
171
|
+
propFees: campaign.campaignParameters.weightFees / 100,
|
172
|
+
propToken0: campaign.campaignParameters.weightToken0 / 100,
|
173
|
+
propToken1: campaign.campaignParameters.weightToken1 / 100,
|
174
|
+
rewardToken: campaign.rewardToken,
|
175
|
+
startTimestamp: campaign.startTimestamp,
|
176
|
+
symbolRewardToken: campaign.campaignParameters.symbolRewardToken,
|
177
|
+
unclaimed: 0,
|
178
|
+
whitelist: campaign.campaignParameters.whitelist,
|
179
|
+
});
|
180
|
+
}
|
181
|
+
res.pools = pools;
|
182
|
+
}
|
183
|
+
return res;
|
184
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Redis } from "../cache";
|
2
|
+
import { engineDbClient } from "../utils/prisma";
|
3
|
+
import axios from "axios";
|
4
|
+
import { log } from "../utils/logger";
|
5
|
+
async function getTokensList() {
|
6
|
+
let res = {};
|
7
|
+
try {
|
8
|
+
res = (await axios.get("https://raw.githubusercontent.com/AngleProtocol/angle-token-list/main/ERC20_LIST.json", {
|
9
|
+
timeout: 5000,
|
10
|
+
})).data[0];
|
11
|
+
}
|
12
|
+
catch (e) {
|
13
|
+
log.error("getTokensList failed", e);
|
14
|
+
}
|
15
|
+
return res;
|
16
|
+
}
|
17
|
+
export const getTokensListWithCache = async () => await Redis.getOrSet("TokenList", getTokensList);
|
18
|
+
export async function getMerklTokenList(chainId) {
|
19
|
+
const tokensRaws = await engineDbClient.tokens.findMany({
|
20
|
+
select: {
|
21
|
+
address: true,
|
22
|
+
decimals: true,
|
23
|
+
symbol: true,
|
24
|
+
},
|
25
|
+
where: {
|
26
|
+
chainId,
|
27
|
+
},
|
28
|
+
});
|
29
|
+
const tokens = {};
|
30
|
+
for (const token of tokensRaws) {
|
31
|
+
tokens[token.address] = {
|
32
|
+
decimals: token.decimals,
|
33
|
+
symbol: token.symbol,
|
34
|
+
};
|
35
|
+
}
|
36
|
+
return tokens;
|
37
|
+
}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
import { Redis } from "../cache";
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
3
|
+
import { BN2Number, DistributionCreator__factory, Distributor__factory, NETWORK_LABELS, NULL_ADDRESS, registry, } from "@sdk";
|
4
|
+
import { batchMulticallCallWithRetry } from "../utils/generic";
|
5
|
+
import { getMerklTokenList, getTokensListWithCache } from "./getTokensList";
|
6
|
+
const DistributorInterface = Distributor__factory.createInterface();
|
7
|
+
const DistributorCreatorInterface = DistributionCreator__factory.createInterface();
|
8
|
+
const MTW_INTERFACE = new Interface([
|
9
|
+
"function isTokenWrapper() pure returns (bool)",
|
10
|
+
"function token() external view returns (address)",
|
11
|
+
]);
|
12
|
+
export async function merklChainData(chainId) {
|
13
|
+
const tokens = await getMerklTokenList(chainId);
|
14
|
+
const distributorAddress = registry(chainId)?.Merkl?.Distributor;
|
15
|
+
const distributionCreatorAddress = registry(chainId)?.Merkl?.DistributionCreator;
|
16
|
+
if (!distributorAddress || !distributionCreatorAddress) {
|
17
|
+
throw `Cannot find distributor or distribution creator address for chain ${NETWORK_LABELS[chainId]}`;
|
18
|
+
}
|
19
|
+
const calls = [
|
20
|
+
{
|
21
|
+
allowFailure: false,
|
22
|
+
callData: DistributorInterface.encodeFunctionData("getMerkleRoot"),
|
23
|
+
target: distributorAddress,
|
24
|
+
},
|
25
|
+
{
|
26
|
+
allowFailure: false,
|
27
|
+
callData: DistributorInterface.encodeFunctionData("tree"),
|
28
|
+
target: distributorAddress,
|
29
|
+
},
|
30
|
+
{
|
31
|
+
allowFailure: false,
|
32
|
+
callData: DistributorInterface.encodeFunctionData("lastTree"),
|
33
|
+
target: distributorAddress,
|
34
|
+
},
|
35
|
+
{
|
36
|
+
allowFailure: false,
|
37
|
+
callData: DistributorInterface.encodeFunctionData("endOfDisputePeriod"),
|
38
|
+
target: distributorAddress,
|
39
|
+
},
|
40
|
+
{
|
41
|
+
allowFailure: false,
|
42
|
+
callData: DistributorInterface.encodeFunctionData("disputer"),
|
43
|
+
target: distributorAddress,
|
44
|
+
},
|
45
|
+
{
|
46
|
+
allowFailure: true,
|
47
|
+
callData: DistributorCreatorInterface.encodeFunctionData("message"),
|
48
|
+
target: distributionCreatorAddress,
|
49
|
+
},
|
50
|
+
{
|
51
|
+
allowFailure: true,
|
52
|
+
callData: DistributorCreatorInterface.encodeFunctionData("getValidRewardTokens()"),
|
53
|
+
target: distributionCreatorAddress,
|
54
|
+
},
|
55
|
+
];
|
56
|
+
const result = await batchMulticallCallWithRetry(chainId, { calls });
|
57
|
+
const tokenList = await getTokensListWithCache();
|
58
|
+
let i = 0;
|
59
|
+
const merkleRoot = DistributorInterface.decodeFunctionResult("getMerkleRoot", result[i++].returnData)[0]?.toString();
|
60
|
+
const treeRoot = DistributorInterface.decodeFunctionResult("tree", result[i++].returnData)[0].toString();
|
61
|
+
const lastTreeRoot = DistributorInterface.decodeFunctionResult("lastTree", result[i++].returnData)[0]?.toString();
|
62
|
+
const endOfDisputePeriod = BN2Number(DistributorInterface.decodeFunctionResult("endOfDisputePeriod", result[i++].returnData)[0], 0);
|
63
|
+
const disputeLive = DistributorInterface.decodeFunctionResult("disputer", result[i++].returnData)[0] !== NULL_ADDRESS;
|
64
|
+
const message = DistributorCreatorInterface.decodeFunctionResult("message", result[i++].returnData)[0]?.toString();
|
65
|
+
const validRewardTokens = DistributorCreatorInterface.decodeFunctionResult("getValidRewardTokens()", result[i++].returnData)[0].map((t) => {
|
66
|
+
const decimals = tokens[t.token]?.decimals
|
67
|
+
? tokens[t.token]?.decimals
|
68
|
+
: tokenList[chainId]?.[t.token]?.decimals
|
69
|
+
? tokenList[chainId][t.token].decimals
|
70
|
+
: undefined;
|
71
|
+
const symbol = tokens[t.token]?.symbol
|
72
|
+
? tokens[t.token]?.symbol
|
73
|
+
: tokenList[chainId]?.[t.token]?.symbol
|
74
|
+
? tokenList[chainId][t.token].symbol
|
75
|
+
: undefined;
|
76
|
+
return {
|
77
|
+
decimals: decimals,
|
78
|
+
minimumAmountPerEpoch: decimals
|
79
|
+
? BN2Number(t.minimumAmountPerEpoch, decimals)
|
80
|
+
: BN2Number(t.minimumAmountPerEpoch),
|
81
|
+
symbol: symbol,
|
82
|
+
token: t.token,
|
83
|
+
};
|
84
|
+
});
|
85
|
+
const missingSymbols = validRewardTokens.filter(t => !t.symbol || !t.decimals);
|
86
|
+
for (const token of missingSymbols) {
|
87
|
+
if (!tokenList[chainId])
|
88
|
+
continue;
|
89
|
+
const tokenInfo = tokenList[chainId][token.token];
|
90
|
+
if (!tokenInfo)
|
91
|
+
continue;
|
92
|
+
token.symbol = tokenInfo.symbol;
|
93
|
+
token.decimals = tokenInfo.decimals;
|
94
|
+
token.minimumAmountPerEpoch = BN2Number(token.minimumAmountPerEpoch, tokenInfo.decimals);
|
95
|
+
}
|
96
|
+
const validRewardTokensCalls = validRewardTokens.reduce((acc, t) => {
|
97
|
+
acc.push({
|
98
|
+
allowFailure: true,
|
99
|
+
target: t.token,
|
100
|
+
callData: MTW_INTERFACE.encodeFunctionData("isTokenWrapper"),
|
101
|
+
});
|
102
|
+
acc.push({
|
103
|
+
allowFailure: true,
|
104
|
+
target: t.token,
|
105
|
+
callData: MTW_INTERFACE.encodeFunctionData("token"),
|
106
|
+
});
|
107
|
+
return acc;
|
108
|
+
}, []);
|
109
|
+
const validRewardTokenRes = await batchMulticallCallWithRetry(chainId, { calls: validRewardTokensCalls });
|
110
|
+
for (let index = 0; index < validRewardTokens.length; index++) {
|
111
|
+
try {
|
112
|
+
if (validRewardTokenRes[2 * index][0] &&
|
113
|
+
MTW_INTERFACE.decodeFunctionResult("isTokenWrapper", validRewardTokenRes[2 * index][1])[0]) {
|
114
|
+
validRewardTokens[index].isTokenWrapper = MTW_INTERFACE.decodeFunctionResult("token", validRewardTokenRes[2 * index + 1][1])[0];
|
115
|
+
}
|
116
|
+
}
|
117
|
+
catch { }
|
118
|
+
}
|
119
|
+
return {
|
120
|
+
disputeLive,
|
121
|
+
endOfDisputePeriod,
|
122
|
+
merkleRoot,
|
123
|
+
treeRoot,
|
124
|
+
lastTreeRoot,
|
125
|
+
message,
|
126
|
+
validRewardTokens,
|
127
|
+
};
|
128
|
+
}
|
129
|
+
export const merklChainDataWithCache = async (chainId) => await Redis.getOrSet(`MerklChainData_${chainId}`, merklChainData, chainId);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Redis } from "../../cache";
|
2
|
+
import { hashArray } from "../../utils/hashArray";
|
3
|
+
import { getMorphoMarkets, getRadiantMarkets, getSiloMarkets } from "@sdk";
|
4
|
+
export const getMorphoMarketsWithCache = async (chainId, subtype) => {
|
5
|
+
return await Redis.getOrSet(`MorphoMarkets_${hashArray([chainId, subtype])}`, getMorphoMarkets, chainId, subtype);
|
6
|
+
};
|
7
|
+
export const getRadiantMarketsWithCache = async (chainId, poolAddressProvider) => await Redis.getOrSet(`RadiantMarkets_${hashArray(chainId, poolAddressProvider)}$`, getRadiantMarkets, chainId, poolAddressProvider);
|
8
|
+
export const getSiloMarketsWithCache = async (chainId, repository) => await Redis.getOrSet(`SiloMarkets_${hashArray([chainId, repository])}`, getSiloMarkets, chainId, repository);
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
2
|
+
import { AjnaSubCampaignType, BN2Number, NETWORK_LABELS, PoolInfoUtilsInterface, } from "@sdk";
|
3
|
+
import { POOL_INFO_UTILS } from "@sdk";
|
4
|
+
import axios from "axios";
|
5
|
+
export async function getAjnaUserPositions(user, _chainId, campaigns) {
|
6
|
+
/**
|
7
|
+
* Fetch user positions
|
8
|
+
*/
|
9
|
+
const calls = [];
|
10
|
+
for (const campaign of Object.values(campaigns)) {
|
11
|
+
if (campaign.subtype === AjnaSubCampaignType.lend) {
|
12
|
+
calls.push({
|
13
|
+
allowFailure: true,
|
14
|
+
callData: PoolInfoUtilsInterface.encodeFunctionData("poolPricesInfo", [campaign.poolId]),
|
15
|
+
target: POOL_INFO_UTILS[_chainId],
|
16
|
+
});
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
calls.push({
|
20
|
+
allowFailure: true,
|
21
|
+
callData: PoolInfoUtilsInterface.encodeFunctionData("borrowerInfo", [campaign.poolId, user]),
|
22
|
+
target: POOL_INFO_UTILS[_chainId],
|
23
|
+
});
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return {
|
27
|
+
cached: false,
|
28
|
+
call: {
|
29
|
+
callData: calls,
|
30
|
+
handler: () => { },
|
31
|
+
reducer: async (result) => {
|
32
|
+
const finalRes = {};
|
33
|
+
const resCalls = await batchMulticallCallWithRetry(_chainId, {
|
34
|
+
calls,
|
35
|
+
});
|
36
|
+
for (const [index, campaignId] of Object.keys(campaigns).entries()) {
|
37
|
+
let userSupply = 0;
|
38
|
+
const res = {
|
39
|
+
userPositions: [],
|
40
|
+
decimals: campaigns[campaignId].decimals,
|
41
|
+
totalSupply: campaigns[campaignId].computedtotalSupply,
|
42
|
+
userTVL: 0,
|
43
|
+
};
|
44
|
+
const resAjna = await axios.get(`https://ajna-api.blockanalitica.com/v4/${NETWORK_LABELS[_chainId].toLowerCase()}/wallets/${user.toLowerCase()}/pools/${campaigns[campaignId].poolId.toLowerCase()}/buckets/?p=1&p_size=50`);
|
45
|
+
if (resAjna.data.count === 0) {
|
46
|
+
res.userTVL = 0;
|
47
|
+
userSupply = 0;
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
if (campaigns[campaignId].subtype === AjnaSubCampaignType.lend) {
|
51
|
+
const htpIndex = PoolInfoUtilsInterface.decodeFunctionResult("poolPricesInfo", resCalls[index].returnData)[3];
|
52
|
+
const lupIndex = PoolInfoUtilsInterface.decodeFunctionResult("poolPricesInfo", resCalls[index].returnData)[5];
|
53
|
+
const threshold = BN2Number(BN2Number(lupIndex, 0) === 0 ? lupIndex : lupIndex.gt(htpIndex) ? lupIndex.add(22) : htpIndex.add(22), 0);
|
54
|
+
let nextRoute = null;
|
55
|
+
if (!!resAjna.data.next) {
|
56
|
+
nextRoute = `https://${resAjna.data.next.slice(resAjna.data.next.indexOf(":") + 1)}`;
|
57
|
+
}
|
58
|
+
let position;
|
59
|
+
for (position of resAjna.data.results) {
|
60
|
+
if (position.bucket_index < threshold) {
|
61
|
+
res.userTVL += Number(position.deposit);
|
62
|
+
userSupply += Number(position.deposit);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
while (nextRoute !== null) {
|
66
|
+
const resNext = await axios.get(nextRoute);
|
67
|
+
let position;
|
68
|
+
for (position of resNext.data.results) {
|
69
|
+
if (position.bucket_index < threshold) {
|
70
|
+
res.userTVL += Number(position.deposit);
|
71
|
+
userSupply += Number(position.deposit);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
if (!!resNext.data.next) {
|
75
|
+
nextRoute = `https://${resNext.data.next.slice(resNext.data.next.indexOf(":") + 1)}`;
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
nextRoute = null;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
userSupply = BN2Number(PoolInfoUtilsInterface.decodeFunctionResult("borrowerInfo", resCalls[index].returnData)[0], 18);
|
84
|
+
res.userTVL = BN2Number(PoolInfoUtilsInterface.decodeFunctionResult("borrowerInfo", resCalls[index].returnData)[0], 18);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
/////
|
88
|
+
if (userSupply > 0) {
|
89
|
+
res.userPositions.push({
|
90
|
+
balance: userSupply,
|
91
|
+
token: campaigns[campaignId].quoteToken,
|
92
|
+
origin: "Direct",
|
93
|
+
totalSupply: campaigns[campaignId].computedtotalSupply,
|
94
|
+
tvl: campaigns[campaignId].tvl,
|
95
|
+
});
|
96
|
+
// to modify
|
97
|
+
}
|
98
|
+
// Add to final result if there are positions
|
99
|
+
if (res.userPositions.length > 0) {
|
100
|
+
finalRes[`11_${campaignId}`] = { ...res };
|
101
|
+
}
|
102
|
+
}
|
103
|
+
return finalRes;
|
104
|
+
},
|
105
|
+
},
|
106
|
+
};
|
107
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { CDPMANAGER_ADDRESS, SORTEDCDPS_ADDRESS } from "../../../constants";
|
2
|
+
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
3
|
+
import { BN2Number, CdpManagerInterface, SortedCdpsInterface } from "@sdk";
|
4
|
+
export async function getBadgerUserPositions(user, _chainId, campaigns) {
|
5
|
+
/**
|
6
|
+
* Fetch user positions
|
7
|
+
*/
|
8
|
+
const calls = [];
|
9
|
+
calls.push({
|
10
|
+
allowFailure: false,
|
11
|
+
callData: CdpManagerInterface.encodeFunctionData("getSystemDebt"),
|
12
|
+
target: CDPMANAGER_ADDRESS,
|
13
|
+
});
|
14
|
+
return {
|
15
|
+
cached: false,
|
16
|
+
call: {
|
17
|
+
callData: calls,
|
18
|
+
handler: () => { },
|
19
|
+
reducer: async (result) => {
|
20
|
+
const finalRes = {};
|
21
|
+
const totalSupplyEBTC = BN2Number(CdpManagerInterface.decodeFunctionResult("getSystemDebt", result[0])[0], 18);
|
22
|
+
for (const campaignId of Object.keys(campaigns)) {
|
23
|
+
let calls = [];
|
24
|
+
let userSupply = 0;
|
25
|
+
const totalSupply = totalSupplyEBTC;
|
26
|
+
const res = {
|
27
|
+
userPositions: [],
|
28
|
+
decimals: campaigns[campaignId].decimals,
|
29
|
+
totalSupply: totalSupplyEBTC,
|
30
|
+
userTVL: 0,
|
31
|
+
};
|
32
|
+
calls.push({
|
33
|
+
allowFailure: false,
|
34
|
+
callData: SortedCdpsInterface.encodeFunctionData("getCdpsOf", [user]),
|
35
|
+
target: SORTEDCDPS_ADDRESS,
|
36
|
+
});
|
37
|
+
const resCdps = await batchMulticallCallWithRetry(_chainId, {
|
38
|
+
calls,
|
39
|
+
});
|
40
|
+
calls = [];
|
41
|
+
for (const res of resCdps) {
|
42
|
+
const cdp = SortedCdpsInterface.decodeFunctionResult("getCdpsOf", res.returnData)[0];
|
43
|
+
if (cdp.length !== 0) {
|
44
|
+
calls.push({
|
45
|
+
allowFailure: false,
|
46
|
+
callData: CdpManagerInterface.encodeFunctionData("Cdps", cdp),
|
47
|
+
target: CDPMANAGER_ADDRESS,
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}
|
51
|
+
const resRecipient = await batchMulticallCallWithRetry(_chainId, {
|
52
|
+
calls,
|
53
|
+
});
|
54
|
+
for (const res of resRecipient) {
|
55
|
+
const cdpSupply = CdpManagerInterface.decodeFunctionResult("Cdps", res.returnData)[0];
|
56
|
+
userSupply += BN2Number(cdpSupply, campaigns[campaignId].decimals);
|
57
|
+
}
|
58
|
+
let i = 0;
|
59
|
+
if (userSupply > 0) {
|
60
|
+
res.userPositions.push({
|
61
|
+
balance: userSupply,
|
62
|
+
token: campaigns[campaignId].targetToken,
|
63
|
+
origin: "Direct",
|
64
|
+
totalSupply: totalSupply,
|
65
|
+
tvl: campaigns[campaignId].tvl,
|
66
|
+
});
|
67
|
+
// to modify
|
68
|
+
}
|
69
|
+
// Add to final result if there are positions
|
70
|
+
if (res.userPositions.length > 0) {
|
71
|
+
finalRes[`9_${campaignId}`] = { ...res };
|
72
|
+
}
|
73
|
+
i++;
|
74
|
+
}
|
75
|
+
return finalRes;
|
76
|
+
},
|
77
|
+
},
|
78
|
+
};
|
79
|
+
}
|