Skip to content

Commit 1257645

Browse files
committed
using internal subgraph endpoints
1 parent 067838d commit 1257645

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@ampleforthorg/sdk": "1.0.18",
6+
"@ampleforthorg/sdk": "1.0.32",
77
"@apollo/client": "^3.3.16",
88
"@craco/craco": "^6.1.2",
99
"@headlessui/react": "^1.4.1",

frontend/src/config/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const networkConfig: NetworkConfig = {
1616
ref: 'mainnet',
1717
name: 'Ethereum',
1818
rpcUrl: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_PROJECT_ID}`,
19-
graphUrl: 'https://api.thegraph.com/subgraphs/name/aalavandhan/amplgeyserv2beta',
19+
graphUrl: `https://web-api.ampleforth.org/graph-cache/ampleforth-token-geyser`,
2020
explorerUrl: 'https://etherscan.io/tx',
2121
nativeCurrency: {
2222
name: 'Ethereum',
@@ -220,7 +220,7 @@ const additionalTokens: AppAdditionalTokensList = {
220220
],
221221
}
222222

223-
export const activeNetworks: Network[] = [Network.Mainnet, Network.Avalanche]
223+
export const activeNetworks: Network[] = [Network.Mainnet]
224224

225225
export function getConnectionConfig(networkId: number | null): ConnectionConfig {
226226
return networkConfig[networkId as Network] || networkConfig[Network.Mainnet]

frontend/src/queries/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export const makeClient = (networkId: number | null) => {
77
uri: graphUrl,
88
cache: new InMemoryCache(),
99
})
10-
}
10+
}

frontend/src/utils/ampleforth.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
import { getAmpleforthPolicy, getRebases, getXCAmpleController, getXCRebases, entities } from '@ampleforthorg/sdk'
1+
import { getAmpleforthPolicy, getRebases, getXCAmpleController, getXCRebases, queries, entities } from '@ampleforthorg/sdk'
22
import { formatUnits } from 'ethers/lib/utils'
33
import { Signer, providers } from 'ethers'
44
import { RewardSchedule, SignerOrProvider } from '../types'
55
import * as ls from './cache'
66
import { DAY_IN_MS } from '../constants'
77

8+
const AMPLEFORTH_CORE_GRAPHQL_ENDPOINT = "https://web-api.ampleforth.org/graph-cache/ampleforth-core"
9+
const getClient = (chainId) => {
10+
const endpoint = (chainId === 1) ? AMPLEFORTH_CORE_GRAPHQL_ENDPOINT : queries.graphHostedURL(chainId);
11+
return queries.initializeClient(endpoint)
12+
}
13+
814
const loadXCRebasesFromCache = async (controller: entities.XCController, chainId: number) =>
915
ls.computeAndCache<entities.XCRebaseData[]>(
10-
async () => (await getXCRebases(controller, chainId)).map((r) => r.rawData),
16+
async () => (await getXCRebases(controller, chainId, getClient(chainId))).map((r) => r.rawData),
1117
`${controller.address}|xc_rebases|${controller.epoch.toString()}`,
1218
DAY_IN_MS,
1319
)
1420

1521
const loadRebasesFromCache = async (policy: entities.Policy, chainId: number) =>
1622
ls.computeAndCache<entities.RebaseData[]>(
17-
async () => (await getRebases(policy, chainId)).map((r) => r.rawData),
23+
async () => (await getRebases(policy, chainId, getClient(chainId))).map((r) => r.rawData),
1824
`${policy.address}|rebases|${policy.epoch.toString()}`,
1925
DAY_IN_MS,
2026
)
@@ -32,20 +38,20 @@ export const computeAMPLRewardShares = async (
3238
const { chainId } = await provider.getNetwork()
3339

3440
if (isCrossChain) {
35-
const controller = await getXCAmpleController(chainId)
36-
const rebases = await loadXCRebasesFromCache(controller, chainId)
41+
const controller = await getXCAmpleController(chainId, getClient(chainId))
42+
const rebases = await loadXCRebasesFromCache(controller, chainId, getClient(chainId))
3743
controller.loadHistoricalRebases(rebases.map((r) => new entities.XCRebase(r)))
38-
// const rebases = await getXCRebases(controller, chainId)
44+
// const rebases = await getXCRebases(controller, chainId, getClient(chainId))
3945
// controller.loadHistoricalRebases(rebases)
4046
const getShares = (schedule: RewardSchedule) =>
4147
parseFloat(formatUnits(schedule.rewardAmount, decimals)) / controller.getSupplyOn(schedule.start).toNumber()
4248
return rewardSchedules.reduce((acc, schedule) => acc + getShares(schedule), 0)
4349
}
4450

45-
const policy = await getAmpleforthPolicy(chainId)
46-
const rebases = await loadRebasesFromCache(policy, chainId)
51+
const policy = await getAmpleforthPolicy(chainId, getClient(chainId))
52+
const rebases = await loadRebasesFromCache(policy, chainId, getClient(chainId))
4753
policy.loadHistoricalRebases(rebases.map((r) => new entities.Rebase(r)))
48-
// const rebases = await getRebases(policy, chainId)
54+
// const rebases = await getRebases(policy, chainId, getClient(chainId))
4955
// policy.loadHistoricalRebases(rebases)
5056
const getShares = (schedule: RewardSchedule) =>
5157
parseFloat(formatUnits(schedule.rewardAmount, decimals)) / policy.getSupplyOn(schedule.start).toNumber()

frontend/yarn.lock

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
# yarn lockfile v1
33

44

5-
"@ampleforthorg/[email protected]":
6-
version "1.0.18"
7-
resolved "https://registry.yarnpkg.com/@ampleforthorg/sdk/-/sdk-1.0.18.tgz#49d936c4db52d7249a4e293215ee995db1f3b35f"
8-
integrity sha512-UavhESOzRKrxWMmGZmiXtobudPGL3jMd1j/MLT4/MCYJqBvDHIBdGn3M5JYqacDv+tqFc1xpm/4mSkLMZzaavQ==
5+
"@0no-co/graphql.web@^1.0.5":
6+
version "1.0.7"
7+
resolved "https://registry.yarnpkg.com/@0no-co/graphql.web/-/graphql.web-1.0.7.tgz#c7a762c887b3482a79ffa68f63de5e96059a62e4"
8+
integrity sha512-E3Qku4mTzdrlwVWGPxklDnME5ANrEGetvYw4i2GCRlppWXXE4QD66j7pwb8HelZwS6LnqEChhrSOGCXpbiu6MQ==
9+
10+
"@ampleforthorg/[email protected]":
11+
version "1.0.32"
12+
resolved "https://registry.yarnpkg.com/@ampleforthorg/sdk/-/sdk-1.0.32.tgz#04df04c69a388b0e18531222c29baa59ed288963"
13+
integrity sha512-q05O05sc8cd/pW+nuh7WsqCKT4rcw/ff+FI9JUtcl4q4R0VL2VGhIn8+RIUQMkRfeDI4huFduRL1RrdWkaEBRg==
914
dependencies:
1015
"@types/bignumber.js" "^5.0.0"
1116
"@typescript-eslint/eslint-plugin" "^4.29.0"
@@ -19,7 +24,7 @@
1924
prettier "^2.3.2"
2025
tiny-invariant "^1.1.0"
2126
typescript "^4.3.5"
22-
urql "^2.0.4"
27+
urql "^4.0.0"
2328

2429
"@ampproject/remapping@^2.0.0":
2530
version "2.0.3"
@@ -2313,11 +2318,6 @@
23132318
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.0.tgz#0eee6373e11418bfe0b5638f654df7a4ca6a3950"
23142319
integrity sha512-wYn6r8zVZyQJ6rQaALBEln5B1pzxb9shV5Ef97kTvn6yVGrqyXVnDqnU24MXnFubR+rZjBY9NWuxX3FB2sTsjg==
23152320

2316-
"@graphql-typed-document-node/core@^3.1.1":
2317-
version "3.1.1"
2318-
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.1.tgz#076d78ce99822258cf813ecc1e7fa460fa74d052"
2319-
integrity sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg==
2320-
23212321
23222322
version "2.1.4"
23232323
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
@@ -3802,13 +3802,13 @@
38023802
"@typescript-eslint/types" "4.33.0"
38033803
eslint-visitor-keys "^2.0.0"
38043804

3805-
"@urql/core@^2.4.1":
3806-
version "2.4.1"
3807-
resolved "https://registry.yarnpkg.com/@urql/core/-/core-2.4.1.tgz#bae449dafe98fb4944f3be61eb8e70ba33f8a46d"
3808-
integrity sha512-HnS54oNwO4pAACKl/2/tNLbRrxAxKawVJuG9UPiixqeEVekiecUQQnCjb9SpOW4Qr54HYzCMDbr3c5px3hfEEg==
3805+
"@urql/core@^5.0.0":
3806+
version "5.0.4"
3807+
resolved "https://registry.yarnpkg.com/@urql/core/-/core-5.0.4.tgz#e5d0e185d0833ebf277be58bd6603fd53e48e07f"
3808+
integrity sha512-gl86J6B6gWXvvkx5omZ+CaGiPQ0chCUGM0jBsm0zTtkDQPRqufv0NSUN6sp2JhGGtTOB0NR6Pd+w7XAVGGyUOA==
38093809
dependencies:
3810-
"@graphql-typed-document-node/core" "^3.1.1"
3811-
wonka "^4.0.14"
3810+
"@0no-co/graphql.web" "^1.0.5"
3811+
wonka "^6.3.2"
38123812

38133813
"@walletconnect/browser-utils@^1.4.1":
38143814
version "1.4.1"
@@ -16467,19 +16467,13 @@ url@^0.11.0:
1646716467
punycode "1.3.2"
1646816468
querystring "0.2.0"
1646916469

16470-
urql@^2.0.4:
16471-
version "2.1.3"
16472-
resolved "https://registry.yarnpkg.com/urql/-/urql-2.1.3.tgz#4bfe631db03dc059738ff774b46244bf1a755c6d"
16473-
integrity sha512-S6GaKM7NJLed25L2qdZxaWFjWggXQHrneEVEe47+ZTQWxmfyV05STMl6DhtnZqb6n1wdT/KUljHkggz0kiE3NA==
16470+
urql@^4.0.0:
16471+
version "4.1.0"
16472+
resolved "https://registry.yarnpkg.com/urql/-/urql-4.1.0.tgz#a75efe572d7b2e69103649a8457d3a63fce31ee8"
16473+
integrity sha512-NfbfTvxy1sM89EQAJWm89qJZihUWk7BSMfrWgfljFXLOf+e7RK7DtV/Tbg2+82HnCG2x3LcEOJenxiFSYEC+bw==
1647416474
dependencies:
16475-
"@urql/core" "^2.4.1"
16476-
use-sync-external-store "1.0.0-rc.0 || ^1.0.0"
16477-
wonka "^4.0.14"
16478-
16479-
"[email protected] || ^1.0.0":
16480-
version "1.0.0-rc.0"
16481-
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.0.0-rc.0.tgz#0d8fb7cbc31ddfb3ee01225f6b0a700cf59c449b"
16482-
integrity sha512-0U9Xlc2QDFzSGMB0DvcJQL0+DIdxDPJC7mnZlYFbl7wrSrPMcs89X5TVkNB6Dzg618m8lZop+U+J6ow3vq9RAQ==
16475+
"@urql/core" "^5.0.0"
16476+
wonka "^6.3.2"
1648316477

1648416478
use@^3.1.0:
1648516479
version "3.1.1"
@@ -17307,10 +17301,10 @@ [email protected]:
1730717301
dependencies:
1730817302
window-getters "^1.0.0"
1730917303

17310-
wonka@^4.0.14:
17311-
version "4.0.15"
17312-
resolved "https://registry.yarnpkg.com/wonka/-/wonka-4.0.15.tgz#9aa42046efa424565ab8f8f451fcca955bf80b89"
17313-
integrity sha512-U0IUQHKXXn6PFo9nqsHphVCE5m3IntqZNB9Jjn7EB1lrR7YTDY3YWgFvEvwniTzXSvOH/XMzAZaIfJF/LvHYXg==
17304+
wonka@^6.3.2:
17305+
version "6.3.4"
17306+
resolved "https://registry.yarnpkg.com/wonka/-/wonka-6.3.4.tgz#76eb9316e3d67d7febf4945202b5bdb2db534594"
17307+
integrity sha512-CjpbqNtBGNAeyNS/9W6q3kSkKE52+FjIj7AkFlLr11s/VWGUu6a2CdYSdGxocIhIVjaW/zchesBQUKPVU69Cqg==
1731417308

1731517309
word-wrap@^1.2.3, word-wrap@~1.2.3:
1731617310
version "1.2.3"

0 commit comments

Comments
 (0)