mirror of
https://github.com/grassrootseconomics/erc20-pool.git
synced 2024-11-07 06:26:47 +01:00
feat: add Deposit and Collect events
* refactor public deposit function: the internal function doesn't emit an event when called within withdraw
This commit is contained in:
parent
6d82807ffe
commit
d244cc05ec
@ -46,6 +46,20 @@ contract SwapPool {
|
|||||||
uint256 fee
|
uint256 fee
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Deposit
|
||||||
|
event Deposit(
|
||||||
|
address indexed initator,
|
||||||
|
address indexed tokenIn,
|
||||||
|
uint256 amountIn
|
||||||
|
);
|
||||||
|
|
||||||
|
// Collect
|
||||||
|
event Collect(
|
||||||
|
address indexed feeAdress,
|
||||||
|
address tokenOut,
|
||||||
|
uint256 amountOut
|
||||||
|
);
|
||||||
|
|
||||||
constructor(string memory _name, string memory _symbol, uint8 _decimals, address _tokenRegistry, address _tokenLimiter) {
|
constructor(string memory _name, string memory _symbol, uint8 _decimals, address _tokenRegistry, address _tokenLimiter) {
|
||||||
name = _name;
|
name = _name;
|
||||||
symbol = _symbol;
|
symbol = _symbol;
|
||||||
@ -106,6 +120,11 @@ contract SwapPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deposit(address _token, uint256 _value) public {
|
function deposit(address _token, uint256 _value) public {
|
||||||
|
_deposit(_token, _value);
|
||||||
|
emit Deposit(msg.sender, _token, _value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _deposit(address _token, uint256 _value) private {
|
||||||
bool r;
|
bool r;
|
||||||
bytes memory v;
|
bytes memory v;
|
||||||
|
|
||||||
@ -164,7 +183,7 @@ contract SwapPool {
|
|||||||
// pool should have enough balance to cover the final outValue (fees already deducted)
|
// pool should have enough balance to cover the final outValue (fees already deducted)
|
||||||
require(balance >= outValue, "ERR_BALANCE");
|
require(balance >= outValue, "ERR_BALANCE");
|
||||||
|
|
||||||
deposit(_inToken, _value);
|
_deposit(_inToken, _value);
|
||||||
|
|
||||||
(r, v) = _outToken.call(abi.encodeWithSignature('transfer(address,uint256)', msg.sender, outValue));
|
(r, v) = _outToken.call(abi.encodeWithSignature('transfer(address,uint256)', msg.sender, outValue));
|
||||||
require(r, "ERR_TOKEN");
|
require(r, "ERR_TOKEN");
|
||||||
@ -199,6 +218,7 @@ contract SwapPool {
|
|||||||
r = abi.decode(v, (bool));
|
r = abi.decode(v, (bool));
|
||||||
require(r, "ERR_TRANSFER");
|
require(r, "ERR_TRANSFER");
|
||||||
|
|
||||||
|
emit Collect(feeAddress, _outToken, _value);
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user