-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delta-neutral basis trading strategy extension contract (#27)
* Add IUniswapV3Quoter interface * Add WIP basis trading strategy contract * Add WIP strategy contract unit tests * Fix bugs in existing contracts and tests * Refactor setter functions; Add unit tests for setter functions * Fix getCurrentEtherIncentive; Add tests for withdrawEtherBalance and getCurrentEtherIncentive * Refactor shouldRebalance; Add tests for shouldRebalance and shouldRebalanceWithBounds * Refactor getChunkRebalanceNotional; Add tests for getChunkRebalanceNotional * Fix disengage; Add unit tests for disengage * Add unit tests for ripcord * Fix reinvest; Add unit tests for reinvest * Remove console logs from contract; Fix comments * Rebase to master * Add javadocs and missing test cases * Fix reinvest; Add appropriate revert logic * Fix coverage; Remove unncessary if block * Fix compilation * Fix imports and failing tests * Fix bug: Update reinvest to onlyAllowedCaller from onlyOperator * Updated version to 0.0.7-basis.0 * Add suggested changes * Remove pending todos * Fix to support all leverages <1, =1, >1; Refactor tests * Add logic to return reinvest only when reinvestable amount > 0; Add unit tests * Fix failing tests; Fix unit calculation * Updated version to 0.0.7-basis.1 * Refactor reinvest * Verify bytes parameters set in exchange settings * Update package to 0.0.7-basis.2 * Update version to 0.0.8; Pull latest set-protocol-v2 * Add check for booleans in exchange params * Add suggested changes * Deposit unused USDC to Perp after rebalance; Add unit tests for all flows * Add check for exchange name * Fix failing tests
- Loading branch information
Sachin
authored
Apr 15, 2022
1 parent
f4e1292
commit a98789a
Showing
13 changed files
with
5,986 additions
and
135 deletions.
There are no files selected for viewing
1,554 changes: 1,554 additions & 0 deletions
1,554
contracts/extensions/DeltaNeutralBasisTradingStrategyExtension.sol
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.6.10; | ||
pragma experimental ABIEncoderV2; | ||
|
||
/// @title Quoter Interface | ||
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps | ||
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting | ||
/// to compute the result. They are also not gas efficient and should not be called on-chain. | ||
interface IUniswapV3Quoter { | ||
/// @notice Returns the amount out received for a given exact input swap without executing the swap | ||
/// @param path The path of the swap, i.e. each token pair and the pool fee | ||
/// @param amountIn The amount of the first token to swap | ||
/// @return amountOut The amount of the last token that would be received | ||
function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut); | ||
|
||
/// @notice Returns the amount out received for a given exact input but for a swap of a single pool | ||
/// @param tokenIn The token being swapped in | ||
/// @param tokenOut The token being swapped out | ||
/// @param fee The fee of the token pool to consider for the pair | ||
/// @param amountIn The desired input amount | ||
/// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// @return amountOut The amount of `tokenOut` that would be received | ||
function quoteExactInputSingle( | ||
address tokenIn, | ||
address tokenOut, | ||
uint24 fee, | ||
uint256 amountIn, | ||
uint160 sqrtPriceLimitX96 | ||
) external returns (uint256 amountOut); | ||
|
||
/// @notice Returns the amount in required for a given exact output swap without executing the swap | ||
/// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order | ||
/// @param amountOut The amount of the last token to receive | ||
/// @return amountIn The amount of first token required to be paid | ||
function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn); | ||
|
||
/// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool | ||
/// @param tokenIn The token being swapped in | ||
/// @param tokenOut The token being swapped out | ||
/// @param fee The fee of the token pool to consider for the pair | ||
/// @param amountOut The desired output amount | ||
/// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap | ||
/// @return amountIn The amount required as the input for the swap in order to receive `amountOut` | ||
function quoteExactOutputSingle( | ||
address tokenIn, | ||
address tokenOut, | ||
uint24 fee, | ||
uint256 amountOut, | ||
uint160 sqrtPriceLimitX96 | ||
) external returns (uint256 amountIn); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.