Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export policies #159

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading