From 5315d1ecb5a556a2c667cb50d56887611674de9b Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Sun, 28 Jan 2018 21:59:18 +0100 Subject: [PATCH 01/10] contracts: proposal for Workers.sol to manage active workers --- contracts/Workers.sol | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 contracts/Workers.sol diff --git a/contracts/Workers.sol b/contracts/Workers.sol new file mode 100644 index 0000000..89ef3dd --- /dev/null +++ b/contracts/Workers.sol @@ -0,0 +1,93 @@ +pragma solidity ^0.4.17; + +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ---------------------------------------------------------------------------- +// Utility chain: Workers +// +// http://www.simpletoken.org/ +// +// ---------------------------------------------------------------------------- + +import "./OpsManaged.sol"; +import "./SafeMath.sol"; + +/// A set of authorised workers +contract Workers is OpsManaged { + using SafeMath for uint256; + + /* + * Storage + */ + /// workers are active up unto the deactivation height + mapping(address => uint256 /* deactivation height */) public workers; + + /* + * Public functions + */ + function Workers() + public + OpsManaged() + { + } + + function setWorker( + address _worker, + uint256 _deactivationHeight) + external + onlyOps + returns (uint256 /* remaining activation length */) + { + require(_deactivationHeight >= block.number); + + workers[_worker] = _deactivationHeight; + + return (_deactivationHeight - block.number); + } + + function removeWorker( + address _worker) + external + onlyOps + returns (bool existed) + { + existed = (workers[_worker] > 0); + + delete workers[_worker]; + + return existed; + } + + // clean up or collectively revoke all workers + function remove() + external + onlyAdminOrOps + { + selfdestruct(msg.sender); + } + + /* + * Public view functions + */ + function isWorker( + address _worker) + external + view + returns (bool /* is active worker */) + { + return (workers[_worker] >= block.number); + } + +} \ No newline at end of file From 93c19335920360680a08808bfcaed61bc9af13ea Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Sun, 28 Jan 2018 23:20:01 +0100 Subject: [PATCH 02/10] contracts: (incomplete) proposal for Airdrop --- contracts/Airdrop.sol | 122 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 contracts/Airdrop.sol diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol new file mode 100644 index 0000000..7297355 --- /dev/null +++ b/contracts/Airdrop.sol @@ -0,0 +1,122 @@ +pragma solidity ^0.4.17; + +// Copyright 2018 OpenST Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ---------------------------------------------------------------------------- +// Utility chain: Airdrop +// +// http://www.simpletoken.org/ +// +// ---------------------------------------------------------------------------- + + +// look to replace with interface +import "./Workers.sol"; + + +contract Airdrop is Pricer { + // SafeMath for uint256 is declared in Pricer.sol + + /* + * Storage + */ + Workers public workers; + address public airdropBudget; + + /* + * Public functions + */ + function Airdrop( + address _brandedToken, + Workers _workers, + address _airdropBudget) + public + Pricer(_brandedToken) + OpsManaged() + { + require(_workers != address(0)); + require(_airdropBudget != address(0)); + + workers = _workers; + airdropBudget = _airdropBudget; + } + + /// airPay matches the behaviour of pricer:pay + /// but allows spending from + function airPay( + /// input parameters for pricer:pay + address _beneficiary, + uint256 _transferAmount, + address _commissionBeneficiary, + uint256 _commissionAmount, + bytes3 _currency, + uint256 _intendedPricePoint, + /// additional input parameters for airdrop + address _user, + uint256 _airdropAmount) + public + returns (uint256 totalPaid, uint256 airdropUsed) + { + require(workers.isWorker(msg.sender)); + + /* + * lift from pricer:pay + * further clean up + */ + require(_beneficiary != address(0)); + require(_transferAmount != 0); + + if (_commissionAmount > 0) { + require(_commissionBeneficiary != address(0)); + } + + uint256 tokenAmount = _transferAmount; + uint256 commissionTokenAmount = _commissionAmount; + uint256 pricePoint = _intendedPricePoint; + if (_currency != 0) { + uint8 tokenDecimals = 0; + (pricePoint, tokenDecimals) = getPricePoint(_currency); + require(pricePoint > 0); + require(isPricePointInRange(_intendedPricePoint, pricePoint, pricerAcceptedMargins[_currency])); + (tokenAmount, commissionTokenAmount) = getBTAmountFromCurrencyValue(pricePoint, + tokenDecimals, _transferAmount, _commissionAmount); + } + /* + * end of pricer:pay + */ + + totalPaid = tokenAmount + commissionTokenAmount; + airdropUsed = _airdropAmount; + if (totalPaid < _airdropAmount) { + airdropUsed = _airdropAmount - totalPaid; + } + // prefund the user from the airdrop budget + require (EIP20Interface(pricerBrandedToken).transferFrom(airdropBudget, _user, airdropUsed)) + + /* + * lift from pricer:pay + */ + require(EIP20Interface(pricerBrandedToken).transferFrom(_user, _beneficiary, tokenAmount)); + if (_commissionBeneficiary != address(0)) { + require(EIP20Interface(pricerBrandedToken).transferFrom(_user, + _commissionBeneficiary, commissionTokenAmount)); + } + + //Trigger Event for PaymentComplete + Payment(_beneficiary, _transferAmount, _commissionBeneficiary, + _commissionAmount, _currency, _intendedPricePoint, pricePoint); + return (totalPaid, airdropUsed); + } +} \ No newline at end of file From 4b9d49f65656e3187bbf455610d12b91009494a0 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Sun, 28 Jan 2018 23:20:55 +0100 Subject: [PATCH 03/10] contracts: change return value to total paid for pay() --- contracts/Pricer.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index f0e67fd..c077e72 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -174,7 +174,7 @@ contract Pricer is OpsManaged, PricerInterface { /// @param _commissionAmount commissionAmount /// @param _currency currency /// @param _intendedPricePoint _intendedPricePoint - /// @return bool isSuccess + /// @return uint256 total paid function pay( address _beneficiary, uint256 _transferAmount, @@ -183,7 +183,7 @@ contract Pricer is OpsManaged, PricerInterface { bytes3 _currency, uint256 _intendedPricePoint) public - returns (bool /* success */) + returns (uint256 /* total paid */) { require(_beneficiary != address(0)); require(_transferAmount != 0); @@ -213,7 +213,7 @@ contract Pricer is OpsManaged, PricerInterface { //Trigger Event for PaymentComplete Payment(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount, _currency, _intendedPricePoint, pricePoint); - return true; + return (tokenAmount + commissionTokenAmount); } /// @dev Takes _currency; From 69c1a0376493c05119e3f6731e2ff12c761bdd9d Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Wed, 14 Feb 2018 19:42:37 +0530 Subject: [PATCH 04/10] Airdrop Contract Changes Airdrop & Pricer Refactoring --- contracts/Airdrop.sol | 229 +++++++++++++++++++++------------- contracts/Pricer.sol | 129 +++++++++++++++---- contracts/PricerInterface.sol | 58 ++++++++- package.json | 1 + 4 files changed, 301 insertions(+), 116 deletions(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index 7297355..939c41c 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -1,3 +1,4 @@ +/* solhint-disable-next-line compiler-fixed */ pragma solidity ^0.4.17; // Copyright 2018 OpenST Ltd. @@ -21,102 +22,156 @@ pragma solidity ^0.4.17; // // ---------------------------------------------------------------------------- - -// look to replace with interface import "./Workers.sol"; +import "./Pricer.sol"; + +contract Airdrop is Pricer, Workers { -contract Airdrop is Pricer { - // SafeMath for uint256 is declared in Pricer.sol - - /* - * Storage - */ - Workers public workers; - address public airdropBudget; - - /* - * Public functions - */ - function Airdrop( - address _brandedToken, - Workers _workers, - address _airdropBudget) - public - Pricer(_brandedToken) - OpsManaged() - { - require(_workers != address(0)); - require(_airdropBudget != address(0)); - - workers = _workers; - airdropBudget = _airdropBudget; - } - - /// airPay matches the behaviour of pricer:pay - /// but allows spending from - function airPay( - /// input parameters for pricer:pay + /* + * Events + */ + /// Event for AirdropPayment complete + event AirdropPayment( address _beneficiary, - uint256 _transferAmount, + uint256 tokenAmount, address _commissionBeneficiary, - uint256 _commissionAmount, + uint256 commissionTokenAmount, + uint256 _actualPricePoint, + address _spender, + uint256 _airdropAmount + ); + + /* + * Storage + */ + Workers public workers; + address public airdropBudgetHolder; + + /* + * Constructor + */ + /// @dev Takes _brandedToken, _baseCurrency, _workers, _airdropBudgetHolder; + /// constructor; + /// public method; + /// @param _brandedToken Branded Token + /// @param _baseCurrency Base Currency + /// @param _workers Workers contract address + /// @param _airdropBudgetHolder Airdrop Budget Holder Address + function Airdrop( + address _brandedToken, + bytes3 _baseCurrency, + Workers _workers, + address _airdropBudgetHolder) + public + Pricer(_brandedToken, _baseCurrency) + OpsManaged() + { + require(_workers != address(0)); + require(airdropBudgetHolder != address(0)); + + workers = _workers; + airdropBudgetHolder = _airdropBudgetHolder; + } + + /* + * External functions + */ + /// clean up or revoke airdrop contract + function remove() + external + onlyAdminOrOps + { + selfdestruct(msg.sender); + } + + /* + * External functions + */ + /// performPay matches the behaviour of Pricer:pay with extra functionality of airdrop evaluation + /// @param _beneficiary beneficiary + /// @param _transferAmount transferAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionAmount commissionAmount + /// @param _currency currency + /// @param _intendedPricePoint intendedPricePoint + /// @param _spender spender + /// @param _airdropAmount airdropAmount + /// @return uint256 totalPaid + function performPay( + address _beneficiary, + uint256 _transferAmount, + address _commissionBeneficiary, + uint256 _commissionAmount, bytes3 _currency, uint256 _intendedPricePoint, - /// additional input parameters for airdrop - address _user, + address _spender, uint256 _airdropAmount) public - returns (uint256 totalPaid, uint256 airdropUsed) - { - require(workers.isWorker(msg.sender)); - - /* - * lift from pricer:pay - * further clean up - */ - require(_beneficiary != address(0)); - require(_transferAmount != 0); - - if (_commissionAmount > 0) { - require(_commissionBeneficiary != address(0)); - } - - uint256 tokenAmount = _transferAmount; - uint256 commissionTokenAmount = _commissionAmount; - uint256 pricePoint = _intendedPricePoint; - if (_currency != 0) { - uint8 tokenDecimals = 0; - (pricePoint, tokenDecimals) = getPricePoint(_currency); - require(pricePoint > 0); - require(isPricePointInRange(_intendedPricePoint, pricePoint, pricerAcceptedMargins[_currency])); - (tokenAmount, commissionTokenAmount) = getBTAmountFromCurrencyValue(pricePoint, - tokenDecimals, _transferAmount, _commissionAmount); + returns ( + uint256 /* totalPaid */) + { + require(workers.isWorker(msg.sender)); + require(_spender != address(0)); + + require(isValidBeneficiaryData(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount)); + + uint256 tokenAmount = _transferAmount; + uint256 commissionTokenAmount = _commissionAmount; + uint256 pricePoint = _intendedPricePoint; + + // check Margin And Calculate BTAmount + if (_currency != "") { + (pricePoint, tokenAmount, commissionTokenAmount) = validateMarginAndCalculateBTAmount(_currency, + _intendedPricePoint, _transferAmount, _commissionAmount); + } + + require(performAirdropTransferToSpender(_spender, _airdropAmount, + tokenAmount, commissionTokenAmount)); + require(performTransfer(_spender, _beneficiary, tokenAmount, + _commissionBeneficiary, commissionTokenAmount)); + + /// Emit AirdropPayment Event + AirdropPayment(_beneficiary, tokenAmount, _commissionBeneficiary, + commissionTokenAmount, pricePoint, _spender, _airdropAmount); + + return ((tokenAmount + commissionTokenAmount)); + } + + /* + * Private functions + */ + /// @dev Takes _spender, _airdropAmount, _tokenAmount, _commissionTokenAmount; + /// Calculate airdropUsed to transfer + /// Perform perform Airdrop Transfer To Spender + /// internal method; + /// @param _spender spenderUser + /// @param _airdropAmount airdropAmount + /// @param _tokenAmount tokenAmount + /// @param _commissionTokenAmount commissionTokenAmount + /// @return uint256 airdropUsed + function performAirdropTransferToSpender( + address _spender, + uint256 _airdropAmount, + uint256 _tokenAmount, + uint256 _commissionTokenAmount) + private + returns ( + bool /* boolean value */) + { + // @Ben Do we need this? Can't we transfer all _airdropAmount to _spender? + uint256 airdropUsed = _airdropAmount; + uint256 totalPaid = (_tokenAmount + _commissionTokenAmount); + if (_airdropAmount > totalPaid) { + airdropUsed = _airdropAmount - totalPaid; } - /* - * end of pricer:pay - */ - - totalPaid = tokenAmount + commissionTokenAmount; - airdropUsed = _airdropAmount; - if (totalPaid < _airdropAmount) { - airdropUsed = _airdropAmount - totalPaid; + + // Prefund the user from the airdrop budget holder + if (airdropUsed > 0) { + require(EIP20Interface(brandedToken()).transferFrom(airdropBudgetHolder, _spender, airdropUsed)); } - // prefund the user from the airdrop budget - require (EIP20Interface(pricerBrandedToken).transferFrom(airdropBudget, _user, airdropUsed)) - - /* - * lift from pricer:pay - */ - require(EIP20Interface(pricerBrandedToken).transferFrom(_user, _beneficiary, tokenAmount)); - if (_commissionBeneficiary != address(0)) { - require(EIP20Interface(pricerBrandedToken).transferFrom(_user, - _commissionBeneficiary, commissionTokenAmount)); - } - - //Trigger Event for PaymentComplete - Payment(_beneficiary, _transferAmount, _commissionBeneficiary, - _commissionAmount, _currency, _intendedPricePoint, pricePoint); - return (totalPaid, airdropUsed); - } + + return true; + } + } \ No newline at end of file diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index e3f378c..a7c21ce 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -1,3 +1,4 @@ +/* solhint-disable-next-line compiler-fixed */ pragma solidity ^0.4.17; // Copyright 2018 OpenST Ltd. @@ -60,8 +61,8 @@ contract Pricer is OpsManaged, PricerInterface { /// @dev Takes _brandedToken, _baseCurrency; /// constructor; /// public method; - /// @param _brandedToken _brandedToken - /// @param _baseCurrency _baseCurrency + /// @param _brandedToken Branded Token + /// @param _baseCurrency Base Currency function Pricer( address _brandedToken, bytes3 _baseCurrency) @@ -262,33 +263,25 @@ contract Pricer is OpsManaged, PricerInterface { public returns (uint256 /* total paid */) { - require(_beneficiary != address(0)); - require(_transferAmount != 0); - - if (_commissionAmount > 0) { - require(_commissionBeneficiary != address(0)); - } + require(isValidBeneficiaryData(_beneficiary, _transferAmount, + _commissionBeneficiary, _commissionAmount)); uint256 tokenAmount = _transferAmount; uint256 commissionTokenAmount = _commissionAmount; uint256 pricePoint = _intendedPricePoint; - if (_currency != 0) { - pricePoint = getPricePoint(_currency); - require(pricePoint > 0); - require(isPricePointInRange(_intendedPricePoint, pricePoint, pricerAcceptedMargins[_currency])); - (tokenAmount, commissionTokenAmount) = getBTAmountFromCurrencyValue(pricePoint, - _transferAmount, _commissionAmount); - } - - require(EIP20Interface(pricerBrandedToken).transferFrom(msg.sender, _beneficiary, tokenAmount)); - if (_commissionBeneficiary != address(0)) { - require(EIP20Interface(pricerBrandedToken).transferFrom(msg.sender, - _commissionBeneficiary, commissionTokenAmount)); + + // check Margin And Calculate BTAmount + if (_currency != "") { + (pricePoint, tokenAmount, commissionTokenAmount) = validateMarginAndCalculateBTAmount(_currency, + _intendedPricePoint, _transferAmount, _commissionAmount); } - + + require(performTransfer(msg.sender, _beneficiary, tokenAmount, + _commissionBeneficiary, commissionTokenAmount)); + //Trigger Event for PaymentComplete Payment(_beneficiary, _transferAmount, _commissionBeneficiary, - _commissionAmount, _currency, _intendedPricePoint, pricePoint); + _commissionAmount, _currency, _intendedPricePoint, pricePoint); return (tokenAmount + commissionTokenAmount); } @@ -309,7 +302,7 @@ contract Pricer is OpsManaged, PricerInterface { /// @dev Takes _intendedPricePoint, _currentPricePoint, _acceptedMargin; /// checks if the current price point is in the acceptable range of intendedPricePoint; - /// private method; + /// internal method; /// @param _intendedPricePoint intendedPricePoint /// @param _currentPricePoint currentPricePoint /// @param _acceptedMargin acceptedMargin @@ -318,7 +311,7 @@ contract Pricer is OpsManaged, PricerInterface { uint256 _intendedPricePoint, uint256 _currentPricePoint, uint256 _acceptedMargin) - private + internal pure returns (bool /*isValid*/) { @@ -334,7 +327,7 @@ contract Pricer is OpsManaged, PricerInterface { /// @dev Takes _pricePoint, _transferAmount, _commissionAmount; /// calculates the number of branded token equivalant to the currency amount; - /// private method; + /// internal method; /// @param _pricePoint pricePoint /// @param _transferAmount transferAmount /// @param _commissionAmount commissionAmount @@ -343,7 +336,7 @@ contract Pricer is OpsManaged, PricerInterface { uint256 _pricePoint, uint256 _transferAmount, uint256 _commissionAmount) - private + internal view returns (uint256, uint256) /* number of BT ,number of commission BT */ { @@ -352,4 +345,88 @@ contract Pricer is OpsManaged, PricerInterface { uint256 commissionAmountBT = SafeMath.div(SafeMath.mul(_commissionAmount, adjConversionRate), _pricePoint); return (amountBT, commissionAmountBT); } + + /// @dev Takes _beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount; + /// checks if the current price point is in the acceptable range of intendedPricePoint; + /// internal method; + /// @param _beneficiary beneficiary + /// @param _transferAmount transferAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionAmount commissionAmount + /// @return bool isValid + function isValidBeneficiaryData( + address _beneficiary, + uint256 _transferAmount, + address _commissionBeneficiary, + uint256 _commissionAmount) + internal + returns (bool /*isValid*/) + { + require(_beneficiary != address(0)); + require(_transferAmount != 0); + + if (_commissionAmount > 0) { + require(_commissionBeneficiary != address(0)); + } + return true; + } + + /// @dev Takes _spender, _beneficiary, _tokenAmount, _commissionBeneficiary, _commissionTokenAmount; + /// Perform tokenAmount transfer + /// Perform commissionTokenAmount transfer + /// internal method; + /// @param _spender spender + /// @param _beneficiary beneficiary + /// @param _tokenAmount tokenAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionTokenAmount commissionTokenAmount + /// @return (bool) + function performTransfer( + address _spender, + address _beneficiary, + uint256 _tokenAmount, + address _commissionBeneficiary, + uint256 _commissionTokenAmount) + internal + returns ( + bool /* boolean value */) + { + require(EIP20Interface(pricerBrandedToken).transferFrom(_spender, _beneficiary, _tokenAmount)); + + if (_commissionBeneficiary != address(0)) { + require(EIP20Interface(pricerBrandedToken).transferFrom(_spender, + _commissionBeneficiary, _commissionTokenAmount)); + } + return true; + } + + /// @dev Takes _currency, _intendedPricePoint, _transferAmount, _commissionAmount; + /// Validate accepted margin + /// Calculates tokenAmount and commissionTokenAmount + /// internal method + /// @param _currency currency + /// @param _intendedPricePoint intendedPricePoint + /// @param _transferAmount transferAmount + /// @param _commissionAmount commissionAmount + /// @return (pricePoint, tokenAmount, commissionTokenAmount) + function validateMarginAndCalculateBTAmount( + bytes3 _currency, + uint256 _intendedPricePoint, + uint256 _transferAmount, + uint256 _commissionAmount) + internal + returns (uint256, uint256, uint256) /* pricePoint, tokenAmount, commissionTokenAmount */ + { + uint256 pricePoint = getPricePoint(_currency); + require(pricePoint > 0); + require(isPricePointInRange(_intendedPricePoint, pricePoint, acceptedMargins(_currency))); + + uint256 tokenAmount; + uint256 commissionTokenAmount; + (tokenAmount, commissionTokenAmount) = getBTAmountFromCurrencyValue(pricePoint, _transferAmount, + _commissionAmount); + + return (pricePoint, tokenAmount, commissionTokenAmount); + } + } diff --git a/contracts/PricerInterface.sol b/contracts/PricerInterface.sol index 6fed0f4..031746c 100644 --- a/contracts/PricerInterface.sol +++ b/contracts/PricerInterface.sol @@ -1,3 +1,4 @@ +/* solhint-disable-next-line compiler-fixed */ pragma solidity ^0.4.17; // Copyright 2018 OpenST Ltd. @@ -167,7 +168,7 @@ contract PricerInterface { /// @param _commissionAmount commissionAmount /// @param _currency currency /// @param _intendedPricePoint _intendedPricePoint - /// @return bool isSuccess + /// @return uint256 totalPaid function pay( address _beneficiary, uint256 _transferAmount, @@ -176,7 +177,7 @@ contract PricerInterface { bytes3 _currency, uint256 _intendedPricePoint) public - returns (bool); + returns (uint256); /// @dev Takes _currency; /// gets current price point for the price oracle for the given currency; @@ -187,6 +188,57 @@ contract PricerInterface { bytes3 _currency) public returns (uint256); - + + /// @dev Takes _intendedPricePoint, _currentPricePoint, _acceptedMargin; + /// checks if the current price point is in the acceptable range of intendedPricePoint; + /// internal method; + /// @param _beneficiary beneficiary + /// @param _transferAmount transferAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionAmount commissionAmount + /// @return bool isValid + function isValidBeneficiaryData( + address _beneficiary, + uint256 _transferAmount, + address _commissionBeneficiary, + uint256 _commissionAmount) + internal + returns (bool); + + /// @dev Takes _spender, _beneficiary, _tokenAmount, _commissionBeneficiary, _commissionTokenAmount; + /// Perform tokenAmount transfer + /// Perform commissionTokenAmount transfer + /// internal method; + /// @param _spender spender + /// @param _beneficiary beneficiary + /// @param _tokenAmount tokenAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionTokenAmount commissionTokenAmount + /// @return (bool) + function performTransfer( + address _spender, + address _beneficiary, + uint256 _tokenAmount, + address _commissionBeneficiary, + uint256 _commissionTokenAmount) + internal + returns (bool); + + /// @dev Takes _currency, _intendedPricePoint, _transferAmount, _commissionAmount; + /// Validate accepted margin + /// Calculates tokenAmount and commissionTokenAmount + /// internal method + /// @param _currency currency + /// @param _intendedPricePoint intendedPricePoint + /// @param _transferAmount transferAmount + /// @param _commissionAmount commissionAmount + /// @return (pricePoint, tokenAmount, commissionTokenAmount) + function validateMarginAndCalculateBTAmount( + bytes3 _currency, + uint256 _intendedPricePoint, + uint256 _transferAmount, + uint256 _commissionAmount) + internal + returns (uint256, uint256, uint256); } \ No newline at end of file diff --git a/package.json b/package.json index fdde599..5bbb226 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "dependencies": { "@openstfoundation/openst-notification": "1.0.0-beta.1", + "@ostdotcom/ost-price-oracle": "^1.0.0-beta.3", "bignumber": "^1.1.0", "bignumber.js": "^4.1.0", "moment": "^2.19.2", From 870649cd8656805b3fdf988bf6f419df9c85a7fb Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Thu, 15 Feb 2018 20:41:44 +0530 Subject: [PATCH 05/10] PR Review Changes --- contracts/Airdrop.sol | 26 +++------ contracts/Pricer.sol | 54 ++++++++++++++++--- contracts/PricerInterface.sol | 20 ++++--- contracts/Workers.sol | 6 +-- contracts/ost-price-oracle/PriceOracle.sol | 12 +---- .../ost-price-oracle/PriceOracleInterface.sol | 10 ++-- 6 files changed, 78 insertions(+), 50 deletions(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index 939c41c..d36cf6d 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -26,19 +26,19 @@ import "./Workers.sol"; import "./Pricer.sol"; -contract Airdrop is Pricer, Workers { +contract Airdrop is Pricer { /* * Events */ /// Event for AirdropPayment complete event AirdropPayment( - address _beneficiary, + address indexed _beneficiary, uint256 tokenAmount, - address _commissionBeneficiary, + address indexed _commissionBeneficiary, uint256 commissionTokenAmount, uint256 _actualPricePoint, - address _spender, + address indexed _spender, uint256 _airdropAmount ); @@ -74,21 +74,10 @@ contract Airdrop is Pricer, Workers { airdropBudgetHolder = _airdropBudgetHolder; } - /* - * External functions - */ - /// clean up or revoke airdrop contract - function remove() - external - onlyAdminOrOps - { - selfdestruct(msg.sender); - } - /* * External functions */ - /// performPay matches the behaviour of Pricer:pay with extra functionality of airdrop evaluation + /// payAirdrop matches the behaviour of Pricer:pay with extra functionality of airdrop evaluation /// @param _beneficiary beneficiary /// @param _transferAmount transferAmount /// @param _commissionBeneficiary commissionBeneficiary @@ -98,7 +87,7 @@ contract Airdrop is Pricer, Workers { /// @param _spender spender /// @param _airdropAmount airdropAmount /// @return uint256 totalPaid - function performPay( + function payAirdrop( address _beneficiary, uint256 _transferAmount, address _commissionBeneficiary, @@ -108,6 +97,7 @@ contract Airdrop is Pricer, Workers { address _spender, uint256 _airdropAmount) public + ///isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns ( uint256 /* totalPaid */) { @@ -128,7 +118,7 @@ contract Airdrop is Pricer, Workers { require(performAirdropTransferToSpender(_spender, _airdropAmount, tokenAmount, commissionTokenAmount)); - require(performTransfer(_spender, _beneficiary, tokenAmount, + require(performTransfers(_spender, _beneficiary, tokenAmount, _commissionBeneficiary, commissionTokenAmount)); /// Emit AirdropPayment Event diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index a7c21ce..81885df 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -77,6 +77,18 @@ contract Pricer is OpsManaged, PricerInterface { pricerConversionRate = UtilityTokenInterface(_brandedToken).conversionRate(); } + /* + * External functions + */ + /// clean up or revoke airdrop contract + function remove() + external + onlyAdminOrOps + { + selfdestruct(msg.sender); + Removed(msg.sender); + } + /// @dev Returns address of the branded token; /// public method; /// @return address @@ -213,7 +225,7 @@ contract Pricer is OpsManaged, PricerInterface { } /// @dev Takes _transferAmount, _commissionAmount, _currency; - /// public method + /// public view method /// @param _transferAmount transferAmount /// @param _commissionAmount commissionAmount /// @param _currency currency @@ -223,6 +235,7 @@ contract Pricer is OpsManaged, PricerInterface { uint256 _commissionAmount, bytes3 _currency) public + view returns ( uint256 pricePoint, uint256 tokenAmount, @@ -261,6 +274,7 @@ contract Pricer is OpsManaged, PricerInterface { bytes3 _currency, uint256 _intendedPricePoint) public + ///isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns (uint256 /* total paid */) { require(isValidBeneficiaryData(_beneficiary, _transferAmount, @@ -276,11 +290,11 @@ contract Pricer is OpsManaged, PricerInterface { _intendedPricePoint, _transferAmount, _commissionAmount); } - require(performTransfer(msg.sender, _beneficiary, tokenAmount, + require(performTransfers(msg.sender, _beneficiary, tokenAmount, _commissionBeneficiary, commissionTokenAmount)); //Trigger Event for PaymentComplete - Payment(_beneficiary, _transferAmount, _commissionBeneficiary, + Payment(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount, _currency, _intendedPricePoint, pricePoint); return (tokenAmount + commissionTokenAmount); } @@ -292,14 +306,18 @@ contract Pricer is OpsManaged, PricerInterface { /// @return (pricePoint) function getPricePoint( bytes3 _currency) - public + public + view returns (uint256) /* pricePoint */ { PriceOracleInterface currentPriceOracle = pricerPriceOracles[_currency]; require(currentPriceOracle != address(0)); return (currentPriceOracle.getPrice()); } - + + /* + * Internal functions + */ /// @dev Takes _intendedPricePoint, _currentPricePoint, _acceptedMargin; /// checks if the current price point is in the acceptable range of intendedPricePoint; /// internal method; @@ -381,7 +399,7 @@ contract Pricer is OpsManaged, PricerInterface { /// @param _commissionBeneficiary commissionBeneficiary /// @param _commissionTokenAmount commissionTokenAmount /// @return (bool) - function performTransfer( + function performTransfers( address _spender, address _beneficiary, uint256 _tokenAmount, @@ -429,4 +447,28 @@ contract Pricer is OpsManaged, PricerInterface { return (pricePoint, tokenAmount, commissionTokenAmount); } + /* + * Modifiers + */ + /// @dev Takes _beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount; + /// checks if the current price point is in the acceptable range of intendedPricePoint; + /// modifier method; + /// @param _beneficiary beneficiary + /// @param _transferAmount transferAmount + /// @param _commissionBeneficiary commissionBeneficiary + /// @param _commissionAmount commissionAmount + modifier isValidBeneficiaryDataModifier( + address _beneficiary, + uint256 _transferAmount, + address _commissionBeneficiary, + uint256 _commissionAmount) { + require(_beneficiary != address(0)); + require(_transferAmount != 0); + + if (_commissionAmount > 0) { + require(_commissionBeneficiary != address(0)); + } + _; + } + } diff --git a/contracts/PricerInterface.sol b/contracts/PricerInterface.sol index 031746c..dbe1f0b 100644 --- a/contracts/PricerInterface.sol +++ b/contracts/PricerInterface.sol @@ -32,25 +32,29 @@ contract PricerInterface { address _beneficiary, uint256 _transferAmount, address _commissionBeneficiary, - uint256 _commissionAmount, + uint256 _commissionAmount, bytes3 _currency, uint256 _intendedPricePoint, uint256 _actualPricePoint); ///Event for price oracles updates for currency event PriceOracleSet( - bytes3 _currency, - address _address); + bytes3 indexed _currency, + address indexed _address); ///Event for price oracles delete event PriceOracleUnset( - bytes3 _currency); + bytes3 indexed _currency); ///Event for accepted margin update for currency event AcceptedMarginSet( - bytes3 _currency, + bytes3 indexed _currency, uint256 _acceptedMargin); + ///Event for Removing Contract + event Removed( + address indexed _sender); + /// @dev Returns address of the branded token; /// public method; /// @return address @@ -150,6 +154,7 @@ contract PricerInterface { uint256 _commissionAmount, bytes3 _currency) public + view returns (uint256, uint256, uint256); /// @dev Takes _beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount, @@ -186,7 +191,8 @@ contract PricerInterface { /// @return (pricePoint) function getPricePoint( bytes3 _currency) - public + public + view returns (uint256); /// @dev Takes _intendedPricePoint, _currentPricePoint, _acceptedMargin; @@ -215,7 +221,7 @@ contract PricerInterface { /// @param _commissionBeneficiary commissionBeneficiary /// @param _commissionTokenAmount commissionTokenAmount /// @return (bool) - function performTransfer( + function performTransfers( address _spender, address _beneficiary, uint256 _tokenAmount, diff --git a/contracts/Workers.sol b/contracts/Workers.sol index b0f8bc5..278582c 100644 --- a/contracts/Workers.sol +++ b/contracts/Workers.sol @@ -40,13 +40,13 @@ contract Workers is OpsManaged { */ ///Event for worker set event WorkerSet( - address _worker, - uint256 _deactivationHeight, + address indexed _worker, + uint256 indexed _deactivationHeight, uint256 _remainingHeight); ///Event for worker removed event WorkerRemoved( - address _worker, + address indexed _worker, bool _existed); /// @dev Constructor; diff --git a/contracts/ost-price-oracle/PriceOracle.sol b/contracts/ost-price-oracle/PriceOracle.sol index 80f32ea..4731ed9 100644 --- a/contracts/ost-price-oracle/PriceOracle.sol +++ b/contracts/ost-price-oracle/PriceOracle.sol @@ -103,20 +103,12 @@ contract PriceOracle is OpsManaged, PriceOracleInterface { /// @return price (Return 0 in case price expired so that call of this method can handle the error case) function getPrice() public + view returns ( uint256 /* price */ ) { // Current Block Number should be less than expiration height - // Emit an event if Price has expired - if (block.number > oracleExpirationHeight) { - // Emit invalid price event - PriceExpired(oracleExpirationHeight); - - return (0); - } - - // Return current price - return (price); + return (block.number > oracleExpirationHeight) ? 0 : price; } /// @dev use this function to get token decimals value diff --git a/contracts/ost-price-oracle/PriceOracleInterface.sol b/contracts/ost-price-oracle/PriceOracleInterface.sol index 663ca3e..439fc4c 100644 --- a/contracts/ost-price-oracle/PriceOracleInterface.sol +++ b/contracts/ost-price-oracle/PriceOracleInterface.sol @@ -1,3 +1,4 @@ +/* solhint-disable-next-line compiler-fixed */ pragma solidity ^0.4.17; // Copyright 2017 OST.com Ltd. @@ -30,12 +31,8 @@ contract PriceOracleInterface { /// @dev event emitted whenever price is updated /// @return _price /// @return _expirationHeight - event PriceUpdated(uint256 _price, - uint256 _expirationHeight); - - /// @dev event emitted if price has expired - /// @return _expirationHeight - event PriceExpired(uint256 _expirationHeight); + event PriceUpdated(uint256 indexed _price, + uint256 indexed _expirationHeight); /* * Functions @@ -94,6 +91,7 @@ contract PriceOracleInterface { /// @return quoteCurrency/baseCurrency value function getPrice() public + view returns( uint256); From 7059b15df121651edc4e81a8d8592419a8cfbd57 Mon Sep 17 00:00:00 2001 From: Jason Banks Date: Thu, 15 Feb 2018 17:16:49 +0100 Subject: [PATCH 06/10] Contracts: comment/uncomment for beneficiary validation modifier. --- contracts/Pricer.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index 81885df..090f4b4 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -274,11 +274,11 @@ contract Pricer is OpsManaged, PricerInterface { bytes3 _currency, uint256 _intendedPricePoint) public - ///isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) + isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns (uint256 /* total paid */) { - require(isValidBeneficiaryData(_beneficiary, _transferAmount, - _commissionBeneficiary, _commissionAmount)); + // require(isValidBeneficiaryData(_beneficiary, _transferAmount, + // _commissionBeneficiary, _commissionAmount)); uint256 tokenAmount = _transferAmount; uint256 commissionTokenAmount = _commissionAmount; From d45e084129263ef59dae129354c60389cbe01962 Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Thu, 15 Feb 2018 21:55:23 +0530 Subject: [PATCH 07/10] Enabling Airdrop modifier for banks to test --- contracts/Airdrop.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index d36cf6d..146483f 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -97,14 +97,14 @@ contract Airdrop is Pricer { address _spender, uint256 _airdropAmount) public - ///isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) + isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns ( uint256 /* totalPaid */) { require(workers.isWorker(msg.sender)); require(_spender != address(0)); - require(isValidBeneficiaryData(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount)); + ///require(isValidBeneficiaryData(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount)); uint256 tokenAmount = _transferAmount; uint256 commissionTokenAmount = _commissionAmount; @@ -149,7 +149,6 @@ contract Airdrop is Pricer { returns ( bool /* boolean value */) { - // @Ben Do we need this? Can't we transfer all _airdropAmount to _spender? uint256 airdropUsed = _airdropAmount; uint256 totalPaid = (_tokenAmount + _commissionTokenAmount); if (_airdropAmount > totalPaid) { From 340baa41f1b42847e1d47c4ea1afa21c634c1a47 Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Thu, 15 Feb 2018 23:19:10 +0530 Subject: [PATCH 08/10] Requested PR Review Changes - Remove modifier isValidBeneficiaryData and replace it with function --- contracts/Airdrop.sol | 21 +++++++++++---------- contracts/Pricer.sol | 29 ++--------------------------- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index 146483f..eae1df4 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -31,12 +31,12 @@ contract Airdrop is Pricer { /* * Events */ - /// Event for AirdropPayment complete + /// Emit AirdropPayment Event event AirdropPayment( address indexed _beneficiary, - uint256 tokenAmount, + uint256 _transferAmount, address indexed _commissionBeneficiary, - uint256 commissionTokenAmount, + uint256 _commissionAmount, uint256 _actualPricePoint, address indexed _spender, uint256 _airdropAmount @@ -97,14 +97,14 @@ contract Airdrop is Pricer { address _spender, uint256 _airdropAmount) public - isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns ( uint256 /* totalPaid */) { require(workers.isWorker(msg.sender)); require(_spender != address(0)); - ///require(isValidBeneficiaryData(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount)); + require(isValidBeneficiaryData(_beneficiary, _transferAmount, + _commissionBeneficiary, _commissionAmount)); uint256 tokenAmount = _transferAmount; uint256 commissionTokenAmount = _commissionAmount; @@ -122,8 +122,8 @@ contract Airdrop is Pricer { _commissionBeneficiary, commissionTokenAmount)); /// Emit AirdropPayment Event - AirdropPayment(_beneficiary, tokenAmount, _commissionBeneficiary, - commissionTokenAmount, pricePoint, _spender, _airdropAmount); + AirdropPayment(_beneficiary, _transferAmount, _commissionBeneficiary, + _commissionAmount, pricePoint, _spender, _airdropAmount); return ((tokenAmount + commissionTokenAmount)); } @@ -149,10 +149,11 @@ contract Airdrop is Pricer { returns ( bool /* boolean value */) { - uint256 airdropUsed = _airdropAmount; uint256 totalPaid = (_tokenAmount + _commissionTokenAmount); - if (_airdropAmount > totalPaid) { - airdropUsed = _airdropAmount - totalPaid; + // Find out minimum of totalPaid and _airdropAmount + uint256 airdropUsed = _airdropAmount; + if (totalPaid < airdropUsed) { + airdropUsed = totalPaid; } // Prefund the user from the airdrop budget holder diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index 090f4b4..6b5aa0c 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -274,11 +274,10 @@ contract Pricer is OpsManaged, PricerInterface { bytes3 _currency, uint256 _intendedPricePoint) public - isValidBeneficiaryDataModifier(_beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount) returns (uint256 /* total paid */) { - // require(isValidBeneficiaryData(_beneficiary, _transferAmount, - // _commissionBeneficiary, _commissionAmount)); + require(isValidBeneficiaryData(_beneficiary, _transferAmount, + _commissionBeneficiary, _commissionAmount)); uint256 tokenAmount = _transferAmount; uint256 commissionTokenAmount = _commissionAmount; @@ -447,28 +446,4 @@ contract Pricer is OpsManaged, PricerInterface { return (pricePoint, tokenAmount, commissionTokenAmount); } - /* - * Modifiers - */ - /// @dev Takes _beneficiary, _transferAmount, _commissionBeneficiary, _commissionAmount; - /// checks if the current price point is in the acceptable range of intendedPricePoint; - /// modifier method; - /// @param _beneficiary beneficiary - /// @param _transferAmount transferAmount - /// @param _commissionBeneficiary commissionBeneficiary - /// @param _commissionAmount commissionAmount - modifier isValidBeneficiaryDataModifier( - address _beneficiary, - uint256 _transferAmount, - address _commissionBeneficiary, - uint256 _commissionAmount) { - require(_beneficiary != address(0)); - require(_transferAmount != 0); - - if (_commissionAmount > 0) { - require(_commissionBeneficiary != address(0)); - } - _; - } - } From 69c7bbba4c11a4faf7a7605db46c272ab571183f Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Fri, 16 Feb 2018 20:45:58 +0530 Subject: [PATCH 09/10] Added _currency in AirdropPayment event --- contracts/Airdrop.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index eae1df4..e92035a 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -37,6 +37,7 @@ contract Airdrop is Pricer { uint256 _transferAmount, address indexed _commissionBeneficiary, uint256 _commissionAmount, + bytes3 _currency, uint256 _actualPricePoint, address indexed _spender, uint256 _airdropAmount @@ -123,7 +124,7 @@ contract Airdrop is Pricer { /// Emit AirdropPayment Event AirdropPayment(_beneficiary, _transferAmount, _commissionBeneficiary, - _commissionAmount, pricePoint, _spender, _airdropAmount); + _commissionAmount, _currency, pricePoint, _spender, _airdropAmount); return ((tokenAmount + commissionTokenAmount)); } From 380c39cc58ef712c19f7a36094835d593c734fed Mon Sep 17 00:00:00 2001 From: abhay-pepo Date: Sat, 17 Feb 2018 22:32:22 +0530 Subject: [PATCH 10/10] Added tokenAmount and commissionTokenAmount in Payment and AirdropPayment event Fire event before calling self destruct --- contracts/Airdrop.sol | 8 ++++---- contracts/Pricer.sol | 6 +++--- contracts/PricerInterface.sol | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/Airdrop.sol b/contracts/Airdrop.sol index e92035a..0d5b571 100644 --- a/contracts/Airdrop.sol +++ b/contracts/Airdrop.sol @@ -34,9 +34,9 @@ contract Airdrop is Pricer { /// Emit AirdropPayment Event event AirdropPayment( address indexed _beneficiary, - uint256 _transferAmount, + uint256 _tokenAmount, address indexed _commissionBeneficiary, - uint256 _commissionAmount, + uint256 _commissionTokenAmount, bytes3 _currency, uint256 _actualPricePoint, address indexed _spender, @@ -123,8 +123,8 @@ contract Airdrop is Pricer { _commissionBeneficiary, commissionTokenAmount)); /// Emit AirdropPayment Event - AirdropPayment(_beneficiary, _transferAmount, _commissionBeneficiary, - _commissionAmount, _currency, pricePoint, _spender, _airdropAmount); + AirdropPayment(_beneficiary, tokenAmount, _commissionBeneficiary, + commissionTokenAmount, _currency, pricePoint, _spender, _airdropAmount); return ((tokenAmount + commissionTokenAmount)); } diff --git a/contracts/Pricer.sol b/contracts/Pricer.sol index 6b5aa0c..3e15c5b 100644 --- a/contracts/Pricer.sol +++ b/contracts/Pricer.sol @@ -85,8 +85,8 @@ contract Pricer is OpsManaged, PricerInterface { external onlyAdminOrOps { - selfdestruct(msg.sender); Removed(msg.sender); + selfdestruct(msg.sender); } /// @dev Returns address of the branded token; @@ -293,8 +293,8 @@ contract Pricer is OpsManaged, PricerInterface { _commissionBeneficiary, commissionTokenAmount)); //Trigger Event for PaymentComplete - Payment(_beneficiary, _transferAmount, _commissionBeneficiary, - _commissionAmount, _currency, _intendedPricePoint, pricePoint); + Payment(_beneficiary, tokenAmount, _commissionBeneficiary, + commissionTokenAmount, _currency, _intendedPricePoint, pricePoint); return (tokenAmount + commissionTokenAmount); } diff --git a/contracts/PricerInterface.sol b/contracts/PricerInterface.sol index dbe1f0b..11d5028 100644 --- a/contracts/PricerInterface.sol +++ b/contracts/PricerInterface.sol @@ -30,9 +30,9 @@ contract PricerInterface { ///Event for payment complete event Payment( address _beneficiary, - uint256 _transferAmount, + uint256 _tokenAmount, address _commissionBeneficiary, - uint256 _commissionAmount, + uint256 _commissionTokenAmount, bytes3 _currency, uint256 _intendedPricePoint, uint256 _actualPricePoint);