Skip to content

Commit d922ce9

Browse files
committed
multichain ampl interface methods
1 parent c1ff3bd commit d922ce9

9 files changed

+85
-30
lines changed

contracts/UFragments.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ contract UFragments is ERC20Detailed, Ownable {
144144
emit Transfer(address(0x0), owner_, _totalSupply);
145145
}
146146

147+
/*
148+
* @notice A multi-chain AMPL interface method. On the base-chain contract it reflects
149+
* the value in the contract store.
150+
* @return globalAMPLSupply The current total supply.
151+
*/
152+
function globalAMPLSupply() external view returns (uint256) {
153+
return _totalSupply;
154+
}
155+
147156
/**
148157
* @return The total number of fragments.
149158
*/

contracts/UFragmentsPolicy.sol

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,25 @@ contract UFragmentsPolicy is Ownable {
210210
rebaseWindowLengthSec = rebaseWindowLengthSec_;
211211
}
212212

213+
/*
214+
* @notice A multi-chain AMPL interface method. On the base-chain contract it reflects
215+
* the value in the contract store.
216+
* @return globalAmpleforthEpoch The current epoch number.
217+
*/
218+
function globalAmpleforthEpoch() external view returns (uint256) {
219+
return epoch;
220+
}
221+
213222
/**
214223
* @notice A multi-chain AMPL interface method. The Ampleforth monetary policy contract
215-
* on the base-chain and XCAmpleController contracts on the satellite-chains
224+
* on the base-chain and XC-AmpleController contracts on the satellite-chains
216225
* implement this method. It atomically returns two values:
217226
* what the current contract believes to be,
218227
* the globalAmpleforthEpoch and globalAMPLSupply.
219228
* @return globalAmpleforthEpoch The current epoch number.
220229
* @return globalAMPLSupply The total supply at the current epoch.
221230
*/
222-
function getGlobalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
231+
function globalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
223232
return (epoch, uFrags.totalSupply());
224233
}
225234

contracts/interfaces/IAMPL.sol

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity 0.4.24;
22

3-
// Interface definition for the AMPL - ERC20 token on Ethereum (the base-chain)
3+
// Public interface definition for the AMPL - ERC20 token on Ethereum (the base-chain)
44
interface IAMPL {
55
// ERC20
66
function totalSupply() external view returns (uint256);
@@ -52,12 +52,8 @@ interface IAMPL {
5252
function transferAllFrom(address from, address to) external returns (bool);
5353

5454
// AMPL specific
55-
function monetaryPolicy() external view returns (address);
56-
5755
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
5856

59-
event LogMonetaryPolicyUpdated(address monetaryPolicy);
60-
6157
// Multi-chain AMPL
6258
function globalAMPLSupply() external view returns (uint256);
6359
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma solidity 0.4.24;
2+
3+
interface IAMPLGovernance {
4+
function monetaryPolicy() external view returns (address);
5+
6+
function setMonetaryPolicy(address monetaryPolicy_) external;
7+
8+
event LogMonetaryPolicyUpdated(address monetaryPolicy);
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pragma solidity 0.4.24;
2+
3+
interface IAMPLSupplyPolicy {
4+
function rebase(uint256 epoch, int256 supplyDelta) external returns (uint256);
5+
}

contracts/interfaces/IAmpleforth.sol

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
pragma solidity 0.4.24;
22

3-
// Interface definition for the Ampleforth supply policy
3+
// Public interface definition for the Ampleforth supply policy on Ethereum (the base-chain)
44
interface IAmpleforth {
55
function rebase() external;
66

7-
function uFrags() external view returns (address);
8-
9-
function cpiOracle() external view returns (address);
10-
11-
function marketOracle() external view returns (address);
12-
13-
function deviationThreshold() external view returns (uint256);
14-
15-
function rebaseLag() external view returns (uint256);
16-
17-
function minRebaseTimeIntervalSec() external view returns (uint256);
7+
function epoch() external view returns (uint256);
188

199
function lastRebaseTimestampSec() external view returns (uint256);
2010

21-
function rebaseWindowOffsetSec() external view returns (uint256);
22-
23-
function rebaseWindowLengthSec() external view returns (uint256);
24-
25-
function epoch() external view returns (uint256);
26-
27-
function inRebaseWindow() public view returns (bool);
11+
function inRebaseWindow() external view returns (bool);
2812

2913
event LogRebase(
3014
uint256 indexed epoch,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
pragma solidity 0.4.24;
2+
3+
interface IAmpleforthGovernance {
4+
function uFrags() external view returns (address);
5+
6+
function cpiOracle() external view returns (address);
7+
8+
function marketOracle() external view returns (address);
9+
10+
function deviationThreshold() external view returns (uint256);
11+
12+
function rebaseLag() external view returns (uint256);
13+
14+
function minRebaseTimeIntervalSec() external view returns (uint256);
15+
16+
function rebaseWindowOffsetSec() external view returns (uint256);
17+
18+
function rebaseWindowLengthSec() external view returns (uint256);
19+
20+
function setCpiOracle(address cpiOracle_) external;
21+
22+
function setMarketOracle(address marketOracle_) external;
23+
24+
function setOrchestrator(address orchestrator_) external;
25+
26+
function setDeviationThreshold(uint256 deviationThreshold_) external;
27+
28+
function setRebaseLag(uint256 rebaseLag_) external;
29+
30+
function setRebaseTimingParameters(
31+
uint256 minRebaseTimeIntervalSec_,
32+
uint256 rebaseWindowOffsetSec_,
33+
uint256 rebaseWindowLengthSec_
34+
) external;
35+
}

test/unit/UFragments.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ describe('UFragments:Initialization', () => {
6565
expect(await uFragments.totalSupply()).to.eq(INITIAL_SUPPLY)
6666
})
6767

68+
it('should set the globalSupply to 50M', async function () {
69+
expect(await uFragments.globalAMPLSupply()).to.eq(INITIAL_SUPPLY)
70+
})
71+
6872
it('should set the scaledTotalSupply', async function () {
6973
expect(await uFragments.scaledTotalSupply()).to.eq(TOTAL_GONS)
7074
})

test/unit/UFragmentsPolicy.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ describe('UFragmentsPolicy:initialize', async function () {
163163
})
164164
it('epoch', async function () {
165165
expect(await uFragmentsPolicy.epoch()).to.eq(0)
166+
expect(await uFragmentsPolicy.globalAmpleforthEpoch()).to.eq(0)
166167
})
167-
it('getGlobalAmpleforthEpochAndAMPLSupply', async function () {
168-
const r = await uFragmentsPolicy.getGlobalAmpleforthEpochAndAMPLSupply()
168+
it('globalAmpleforthEpochAndAMPLSupply', async function () {
169+
const r = await uFragmentsPolicy.globalAmpleforthEpochAndAMPLSupply()
169170
expect(r[0]).to.eq(0)
170171
expect(r[1]).to.eq(0)
171172
})
@@ -831,11 +832,14 @@ describe('UFragmentsPolicy:Rebase', async function () {
831832
it('should increment epoch', async function () {
832833
await uFragmentsPolicy.connect(orchestrator).rebase()
833834
expect(await uFragmentsPolicy.epoch()).to.eq(prevEpoch.add(1))
835+
expect(await uFragmentsPolicy.globalAmpleforthEpoch()).to.eq(
836+
prevEpoch.add(1),
837+
)
834838
})
835839

836-
it('should update getGlobalAmpleforthEpochAndAMPLSupply', async function () {
840+
it('should update globalAmpleforthEpochAndAMPLSupply', async function () {
837841
await uFragmentsPolicy.connect(orchestrator).rebase()
838-
const r = await uFragmentsPolicy.getGlobalAmpleforthEpochAndAMPLSupply()
842+
const r = await uFragmentsPolicy.globalAmpleforthEpochAndAMPLSupply()
839843
expect(r[0]).to.eq(prevEpoch.add(1))
840844
expect(r[1]).to.eq('1010')
841845
})

0 commit comments

Comments
 (0)