Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/events #12

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ docs/
lcov.info
lcov.info.pruned
report
coverage/
coverage/
broadcast/
14 changes: 10 additions & 4 deletions src/Validly.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ contract Validly is IValidly, ERC20, ReentrancyGuard {

(amount0, amount1) =
pool.depositLiquidity(amount0, amount1, msg.sender, _verificationContext, abi.encode(msg.sender));

emit Deposit(msg.sender, _recipient, amount0, amount1, shares);
}

/**
Expand Down Expand Up @@ -215,11 +217,13 @@ contract Validly is IValidly, ERC20, ReentrancyGuard {
revert Validly__withdraw_invalidRecipient();
}

(uint256 reserve0, uint256 reserve1) = pool.getReserves();
{
(uint256 reserve0, uint256 reserve1) = pool.getReserves();

uint256 totalSupplyCache = totalSupply();
amount0 = Math.mulDiv(reserve0, _shares, totalSupplyCache);
amount1 = Math.mulDiv(reserve1, _shares, totalSupplyCache);
uint256 totalSupplyCache = totalSupply();
amount0 = Math.mulDiv(reserve0, _shares, totalSupplyCache);
amount1 = Math.mulDiv(reserve1, _shares, totalSupplyCache);
}

if (amount0 == 0 || amount1 == 0) revert Validly__withdraw_AmountZero();

Expand All @@ -234,6 +238,8 @@ contract Validly is IValidly, ERC20, ReentrancyGuard {
_burn(msg.sender, _shares);

pool.withdrawLiquidity(amount0, amount1, msg.sender, _recipient, _verificationContext);

emit Withdraw(msg.sender, _recipient, amount0, amount1, _shares);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/IValidly.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {ISovereignALM} from "@valantis-core/ALM/interfaces/ISovereignALM.sol";
import {ISovereignPool} from "@valantis-core/pools/interfaces/ISovereignPool.sol";

interface IValidly is ISovereignALM {
event Deposit(address sender, address recipient, uint256 amount0, uint256 amount1, uint256 shares);

event Withdraw(address sender, address recipient, uint256 amount0, uint256 amount1, uint256 shares);

function MINIMUM_LIQUIDITY() external view returns (uint256);

function INVARIANT_CACHE_SLOT() external view returns (bytes32);
Expand Down