Skip to content

Commit

Permalink
feat: export policies
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed Nov 10, 2024
1 parent 695286d commit 23b7ba3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ verbosity = 3

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
testnet = "${TESTNET_RPC_URL}"

[fmt]
bracket_spacing = true
Expand Down
4 changes: 4 additions & 0 deletions src/Modules.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ import {
import { ERC7484RegistryAdapter } from "module-bases/ERC7484RegistryAdapter.sol";
import { ERC7579ModuleBase } from "module-bases/ERC7579ModuleBase.sol";
import { TrustedForwarder } from "module-bases/utils/TrustedForwarder.sol";
import { ERC1271Policy } from "module-bases/ERC1271Policy.sol";
import { ERC7579ActionPolicy } from "module-bases/ERC7579ActionPolicy.sol";
import { ERC7579PolicyBase } from "module-bases/ERC7579PolicyBase.sol";
import { ERC7579UserOpPolicy } from "module-bases/ERC7579UserOpPolicy.sol";
18 changes: 0 additions & 18 deletions test/integrations/SwapTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,12 @@ contract TestUniswap is BaseTest {
function testApproveAndSwap() public {
address poolAddress = UniswapV3Integration.getPoolAddress(address(tokenA), address(tokenB));
uint160 sqrtPriceX96 = UniswapV3Integration.getSqrtPriceX96(poolAddress);
emit log_named_uint("Square Root Price X96", sqrtPriceX96);

uint256 priceRatio = UniswapV3Integration.sqrtPriceX96toPriceRatio(sqrtPriceX96);

emit log_named_uint("Price Ratio", priceRatio);

uint256 price =
UniswapV3Integration.priceRatioToPrice(priceRatio, poolAddress, address(tokenA));

emit log_named_uint("Price", price);

bool swapToken0to1 = UniswapV3Integration.checkTokenOrder(address(tokenA), poolAddress);

uint256 priceRatioLimit;
Expand All @@ -72,23 +67,14 @@ contract TestUniswap is BaseTest {
priceRatioLimit = (priceRatio * (1000 + slippage)) / 1000;
}

emit log_named_uint("Price Ratio Limit", priceRatioLimit);

uint256 priceLimit =
UniswapV3Integration.priceRatioToPrice(priceRatioLimit, poolAddress, address(tokenA));

emit log_named_uint("Price Limit", priceLimit);

uint160 sqrtPriceLimitX96 = UniswapV3Integration.priceRatioToSqrtPriceX96(priceRatioLimit);

emit log_named_uint("sqrtPriceLimitX96", sqrtPriceLimitX96);

uint256 initialAccountBalanceA = tokenA.balanceOf(instance.account);
uint256 initialAccountBalanceB = tokenB.balanceOf(instance.account);

emit log_named_uint("Initial Balance of Token A (account)", initialAccountBalanceA);
emit log_named_uint("Initial Balance of Token B (account)", initialAccountBalanceB);

Execution[] memory swap = UniswapV3Integration.approveAndSwap(
instance.account, tokenA, tokenB, amountIn, sqrtPriceLimitX96
);
Expand All @@ -104,11 +90,7 @@ contract TestUniswap is BaseTest {
uint256 finalAccountBalanceA = tokenA.balanceOf(instance.account);
uint256 finalAccountBalanceB = tokenB.balanceOf(instance.account);

emit log_named_uint("Final Balance of Token A (account)", finalAccountBalanceA);
emit log_named_uint("Final Balance of Token B (account)", finalAccountBalanceB);

sqrtPriceX96 = UniswapV3Integration.getSqrtPriceX96(poolAddress);
emit log_named_uint("Post Swap Square Root Price X96", sqrtPriceX96);

require(
finalAccountBalanceA < initialAccountBalanceA,
Expand Down

0 comments on commit 23b7ba3

Please sign in to comment.