-
Notifications
You must be signed in to change notification settings - Fork 42
Conversation
Only TBTCDepositToken should be changed since it is the only contract used. The rest are just address placeholders for init funcitons.
FeeRebateToken not using IERC721 since the interface does not expose an exists() function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few questions/notes.
@@ -354,8 +350,7 @@ library DepositUtils { | |||
/// @dev We cast the address to a uint256 to match the 721 standard. | |||
/// @return The current deposit beneficiary. | |||
function depositOwner(Deposit storage _d) public view returns (address payable) { | |||
IERC721 _tbtcDepositToken = IERC721(_d.TBTCDepositToken); | |||
return address(uint160(_tbtcDepositToken.ownerOf(uint256(address(this))))); | |||
return address(uint160(_d.tbtcDepositToken.ownerOf(uint256(address(this))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there room here for an overload of ownerAddressOf
that takes a Deposit
and returns an address
and does all of the weird type conversions for us as needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that might be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth cycles unless you're motivated, but yeah, seems cleaner.
Instead of casting the parameter adress, accept Contract type directly
Add functions needed to create a new Deposit.
The interface should contain all function sneeded to create the Deposit.
address public feeRebateToken; | ||
TBTCSystem public tbtcSystem; | ||
TBTCToken public tbtcToken; | ||
FeeRebateToken public feeRebateToken; | ||
address public vendingMachine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we hit this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only use the address and never call any VendingMachine
contract functions.
Hitting this would be counterproductive since we would just have to cast it back to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use the address? createNewDeposit
should likewise take a VendingMachine
, right? Generally eschewing the type check is a bad idea, and if we have to cast to a looser type at the use point, that's fine---otherwise you're leaving on the table the capacity of the compiler to bonk you when you mishandle some point in the initialization chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use the address?
It's just used for redemption logic:
if(tdtHolder == vendingMachine){...}
Worth noting, It's introduced into the system as a contract type via tbtcSystem.initialize().
Then it's passed along and stored as an address. Might be worth renaming it to vendingMachineAddress
to avoid confusion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. Makes it clear that we're really only interested in the address.
Also makes it clear this is a dirty dirty hack and in another life where we had more time we'd try to get around it haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok awesome
function requestNewKeep(uint256 _m, uint256 _n, uint256 _bond) external payable returns (address); | ||
function getSignerFeeDivisor() external view returns (uint256); | ||
function getUndercollateralizedThresholdPercent() external view returns (uint128); | ||
function getSeverelyUndercollateralizedThresholdPercent() external view returns (uint128); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably our docs should be here rather than on TBTCSystem
, but I need to see how our documentation generator is operating.
Explicit visibility for consistency
When a contract has use beyon it's address, Pass the contract type isntead of the address.
dd39eaf
to
41104d0
Compare
Use `this` instead of casting twice to get to the same result.
Take an explicit contract type over an address
We're not using the contract instance, clarify that we are only using the address
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
Changing distributeERC20Reward to accept IERC20 param Requires some dependency syncing Revert the change for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's do ittt.
closes: #507
Rather than storing addresses and then casting to the known contract type, it’s better to use the best type available so the compiler can check for type safety.