Skip to content
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
33 changes: 33 additions & 0 deletions src/algorithms/clvr.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import { BaseAlgorithm } from "./BaseAlgorithm.sol";
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";

/// @title Clever Lookahead Volatility Reduction (CLVR) Ordering Contract.
/// @author Meek Msaki @ Async Labs
/// @notice This contract implements the CLVR algorithm for ordering transactions.
/// @notice CLVR selects the next trade that minimizes price volatility (ln p0 - ln P(d, t))^2.
/// The rule picks at each step t as the next trade that causes minimal local one-step price volatility from the status
/// quo price p0.
/// @custom:reference https://arxiv.org/abs/2408.02634
contract CLVR is BaseAlgorithm {

constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }

/// @inheritdoc IAlgorithm
function name() external pure override returns (string memory) {
return "CLVR";
}

/// @inheritdoc IAlgorithm
function version() external pure override returns (string memory) {
return "1.0.0";
}

/// @inheritdoc IAlgorithm
function orderingRule(bool zeroForOne, uint256 amount) external override {
/// TODO: Implement the CLVR algorithm logic here.
}

}
30 changes: 30 additions & 0 deletions src/algorithms/gmd.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import { BaseAlgorithm } from "./BaseAlgorithm.sol";
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";

/// @title Gini Mean Difference (GMD).
/// @author Meek Msaki @ Async Labs
/// @notice This contract implements the GMD algorithm for ordering transactions.
/// @custom:gpt-description https://chatgpt.com/share/68558f98-3fd0-8003-8cec-d54a575fc688
contract GMD is BaseAlgorithm {

constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }

/// @inheritdoc IAlgorithm
function name() external pure override returns (string memory) {
return "GMD";
}

/// @inheritdoc IAlgorithm
function version() external pure override returns (string memory) {
return "1.0.0";
}

/// @inheritdoc IAlgorithm
function orderingRule(bool zeroForOne, uint256 amount) external override {
/// TODO: Implement the GMD algorithm logic here.
}

}
36 changes: 36 additions & 0 deletions src/algorithms/gsr.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import { BaseAlgorithm } from "./BaseAlgorithm.sol";
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";

/// @title Greedy Sequencing Rule (GSR) Ordering Contract
/// @author Meek Msaki @ Async Labs
/// @notice This contract implements the Greedy Sequencing Rule (GSR) for ordering transactions.
/// The GSR algorithm is a transaction ordering rule that follows the following principles:
/// 1. Start with any trade. Incase of GSRa, the first trade is the smallest trade.
/// 2. If the price is above status-quo (overbought), pick a sell.
/// 3. Otherwise, pick a buy.
/// 4. Repeat 2-3 until all choices are exhausted.
/// @custom:clvr https://arxiv.org/abs/2408.02634
/// @custom:gdr https://arxiv.org/pdf/2209.15569
contract GSR is BaseAlgorithm {

constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }

/// @inheritdoc IAlgorithm
function name() external pure override returns (string memory) {
return "GSR";
}

/// @inheritdoc IAlgorithm
function version() external pure override returns (string memory) {
return "1.0.0";
}

/// @inheritdoc IAlgorithm
function orderingRule(bool zeroForOne, uint256 amount) external pure override {
/// TODO: Implement the GSR algorithm logic here.
}

}
31 changes: 31 additions & 0 deletions src/algorithms/vgsr.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import { BaseAlgorithm } from "./BaseAlgorithm.sol";
import { IAlgorithm } from "@async-swap/interfaces/IAlgorithm.sol";

/// @title Volume Heuristic Greedy Sequencing Rule (VGSR).
/// @author Async Labs
/// @notice This contract implements the Volume Heuristic Greedy Sequencing Rule (VGSR) for ordering transactions.
/// 1. On top of the GSR method (namely, alternate between buy and sell).
/// 1. The algorithm prioritizes selecting small transactions before bigger ones.
contract VGSR is BaseAlgorithm {

constructor(address _hookAddress) BaseAlgorithm(_hookAddress) { }

/// @inheritdoc IAlgorithm
function name() external pure override returns (string memory) {
return "VGSR";
}

/// @inheritdoc IAlgorithm
function version() external pure override returns (string memory) {
return "1.0.0";
}

/// @inheritdoc IAlgorithm
function orderingRule(bool zeroForOne, uint256 amount) external pure override {
/// TODO: Implement the VGSR algorithm logic here.
}

}