event ClearedDeposit(address fromAddress, address toAddress, uint fromETHAmount, uint toAmount, uint depositIndex)
event Exchange(string fromCurrency, uint fromAmount, string toCurrency, uint toAmount)
event FundsWalletUpdated(address newFundsWallet)
event MinimumDepositAmountUpdated(uint amount)
event NonPayableContract(address receiver, uint amount)
event OracleUpdated(address newOracle)
event PriceStalePeriodUpdated(uint priceStalePeriod)
event PricesUpdated(uint newEthPrice, uint newSynthetixPrice, uint timeSent)
event SynthDeposit(address user, uint amount, uint depositIndex)
event SynthDepositNotAccepted(address user, uint amount, uint minimum)
event SynthDepositRemoved(address user, uint amount, uint depositIndex)
event SynthUpdated(Synth newSynthContract)
event SynthWithdrawal(address user, uint amount)
event SynthetixUpdated(Synthetix newSynthetixContract)
function depositSynths(uint amount) external
DepositSynths: Allows users to deposit synths via the approve / transferFrom workflow if they'd like. You can equally just transfer synths to this contract and it will work exactly the same way but with one less call (and therefore cheaper transaction fees).
amount- The amount of sUSD you wish to deposit (must have been approved first)
function exchangeEtherForSynthetixAtRate(uint guaranteedEtherRate, uint guaranteedSynthetixRate) public payable returns (uint)
Exchange ETH to SNX while insisting on a particular set of rates. This allows a user to exchange while protecting against frontrunning by the contract owner on the exchange rates.
function exchangeEtherForSynthsAtRate(uint guaranteedRate) public payable returns (uint)
Exchange ETH to sUSD while insisting on a particular rate. This allows a user to exchange while protecting against frontrunning by the contract owner on the exchange rate.
function exchangeSynthsForSynthetixAtRate(uint synthAmount, uint guaranteedRate) public returns (uint)
Exchange sUSD for SNX while insisting on a particular rate. This allows a user to exchange while protecting against frontrunning by the contract owner on the exchange rate.
function (address _owner, address _fundsWallet, Synthetix _synthetix, Synth _synth, FeePool _feePool, address _oracle, uint _usdToEthPrice, uint _usdToSnxPrice) public
_owner- The owner of this contract.
_fundsWallet- The recipient of ETH and Synths that are sent to this contract while exchanging.
_synthetix- The Synthetix contract we'll interact with for balances and sending.
_synth- The Synth contract we'll interact with for balances and sending.
_oracle- The address which is able to update price information.
_usdToEthPrice- The current price of ETH in USD, expressed in UNIT.
_usdToSnxPrice- The current price of Synthetix in USD, expressed in UNIT.
function () external payable
Fallback function (exchanges ETH to sUSD).
function pricesAreStale() public view returns (bool)
Check if the prices haven't been updated for longer than the stale period.
function setFundsWallet(address _fundsWallet) external
Set the funds wallet where ETH raised is held.
_fundsWallet- The new address to forward ETH and Synths to
function setMinimumDepositAmount(uint _amount) external
Set the minimum deposit amount required to depoist sUSD into the FIFO queue.
_amount- The new new minimum number of sUSD required to deposit
function setOracle(address _oracle) external
Set the Oracle that pushes the synthetix price to this contract.
_oracle- The new oracle address
function setPriceStalePeriod(uint _time) external
Set the stale period on the updated price variables.
_time- The new priceStalePeriod
function setSynth(Synth _synth) external
Set the Synth contract that the issuance controller uses to issue Synths.
_synth- The new synth contract target
function setSynthetix(Synthetix _synthetix) external
Set the Synthetix contract that the issuance controller uses to issue SNX.
_synthetix- The new synthetix contract target
function synthetixReceivedForEther(uint amount) public view returns (uint)
Calculate how many SNX you will receive if you transfer an amount of ether.
amount- The amount of ether (in wei) you want to ask about
function synthetixReceivedForSynths(uint amount) public view returns (uint)
Calculate how many SNX you will receive if you transfer an amount of synths.
amount- The amount of synths (in 18 decimal places) you want to ask about
function synthsReceivedForEther(uint amount) public view returns (uint)
Calculate how many synths you will receive if you transfer an amount of ether.
amount- The amount of ether (in wei) you want to ask about
function tokenFallback(address from, uint amount, bytes data) external returns (bool)
Triggers when users send us SNX or sUSD, but the modifier only allows sUSD calls to proceed.
from- The address sending the sUSD
amount- The amount of sUSD
function updatePrices(uint newEthPrice, uint newSynthetixPrice, uint timeSent) external
Access point for the oracle to update the prices of SNX / eth.
newEthPrice- The current price of ether in USD, specified to 18 decimal places.
newSynthetixPrice- The current price of SNX in USD, specified to 18 decimal places.
timeSent- The timestamp from the oracle when the transaction was created. This ensures we don't consider stale prices as current in times of heavy network congestion.
function withdrawMyDepositedSynths() external
Allows a user to withdraw all of their previously deposited synths from this contract if needed. Developer note: We could keep an index of address to deposits to make this operation more efficient but then all the other operations on the queue become less efficient. It's expected that this function will be very rarely used, so placing the inefficiency here is intentional. The usual use case does not involve a withdrawal.
function withdrawSynthetix(uint amount) external
Allows the owner to withdraw SNX from this contract if needed.
amount- The amount of SNX to attempt to withdraw (in 18 decimal places).