Skip to content

Commit 91390c5

Browse files
author
justin j. moses
authored
Interface improvements for third parties (Synthetixio#514)
1 parent b015b8f commit 91390c5

File tree

8 files changed

+129
-59
lines changed

8 files changed

+129
-59
lines changed

contracts/Synthetix.sol

+1-7
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ contract Synthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
172172
return _totalIssuedSynths(currencyKey, true);
173173
}
174174

175-
/**
176-
* @notice Returns the currencyKeys of availableSynths for rate checking
177-
*/
178175
function availableCurrencyKeys() public view returns (bytes32[] memory) {
179176
bytes32[] memory currencyKeys = new bytes32[](availableSynths.length);
180177

@@ -185,10 +182,7 @@ contract Synthetix is IERC20, ExternStateToken, MixinResolver, ISynthetix {
185182
return currencyKeys;
186183
}
187184

188-
/**
189-
* @notice Returns the count of available synths in the system, which you can use to iterate availableSynths
190-
*/
191-
function availableSynthCount() public view returns (uint) {
185+
function availableSynthCount() external view returns (uint) {
192186
return availableSynths.length;
193187
}
194188

contracts/interfaces/IDepot.sol

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@ pragma solidity ^0.5.16;
22

33

44
interface IDepot {
5-
function exchangeEtherForSynths() external payable returns (uint);
5+
// Views
6+
function fundsWallet() external view returns (address payable);
67

7-
function exchangeEtherForSynthsAtRate(uint guaranteedRate) external payable returns (uint);
8+
function maxEthPurchase() external view returns (uint);
9+
10+
function minimumDepositAmount() external view returns (uint);
11+
12+
function synthsReceivedForEther(uint amount) external view returns (uint);
13+
14+
function totalSellableDeposits() external view returns (uint);
815

16+
// Mutative functions
917
function depositSynths(uint amount) external;
1018

19+
function exchangeEtherForSynths() external payable returns (uint);
20+
21+
function exchangeEtherForSynthsAtRate(uint guaranteedRate) external payable returns (uint);
22+
1123
function withdrawMyDepositedSynths() external;
1224

13-
// Deprecated ABI for MAINNET. Only used on Testnets
25+
// Note: On mainnet no SNX has been deposited. The following functions are kept alive for testnet SNX faucets.
1426
function exchangeEtherForSNX() external payable returns (uint);
1527

1628
function exchangeEtherForSNXAtRate(uint guaranteedRate, uint guaranteedSynthetixRate) external payable returns (uint);
+35-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
pragma solidity ^0.5.16;
22

3+
import "@chainlink/contracts-0.0.3/src/v0.5/dev/AggregatorInterface.sol";
4+
35

46
interface IExchangeRates {
57
// Views
8+
function aggregators(bytes32 currencyKey) external view returns (AggregatorInterface);
9+
10+
function anyRateIsStale(bytes32[] calldata currencyKeys) external view returns (bool);
11+
12+
function currentRoundForRate(bytes32 currencyKey) external view returns (uint);
13+
614
function effectiveValue(
715
bytes32 sourceCurrencyKey,
816
uint sourceAmount,
917
bytes32 destinationCurrencyKey
1018
) external view returns (uint);
1119

12-
function rateForCurrency(bytes32 currencyKey) external view returns (uint);
13-
14-
function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);
15-
16-
function rateIsStale(bytes32 currencyKey) external view returns (bool);
17-
18-
function rateIsFrozen(bytes32 currencyKey) external view returns (bool);
19-
20-
function anyRateIsStale(bytes32[] calldata currencyKeys) external view returns (bool);
21-
22-
function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);
23-
2420
function effectiveValueAtRound(
2521
bytes32 sourceCurrencyKey,
2622
uint sourceAmount,
@@ -29,14 +25,40 @@ interface IExchangeRates {
2925
uint roundIdForDest
3026
) external view returns (uint);
3127

28+
function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);
29+
3230
function getLastRoundIdBeforeElapsedSecs(
3331
bytes32 currencyKey,
3432
uint startingRoundId,
3533
uint startingTimestamp,
3634
uint timediff
3735
) external view returns (uint);
3836

39-
function ratesAndStaleForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory, bool);
37+
function inversePricing(bytes32 currencyKey)
38+
external
39+
view
40+
returns (
41+
uint entryPoint,
42+
uint upperLimit,
43+
uint lowerLimit,
44+
bool frozen
45+
);
46+
47+
function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);
48+
49+
function oracle() external view returns (address);
4050

4151
function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time);
52+
53+
function rateForCurrency(bytes32 currencyKey) external view returns (uint);
54+
55+
function rateIsFrozen(bytes32 currencyKey) external view returns (bool);
56+
57+
function rateIsStale(bytes32 currencyKey) external view returns (bool);
58+
59+
function ratesAndStaleForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory, bool);
60+
61+
function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);
62+
63+
function rateStalePeriod() external view returns (uint);
4264
}

contracts/interfaces/IExchanger.sol

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ pragma solidity ^0.5.16;
33

44
interface IExchanger {
55
// Views
6-
function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);
6+
function calculateAmountAfterSettlement(
7+
address from,
8+
bytes32 currencyKey,
9+
uint amount,
10+
uint refunded
11+
) external view returns (uint amountAfterSettlement);
712

813
function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view returns (uint);
914

15+
function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);
16+
1017
function settlementOwing(address account, bytes32 currencyKey)
1118
external
1219
view
@@ -16,22 +23,7 @@ interface IExchanger {
1623
uint numEntries
1724
);
1825

19-
function calculateAmountAfterSettlement(
20-
address from,
21-
bytes32 currencyKey,
22-
uint amount,
23-
uint refunded
24-
) external view returns (uint amountAfterSettlement);
25-
2626
// Mutative functions
27-
function settle(address from, bytes32 currencyKey)
28-
external
29-
returns (
30-
uint reclaimed,
31-
uint refunded,
32-
uint numEntries
33-
);
34-
3527
function exchange(
3628
address from,
3729
bytes32 sourceCurrencyKey,
@@ -47,4 +39,12 @@ interface IExchanger {
4739
uint sourceAmount,
4840
bytes32 destinationCurrencyKey
4941
) external returns (uint amountReceived);
42+
43+
function settle(address from, bytes32 currencyKey)
44+
external
45+
returns (
46+
uint reclaimed,
47+
uint refunded,
48+
uint numEntries
49+
);
5050
}

contracts/interfaces/IFeePool.sol

+18-4
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,36 @@ pragma solidity ^0.5.16;
33

44
interface IFeePool {
55
// Views
6+
function amountReceivedFromExchange(uint value) external view returns (uint);
7+
8+
function exchangeFeeRate() external view returns (uint);
69

7-
// solhint-disable func-name-mixedcase
10+
// solhint-disable-next-line func-name-mixedcase
811
function FEE_ADDRESS() external view returns (address);
912

10-
function exchangeFeeRate() external view returns (uint);
13+
function feesAvailable(address account) external view returns (uint, uint);
1114

12-
function amountReceivedFromExchange(uint value) external view returns (uint);
15+
function isFeesClaimable(address account) external view returns (bool);
16+
17+
function totalFeesAvailable() external view returns (uint);
18+
19+
function totalRewardsAvailable() external view returns (uint);
1320

1421
// Mutative Functions
15-
function recordFeePaid(uint sUSDAmount) external;
22+
function claimFees() external returns (bool);
23+
24+
function claimOnBehalf(address claimingForAddress) external returns (bool);
1625

26+
function closeCurrentFeePeriod() external;
27+
28+
// Restricted: used internally to Synthetix
1729
function appendAccountIssuanceRecord(
1830
address account,
1931
uint lockedAmount,
2032
uint debtEntryIndex
2133
) external;
2234

35+
function recordFeePaid(uint sUSDAmount) external;
36+
2337
function setRewardsToDistribute(uint amount) external;
2438
}

contracts/interfaces/IIssuer.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface IIssuer {
77

88
function lastIssueEvent(address account) external view returns (uint);
99

10-
// Mutative functions
10+
// Restricted: used internally to Synthetix
1111
function issueSynths(address from, uint amount) external;
1212

1313
function issueSynthsOnBehalf(

contracts/interfaces/ISynth.sol

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ interface ISynth {
55
// Views
66
function currencyKey() external view returns (bytes32);
77

8-
// Mutative functions
9-
function burn(address account, uint amount) external;
10-
11-
function issue(address account, uint amount) external;
8+
function transferableSynths(address account) external view returns (uint);
129

10+
// Mutative functions
1311
function transferAndSettle(address to, uint value) external returns (bool);
1412

1513
function transferFromAndSettle(
1614
address from,
1715
address to,
1816
uint value
1917
) external returns (bool);
18+
19+
// Restricted: used internally to Synthetix
20+
function burn(address account, uint amount) external;
21+
22+
function issue(address account, uint amount) external;
2023
}

contracts/interfaces/ISynthetix.sol

+36-11
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import "../interfaces/ISynth.sol";
55

66
interface ISynthetix {
77
// Views
8-
function synths(bytes32 currencyKey) external view returns (ISynth);
8+
function availableCurrencyKeys() external view returns (bytes32[] memory);
99

10-
function synthsByAddress(address synthAddress) external view returns (bytes32);
10+
function availableSynthCount() external view returns (uint);
1111

12-
function collateralisationRatio(address issuer) external view returns (uint);
13-
14-
function totalIssuedSynths(bytes32 currencyKey) external view returns (uint);
12+
function collateral(address account) external view returns (uint);
1513

16-
function totalIssuedSynthsExcludeEtherCollateral(bytes32 currencyKey) external view returns (uint);
14+
function collateralisationRatio(address issuer) external view returns (uint);
1715

1816
function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint);
1917

@@ -22,6 +20,10 @@ interface ISynthetix {
2220
view
2321
returns (uint debtBalance, uint totalSystemValue);
2422

23+
function isWaitingPeriod(bytes32 currencyKey) external view returns (bool);
24+
25+
function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);
26+
2527
function remainingIssuableSynths(address issuer)
2628
external
2729
view
@@ -31,24 +33,47 @@ interface ISynthetix {
3133
uint totalSystemDebt
3234
);
3335

34-
function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);
36+
function synths(bytes32 currencyKey) external view returns (ISynth);
3537

36-
function isWaitingPeriod(bytes32 currencyKey) external view returns (bool);
38+
function synthsByAddress(address synthAddress) external view returns (bytes32);
39+
40+
function totalIssuedSynths(bytes32 currencyKey) external view returns (uint);
41+
42+
function totalIssuedSynthsExcludeEtherCollateral(bytes32 currencyKey) external view returns (uint);
43+
44+
function transferableSynthetix(address account) external view returns (uint);
3745

3846
// Mutative Functions
47+
function burnSynths(uint amount) external;
48+
49+
function burnSynthsOnBehalf(address burnForAddress, uint amount) external;
50+
51+
function burnSynthsToTarget() external;
52+
53+
function burnSynthsToTargetOnBehalf(address burnForAddress) external;
54+
3955
function exchange(
4056
bytes32 sourceCurrencyKey,
4157
uint sourceAmount,
4258
bytes32 destinationCurrencyKey
4359
) external returns (uint amountReceived);
4460

45-
function issueSynths(uint amount) external;
61+
function exchangeOnBehalf(
62+
address exchangeForAddress,
63+
bytes32 sourceCurrencyKey,
64+
uint sourceAmount,
65+
bytes32 destinationCurrencyKey
66+
) external returns (uint amountReceived);
4667

4768
function issueMaxSynths() external;
4869

49-
function burnSynths(uint amount) external;
70+
function issueMaxSynthsOnBehalf(address issueForAddress) external;
5071

51-
function burnSynthsToTarget() external;
72+
function issueSynths(uint amount) external;
73+
74+
function issueSynthsOnBehalf(address issueForAddress, uint amount) external;
75+
76+
function mint() external returns (bool);
5277

5378
function settle(bytes32 currencyKey)
5479
external

0 commit comments

Comments
 (0)