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: Derivative and SamplePoint suggestions #83

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
44 changes: 44 additions & 0 deletions evm/src/interfaces/ISwapAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,50 @@ interface ISwapAdapter is ISwapAdapterTypes {
uint256[] memory specifiedAmounts
) external returns (Fraction[] memory prices);

/// @notice Calculates pool prices derivatives for specified amounts
/// (optional).
/// @dev TODO
/// @param poolId The ID of the trading pool.
/// @param sellToken The token being sold.
/// @param buyToken The token being bought.
/// @param specifiedAmounts The specified amounts used for price
/// calculation.
/// @return prices array of prices as fractions corresponding to the
/// provided amounts.
function priceDerivative(
bytes32 poolId,
address sellToken,
address buyToken,
uint256[] memory specifiedAmounts
) external returns (Fraction[] memory prices);

/// @notice Calculates second pool prices derivatives for specified amounts
/// (optional).
/// @dev TODO
/// @param poolId The ID of the trading pool.
/// @param sellToken The token being sold.
/// @param buyToken The token being bought.
/// @param specifiedAmounts The specified amounts used for price
/// calculation.
/// @return prices array of prices as fractions corresponding to the
/// provided amounts.
function priceSecondDerivative(
bytes32 poolId,
address sellToken,
address buyToken,
uint256[] memory specifiedAmounts
) external returns (Fraction[] memory prices);

/// @notice Suggests sample points on the price and derivative functions.
/// @dev TODO
/// @param poolId The ID of the trading pool.
/// @param sellToken The token being sold.
/// @param buyToken The token being bought.
/// @return array of sample points
function samplePoints(bytes32 poolId, address sellToken, address buyToken)
external
returns (uint256[] memory points);

/**
* @notice Simulates swapping tokens on a given pool.
* @dev This function should be state modifying, meaning it should actually
Expand Down
8 changes: 7 additions & 1 deletion evm/src/interfaces/ISwapAdapterTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ interface ISwapAdapterTypes {
HardLimits,
// Indicates whether the pool's price function can be called with
// amountIn=0 to return the current price (optional)
MarginalPrice
MarginalPrice,
// Support evaluating the price derivative function (optional)
Derivatives,
// Support evaluating the second price derivative function (optional)
SecondDerivatives,
// Support evaluating the price sample point function (optional)
SamplePoints
}

/// @dev Representation used for rational numbers such as prices.
Expand Down
Loading