-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAMPLMaticRebaseGateway.sol
50 lines (42 loc) · 1.63 KB
/
AMPLMaticRebaseGateway.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.7.3;
import {FxBaseRootTunnel} from "fx-portal/contracts/tunnel/FxBaseRootTunnel.sol";
import {Layer2RebaseGateway} from "../../base-bridge-gateways/Layer2RebaseGateway.sol";
import {IAmpleforth} from "uFragments/contracts/interfaces/IAmpleforth.sol";
import {IERC20} from "oz-contracts/contracts/token/ERC20/IERC20.sol";
/**
* @title AMPLMaticRebaseGateway: AMPL-Matic Rebase Gateway Contract
* @dev This contract is deployed on the base chain (Ethereum).
*
* It's a pass-through contract between the Matic's bridge contracts and
* the Ampleforth policy.
*
*/
contract AMPLMaticRebaseGateway is Layer2RebaseGateway, FxBaseRootTunnel {
address public immutable ampl;
address public immutable policy;
/**
* @dev No-op as rebase report is one-way.
*/
function _processMessageFromChild(bytes memory data) internal override {
return;
}
/**
* @dev Builds the payload and transmits rebase report to matic.
*/
function reportRebase() external override {
uint256 recordedGlobalAmpleforthEpoch = IAmpleforth(policy).epoch();
uint256 recordedGlobalAMPLSupply = IERC20(ampl).totalSupply();
emit XCRebaseReportOut(recordedGlobalAmpleforthEpoch, recordedGlobalAMPLSupply);
_sendMessageToChild(abi.encode(recordedGlobalAmpleforthEpoch, recordedGlobalAMPLSupply));
}
constructor(
address _checkpointManager,
address _fxRoot,
address ampl_,
address policy_
) FxBaseRootTunnel(_checkpointManager, _fxRoot) {
ampl = ampl_;
policy = policy_;
}
}