Skip to content

Commit

Permalink
Optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Feb 16, 2025
1 parent dc41f3d commit 9ba9407
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions contracts/V1EMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ contract V1EMP is
using SafeMath for uint256;


/// @inheritdoc IV1EMP
address public override manager;

address[] internal _utilizedV1EMPStrategy;

/// @inheritdoc IV1EMP
bool public override utilizedERC20DepositOpen;
/// @inheritdoc IV1EMP
bool public override utilizedERC20WithdrawFull;
/// @inheritdoc IV1EMP
bool public override utilizedERC20WithdrawOpen;

/// @inheritdoc IV1EMP
uint256 public override feeRateGovernance;
/// @inheritdoc IV1EMP
uint256 public override feeRateManager;

IV1EMPRegistry internal immutable _I_V1_EMP_REGISTRY;
Expand Down
2 changes: 2 additions & 0 deletions contracts/V1EMPRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ contract V1EMPRegistry is
address internal _v1EMPStrategyDeployer;
address internal _v1EMPStrategyUtility;

/// @inheritdoc IV1EMPRegistry
uint256 public override v1EMPIdTracker;
/// @inheritdoc IV1EMPRegistry
uint256 public override v1EMPStrategyIdTracker;

mapping (address eRC20 => address eRC20ETHValueProvider) public override eRC20_eRC20ETHValueProvider;
Expand Down
6 changes: 6 additions & 0 deletions contracts/V1EMPStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ contract V1EMPStrategy is
using SafeMath for uint256;


/// @inheritdoc IV1EMPStrategy
address public override manager;

address[] internal _utilizedERC20;

/// @inheritdoc IV1EMPStrategy
bool public override utilizedERC20DepositOpen;
/// @inheritdoc IV1EMPStrategy
bool public override utilizedERC20WithdrawOpen;

/// @inheritdoc IV1EMPStrategy
uint256 public override sharesTotal;
/// @inheritdoc IV1EMPStrategy
uint256 public override utilizedERC20UpdateTracker;

IV1EMPRegistry internal immutable _I_V1_EMP_REGISTRY;

/// @inheritdoc IV1EMPStrategy
IERC20Handler public override iERC20Handler;

mapping (address utilizedERC20 => UtilizationERC20 utilizationERC20) internal _utilizedERC20_utilizationERC20;
Expand Down
4 changes: 2 additions & 2 deletions contracts/V1EMPUtility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract V1EMPUtility is
using SafeMath for uint256;


uint8 public constant TOLERANCE = 10;
uint8 internal constant _TOLERANCE = 10;

IV1EMPRegistry internal immutable _I_V1_EMP_REGISTRY;

Expand Down Expand Up @@ -75,7 +75,7 @@ contract V1EMPUtility is
{
if (IERC20(utilizedERC20).balanceOf(_v1EMP) < transferAmount)
{
return transferAmount -= TOLERANCE;
return transferAmount -= _TOLERANCE;
}

return transferAmount;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@yield-sync/erc20-eth-value-provider": "^0.0.5",
"@yield-sync/erc20-handler": "^0.0.5",
"@yield-sync/governance": "^0.0.42",
"@yield-sync/utility": "^0.0.16",
"@yield-sync/utility": "^0.0.17",
"chai": "^4.4.1",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
Expand Down
3 changes: 2 additions & 1 deletion test/3-EMPUtility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ describe("[3.0] V1EMPUtility.sol", async () => {

it("Should return TOLERATED transferAmount if EMP balance less than transferAmount..", async () => {
const AMOUNT = 100;
const TOLERANCE = 10;

const toleratedAmount = await eMPUtility.optimizedTransferAmount(
fakeEMP.address,
eRC20A.address,
AMOUNT
);

expect(toleratedAmount).to.be.equal(AMOUNT - await eMPUtility.TOLERANCE());
expect(toleratedAmount).to.be.equal(AMOUNT - TOLERANCE);
});
});

Expand Down
6 changes: 4 additions & 2 deletions test/7-EMP/2-withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ describe("[7.2] V1EMP.sol - Withdrawing Tokens", async () => {
const s1Balance = await strategies[0].contract.eMP_shares(eMP.address);
const s2Balance = await strategies[1].contract.eMP_shares(eMP.address);

const TOLERANCE = 10;

// Withdraw only partial balanceOf EMP
await eMP.utilizedV1EMPStrategyWithdraw([s1Balance.div(23), s2Balance.div(35)]);

Expand All @@ -393,7 +395,7 @@ describe("[7.2] V1EMP.sol - Withdrawing Tokens", async () => {

expect(EMP_BALANCE_A).to.be.equal(BeforeBalanceAEMP);
expect(EMP_BALANCE_B).to.be.equal(BeforeBalanceBEMP);
expect(EMP_BALANCE_C).to.be.equal(BeforeBalanceCEMP.add(await eMPUtility.TOLERANCE()).sub(1));
expect(EMP_BALANCE_C).to.be.equal(BeforeBalanceCEMP.add(TOLERANCE).sub(1));


const OWNER_BALANCE_A = await eRC20A.balanceOf(owner.address);
Expand All @@ -402,7 +404,7 @@ describe("[7.2] V1EMP.sol - Withdrawing Tokens", async () => {

expect(OWNER_BALANCE_A).to.be.equal(BeforeBalanceAOwner);
expect(OWNER_BALANCE_B).to.be.equal(BeforeBalanceBOwner);
expect(OWNER_BALANCE_C).to.be.equal(BeforeBalanceCOwner.sub(await eMPUtility.TOLERANCE()));
expect(OWNER_BALANCE_C).to.be.equal(BeforeBalanceCOwner.sub(TOLERANCE));


const EMP_SHARE_STRATEGY_0_BALANCE = await strategies[0].contract.eMP_shares(eMP.address);
Expand Down

0 comments on commit 9ba9407

Please sign in to comment.