Skip to content

Public Contract interfaces #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/UFragmentsPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ contract UFragmentsPolicy is Ownable {

/**
* @notice A multi-chain AMPL interface method. The Ampleforth monetary policy contract
* on the base-chain and XCAmpleController contracts on the satellite-chains
* on the base-chain and XC-AmpleController contracts on the satellite-chains
* implement this method. It atomically returns two values:
* what the current contract believes to be,
* the globalAmpleforthEpoch and globalAMPLSupply.
* @return globalAmpleforthEpoch The current epoch number.
* @return globalAMPLSupply The total supply at the current epoch.
*/
function getGlobalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
function globalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
return (epoch, uFrags.totalSupply());
}

Expand Down
49 changes: 49 additions & 0 deletions contracts/interfaces/IAMPL.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pragma solidity 0.4.24;

// Public interface definition for the AMPL - ERC20 token on Ethereum (the base-chain)
interface IAMPL {
// ERC20
function totalSupply() external view returns (uint256);

function balanceOf(address who) external view returns (uint256);

function allowance(address owner_, address spender) external view returns (uint256);

function transfer(address to, uint256 value) external returns (bool);

function approve(address spender, uint256 value) external returns (bool);

function increaseAllowance(address spender, uint256 addedValue) external returns (bool);

function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);

function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);

// EIP-2612
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;

function nonces(address owner) external view returns (uint256);

function DOMAIN_SEPARATOR() external view returns (bytes32);

// Elastic token interface
function scaledBalanceOf(address who) external view returns (uint256);

function scaledTotalSupply() external view returns (uint256);

function transferAll(address to) external returns (bool);

function transferAllFrom(address from, address to) external returns (bool);
}
12 changes: 12 additions & 0 deletions contracts/interfaces/IAmpleforth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pragma solidity 0.4.24;

// Public interface definition for the Ampleforth supply policy on Ethereum (the base-chain)
interface IAmpleforth {
function epoch() external view returns (uint256);

function lastRebaseTimestampSec() external view returns (uint256);

function inRebaseWindow() external view returns (bool);

function globalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256);
}
6 changes: 6 additions & 0 deletions contracts/interfaces/IOrchestrator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity 0.4.24;

// Public interface definition for the Ampleforth Orchestrator on Ethereum (the base-chain)
interface IOrchestrator {
function rebase() external;
}
8 changes: 4 additions & 4 deletions test/unit/UFragmentsPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ describe('UFragmentsPolicy:initialize', async function () {
it('epoch', async function () {
expect(await uFragmentsPolicy.epoch()).to.eq(0)
})
it('getGlobalAmpleforthEpochAndAMPLSupply', async function () {
const r = await uFragmentsPolicy.getGlobalAmpleforthEpochAndAMPLSupply()
it('globalAmpleforthEpochAndAMPLSupply', async function () {
const r = await uFragmentsPolicy.globalAmpleforthEpochAndAMPLSupply()
expect(r[0]).to.eq(0)
expect(r[1]).to.eq(0)
})
Expand Down Expand Up @@ -833,9 +833,9 @@ describe('UFragmentsPolicy:Rebase', async function () {
expect(await uFragmentsPolicy.epoch()).to.eq(prevEpoch.add(1))
})

it('should update getGlobalAmpleforthEpochAndAMPLSupply', async function () {
it('should update globalAmpleforthEpochAndAMPLSupply', async function () {
await uFragmentsPolicy.connect(orchestrator).rebase()
const r = await uFragmentsPolicy.getGlobalAmpleforthEpochAndAMPLSupply()
const r = await uFragmentsPolicy.globalAmpleforthEpochAndAMPLSupply()
expect(r[0]).to.eq(prevEpoch.add(1))
expect(r[1]).to.eq('1010')
})
Expand Down