You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a common pattern to include an ERC20 token extraction mechanism in rapidly developed contracts in case of accidentally trapped funds. I think it could be useful to upgrade all the gem join contracts to be compliant with part of the ERC20 standard - specifically transfer, transferFrom and balanceOf. This would basically provide an ERC20-compliant escape hatch for accidentally stuck collateral to be extracted from Maker.
The functions would look something like this (pseudocode):
function balanceOf (account) {
// Return the ink that can be freed from vat.frob (after repaying with the available vat.dai) and any vat.gem available
}
function transfer (address recipient, uint amount) {
if (vat.gem[ilk][msg.sender] < amount) {
// Pull the ink out of the cdp and repay as much dai as available
vat.frob(ilk, msg.sender, msg.sender, msg.sender, -int(sub(amount, vat.gem[ilk][msg.sender])), -int(vat.dai[msg.sender]));
}
exit(recipient, amount);
}
function transferFrom (address sender, address recipient, uint amount) {
require(sender == msg.sender)
transfer(recipient, amount);
}
This would allow anyone to completely unwind a CDP with only the ERC20 transfer semantics as any account is able to repay debt. So for example to unwind my locked CDP, I can do: Flash Loan (Dai), Repay all CDP Debt, gemJoin.transfer(myAccount, gemJoin.getBalance()), Trade Gem for Dai, Repay Flash Dai Loan.
The only downside I can see to this is a slight increase in code complexity, but we get the added benefit of lower liquidations from trapped funds.
The text was updated successfully, but these errors were encountered:
It's a common pattern to include an ERC20 token extraction mechanism in rapidly developed contracts in case of accidentally trapped funds. I think it could be useful to upgrade all the gem join contracts to be compliant with part of the ERC20 standard - specifically
transfer
,transferFrom
andbalanceOf
. This would basically provide an ERC20-compliant escape hatch for accidentally stuck collateral to be extracted from Maker.The functions would look something like this (pseudocode):
This would allow anyone to completely unwind a CDP with only the ERC20 transfer semantics as any account is able to repay debt. So for example to unwind my locked CDP, I can do: Flash Loan (Dai), Repay all CDP Debt, gemJoin.transfer(myAccount, gemJoin.getBalance()), Trade Gem for Dai, Repay Flash Dai Loan.
The only downside I can see to this is a slight increase in code complexity, but we get the added benefit of lower liquidations from trapped funds.
The text was updated successfully, but these errors were encountered: