Skip to content

Commit 440db54

Browse files
authored
Merge pull request #212 from tetu-io/dev
Dev
2 parents d029d41 + 900429e commit 440db54

16 files changed

+1006
-18
lines changed

contracts/base/vault/SmartVault.sol

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract SmartVault is Initializable, ERC20Upgradeable, VaultStorage, Controllab
3434
// ************* CONSTANTS ********************
3535
/// @notice Version of the contract
3636
/// @dev Should be incremented when contract changed
37-
string public constant override VERSION = "1.10.6";
37+
string public constant override VERSION = "1.10.8";
3838
/// @dev Denominator for penalty numerator
3939
uint256 public constant override LOCK_PENALTY_DENOMINATOR = 1000;
4040
uint256 public constant override TO_INVEST_DENOMINATOR = 1000;
@@ -113,6 +113,7 @@ contract SmartVault is Initializable, ERC20Upgradeable, VaultStorage, Controllab
113113
}
114114
// set 100% to invest
115115
_setToInvest(TO_INVEST_DENOMINATOR);
116+
_setDoHardWorkOnInvest(true);
116117
// set deposit fee
117118
if (_depositFee > 0) {
118119
require(_depositFee <= DEPOSIT_FEE_DENOMINATOR / 100);
@@ -338,7 +339,13 @@ contract SmartVault is Initializable, ERC20Upgradeable, VaultStorage, Controllab
338339
_isActive();
339340
_onlyAllowedUsers(msg.sender);
340341

342+
// need to invest before mint, if we will compound the profit the user should receive correct amount of shares
343+
if (_alwaysInvest()) {
344+
_invest();
345+
}
346+
341347
_deposit(amount, msg.sender, msg.sender);
348+
342349
if (_alwaysInvest()) {
343350
_invest();
344351
}
@@ -350,7 +357,10 @@ contract SmartVault is Initializable, ERC20Upgradeable, VaultStorage, Controllab
350357
_isActive();
351358
_onlyAllowedUsers(msg.sender);
352359

360+
_invest();
361+
353362
_deposit(amount, msg.sender, msg.sender);
363+
354364
_invest();
355365
}
356366

@@ -360,7 +370,12 @@ contract SmartVault is Initializable, ERC20Upgradeable, VaultStorage, Controllab
360370
_isActive();
361371
_onlyAllowedUsers(msg.sender);
362372

373+
if (_alwaysInvest()) {
374+
_invest();
375+
}
376+
363377
_deposit(amount, msg.sender, holder);
378+
364379
if (_alwaysInvest()) {
365380
_invest();
366381
}

contracts/infrastructure/price/IPriceCalculator.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,4 @@ interface IPriceCalculator {
1818

1919
function getPriceWithDefaultOutput(address token) external view returns (uint256);
2020

21-
function getLargestPool(address token, address[] memory usedLps) external view returns (address, uint256, address);
22-
23-
function getPriceFromLp(address lpAddress, address token) external view returns (uint256);
24-
2521
}

contracts/infrastructure/price/PriceCalculator.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ contract PriceCalculator is Initializable, ControllableV2, IPriceCalculator {
349349
// Gives the LP with largest liquidity for a given token
350350
// and a given tokenset (either keyTokens or pricingTokens)
351351
function getLargestPool(address token, address[] memory usedLps)
352-
public override view returns (address, uint256, address) {
352+
public view returns (address, uint256, address) {
353353
uint256 largestLpSize = 0;
354354
address largestKeyToken = address(0);
355355
uint256 largestPlatformIdx = 0;
@@ -465,7 +465,7 @@ contract PriceCalculator is Initializable, ControllableV2, IPriceCalculator {
465465
}
466466

467467
//Generic function giving the price of a given token vs another given token on Swap platform.
468-
function getPriceFromLp(address lpAddress, address token) public override view returns (uint256) {
468+
function getPriceFromLp(address lpAddress, address token) public view returns (uint256) {
469469
address _factory = IUniswapV2Pair(lpAddress).factory();
470470
if (_factory == DYSTOPIA_FACTORY || _factory == CONE_FACTORY) {
471471
(address token0, address token1) = IDystopiaPair(lpAddress).tokens();

0 commit comments

Comments
 (0)