Skip to content

Commit a61354c

Browse files
author
CLINT
authored
Eth Collateral Trial 2 (Synthetixio#612)
1 parent 6106a7a commit a61354c

File tree

3 files changed

+180
-119
lines changed

3 files changed

+180
-119
lines changed

contracts/EtherCollateral.sol

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract EtherCollateral is Owned, Pausable, ReentrancyGuard, MixinResolver, IEt
3636
// ========== SETTER STATE VARIABLES ==========
3737

3838
// The ratio of Collateral to synths issued
39-
uint256 public collateralizationRatio = SafeDecimalMath.unit() * 150;
39+
uint256 public collateralizationRatio = SafeDecimalMath.unit() * 125; // SCCP-27
4040

4141
// If updated, all outstanding loans will pay this interest rate in on closure of the loan. Default 5%
4242
uint256 public interestRate = (5 * SafeDecimalMath.unit()) / 100;
@@ -48,7 +48,7 @@ contract EtherCollateral is Owned, Pausable, ReentrancyGuard, MixinResolver, IEt
4848
// Maximum amount of sETH that can be issued by the EtherCollateral contract. Default 5000
4949
uint256 public issueLimit = SafeDecimalMath.unit() * 5000;
5050

51-
// Minimum amount of ETH to create loan preventing griefing and gas consumption. Min 1ETH = 0.6666666667 sETH
51+
// Minimum amount of ETH to create loan preventing griefing and gas consumption. Min 1ETH = 0.8 sETH
5252
uint256 public minLoanSize = SafeDecimalMath.unit() * 1;
5353

5454
// Maximum number of loans an account can create
@@ -201,8 +201,8 @@ contract EtherCollateral is Owned, Pausable, ReentrancyGuard, MixinResolver, IEt
201201
}
202202

203203
// returns value of 100 / collateralizationRatio.
204-
// e.g. 100/150 = 0.666666666666666667
205-
// or in wei 100000000000000000000/150000000000000000000 = 666666666666666667
204+
// e.g. 100/125 = 0.8
205+
// or in wei 100000000000000000000/125000000000000000000 = 800000000000000000
206206
function issuanceRatio() public view returns (uint256) {
207207
// this Rounds so you get slightly more rather than slightly less
208208
// 4999999999999999995000
@@ -372,26 +372,26 @@ contract EtherCollateral is Owned, Pausable, ReentrancyGuard, MixinResolver, IEt
372372
// Calculate and deduct interest(5%) and minting fee(50 bips) in ETH
373373
uint256 interestAmount = accruedInterestOnLoan(synthLoan.loanAmount, _loanLifeSpan(synthLoan));
374374
uint256 mintingFee = _calculateMintingFee(synthLoan);
375-
uint256 totalFees = interestAmount.add(mintingFee);
375+
uint256 totalFeeETH = interestAmount.add(mintingFee);
376376

377377
// Burn all Synths issued for the loan
378378
synthsETH().burn(msg.sender, synthLoan.loanAmount);
379379

380380
// Fee Distribution. Purchase sUSD with ETH from Depot
381381
require(
382-
IERC20(address(synthsUSD())).balanceOf(address(depot())) >= totalFees,
382+
IERC20(address(synthsUSD())).balanceOf(address(depot())) >= depot().synthsReceivedForEther(totalFeeETH),
383383
"The sUSD Depot does not have enough sUSD to buy for fees"
384384
);
385-
depot().exchangeEtherForSynths.value(totalFees)();
385+
depot().exchangeEtherForSynths.value(totalFeeETH)();
386386

387387
// Transfer the sUSD to distribute to SNX holders.
388388
IERC20(address(synthsUSD())).transfer(FEE_ADDRESS, IERC20(address(synthsUSD())).balanceOf(address(this)));
389389

390390
// Send remainder ETH to caller
391-
address(msg.sender).transfer(synthLoan.collateralAmount.sub(totalFees));
391+
address(msg.sender).transfer(synthLoan.collateralAmount.sub(totalFeeETH));
392392

393393
// Tell the Dapps
394-
emit LoanClosed(account, loanID, totalFees);
394+
emit LoanClosed(account, loanID, totalFeeETH);
395395
}
396396

397397
function _getLoanFromStorage(address account, uint256 loanID) private view returns (SynthLoanStruct memory) {

contracts/interfaces/IDepot.sol

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity >=0.4.24;
22

3+
contract IDepot {
34

4-
interface IDepot {
55
// Views
66
function fundsWallet() external view returns (address payable);
77

@@ -29,5 +29,9 @@ interface IDepot {
2929

3030
function exchangeSynthsForSNX(uint synthAmount) external returns (uint);
3131

32-
function exchangeSynthsForSNXAtRate(uint synthAmount, uint guaranteedRate) external returns (uint);
32+
function synthetixReceivedForEther(uint amount) public view returns (uint);
33+
34+
function synthetixReceivedForSynths(uint amount) public view returns (uint);
35+
36+
function withdrawSynthetix(uint amount) external;
3337
}

0 commit comments

Comments
 (0)