Skip to content

Commit

Permalink
Merge pull request #382 from primitivefinance/fix/swap-pool-check
Browse files Browse the repository at this point in the history
feat: move checkPool to revert early
  • Loading branch information
clemlak authored May 18, 2023
2 parents 7ee0484 + fad94ed commit e440fce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/Portfolio.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ abstract contract PortfolioVirtual is Objective {
_preLock();
if (_currentMulticall == false) _deposit();

// --- Checks --- //
if (!checkPool(args.poolId)) revert NonExistentPool(args.poolId);

PortfolioPool storage pool = pools[args.poolId];

// Scale amounts from native token decimals to WAD.
Expand Down Expand Up @@ -427,9 +430,6 @@ abstract contract PortfolioVirtual is Objective {
info.tokenOutput = pool.pair.tokenAsset;
}

// --- Checks --- //
if (!checkPool(args.poolId)) revert NonExistentPool(args.poolId);

(bool success, int256 invariant) =
_beforeSwapEffects(args.poolId, args.sellAsset);
if (!success) revert PoolExpired();
Expand Down

0 comments on commit e440fce

Please sign in to comment.