Skip to content

Commit 6f058cb

Browse files
committed
algorithm scaffolds
1 parent f2f43e5 commit 6f058cb

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed

src/algorithms/clvr.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import { BaseAlgorithm } from "./BaseAlgorithm.sol";
5+
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
6+
7+
/// @title Clever Lookahead Volatility Reduction (CLVR) Ordering Contract.
8+
/// @author Meek Msaki @ Async Labs
9+
/// @notice This contract implements the CLVR algorithm for ordering transactions.
10+
/// @notice CLVR selects the next trade that minimizes price volatility (ln p0 - ln P(d, t))^2.
11+
/// The rule picks at each step t as the next trade that causes minimal local one-step price volatility from the status
12+
/// quo price p0.
13+
/// @custom:reference https://arxiv.org/abs/2408.02634
14+
contract CLVR is BaseAlgorithm {
15+
16+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
17+
18+
/// @inheritdoc IAlgorithm
19+
function name() external pure override returns (string memory) {
20+
return "CLVR";
21+
}
22+
23+
/// @inheritdoc IAlgorithm
24+
function version() external pure override returns (string memory) {
25+
return "1.0.0";
26+
}
27+
28+
/// @inheritdoc IAlgorithm
29+
function orderingRule(bool zeroForOne, uint256 amount) external override {
30+
/// TODO: Implement the CLVR algorithm logic here.
31+
}
32+
33+
}

src/algorithms/gmd.sol

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import { BaseAlgorithm } from "./BaseAlgorithm.sol";
5+
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
6+
7+
/// @title Gini Mean Difference (GMD).
8+
/// @author Meek Msaki @ Async Labs
9+
/// @notice This contract implements the GMD algorithm for ordering transactions.
10+
/// @custom:gpt-description https://chatgpt.com/share/68558f98-3fd0-8003-8cec-d54a575fc688
11+
contract GMD is BaseAlgorithm {
12+
13+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
14+
15+
/// @inheritdoc IAlgorithm
16+
function name() external pure override returns (string memory) {
17+
return "GMD";
18+
}
19+
20+
/// @inheritdoc IAlgorithm
21+
function version() external pure override returns (string memory) {
22+
return "1.0.0";
23+
}
24+
25+
/// @inheritdoc IAlgorithm
26+
function orderingRule(bool zeroForOne, uint256 amount) external override {
27+
/// TODO: Implement the GMD algorithm logic here.
28+
}
29+
30+
}

src/algorithms/gsr.sol

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import { BaseAlgorithm } from "./BaseAlgorithm.sol";
5+
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
6+
7+
/// @title Greedy Sequencing Rule (GSR) Ordering Contract
8+
/// @author Meek Msaki @ Async Labs
9+
/// @notice This contract implements the Greedy Sequencing Rule (GSR) for ordering transactions.
10+
/// The GSR algorithm is a transaction ordering rule that follows the following principles:
11+
/// 1. Start with any trade. Incase of GSRa, the first trade is the smallest trade.
12+
/// 2. If the price is above status-quo (overbought), pick a sell.
13+
/// 3. Otherwise, pick a buy.
14+
/// 4. Repeat 2-3 until all choices are exhausted.
15+
/// @custom:clvr https://arxiv.org/abs/2408.02634
16+
/// @custom:gdr https://arxiv.org/pdf/2209.15569
17+
contract GSR is BaseAlgorithm {
18+
19+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
20+
21+
/// @inheritdoc IAlgorithm
22+
function name() external pure override returns (string memory) {
23+
return "GSR";
24+
}
25+
26+
/// @inheritdoc IAlgorithm
27+
function version() external pure override returns (string memory) {
28+
return "1.0.0";
29+
}
30+
31+
/// @inheritdoc IAlgorithm
32+
function orderingRule(bool zeroForOne, uint256 amount) external pure override {
33+
/// TODO: Implement the GSR algorithm logic here.
34+
}
35+
36+
}

src/algorithms/vgsr.sol

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import { BaseAlgorithm } from "./BaseAlgorithm.sol";
5+
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";
6+
7+
/// @title Volume Heuristic Greedy Sequencing Rule (VGSR).
8+
/// @author Async Labs
9+
/// @notice This contract implements the Volume Heuristic Greedy Sequencing Rule (VGSR) for ordering transactions.
10+
/// 1. On top of the GSR method (namely, alternate between buy and sell).
11+
/// 1. The algorithm prioritizes selecting small transactions before bigger ones.
12+
contract VGSR is BaseAlgorithm {
13+
14+
constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }
15+
16+
/// @inheritdoc IAlgorithm
17+
function name() external pure override returns (string memory) {
18+
return "VGSR";
19+
}
20+
21+
/// @inheritdoc IAlgorithm
22+
function version() external pure override returns (string memory) {
23+
return "1.0.0";
24+
}
25+
26+
/// @inheritdoc IAlgorithm
27+
function orderingRule(bool zeroForOne, uint256 amount) external pure override {
28+
/// TODO: Implement the VGSR algorithm logic here.
29+
}
30+
31+
}

0 commit comments

Comments
 (0)