File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed
Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
2929 mapping (PoolId poolId => AsyncFiller.State) public asyncOrders;
3030 /// Ordering algortim
3131 IAlgorithm public immutable ALGORITHM;
32+ mapping (uint256 block = > uint256 volatility ) public kvolatility;
3233
3334 /// Event emitted when a swap is executed.
3435 /// @param id The poolId of the pool where the swap occurred.
@@ -117,6 +118,10 @@ contract AsyncSwap is BaseHook, IAsyncSwapAMM {
117118
118119 /// @inheritdoc IAsyncSwapAMM
119120 function executeOrders (AsyncOrder[] calldata orders , bytes calldata userParams ) external {
121+ /// Sort poolIDs
122+ /// Order swaps by poolId
123+
124+ uint256 volatility = ALGORITHM.getVolatility (orders);
120125 for (uint8 i = 0 ; i < orders.length ; i++ ) {
121126 AsyncOrder calldata order = orders[i];
122127 // Use transaction ordering algorithm to ensure correct execution order
Original file line number Diff line number Diff line change 22pragma solidity ^ 0.8.26 ;
33
44import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol " ;
5+ import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol " ;
56
67contract BaseAlgorithm is IAlgorithm {
78
@@ -42,4 +43,9 @@ contract BaseAlgorithm is IAlgorithm {
4243 revert ("BaseAlgorithm: orderingRule not implemented " );
4344 }
4445
46+ function getVolatility (AsyncOrder[] memory orders ) external pure virtual override returns (uint256 ) {
47+ orders;
48+ revert ("BaseAlgorithm: orderingRule not implemented " );
49+ }
50+
4551}
Original file line number Diff line number Diff line change 22pragma solidity ^ 0.8.26 ;
33
44import { BaseAlgorithm } from "./BaseAlgorithm.sol " ;
5+
56import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol " ;
7+ import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol " ;
68
79/// @title Clever Lookahead Volatility Reduction (CLVR) Ordering Contract.
810/// @author Meek Msaki @ Async Labs
@@ -30,4 +32,15 @@ contract CLVR is BaseAlgorithm {
3032 /// TODO: Implement the CLVR algorithm logic here.
3133 }
3234
35+ function getVolatility (AsyncOrder[] memory orders ) external pure override returns (uint256 ) {
36+ uint256 accum;
37+ uint256 vol;
38+ for (uint256 i = 0 ; i < orders.length ; i++ ) {
39+ accum;
40+ AsyncOrder memory order = orders[i];
41+ order.amountIn;
42+ }
43+ return vol;
44+ }
45+
3346}
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.26 ;
33
4+ import { AsyncOrder } from "@async-swap/types/AsyncOrder.sol " ;
5+
46/// @title Algorithm Interface
57/// @author Async Labs
68/// @notice This interface defines the functions for transaction ordering algorithms used in the Async Swap AMM hook.
@@ -20,4 +22,6 @@ interface IAlgorithm {
2022 /// @return The version of the algorithm as a string.
2123 function version () external view returns (string memory );
2224
25+ function getVolatility (AsyncOrder[] memory orders ) external pure returns (uint256 );
26+
2327}
You can’t perform that action at this time.
0 commit comments