Skip to content

Commit

Permalink
Cache api clean up (#4035)
Browse files Browse the repository at this point in the history
* Cache api clean up

* lint fix
  • Loading branch information
piekczyk authored Sep 26, 2024
1 parent 91415f3 commit 8be1fe6
Show file tree
Hide file tree
Showing 17 changed files with 8 additions and 2,071 deletions.
1 change: 0 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ REFERRAL_SUBGRAPH_URL=""

AAVE_SUBGRAPH_URL=""
AAVE_OPTIMISM_SUBGRAPH_URL=""
MAINNET_CACHE_URL="https://cache-mainnet-staging.staging.summer.fi/api/v1"

GROOVE_WIDGET_ID=

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/aws-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
--build-arg AJNA_SUBGRAPH_V2_URL_GOERLI=${{ secrets.AJNA_SUBGRAPH_V2_URL_GOERLI }} \
--build-arg MIXPANEL_ENV=production \
--build-arg MIXPANEL_KEY=${{ secrets.MIXPANEL_KEY_PROD }} \
--build-arg MAINNET_CACHE_URL=${{ secrets.MAINNET_CACHE_URL_PROD }} \
--build-arg INFURA_PROJECT_ID=${{ secrets.INFURA_PROJECT_ID_PROD }} \
--build-arg ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }} \
--build-arg BLOCKNATIVE_API_KEY=${{ secrets.BLOCKNATIVE_API_KEY_PROD }} \
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/aws-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
BLOCKNATIVE_API_KEY_STAGING: ${{ secrets.BLOCKNATIVE_API_KEY_STAGING }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
INFURA_PROJECT_ID_STAGING: ${{ secrets.INFURA_PROJECT_ID_STAGING }}
MAINNET_CACHE_URL_STAGING: ${{ secrets.MAINNET_CACHE_URL_STAGING }}
MIXPANEL_KEY_STAGING: ${{ secrets.MIXPANEL_KEY_STAGING }}
ONE_INCH_API_KEY_STAGING: ${{ secrets.ONE_INCH_API_KEY_STAGING }}
ONE_INCH_API_URL_STAGING: ${{ secrets.ONE_INCH_API_URL_STAGING }}
Expand All @@ -46,7 +45,7 @@ jobs:
NEWSLETTER_PUBLICATION_ID: ${{ secrets.NEWSLETTER_PUBLICATION_ID }}
NEWSLETTER_ENDPOINT: ${{ secrets.NEWSLETTER_ENDPOINT }}
run: |
required_secrets=("AJNA_SUBGRAPH_URL_STAGING" "AJNA_SUBGRAPH_URL_GOERLI" "AJNA_SUBGRAPH_V2_URL_STAGING" "AJNA_SUBGRAPH_V2_URL_GOERLI" "MIXPANEL_KEY_STAGING" "MAINNET_CACHE_URL_STAGING" "INFURA_PROJECT_ID_STAGING" "ETHERSCAN_API_KEY" "BLOCKNATIVE_API_KEY_STAGING" "SENTRY_AUTH_TOKEN" "PRODUCT_HUB_KEY" "ONE_INCH_API_KEY_STAGING" "ONE_INCH_API_URL_STAGING" "REFERRAL_SUBGRAPH_URL_STAGING" "NEWSLETTER_API_KEY" "NEWSLETTER_PUBLICATION_ID" "NEWSLETTER_ENDPOINT")
required_secrets=("AJNA_SUBGRAPH_URL_STAGING" "AJNA_SUBGRAPH_URL_GOERLI" "AJNA_SUBGRAPH_V2_URL_STAGING" "AJNA_SUBGRAPH_V2_URL_GOERLI" "MIXPANEL_KEY_STAGING" "INFURA_PROJECT_ID_STAGING" "ETHERSCAN_API_KEY" "BLOCKNATIVE_API_KEY_STAGING" "SENTRY_AUTH_TOKEN" "PRODUCT_HUB_KEY" "ONE_INCH_API_KEY_STAGING" "ONE_INCH_API_URL_STAGING" "REFERRAL_SUBGRAPH_URL_STAGING" "NEWSLETTER_API_KEY" "NEWSLETTER_PUBLICATION_ID" "NEWSLETTER_ENDPOINT")
fail=false
for secret in "${required_secrets[@]}"; do
secret_value=$(printenv $secret)
Expand Down Expand Up @@ -97,7 +96,6 @@ jobs:
AJNA_SUBGRAPH_V2_URL_GOERLI: ${{ secrets.AJNA_SUBGRAPH_V2_URL_GOERLI }}
MIXPANEL_ENV: staging
MIXPANEL_KEY: ${{ secrets.MIXPANEL_KEY_STAGING }}
MAINNET_CACHE_URL: ${{ secrets.MAINNET_CACHE_URL_STAGING }}
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID_STAGING }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY_STAGING }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/dockerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
docker build --build-arg COMMIT_SHA=${{ env.SHA_TAG }} \
--build-arg MIXPANEL_ENV=staging \
--build-arg MIXPANEL_KEY=${{ secrets.MIXPANEL_STAGING_KEY }} \
--build-arg MAINNET_CACHE_URL=${{ secrets.MAINNET_CACHE_URL }} \
--build-arg INFURA_PROJECT_ID=${{ secrets.INFURA_PROJECT_ID }} \
--build-arg ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }} \
--build-arg BLOCKNATIVE_API_KEY=${{ secrets.BLOCKNATIVE_API_KEY }} \
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ARG COMMIT_SHA='' \
AJNA_SUBGRAPH_V2_URL_GOERLI='' \
MIXPANEL_ENV='' \
MIXPANEL_KEY='' \
MAINNET_CACHE_URL='' \
SHOW_BUILD_INFO='' \
ETHERSCAN_API_KEY='' \
BLOCKNATIVE_API_KEY='' \
Expand All @@ -46,7 +45,6 @@ ENV COMMIT_SHA=$COMMIT_SHA \
AJNA_SUBGRAPH_V2_URL_GOERLI=$AJNA_SUBGRAPH_V2_URL_GOERLI \
MIXPANEL_ENV=$MIXPANEL_ENV \
MIXPANEL_KEY=$MIXPANEL_KEY \
MAINNET_CACHE_URL=$MAINNET_CACHE_URL \
ETHERSCAN_API_KEY=$ETHERSCAN_API_KEY \
BLOCKNATIVE_API_KEY=$BLOCKNATIVE_API_KEY \
INFURA_PROJECT_ID=$INFURA_PROJECT_ID \
Expand Down
1 change: 0 additions & 1 deletion blockchain/contracts/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export const arbitrumContracts: MainnetContractsWithOptional = {
adaptiveCurveIrm: contractDesc(morphoBlue, arbitrum.morphoblue.AdaptiveCurveIrm),
balancerVault: contractDesc(balancerVault, arbitrum.common.BalancerVault),
// NOT contracts
cacheApi: 'not-implemented',
safeConfirmations: 6,
openVaultSafeConfirmations: 6,
taxProxyRegistries: [],
Expand Down
1 change: 0 additions & 1 deletion blockchain/contracts/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export const baseContracts: MainnetContractsWithOptional = {
adaptiveCurveIrm: contractDesc(morphoBlue, base.morphoblue.AdaptiveCurveIrm),
balancerVault: contractDesc(balancerVault, base.common.BalancerVault),
// NOT contracts
cacheApi: 'not-implemented',
safeConfirmations: 6,
openVaultSafeConfirmations: 6,
taxProxyRegistries: [],
Expand Down
1 change: 0 additions & 1 deletion blockchain/contracts/goerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ export const goerliContracts: MainnetContractsWithOptional = {
adaptiveCurveIrm: contractDesc(morphoBlue, goerli.morphoblue.AdaptiveCurveIrm),
balancerVault: contractDesc(balancerVault, goerli.common.BalancerVault),
// NOT contracts
cacheApi: 'https://cache-goerli-staging.staging.summer.fi/api/v1',
safeConfirmations: 6,
openVaultSafeConfirmations: 6,
taxProxyRegistries: [],
Expand Down
3 changes: 1 addition & 2 deletions blockchain/contracts/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
supportedIlks,
tokensMainnet,
} from 'blockchain/tokens/mainnet'
import { etherscanAPIKey, mainnetCacheUrl } from 'config/runtimeConfig'
import { etherscanAPIKey } from 'config/runtimeConfig'
import type { Optional } from 'helpers/types'

import type { OptionalContracts } from './optional-contracts'
Expand Down Expand Up @@ -263,7 +263,6 @@ export const mainnetContracts = {
adaptiveCurveIrm: contractDesc(morphoBlue, mainnet.morphoblue.AdaptiveCurveIrm),
balancerVault: contractDesc(ajnaReedemer, mainnet.common.BalancerVault),
// not contracts
cacheApi: mainnetCacheUrl,
safeConfirmations: 10,
openVaultSafeConfirmations: 6,
taxProxyRegistries: [],
Expand Down
1 change: 0 additions & 1 deletion blockchain/contracts/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ export const optimismContracts: OptimismContracts = {
adaptiveCurveIrm: contractDesc(morphoBlue, optimism.morphoblue.AdaptiveCurveIrm),
balancerVault: contractDesc(balancerVault, optimism.common.BalancerVault),
// NOT contracts
cacheApi: 'not-implemented',
safeConfirmations: 6,
openVaultSafeConfirmations: 6,
taxProxyRegistries: [],
Expand Down
17 changes: 0 additions & 17 deletions blockchain/networks/networks-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
polygonMainnetRpc,
polygonMumbaiRpc,
} from 'config/rpcConfig'
import { mainnetCacheUrl } from 'config/runtimeConfig'
import type { ethers } from 'ethers'
import type { ContractDesc } from 'features/web3Context'
import { GraphQLClient } from 'graphql-request'
import type { Abi } from 'helpers/types/Abi.types'
import { keyBy, memoize } from 'lodash'
import arbitrumMainnetBadge from 'public/static/img/network_icons/arbitrum_badge_mainnet.svg'
Expand Down Expand Up @@ -66,7 +64,6 @@ export type NetworkConfig = {
rpcUrl: string
getReadProvider: () => ethers.providers.Provider | undefined
getParentNetwork: () => NetworkConfig | undefined
getCacheApi: () => GraphQLClient | undefined
isCustomFork?: boolean
links?: { label: string; url?: string; openBridgeWidget?: boolean }[]
}
Expand Down Expand Up @@ -111,7 +108,6 @@ const mainnetConfig: NetworkConfig = {
name: NetworkNames.ethereumMainnet,
}),
),
getCacheApi: memoize(() => new GraphQLClient(mainnetCacheUrl)),
isCustomFork: false,
getParentNetwork: () => undefined,
links: [{ label: 'Etherscan', url: 'https://etherscan.io/' }],
Expand Down Expand Up @@ -142,9 +138,6 @@ const goerliConfig: NetworkConfig = {
name: NetworkNames.ethereumGoerli,
}),
),
getCacheApi: memoize(
() => new GraphQLClient('https://cache-goerli-staging.staging.summer.fi/api/v1'),
),
isCustomFork: false,
getParentNetwork: () => undefined,
}
Expand Down Expand Up @@ -174,7 +167,6 @@ const arbitrumMainnetConfig: NetworkConfig = {
name: NetworkNames.arbitrumMainnet,
}),
),
getCacheApi: () => undefined,
getParentNetwork: () => undefined,
isCustomFork: false,
links: [
Expand Down Expand Up @@ -210,7 +202,6 @@ const arbitrumGoerliConfig: NetworkConfig = {
}),
),
getParentNetwork: () => undefined,
getCacheApi: () => undefined,
isCustomFork: false,
}

Expand All @@ -233,7 +224,6 @@ const polygonMainnetConfig: NetworkConfig = {
token: 'ETH',
rpcUrl: polygonMainnetRpc,
getReadProvider: () => undefined,
getCacheApi: () => undefined,
getParentNetwork: () => undefined,
isCustomFork: false,
}
Expand All @@ -258,7 +248,6 @@ const polygonMumbaiConfig: NetworkConfig = {
rpcUrl: polygonMumbaiRpc,
getReadProvider: () => undefined,
getParentNetwork: () => undefined,
getCacheApi: () => undefined,
isCustomFork: false,
}

Expand Down Expand Up @@ -287,7 +276,6 @@ const optimismMainnetConfig: NetworkConfig = {
name: NetworkNames.optimismMainnet,
}),
),
getCacheApi: () => undefined,
getParentNetwork: () => undefined,
isCustomFork: false,
links: [
Expand Down Expand Up @@ -317,7 +305,6 @@ const optimismGoerliConfig: NetworkConfig = {
rpcUrl: optimismGoerliRpc,
getReadProvider: () => undefined,
getParentNetwork: () => undefined,
getCacheApi: () => undefined,
isCustomFork: false,
}

Expand Down Expand Up @@ -346,7 +333,6 @@ const baseMainnetConfig: NetworkConfig = {
name: NetworkNames.baseMainnet,
}),
),
getCacheApi: () => undefined,
getParentNetwork: () => undefined,
isCustomFork: false,
links: [
Expand Down Expand Up @@ -382,7 +368,6 @@ const baseGoerliConfig: NetworkConfig = {
}),
),
getParentNetwork: () => undefined,
getCacheApi: () => undefined,
isCustomFork: false,
}

Expand All @@ -402,7 +387,6 @@ export const emptyNetworkConfig: NetworkConfig = {
token: 'ETH',
rpcUrl: 'empty',
getReadProvider: () => undefined,
getCacheApi: () => undefined,
getParentNetwork: () => undefined,
isCustomFork: false,
}
Expand Down Expand Up @@ -436,7 +420,6 @@ export const defaultForkSettings: NetworkConfig = {
rpcUrl: '',
getReadProvider: () => undefined,
getParentNetwork: () => undefined,
getCacheApi: () => undefined,
isCustomFork: true,
}

Expand Down
4 changes: 0 additions & 4 deletions config/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ export const infuraProjectId =
process.env.INFURA_PROJECT_ID || getConfig()?.publicRuntimeConfig?.infuraProjectId || ''
export const etherscanAPIKey =
process.env.ETHERSCAN_API_KEY || getConfig()?.publicRuntimeConfig?.etherscan || ''
export const mainnetCacheUrl =
process.env.MAINNET_CACHE_URL ||
getConfig()?.publicRuntimeConfig?.mainnetCacheURL ||
'https://oazo-bcache.new.summer.fi/api/v1'
10 changes: 1 addition & 9 deletions features/aave/get-common-parts-from-app-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ import type BigNumber from 'bignumber.js'
import { tokenAllowance } from 'blockchain/better-calls/erc20'
import type { ChainlinkSupportedNetworks } from 'blockchain/calls/chainlink/chainlinkPriceOracle'
import { getChainlinkOraclePrice } from 'blockchain/calls/chainlink/chainlinkPriceOracle'
import { getNetworkContracts } from 'blockchain/contracts'
import type { NetworkIds } from 'blockchain/networks'
import { userDpmProxies$ } from 'blockchain/userDpmProxies'
import type { UserDpmAccount } from 'blockchain/userDpmProxies.types'
import type { AccountContext } from 'components/context/AccountContextProvider'
import { getAllowanceStateMachine } from 'features/stateMachines/allowance'
import { getOpenProxyStateMachine } from 'features/stateMachines/proxy/pipelines'
import { GraphQLClient } from 'graphql-request'
import type { MainContext } from 'helpers/context/MainContext.types'
import type { ProductContext } from 'helpers/context/ProductContext.types'
import { makeOneObservable } from 'lendingProtocols/pipelines'
import { memoize } from 'lodash'
import { curry } from 'ramda'
import type { Observable } from 'rxjs'
import { of } from 'rxjs'
import { distinctUntilKeyChanged, map, switchMap } from 'rxjs/operators'
import { map, switchMap } from 'rxjs/operators'

import { getProxiesRelatedWithPosition$ } from './helpers'
import { getAvailableDPMProxy$, getOperationExecutorTransactionMachine } from './services'
Expand All @@ -35,11 +33,6 @@ export function getCommonPartsFromProductContext(
refresh$: Observable<unknown>,
networkId: ChainlinkSupportedNetworks,
) {
const disconnectedGraphQLClient$ = context$.pipe(
distinctUntilKeyChanged('chainId'),
map(({ chainId }) => new GraphQLClient(getNetworkContracts(networkId, chainId).cacheApi)),
)

const proxyForAccount$: Observable<string | undefined> = contextForAddress$.pipe(
switchMap(({ account }) => proxyAddress$(account)),
)
Expand Down Expand Up @@ -113,7 +106,6 @@ export function getCommonPartsFromProductContext(
proxiesRelatedWithPosition$,
unconsumedDpmProxyForConnectedAccount$: unconsumedDpmForStrategyNetwork,
contextForAddress$,
disconnectedGraphQLClient$,
chainLinkETHUSDOraclePrice$,
}
}
22 changes: 5 additions & 17 deletions features/dsr/helpers/dsrHistory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import BigNumber from 'bignumber.js'
import { getNetworkContracts } from 'blockchain/contracts'
import type { Context } from 'blockchain/network.types'
import { NetworkIds } from 'blockchain/networks'
import { getRpcProvider, NetworkIds } from 'blockchain/networks'
import { getNetworkRpcEndpoint } from 'blockchain/networks/get-network-rpc-endpoint'
import { funcSigTopic } from 'blockchain/utils'
import { gql, GraphQLClient } from 'graphql-request'
import padStart from 'lodash/padStart'
import type { Observable } from 'rxjs'
import { combineLatest, merge, of } from 'rxjs'
Expand Down Expand Up @@ -62,11 +61,10 @@ const eventSigntures: Dictionary<string[]> = {
}

async function getBlockTimestamp({ chainId }: Context, blockNumber: number): Promise<number> {
const apiClient = new GraphQLClient(getNetworkContracts(NetworkIds.MAINNET, chainId).cacheApi)
const block = await apiClient.request(historicalBlockNumbers, {
blockNumber,
})
return new Date(block.allHistoricBlocks.nodes[0].timestamp).getTime() / 1000
const provider = getRpcProvider(chainId)
const block = await provider.getBlock(blockNumber)

return new Date(block.timestamp).getTime()
}

function createEventTypeHistory$(
Expand Down Expand Up @@ -153,13 +151,3 @@ export function createDsrHistory$(context: Context, proxyAddress: string): Obser
}),
)
}

export const historicalBlockNumbers = gql`
query timestamp($blockNumber: Int) {
allHistoricBlocks(first: 1, filter: { number: { equalTo: $blockNumber } }) {
nodes {
timestamp
}
}
}
`
13 changes: 0 additions & 13 deletions graphql.config.yml

This file was deleted.

1 change: 0 additions & 1 deletion runtime.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const publicRuntimeConfig = {
exchangeAddress:
process.env.USE_DUMMY === '1' ? process.env.DUMMY_EXCHANGE : process.env.EXCHANGE,
multiplyProxyActions: process.env.MULTIPLY_PROXY_ACTIONS,
mainnetCacheURL: process.env.MAINNET_CACHE_URL,
discoverProxyUrl: process.env.DISCOVER_PROXY_URL,
ajnaSubgraphUrl: process.env.AJNA_SUBGRAPH_URL,
ajnaSubgraphUrlGoerli: process.env.AJNA_SUBGRAPH_URL_GOERLI,
Expand Down
Loading

0 comments on commit 8be1fe6

Please sign in to comment.