Repository navigation
Conversation
948b1b5 to
f70648d
Compare
|
Hey, @vyomshm let me know when should I start reviewing your code? |
|
Hey @satyamakgec Please review my PR |
1af87df to
9722fe4
Compare
|
@satyamakgec @FOBCrypto I've made the suggested changes, please review again. |
maxsam4
left a comment
There was a problem hiding this comment.
Other than the suggested changes, Can you please also increase the coverage of your code?
Branch coverage of MaximumVolumeTransferManager.sol is at 80% currently. We would ideally like to see 100% coverage but a minimum of 95% is required.
| ); | ||
|
|
||
| for(uint256 i = 0; i < _maximumVolumes.length; i++){ | ||
| addMaxVolumeRestricion( |
There was a problem hiding this comment.
Create an internal function and use it here as well as in addMaxVolumeRestricion(). Doing so will save gas as parameters are not copied into memory again for internal functions.
|
@vyomshm Please push the changes before marking conversations as resolved. |
Co-Authored-By: vyomshm <vyomshm@gmail.com>
…olymath-core into vol-restriction-module
|
@satyamakgec @maxsam4 @FOBCrypto I've increased my test coverage + implemented changes as discussed. Ready for another review👍 |
|
Nice work @vyomshm ! The branch coverage is still at 92.5% with 3 uncovered branches. I would love for them to be covered as well (all of them can be covered). You can see the uncovered branches at https://coveralls.io/builds/19635412/source?filename=contracts%2Fmodules%2FTransferManager%2FMaximumVolumeTransferManager.sol |
|
@maxsam4 @satyamakgec @FOBCrypto Coverage is now at 100% |
|
@satyamakgec @FOBCrypto @maxsam4 made the changes. please have a look |
|
@maxsam4 have you had a chance to look through this? Would love to see this get resolved before you guys get too busy with pre-devcon4 events :) |
| * @notice allows admin to delete a maximum volume transfer restriction | ||
| * @param _index representing the array index of the maximum volume transfer restriction | ||
| */ | ||
| function removeMaximumTransferRestriction(uint256 _index) public withPerm(ADMIN){ |
There was a problem hiding this comment.
Can you please add a batch/multi versions of this.
There was a problem hiding this comment.
@satyamakgec @maxsam4 Currently, removing a single array element will almost always change the order of restrictions in the array( except when the restriction to be deleted in the last one). This could render some of the indices provided unusable and therefore cause the function to revert.
I could write an implementation which would preserve the order of restrictions by shifting the elements instead of swapping them(as implemented now) but doing so would make the function extremely costly in terms of gas.
string element = myArray[index];
for (uint i = index; i < myArray.length - 1; i++) {
myArray[index] = myArray[index + 1];
}
myArray.length--;
Please advise on how to proceed with this.
There was a problem hiding this comment.
I think one way around the problem can be by adding a unique id to MaximumVolumeRestriction struct and maintaining an array of that id for parsing. maximumVolumeRestrictions can be made a mapping rather than an array then.
| * @param _endTime timestamp representing when this maximum volume restriction ends | ||
| * @param _rollingPeriodInterval interval period representing one of five RollingIntervals | ||
| */ | ||
| function modifyMaximumTransferRestriction( |
There was a problem hiding this comment.
Can you please add a batch/multi versions of this.
maxsam4
left a comment
There was a problem hiding this comment.
I was going through the logic once again and it seems flawed. There can be multiple restrictions of overlapping periods which can make the logic fail. For example, consider a case when there is a monthly restriction started on 1st Jan and another monthly restriction started on 15th Jan. If anyone tries to transfer tokens on 16th of Jan, the below line will be executed twice
volumeTally[_from][monthly][0] = _amount.add(volumeTally[_from][monthly][0]);
This should have been executed only once.
There are a lot more problematic scenarios due to this. Another example with the same restrictions will be when a transfer is done on 1st Feb. volumeTally[_from][monthly][0] will now contain info about the volume of trade that happened on 1st of Jan but the second restriction will not be expecting that.
Basically, the logic will fail when there are overlapping trade restriction periods. Please, rethink about it and try to fix it.
|
I was just going through the requirements and specs of this module and seems like your implementation and our requirements don't completely match. Please have a look at https://www.lucidchart.com/invitations/accept/75bdef55-cd39-48d9-bc1c-ac1d2fc76a39 again. We want different people to be linked with different volume restrictions. Not all restrictions need to be imposed on every user. |
|
@maxsam4 With regards to your first comment, would be executed only when relevant. |
|
Please clarify if my interpretation of the module is wrong, so I can rectify my codebase. |
@vyomshm Solidity does not support decimals which means after
I agree that we could have been clearer about the specs but as the second assumption in lucidchart states, the token owner should be able to impose different restrictions on different sets of token holders. Please rework your approach accordingly. |
|
@CPSTL @satyamakgec @maxsam4 Just to be clear, we want maxVolume transfer restrictions to exist for specific addresses only and not as Global impositions ? This would require changing Can you confirm this is the approach I should proceed with? |
|
@vyomshm We want both the abilities. Global restrictions + restrictions on only a subset of address. |
|
@maxsam4 okay, I'll wait. Just so you know, I've figured out the easiest fix for the same periodId issue. As in my original implementation we should define periodId as follows- Also I believe we can implement the multi version of |
That won't work for the same reasons I said when you first implemented it. Also, Even in this case, there will be collisions because solidity does not support floating points. It will round them to the nearest integer. |
|
@maxsam4 I understand what you're saying. As I see it the best way to avoid any sort of collisions will be to maintain a separate One way to do this would be to add to modify the
|
|
@maxsam4 have you had a chance to talk with the team yet? |
|
@vyomshm Sorry, we are busy with devcon this week. I'll get back to you next week. Thanks for understanding. |
|
@maxsam4 Could you update me on how to proceed with this? |
|
Bounty paid. Thanks a lot for your contribution @vyomshm . |

Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
feature - ref #267
What is the current behavior?
#267
No way to add global token volume transfer restrictions
What is the new behavior?
Feature added - A new Transfer Manager module
Issuers can now create(as well as remove and modify) multiple maximum volume transfer restrictions which will be applied globally to every transfer
Does this PR introduce a breaking change?
(What changes might users need to make in their application due to this PR?)
No
Any Other information: