-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The default test token should not have 18 decimals #203
Comments
Specifically, the problem is that the current
Whereas if the default token does not have 18 decimals, two variables have to be introduced. |
Thanks for opening this issue.
I don't think this is true. In the concrete tests, wherever the decimal can affect the results, we have always used two assets (usdc and dai). Even in the case of a refund, the tests cover both usdc and dai.
Now on
The role of the function
|
I think it is.
Not true because the decimal affects the result whenever a numerical constant is used, and not every test that references a numerical constant tests both DAI and USDC. I did not say the concrete tests test only one token, which has 18 decimals. I said that the token used in the default stream has 18 decimals. By extension, the default number of decimals is assumed to be 18 throughout the tests.
I've seen this constant used as both a normalized and non-normalized amount. This works because the default number of decimals is 18. Also related: #199
Yeah, I have renamed it in my branch. |
Wether we use an amount of 18 decimals for flow/test/integration/concrete/deposit/deposit.t.sol Lines 33 to 45 in 3606035
flow/test/integration/concrete/refund/refund.t.sol Lines 91 to 108 in 3606035
flow/test/integration/concrete/withdraw-at/withdrawAt.t.sol Lines 186 to 219 in 3606035
For example, in |
@andreivladbrg I'm afraid I don't think you have understood my argument. I have explained why we want a non-18 default number of decimals in my previous reply. Could you please re-read it and tell me what you think about it?
No. It's not just about wording. When the default number of decimals is 18, the constants have duplicate meanings. |
no, as Shub said, the input param is a 18 decimal number only
where exactly it has been used as non-normalized amount? once again, that input param in |
I think if we make this change: #184 it would make the distinction between them clearer. |
yes, and as I said in the OP, the same For example:
Yes.
Exactly. We have to explicitly normalize it and maintain multiple constants.
The PRBMath types are orthogonal to this issue. |
i guess the misunderstanding between us comes from the fact that, according to the current design (main), the amount implicitly means an 18-decimal number. you’re referring to the refactor you’ve just made, right?
the event correctly emits the refund amount (18 decimal, not the transfer amount)
that's because any amount is expected to be of 18, if "transfer" is not specified
i don't think so, using /// @notice Emitted when assets are refunded from a Flow stream.
/// @param streamId The ID of the Flow stream.
/// @param sender The address of the stream's sender.
/// @param refundAmount The amount of assets refunded to the sender, denoted in 18 decimals.
/// @param transferAmount The amount transferred to the sender, denoted in asset's decimals.
event RefundFromFlowStream(
uint256 indexed streamId, address indexed sender, UD21x18 refundAmount, uint128 transferAmount
);
/// @dev Emits `RefundFromFlowStream` event
/// @param streamId The ID of the stream to refund from.
/// @param amount The amount to refund, denoted in 18 decimals.
function refund(uint256 streamId, UD21x18 amount) external returns (uint128 transferAmount);
abstract contract Constants {
UD21x18 internal constant REFUND_AMOUNT = UD21x18.wrap(10_000e18);
} |
Yeah I think you're right, there doesn't appear to be any double use of I still find it helpful to use a default token with 6 decimals to draw a line in the sand between normalized and non-normalized amounts. At a minimum, it would avoid confusions like mine.
Yes, and that's too simplistic as per our discussion in #199 |
it is impossible to prevent everyone's confusion. flow/src/interfaces/ISablierFlow.sol Line 61 in f82aedc
flow/src/interfaces/ISablierFlow.sol Line 336 in f82aedc
you stated this, but we have not yet agreed on whether it is 'simplistic' on that discussion however, i left a relevant answer here: #202 (comment) |
Indeed. This was my goal with changing the default test token to use 6 decimals.
Unrelated to this issue/ discussion. Here we're talking about constant names in the tests. The explicit names I have added in #205 are clearer because they are explicit.
It doesn't say anything about what happened to the amount. The normalized terminology (or scaled) indicates that a normalization/ scaling process has occurred. |
The current default test token is DAI, which has 18 decimals. This is not great because Flow normalizes and denormalizes token amounts to 18 decimals.
The default asset should be a little more complex and not have 18 decimals.
Doing so would avoid cases like this, where the test passes because of an accident not because it is correctly written:
flow/test/integration/concrete/refund/refund.t.sol
Line 137 in 3606035
This test works because the default asset has 18 decimals and the
REFUND_AMOUNT
is already normalized. If the default asset didn't have 18 decimals, theREFUND_AMOUNT
would have to be normalized.The text was updated successfully, but these errors were encountered: