-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
# Conflicts: # contracts/Workers.sol
Airdrop & Pricer Refactoring
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.
please already review comments, and we'll discuss more tomorrow during the call
@@ -4,6 +4,7 @@ | |||
"description": "", | |||
"dependencies": { | |||
"@openstfoundation/openst-notification": "1.0.0-beta.1", | |||
"@ostdotcom/ost-price-oracle": "^1.0.0-beta.3", |
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.
openst-payments cannot have a dependency on ostdotcom/ost-price-oracle
; we outlined the tasks for there to be a price oracle interface defined in openst-payments, and for testing we want a PriceOracleMock that fills that interface
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.
As per discussion we will take in a different ticket.
contracts/Airdrop.sol
Outdated
* External functions | ||
*/ | ||
/// clean up or revoke airdrop contract | ||
function remove() |
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 the remove function not be implemented in Pricer.sol
, and can be inherited here without change.
contracts/Airdrop.sol
Outdated
external | ||
onlyAdminOrOps | ||
{ | ||
selfdestruct(msg.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.
an event before self-destruct is useful
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.
adding event "Removed"
contracts/Airdrop.sol
Outdated
import "./Pricer.sol"; | ||
|
||
|
||
contract Airdrop is Pricer, Workers { |
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.
Airdrop is not Workers
contracts/Airdrop.sol
Outdated
/* | ||
* External functions | ||
*/ | ||
/// performPay matches the behaviour of Pricer:pay with extra functionality of airdrop evaluation |
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.
performPay
is not a suitable name;
least preferred, performAirPay
on Airdrop; and performPay
on Pricer; but we dont prefix with perform
for core external function calls
so airdropPay
on Airdrop; and pay
on pricer;
or payAirdrop
on Airdrop; and pay
on pricer;
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.
payAirdrop on Airdrop; and pay on pricer;
Sounds good.
contracts/Airdrop.sol
Outdated
* Events | ||
*/ | ||
/// Event for AirdropPayment complete | ||
event AirdropPayment( |
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.
up to three arguments can be indexed
and it makes them (expanded and) searchable in the logs; also for formatting on events we've previously filled the line (different from function signatures)
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.
Indexing is cool. Does indexing cost extra gas or it's neglegible?
Can we do indexing on uint256 also?
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 for formatting on events we've previously filled the line (different from function signatures)
Didn't understand this point. Please explain with an example?
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.
@benjaminbollen: for consistency/ease, we started declaring events similar to functions,
event EventName(
arg,
arg,
arg)
This way it not subject to personal preference in terms of how many is too many arguments to list on the line. We can go back to the other way, if preferred, but that will mean changes in other rule for max number of arguments per line (so that how it looks in an individual dev's editor is not driving the decision).
@@ -1,3 +1,4 @@ | |||
/* solhint-disable-next-line compiler-fixed */ |
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.
There is no need for PricerINterface.sol
, please remove
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.
as we concluded we will keep it.
|
||
uint256 tokenAmount; | ||
uint256 commissionTokenAmount; | ||
(tokenAmount, commissionTokenAmount) = getBTAmountFromCurrencyValue(pricePoint, _transferAmount, |
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 function call to getBTAmountFromCurrencyValue
should be inlined (as demonstrated that it calls again for getPricePoint
; and the function itself on L221 should be removed;
the functionality of having this function (L221) public is achievable in the interaction layer by using getPricePoint
;
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.
as we concluded getPricePoint is called once in pay and payAirdrop flow.
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.
correction, getBTAmountFromCurrencyValue
does not query getPricePoint
; there is still value in looking to inline this function to reduce the stack depth;
in return getPricePointandCalculateAmounts
can be moved to the interaction layer
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.
@benjaminbollen: are you noting this for posterity or commenting that this is a change you would like Abhay to make for this PR (which I think contradicts what we agreed in the meeting)? And does this relate to #50?
contracts/Pricer.sol
Outdated
_commissionAmount, _currency, _intendedPricePoint, pricePoint); | ||
return true; | ||
_commissionAmount, _currency, _intendedPricePoint, pricePoint); | ||
return (tokenAmount + commissionTokenAmount); | ||
} | ||
|
||
/// @dev Takes _currency; |
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.
getPricePoint
needs to be a public view
function; this produces a warning because Price Oracle can emit an event; but the conclusion is then to remove the event emission from getPrice
in Price Oracle; this should also be be specified in the Price Oracle interface
again, the interaction layer can determine that there was no valid price point based on the return value, and an event on the get function is not needed
@@ -1,3 +1,4 @@ | |||
/* solhint-disable-next-line compiler-fixed */ |
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.
on L34: Pricer is not PricerInterface; the dependency direction is reversed; pricer calls on contracts, for now other contracts dont call on pricer; neither is there anything general about pricer worthy of generalising in an interface
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.
as we concluded we will keep PricerInterface.sol
/// @param _commissionBeneficiary commissionBeneficiary | ||
/// @param _commissionAmount commissionAmount | ||
/// @return bool isValid | ||
function isValidBeneficiaryData( |
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 function is ideal to put as up in Pricer.sol as a modifier
contracts/Pricer.sol
Outdated
/// @param _commissionBeneficiary commissionBeneficiary | ||
/// @param _commissionTokenAmount commissionTokenAmount | ||
/// @return (bool) | ||
function performTransfer( |
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.
rename to performTransfers
@benjaminbollen Done with requested changes. Few points:
|
- Remove modifier isValidBeneficiaryData and replace it with 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.
LGTM
contracts/Airdrop.sol
Outdated
|
||
/* | ||
* Events | ||
*/ | ||
/// Event for AirdropPayment complete | ||
/// Emit AirdropPayment Event | ||
event AirdropPayment( |
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.
the event AirdropPayment
is missing the quote currency; worth adding if we have the price point?
contracts/Airdrop.sol
Outdated
address _commissionBeneficiary, | ||
uint256 commissionTokenAmount, | ||
address indexed _beneficiary, | ||
uint256 _transferAmount, |
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.
Note: for alignment with Payment
event from tokenAmount
to transferAmount
; we can take input from Saas what the best set of return values;
contracts/Pricer.sol
Outdated
onlyAdminOrOps | ||
{ | ||
selfdestruct(msg.sender); | ||
Removed(msg.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.
Can we put the event before the selfdestruct; or does solidity change the order of execution?
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.
Makes sense,
Since the contract is killed off and there is no one/nothing left to return after destroyed. It obliterated the next step.
…ment event Fire event before calling self destruct
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.
Lgtm
Flow
commission beneficiary