-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
2c4f44a
to
dc858d8
Compare
@@ -54,7 +54,7 @@ contract ERC721MarginPosition is | |||
address margin | |||
) | |||
public | |||
ERC721Token("dYdX Margin Positions", "DYDX-M") | |||
ERC721Token("dYdX Margin Positions", "DYDX-MarginPosition") |
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 is too long for a symbol. I liked the old one better, if you want to know what it means, just look at the name
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.
done
// Mapping from an address to other addresses that are approved to be margin-callers | ||
mapping (address => mapping (address => bool)) public approvedCallers; | ||
|
||
// Mapping from a positionId to the value of totalOwedTokensRepaidToLender for the position when |
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 don't think you should use a variable name to describe part of what this is
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.
especially if totalOwedTokensRepaidToLender
is not another defined state variable
|
||
// Mapping from a positionId to the address of the owedToken of that position. Needed because | ||
// margin erases this information when the position is closed. | ||
mapping (bytes32 => address) public owedTokenForPosition; |
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.
hmm... I hadn't thought about this. This is a bit unfortunate we have to have this
address margin | ||
) | ||
public | ||
ERC721Token("dYdX Margin Loans", "DYDX-Loan") |
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 also feel DYDX-Loan
is too long for a symbol
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.
done
// ============ Token-Holder functions ============ | ||
|
||
/** | ||
* Approves any address to margin-call any of the positions owned by the sender. |
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.
approves "an" address
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.
done
) | ||
external | ||
onlyMargin | ||
nonReentrant |
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.
same thing for nonReentrant
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.
done
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.
+1 leave in for this one
) | ||
external | ||
onlyMargin | ||
nonReentrant |
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.
not 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.
done
) | ||
external | ||
onlyMargin | ||
nonReentrant |
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.
same
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.
done
|
||
address owedToken = owedTokenForPosition[positionId]; | ||
address owner = ownerOf(uint256(positionId)); | ||
TokenInteract.transfer(owedToken, owner, tokensToSend); |
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 think we should add an assert(TokenInteract.balanceOf(owedToken , address(this)) > tokensToSend
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.
done
address owedToken = owedTokenForPosition[positionId]; | ||
address owner = ownerOf(uint256(positionId)); | ||
TokenInteract.transfer(owedToken, owner, tokensToSend); | ||
|
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 don't know if you want to do it in this function or another helper, but we should burn the token if the position is closed. Also delete owedTokensRepaidSinceLastWithdraw
and owedTokenForPosition
as commented above
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.
also don't do owedTokensRepaidSinceLastWithdraw[positionId] = totalRepaid;
on line 303 if we're just about to delete it anyways
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.
done
I can't override It's dumb because it should be able to do that as the visibility doesn't affect the ABI |
2eb61ae
to
3aa7b83
Compare
@@ -27,7 +27,7 @@ contract ERC20Short is ERC20Position { | |||
margin, | |||
initialTokenHolder, | |||
trustedRecipients, | |||
"DYDX-S" | |||
"D/SS" |
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.
just one "S" like the nouns are "leveraged long" and "short"
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.
done
@@ -62,6 +62,6 @@ contract ERC20Long is ERC20Position { | |||
pure | |||
returns (bytes) | |||
{ | |||
return "dYdX Tokenized Long"; | |||
return "dYdX ERC20 Leveraged-Long"; |
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.
"dYdX Leveraged-Long Token"
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.
done
@@ -62,6 +62,6 @@ contract ERC20Short is ERC20Position { | |||
pure | |||
returns (bytes) | |||
{ | |||
return "dYdX Tokenized Short"; | |||
return "dYdX ERC20 Short-Sell"; |
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.
"dYdX Short Token"
@@ -62,6 +62,6 @@ contract ERC20Short is ERC20Position { | |||
pure | |||
returns (bytes) | |||
{ | |||
return "dYdX Tokenized Short"; | |||
return "dYdX Short-Sell"; |
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.
"dYdX Short Token"
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.
done
@@ -62,6 +62,6 @@ contract ERC20Long is ERC20Position { | |||
pure | |||
returns (bytes) | |||
{ | |||
return "dYdX Tokenized Long"; | |||
return "dYdX Leveraged-Long"; |
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.
"dYdX Leveraged Long Token"
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.
done
@@ -27,7 +27,7 @@ contract ERC20Short is ERC20Position { | |||
margin, | |||
initialTokenHolder, | |||
trustedRecipients, | |||
"DYDX-S" | |||
"d/SS" |
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.
just "d/S"
the nouns are "Short" and "Leveraged Long"
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.
done
) | ||
external | ||
onlyMargin | ||
nonReentrant |
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.
+1 leave in for this one
address owner = ownerOf(uint256(positionId)); | ||
require(owner != address(0)); | ||
|
||
address owedToken = owedTokenAddress[positionId]; |
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.
maybe also assert(owedToken != address(0)
I know it shouldn't be, but just to be sure
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 think it's fine to not have that assert. It definitely shouldn't be, but if there were a problem that big, it should be asserted in the base protocol instead. Secondly it should revert on TokenInteract.transfer() anyway if the address is zero
No description provided.