Skip to content

Commit

Permalink
feat: test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
ts0yu authored Sep 8, 2024
1 parent 444095b commit 6f82389
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions contracts/utils/test/ModifyLiquidityTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pragma solidity ^0.8.10;

import {PoolManager} from "v4-core/PoolManager.sol";
import {PoolModifyLiquidityTest} from "v4-core/test/PoolModifyLiquidityTest.sol";
import {ArenaToken} from "src/ArenaToken.sol";
import {PoolKey} from "v4-core/types/PoolKey.sol";
import {Currency} from "v4-core/types/Currency.sol";
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";

contract Test {
function test_liquidityAdd() public {
PoolManager poolManager = new PoolManager(0);
PoolModifyLiquidityTest router = new PoolModifyLiquidityTest(poolManager);

ArenaToken currency0 = new ArenaToken("currency0", "c0", 18);
ArenaToken currency1 = new ArenaToken("currency1", "c1", 18);

currency0.mint(address(this), 100000000000000);
currency1.mint(address(this), 100000000000000);

currency0.approve(address(router), 100000000000000);
currency1.approve(address(router), 100000000000000);

if (currency0 > currency1) {
(currency0, currency1) = (currency1, currency0);
}

PoolKey memory poolKey = PoolKey ({
currency0: Currency.wrap(address(currency0)),
currency1: Currency.wrap(address(currency1)),
fee: 4000,
tickSpacing: 2,
hooks: IHooks(address(0))
});

// Represents a 1:1 ratio of assets in the pool.
poolManager.initialize(poolKey, 79228162514264337593543950336, "");

IPoolManager.ModifyLiquidityParams memory params = IPoolManager.ModifyLiquidityParams ({
tickLower: -20,
tickUpper: 20,
liquidityDelta: 1000,
salt: ""
});

router.modifyLiquidity(poolKey, params, "");
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ mod tests {
salt: FixedBytes::ZERO,
};

println!("{:#?}", signal);
println!("{:#?}", params);

engine
.modify_liquidity(signal.pool, params, Bytes::new(), provider.clone())
Expand Down

0 comments on commit 6f82389

Please sign in to comment.