Skip to content

Commit

Permalink
Merge pull request #433 from primitivefinance/fix/normal-strategy-hook
Browse files Browse the repository at this point in the history
fix(afterCreate): adds return true to afterCreate hook
  • Loading branch information
Alexangelj authored Aug 10, 2023
2 parents 81fd335 + e96e633 commit 47d1e0b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/Portfolio.sol
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ contract Portfolio is ERC1155, IPortfolio {
_getLastPoolId = poolId;

// This call also prevents accidently creating a pool with an invalid strategy target address.
IStrategy(getStrategy(poolId)).afterCreate(poolId, strategyArgs);
bool success =
IStrategy(getStrategy(poolId)).afterCreate(poolId, strategyArgs);
if (!success) revert Portfolio_AfterCreateFail();

emit CreatePool(
poolId,
Expand Down
1 change: 1 addition & 0 deletions contracts/libraries/PortfolioLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "./ConstantsLib.sol" as ConstantsLib;
import "./PoolLib.sol";
import "./SwapLib.sol";

error Portfolio_AfterCreateFail();
error Portfolio_BeforeSwapFail();
error Portfolio_DuplicateToken();
error Portfolio_Insolvent(address token, int256 net);
Expand Down
2 changes: 2 additions & 0 deletions contracts/strategies/NormalStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ contract NormalStrategy is INormalStrategy {
durationSeconds: config.durationSeconds,
isPerpetual: config.isPerpetual
});

return true;
}

/// @inheritdoc IStrategy
Expand Down

0 comments on commit 47d1e0b

Please sign in to comment.