Skip to content

Commit 6fe8f35

Browse files
authored
Target rate change (#15)
* checked in new abis and deployed addresses * updated info script * added todo * inter * updated subgraph, address handing and removed seldom used call handlers * updated sdk
1 parent 90eebaf commit 6fe8f35

File tree

26 files changed

+636
-392
lines changed

26 files changed

+636
-392
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15
1+
16

sdk/examples/index.ts

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
getAmpleforthMarketOracle,
3-
getAmpleforthCPIOracle,
3+
getAmpleforthCPIOracles,
44
getOracleProviderReports,
55
getAmpleforthPolicy,
66
getRebases,
@@ -11,22 +11,32 @@ import {
1111
getXCRebases,
1212
getXCAmpleToken,
1313
queries,
14+
deployments,
1415
} from '../src'
1516

16-
async function printAMPLData(chainID: number) {
17+
async function printAMPLData(chainID: number, client: queries.Client) {
1718
console.log('------------------------')
1819
console.log('chainID', chainID)
1920
const now = Date.now() / 1000
21+
const deployment = deployments.getDeployment(chainID)
2022

21-
const marketOracle = await getAmpleforthMarketOracle(chainID)
23+
const marketOracle = await getAmpleforthMarketOracle(chainID, client)
2224
console.log('Market oracle', marketOracle.getData().toString())
2325
console.log('Providers ', marketOracle.providers.length)
26+
for (const p in marketOracle.providers) {
27+
const provider = marketOracle.providers[p]
28+
console.log(
29+
provider.address,
30+
provider.activeReports.map((r: any) => r.report.toString()),
31+
)
32+
}
2433

25-
const cpiOracle = await getAmpleforthCPIOracle(chainID)
34+
const cpiOracles = await getAmpleforthCPIOracles(chainID, client)
35+
const cpiOracle = cpiOracles[0]
2636
console.log('CPI oracle', cpiOracle.getData().toString())
2737
console.log('Providers ', cpiOracle.providers.length)
2838

29-
const policy = await getAmpleforthPolicy(chainID)
39+
const policy = await getAmpleforthPolicy(chainID, client)
3040
console.log('Epoch', policy.epoch.toString())
3141
console.log('Supply', policy.supply.toString())
3242

@@ -48,74 +58,86 @@ async function printAMPLData(chainID: number) {
4858
)
4959
}
5060

51-
const ampl = await getAMPLToken(chainID)
61+
const ampl = await getAMPLToken(chainID, client)
5262
const b = await getTokenBalance(
5363
ampl,
54-
'0x6723b7641c8ac48a61f5f505ab1e9c03bb44a301',
55-
chainID,
64+
'0x223592a191ECfC7FDC38a9256c3BD96E771539A9',
65+
client,
5666
)
5767
console.log('User Balance', b.balance.toString())
5868

5969
const a = await getTokenApproval(
6070
ampl,
6171
'0xd99528ce2a83fbad03c1b50bb39e5653b91072b3',
6272
'0x881d40237659c251811cec9c364ef91dc08d300c',
63-
chainID,
73+
client,
6474
)
6575
console.log('User Approval', a.value.toString())
6676

67-
const providerReports = await getOracleProviderReports(
68-
marketOracle,
69-
marketOracle.providers[0].id,
70-
chainID,
77+
const rateProviderReports = await getOracleProviderReports(
78+
marketOracle.address,
79+
marketOracle.providers[0].address,
80+
client,
7181
)
72-
console.log('Provider reports', providerReports.length)
82+
console.log('Rate provider reports', rateProviderReports.length)
7383

74-
const rebases = await getRebases(policy, chainID)
84+
const cpiProviderReports = await getOracleProviderReports(
85+
cpiOracle.address,
86+
cpiOracle.providers[0].address,
87+
client,
88+
)
89+
console.log('CPI provider reports', cpiProviderReports.length)
90+
91+
const historicCpiProviderReports = await getOracleProviderReports(
92+
cpiOracles[1].address,
93+
cpiOracles[1].providers[0].address,
94+
client,
95+
)
96+
console.log(
97+
'Historic CPI provider reports',
98+
historicCpiProviderReports.length,
99+
)
100+
101+
const rebases = await getRebases(policy, client)
75102
console.log('Rebases', rebases.length)
76103
policy.loadHistoricalRebases(rebases)
77104
}
78105

79-
async function printXCAmpleData(chainID: number) {
106+
async function printXCAmpleData(chainID: number, client: queries.Client) {
80107
console.log('------------------------')
81108
console.log('chainID', chainID)
82109

83-
const xcController = await getXCAmpleController(chainID)
110+
const xcController = await getXCAmpleController(chainID, client)
84111
console.log('Epoch', xcController.epoch.toString())
85112
console.log('Supply', xcController.supply.toString())
86113

87-
const xcAmple = await getXCAmpleToken(chainID)
114+
const xcAmple = await getXCAmpleToken(chainID, client)
88115
const b = await getTokenBalance(
89116
xcAmple,
90117
'0xe36ae366692acbf696715b6bddce0938398dd991',
91-
chainID,
118+
client,
92119
)
93120
console.log('User Balance', b.balance.toString())
94121

95122
const a = await getTokenApproval(
96123
xcAmple,
97124
'0xa308de214e01c365834e3344c1088b0d2b97559c',
98125
'0xe36ae366692acbf696715b6bddce0938398dd991',
99-
chainID,
126+
client,
100127
)
101128
console.log('User Approval', a.value.toString())
102129

103-
const rebases = await getXCRebases(xcController, chainID)
130+
const rebases = await getXCRebases(xcController, client)
104131
console.log('Rebases', rebases.length)
105132
xcController.loadHistoricalRebases(rebases)
106133
}
107134

108135
async function run() {
109-
if (process.argv.length < 3) {
110-
console.log(
111-
'provide API Key as command line argument to run mainnet example',
112-
)
113-
} else {
114-
queries.initializeApiKey(process.argv[process.argv.length-1])
115-
await printAMPLData(1)
116-
}
117-
await printXCAmpleData(43114)
118-
await printAMPLData(5)
136+
console.log('Endpoint', queries.graphHostedURL(1))
137+
const client = queries.initializeClient(queries.graphHostedURL(1))
138+
await printAMPLData(1, client)
139+
// await printXCAmpleData(43114)
140+
// await printAMPLData(5)
119141
}
120142

121143
run()

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ampleforthorg/sdk",
3-
"version": "1.0.27",
3+
"version": "1.0.30",
44
"description": "Typescript SDK for the Ampleforth Protocol",
55
"license": "GPL-3.0-or-later",
66
"main": "dist/src/index.js",

0 commit comments

Comments
 (0)