Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Use specific contract types #542

Merged
merged 13 commits into from
Mar 26, 2020
6 changes: 3 additions & 3 deletions solidity/contracts/deposit/Deposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contract Deposit is DepositFactoryAuthority {
/// @param _TBTCToken `TBTCToken` contract. More info in TBTCToken`.
/// @param _TBTCDepositToken `TBTCDepositToken` (TDT) contract. More info in `TBTCDepositToken`.
/// @param _FeeRebateToken `FeeRebateToken` (FRT) contract. More info in `FeeRebateToken`.
/// @param _VendingMachine `VendingMachine` address. More info in `VendingMachine`.
/// @param _VendingMachineAddress `VendingMachine` address. More info in `VendingMachine`.
/// @param _m Signing group honesty threshold.
/// @param _n Signing group size.
/// @param _lotSizeSatoshis The minimum amount of satoshi the funder is required to send.
Expand All @@ -113,7 +113,7 @@ contract Deposit is DepositFactoryAuthority {
TBTCToken _TBTCToken,
IERC721 _TBTCDepositToken,
FeeRebateToken _FeeRebateToken,
address _VendingMachine,
address _VendingMachineAddress,
uint256 _m,
uint256 _n,
uint256 _lotSizeSatoshis
Expand All @@ -122,7 +122,7 @@ contract Deposit is DepositFactoryAuthority {
self.tbtcToken = _TBTCToken;
self.tbtcDepositToken = _TBTCDepositToken;
self.feeRebateToken = _FeeRebateToken;
self.VendingMachine = _VendingMachine;
self.VendingMachineAddress = _VendingMachineAddress;
Shadowfiend marked this conversation as resolved.
Show resolved Hide resolved
self.createNewDeposit(_m, _n, _lotSizeSatoshis);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/DepositLiquidation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ library DepositLiquidation {
uint256 lotSizeTbtc = _d.lotSizeTbtc();
require(_d.tbtcToken.balanceOf(msg.sender) >= lotSizeTbtc, "Not enough TBTC to cover outstanding debt");

if(tdtHolder == _d.VendingMachine){
if(tdtHolder == _d.VendingMachineAddress){
_d.tbtcToken.burnFrom(msg.sender, lotSizeTbtc); // burn minimal amount to cover size
}
else{
Expand Down
6 changes: 3 additions & 3 deletions solidity/contracts/deposit/DepositRedemption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ library DepositRedemption {
IBondedECDSAKeep _keep = IBondedECDSAKeep(_d.keepAddress);

_d.tbtcToken.approve(_d.keepAddress, _d.signerFee());
_keep.distributeERC20Reward(address(_d.tbtcToken), _d.signerFee());
_keep.distributeERC20Reward(_d.tbtcToken, _d.signerFee());
}

/// @notice Closes keep associated with the deposit.
Expand All @@ -59,7 +59,7 @@ library DepositRedemption {
/// @dev Burns or transfers depending on term and supply-peg impact.
function performRedemptionTBTCTransfers(DepositUtils.Deposit storage _d) internal {
address tdtHolder = _d.depositOwner();
address vendingMachine = _d.VendingMachine;
address vendingMachineAddress = _d.VendingMachineAddress;

uint256 tbtcLot = _d.lotSizeTbtc();
uint256 signerFee = _d.signerFee();
Expand All @@ -81,7 +81,7 @@ library DepositRedemption {
// As compensation, the TDT owner is reimbursed in TBTC
// Vending Machine-owned TDTs have been used to mint TBTC,
// and we should always burn a full TBTC to redeem the deposit.
if(tdtHolder == vendingMachine){
if(tdtHolder == vendingMachineAddress){
_d.tbtcToken.burnFrom(msg.sender, tbtcLot);
}
// if signer fee is not escrowed, escrow and it here and send the rest to TDT owner
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/deposit/DepositUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library DepositUtils {
TBTCToken tbtcToken;
IERC721 tbtcDepositToken;
FeeRebateToken feeRebateToken;
address VendingMachine;
address VendingMachineAddress;
uint256 lotSizeSatoshis;
uint8 currentState;
uint256 signerFeeDivisor;
Expand Down
10 changes: 5 additions & 5 deletions solidity/contracts/proxy/DepositFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{
TBTCSystem public tbtcSystem;
TBTCToken public tbtcToken;
FeeRebateToken public feeRebateToken;
address public vendingMachine;
address public vendingMachineAddress;
uint256 public keepThreshold;
uint256 public keepSize;

Expand All @@ -38,7 +38,7 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{
/// @param _tbtcToken TBTC token contract.
/// @param _tbtcDepositToken TBTC Deposit Token contract.
/// @param _feeRebateToken AFee Rebate Token contract.
/// @param _vendingMachine Address of the Vending Machine contract.
/// @param _vendingMachineAddress Address of the Vending Machine contract.
/// @param _keepThreshold Minimum number of honest keep members.
/// @param _keepSize Number of all members in a keep.
function setExternalDependencies(
Expand All @@ -47,7 +47,7 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{
TBTCToken _tbtcToken,
TBTCDepositToken _tbtcDepositToken,
FeeRebateToken _feeRebateToken,
address _vendingMachine,
address _vendingMachineAddress,
uint256 _keepThreshold,
uint256 _keepSize
) public onlyTbtcSystem {
Expand All @@ -56,7 +56,7 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{
tbtcSystem = _tbtcSystem;
tbtcToken = _tbtcToken;
feeRebateToken = _feeRebateToken;
vendingMachine = _vendingMachine;
vendingMachineAddress = _vendingMachineAddress;
keepThreshold = _keepThreshold;
keepSize = _keepSize;
}
Expand All @@ -81,7 +81,7 @@ contract DepositFactory is CloneFactory, TBTCSystemAuthority{
tbtcToken,
tbtcDepositToken,
feeRebateToken,
vendingMachine,
vendingMachineAddress,
keepThreshold,
keepSize,
_lotSizeSatoshis
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/system/TBTCSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {
);
_depositFactory.setExternalDependencies(
_masterDepositAddress,
TBTCSystem(address(this)),
this,
_tbtcToken,
_tbtcDepositToken,
_feeRebateToken,
Expand Down
8 changes: 4 additions & 4 deletions solidity/contracts/test/deposit/TestDeposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract TestDeposit is Deposit {
TBTCToken _TBTCToken,
IERC721 _TBTCDepositToken,
FeeRebateToken _FeeRebateToken,
address _VendingMachine,
address _vendingMachineAddress,
uint256 _m,
uint256 _n,
uint256 _lotSizeSatoshis
Expand All @@ -26,7 +26,7 @@ contract TestDeposit is Deposit {
self.tbtcToken = (_TBTCToken);
self.tbtcDepositToken = (_TBTCDepositToken);
self.feeRebateToken = (_FeeRebateToken);
self.VendingMachine = _VendingMachine;
self.VendingMachineAddress = _vendingMachineAddress;
self.createNewDeposit(_m, _n, _lotSizeSatoshis);
return true;
}
Expand All @@ -36,13 +36,13 @@ contract TestDeposit is Deposit {
address _token,
address _tbtcDepositToken,
address _feeRebateToken,
address _vendingMachine
address _vendingMachineAddress
) public {
self.tbtcSystem = ITBTCSystem(_sys);
self.tbtcToken = TBTCToken(_token);
self.tbtcDepositToken = IERC721(_tbtcDepositToken);
self.feeRebateToken = FeeRebateToken(_feeRebateToken);
self.VendingMachine = _vendingMachine;
self.VendingMachineAddress = _vendingMachineAddress;
Shadowfiend marked this conversation as resolved.
Show resolved Hide resolved
}

function reset() public {
Expand Down
3 changes: 2 additions & 1 deletion solidity/contracts/test/keep/ECDSAKeepStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.5.10;
import {
IBondedECDSAKeep
} from "@keep-network/keep-ecdsa/contracts/api/IBondedECDSAKeep.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";

/// @notice Implementation of ECDSAKeep interface used in tests only
/// @dev This is a stub used in tests, so we don't have to call actual ECDSAKeep
Expand Down Expand Up @@ -35,7 +36,7 @@ contract ECDSAKeepStub is IBondedECDSAKeep {
// solium-disable-previous-line no-empty-blocks
}

function distributeERC20Reward(address _asset, uint256 _value) external {
function distributeERC20Reward(IERC20 _asset, uint256 _value) external {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be enough, we have to play this out over both repos. Let's do that in a separate PR.

Copy link
Contributor Author

@NicholasDotSol NicholasDotSol Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be enough

We just need an interface change from keep-ecdsa. This should be enough for Deposit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to play this out over both repos

Okay with moving to separate PR to unblock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the interface change will also require changing the implementors of the interface, etc. It's not going to be huge, just needs a little more finesse :)

// solium-disable-previous-line no-empty-blocks
}

Expand Down