Skip to content

Commit 64af2cd

Browse files
committed
updated xc controller interface
1 parent 6f5c5d3 commit 64af2cd

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

contracts/satellite-chain/xc-ampleforth/XCAmpleController.sol

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313

1414
import {UInt256Lib} from "./UInt256Lib.sol";
1515
import {IXCAmple} from "../../_interfaces/IXCAmple.sol";
16+
import {IXCAmpleSupplyPolicy} from "../../_interfaces/IXCAmpleSupplyPolicy.sol";
1617
import {IBatchTxExecutor} from "../../_interfaces/IBatchTxExecutor.sol";
1718

1819
/**
@@ -113,7 +114,7 @@ contract XCAmpleController is OwnableUpgradeable {
113114
* @param xcAmpleAmount The amount of xcAmples to be mint on this chain.
114115
*/
115116
function mint(address recipient, uint256 xcAmpleAmount) external onlyBridgeGateway {
116-
IXCAmple(xcAmple).mint(recipient, xcAmpleAmount);
117+
IXCAmpleSupplyPolicy(xcAmple).mint(recipient, xcAmpleAmount);
117118
emit GatewayMint(msg.sender, recipient, xcAmpleAmount);
118119
}
119120

@@ -125,7 +126,7 @@ contract XCAmpleController is OwnableUpgradeable {
125126
* @param xcAmpleAmount The amount of xcAmples to be burnt on this chain.
126127
*/
127128
function burn(address depositor, uint256 xcAmpleAmount) external onlyBridgeGateway {
128-
IXCAmple(xcAmple).burn(depositor, xcAmpleAmount);
129+
IXCAmpleSupplyPolicy(xcAmple).burn(depositor, xcAmpleAmount);
129130
emit GatewayBurn(msg.sender, depositor, xcAmpleAmount);
130131
}
131132

@@ -149,6 +150,19 @@ contract XCAmpleController is OwnableUpgradeable {
149150
);
150151
}
151152

153+
/**
154+
* @notice A multi-chain AMPL interface method. The Ampleforth monetary policy contract
155+
* on the base-chain and XCAmpleController contracts on the satellite-chains
156+
* implement this method. It atomically returns two values:
157+
* what the current contract believes to be,
158+
* the globalAmpleforthEpoch and globalAMPLSupply.
159+
* @return globalAmpleforthEpoch The recorded global Ampleforth epoch.
160+
* @return globalAMPLSupply The recorded global AMPL supply.
161+
*/
162+
function globalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
163+
return (globalAmpleforthEpoch, IXCAmple(xcAmple).globalAMPLSupply());
164+
}
165+
152166
/**
153167
* @notice Initiate a new rebase operation.
154168
* @dev Once the Bridge gateway reports new epoch and total supply Rebase can be triggered on this satellite chain.
@@ -168,7 +182,7 @@ contract XCAmpleController is OwnableUpgradeable {
168182
int256 recordedGlobalAMPLSupply = IXCAmple(xcAmple).globalAMPLSupply().toInt256Safe();
169183

170184
// execute rebase on this chain
171-
IXCAmple(xcAmple).rebase(nextGlobalAmpleforthEpoch, nextGlobalAMPLSupply);
185+
IXCAmpleSupplyPolicy(xcAmple).rebase(nextGlobalAmpleforthEpoch, nextGlobalAMPLSupply);
172186

173187
// calculate supply delta
174188
int256 supplyDelta = nextGlobalAMPLSupply.toInt256Safe().sub(recordedGlobalAMPLSupply);

test/unit/satellite-chain/xc-ampleforth/xc_controller.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ async function setupContracts () {
1515
.connect(deployer)
1616
.deploy();
1717

18+
await mockToken.updateGlobalAMPLSupply(39992123);
19+
1820
// deploy upgradable token
1921
const factory = await ethers.getContractFactory(
2022
'contracts/satellite-chain/xc-ampleforth/XCAmpleController.sol:XCAmpleController',
@@ -42,6 +44,12 @@ describe('XCAmpleController:Initialization', () => {
4244
it('should set the owner', async function () {
4345
expect(await controller.owner()).to.eq(await deployer.getAddress());
4446
});
47+
48+
it('should return the globalAmpleforthEpochAndAMPLSupply', async function () {
49+
const r = await controller.globalAmpleforthEpochAndAMPLSupply();
50+
expect(r[0]).to.eq(1);
51+
expect(r[1]).to.eq('39992123');
52+
});
4553
});
4654

4755
describe('XCAmpleController:setRebaseRelayer', async () => {

test/unit/satellite-chain/xc-ampleforth/xc_controller_rebase.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ describe('XCAmpleController:rebase', async () => {
8181
expect(await controller.globalAmpleforthEpoch()).to.eq(2);
8282
});
8383

84+
it('should update globalAmpleforthEpochAndAMPLSupply', async function () {
85+
await controller.connect(bridge).reportRebase(2, 50626634);
86+
await controller.connect(rebaseCaller).rebase();
87+
const r = await controller.globalAmpleforthEpochAndAMPLSupply();
88+
expect(r[0]).to.eq('2');
89+
expect(r[1]).to.eq('50626634');
90+
});
91+
8492
it('should update lastRebaseTimestampSec', async function () {
8593
const t1 = await controller.lastRebaseTimestampSec();
8694
await increaseTime(3600);

0 commit comments

Comments
 (0)