mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
Fixed Deflationary/Rebasing Token bug in token pool
This commit is contained in:
parent
4bff80010d
commit
6bbe1f80c8
|
@ -121,13 +121,17 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
*/
|
*/
|
||||||
function deposit(uint tknAmt) external payable nonReentrant whenNotPaused returns (uint mintAmt) {
|
function deposit(uint tknAmt) external payable nonReentrant whenNotPaused returns (uint mintAmt) {
|
||||||
require(msg.value == 0, "non-eth-pool");
|
require(msg.value == 0, "non-eth-pool");
|
||||||
|
require(tknAmt != 0, "tknAmt-is-zero");
|
||||||
uint _tokenBal = wdiv(totalSupply(), exchangeRate);
|
uint _tokenBal = wdiv(totalSupply(), exchangeRate);
|
||||||
uint _newTknBal = add(_tokenBal, tknAmt);
|
uint _newTknBal = add(_tokenBal, tknAmt);
|
||||||
require(_newTknBal < registry.poolCap(address(this)), "pool-cap-reached");
|
require(_newTknBal < registry.poolCap(address(this)), "pool-cap-reached");
|
||||||
|
uint initalBal = baseToken.balanceOf(address(this));
|
||||||
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
||||||
mintAmt = wmul(tknAmt, exchangeRate);
|
uint finalBal = baseToken.balanceOf(address(this));
|
||||||
|
uint _tknAmt = sub(finalBal, initalBal);
|
||||||
|
mintAmt = wmul(_tknAmt, exchangeRate);
|
||||||
_mint(msg.sender, mintAmt);
|
_mint(msg.sender, mintAmt);
|
||||||
emit LogDeposit(msg.sender, tknAmt, mintAmt);
|
emit LogDeposit(msg.sender, _tknAmt, mintAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user