Skip to content

Commit

Permalink
fix: balanceDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTimepunk committed Oct 30, 2024
1 parent 86e76c5 commit ccc551a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ build-sizes: ## Builds the project and shows sizes

.PHONY: test-vvv
test-vvv: ## Runs tests with verbose output
forge test --match-contract SuperformRouterPlusTest --evm-version cancun

forge test --match-test test_rebalanceMultiPositions_tokenRefunds_interimDust_allowanceNot0 --evm-version cancun -vvvvv

.PHONY: ftest
ftest: ## Runs tests with cancun evm version
Expand Down
50 changes: 50 additions & 0 deletions test/unit/router-plus/SuperformRouterPlus.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,56 @@ contract SuperformRouterPlusTest is ProtocolActions {
SuperformRouterPlus(ROUTER_PLUS_SOURCE).rebalanceMultiPositions{ value: 2 ether }(args);
}

function test_rebalanceMultiPositions_tokenRefunds_interimDust() public {
vm.startPrank(deployer);

_directDeposit(superformId1, 1e18);
_directDeposit(superformId2, 1e6);

(ISuperformRouterPlus.RebalanceMultiPositionsSyncArgs memory args, uint256 totalAmountToDeposit) =
_buildRebalanceTwoPositionsToOneVaultXChainArgs();

SingleVaultSFData memory sfDataRebalanceTo =
abi.decode(_parseCallData(args.rebalanceToCallData), (SingleXChainSingleVaultStateReq)).superformData;

/// @dev keeper attempting to rug the user by reducing amount in
sfDataRebalanceTo.liqRequest.txData = _buildLiqBridgeTxData(
LiqBridgeTxDataArgs(
1,
args.interimAsset,
getContract(OP, "DAI"),
getContract(OP, "DAI"),
getContract(SOURCE_CHAIN, "SuperformRouter"),
SOURCE_CHAIN,
OP,
OP,
false,
getContract(OP, "CoreStateRegistry"),
uint256(OP),
totalAmountToDeposit - 1e4,
false,
0,
1,
1,
1,
address(0)
),
false
);

args.rebalanceToCallData = abi.encodeCall(
IBaseRouter.singleXChainSingleVaultDeposit, SingleXChainSingleVaultStateReq(AMBs, OP, sfDataRebalanceTo)
);

SuperPositions(SUPER_POSITIONS_SOURCE).increaseAllowance(
ROUTER_PLUS_SOURCE, superformId1, args.sharesToRedeem[0]
);
SuperPositions(SUPER_POSITIONS_SOURCE).increaseAllowance(
ROUTER_PLUS_SOURCE, superformId2, args.sharesToRedeem[1]
);
SuperformRouterPlus(ROUTER_PLUS_SOURCE).rebalanceMultiPositions{ value: 2 ether }(args);
}

function test_rebalanceSinglePosition_singleXChainSingleVaultDepositSelector() public {
vm.startPrank(deployer);

Expand Down

0 comments on commit ccc551a

Please sign in to comment.