Skip to content

Commit

Permalink
added Released event on Factory lvl
Browse files Browse the repository at this point in the history
  • Loading branch information
roleengineer committed Jan 14, 2025
1 parent efd956d commit ab1ed03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/CirclesBacking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ contract CirclesBacking {

uint256 bptAmount = IERC20(lbp).balanceOf(address(this));
IERC20(lbp).transfer(receiver, bptAmount);

// emit event on factory lvl
FACTORY.notifyRelease(lbp);
}

// Internal functions
Expand Down
21 changes: 17 additions & 4 deletions src/factory/CirclesBackingFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ contract CirclesBackingFactory {
address personalCirclesAddress
);
/// @notice Emitted when a Circles backing process is completed.
event CirclesBackingCompleted(address indexed backer, address indexed circlesBackingInstance, address lbp);
event CirclesBackingCompleted(address indexed backer, address indexed circlesBackingInstance, address indexed lbp);
/// @notice Emitted when a Circles backing is ended by user due to release of LP tokens.
event Released(address indexed backer, address indexed circlesBackingInstance, address indexed lbp);

// Constants
/// @notice Address allowed to set supported backing assets and global bpt release timestamp.
Expand Down Expand Up @@ -113,6 +115,11 @@ contract CirclesBackingFactory {
_;
}

function onlyCirclesBacking() private view returns (address backer) {
backer = backerOf[msg.sender];
if (backer == address(0)) revert OnlyCirclesBacking();
}

/**
* @dev Reentrancy guard for nonReentrant functions.
* see https://soliditylang.org/blog/2024/01/26/transient-storage/
Expand Down Expand Up @@ -194,16 +201,15 @@ contract CirclesBackingFactory {
// LBP logic

/// @notice Creates LBP with underlying assets: `backingAssetAmount` backingAsset(`backingAsset`) and `CRC_AMOUNT` InflationaryCircles(`personalCRC`).
/// @dev Only Circles Backing instances are able to call.
/// @param personalCRC Address of InflationaryCircles (stable ERC20) used as underlying asset in lbp.
/// @param backingAsset Address of backing asset used as underlying asset in lbp.
/// @param backingAssetAmount Amount of backing asset used in lbp.
function createLBP(address personalCRC, uint256 personalCRCAmount, address backingAsset, uint256 backingAssetAmount)
external
returns (address lbp, bytes32 poolId, IVault.JoinPoolRequest memory request, address vault)
{
address backer = backerOf[msg.sender];
if (backer == address(0)) revert OnlyCirclesBacking();

address backer = onlyCirclesBacking();
// prepare inputs
IERC20[] memory tokens = new IERC20[](2);
bool tokenZero = personalCRC < backingAsset;
Expand Down Expand Up @@ -241,6 +247,13 @@ contract CirclesBackingFactory {
emit CirclesBackingCompleted(backer, msg.sender, lbp);
}

/// @notice Emits Released event on instance request.
/// @dev Only Circles Backing instances are able to call.
function notifyRelease(address lbp) external {
address backer = onlyCirclesBacking();
emit Released(backer, msg.sender, lbp);
}

/// @notice General wrapper function over vault.exitPool, allows to extract
/// liquidity from pool by approving this Factory to spend Balancer Pool Tokens.
/// @dev Required Balancer Pool Token approval for bptAmount before call
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/IFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ interface IFactory {
external
returns (address lbp, bytes32 poolId, IVault.JoinPoolRequest memory request, address vault);
function releaseTimestamp() external view returns (uint32);
function notifyRelease(address lbp) external;
}

0 comments on commit ab1ed03

Please sign in to comment.