forked from WTFAcademy/WTF-Dapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new course init contracts (WTFAcademy#80)
- Loading branch information
1 parent
de6ad41
commit e431e1f
Showing
22 changed files
with
465 additions
and
21 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.24; | ||
|
||
interface IFactory { | ||
function parameters() | ||
external | ||
view | ||
returns (address factory, address token0, address token1, uint24 fee); | ||
|
||
event PoolCreated( | ||
address indexed token0, | ||
address indexed token1, | ||
uint24 indexed fee, | ||
address pool | ||
); | ||
|
||
function getPool( | ||
address tokenA, | ||
address tokenB, | ||
uint24 fee | ||
) external view returns (address pool); | ||
|
||
function createPool( | ||
address tokenA, | ||
address tokenB, | ||
uint24 fee | ||
) external returns (address pool); | ||
} |
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,110 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.24; | ||
|
||
interface IMintCallback { | ||
function mintCallback( | ||
uint256 amount0Owed, | ||
uint256 amount1Owed, | ||
bytes calldata data | ||
) external; | ||
} | ||
|
||
interface ISwapCallback { | ||
function swapCallback( | ||
int256 amount0Delta, | ||
int256 amount1Delta, | ||
bytes calldata data | ||
) external; | ||
} | ||
|
||
interface IPool { | ||
function factory() external view returns (address); | ||
|
||
function token0() external view returns (address); | ||
|
||
function token1() external view returns (address); | ||
|
||
function fee() external view returns (uint24); | ||
|
||
function tickLower() external view returns (int24); | ||
|
||
function tickUpper() external view returns (int24); | ||
|
||
function sqrtPriceX96() external view returns (uint160); | ||
|
||
function tick() external view returns (int24); | ||
|
||
function liquidity() external view returns (uint128); | ||
|
||
function positions( | ||
int8 positionType | ||
) | ||
external | ||
view | ||
returns (uint128 _liquidity, uint128 tokensOwed0, uint128 tokensOwed1); | ||
|
||
function initialize( | ||
uint160 sqrtPriceX96, | ||
int24 tickLower, | ||
int24 tickUpper | ||
) external; | ||
|
||
event Mint( | ||
address sender, | ||
address indexed owner, | ||
int8 indexed positionType, | ||
uint128 amount, | ||
uint256 amount0, | ||
uint256 amount1 | ||
); | ||
|
||
function mint( | ||
address recipient, | ||
int8 positionType, | ||
uint128 amount, | ||
bytes calldata data | ||
) external returns (uint256 amount0, uint256 amount1); | ||
|
||
event Collect( | ||
address indexed owner, | ||
address recipient, | ||
int8 indexed positionType, | ||
uint128 amount0, | ||
uint128 amount1 | ||
); | ||
|
||
function collect( | ||
address recipient, | ||
int8 positionType | ||
) external returns (uint128 amount0, uint128 amount1); | ||
|
||
event Burn( | ||
address indexed owner, | ||
int8 indexed positionType, | ||
uint128 amount, | ||
uint256 amount0, | ||
uint256 amount1 | ||
); | ||
|
||
function burn( | ||
int8 positionType | ||
) external returns (uint256 amount0, uint256 amount1); | ||
|
||
event Swap( | ||
address indexed sender, | ||
address indexed recipient, | ||
int256 amount0, | ||
int256 amount1, | ||
uint160 sqrtPriceX96, | ||
uint128 liquidity, | ||
int24 tick | ||
); | ||
|
||
function swap( | ||
address recipient, | ||
bool zeroForOne, | ||
int256 amountSpecified, | ||
uint160 sqrtPriceLimitX96, | ||
bytes calldata data | ||
) external returns (int256 amount0, int256 amount1); | ||
} |
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.8.24; | ||
pragma abicoder v2; | ||
|
||
interface IPoolManager { | ||
struct PoolKey { | ||
address token0; | ||
address token1; | ||
uint24 fee; | ||
} | ||
|
||
function getPools() external view returns (PoolKey[] memory pools); | ||
|
||
function getTokens() external view returns (address[] memory tokens); | ||
|
||
function getTokenPools( | ||
address token | ||
) external view returns (PoolKey[] memory pools); | ||
|
||
struct PoolInfo { | ||
// the current protocol fee as a percentage of the swap fee taken on withdrawal | ||
// represented as an integer denominator (1/x)% | ||
uint8 feeProtocol; | ||
// tick range | ||
int24 tickLower; | ||
int24 tickUpper; | ||
// the current tick | ||
int24 tick; | ||
// the current price | ||
uint160 sqrtPriceX96; | ||
} | ||
|
||
function getPoolInfo( | ||
address token0, | ||
address token1, | ||
uint24 fee | ||
) external view returns (PoolInfo memory poolInfo); | ||
|
||
struct CreateAndInitializeParams { | ||
address token0; | ||
address token1; | ||
uint24 fee; | ||
int24 tickLower; | ||
int24 tickUpper; | ||
uint160 sqrtPriceX96; | ||
} | ||
|
||
function createAndInitializePoolIfNecessary( | ||
CreateAndInitializeParams calldata params | ||
) external payable returns (address pool); | ||
} |
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,58 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.24; | ||
pragma abicoder v2; | ||
|
||
interface IPositionManager { | ||
function getPositions( | ||
address owner | ||
) external view returns (uint256[] memory positionIds); | ||
|
||
struct PositionInfo { | ||
// address owner; | ||
address token0; | ||
address token1; | ||
uint24 fee; | ||
int128 liquidity; | ||
// tick range | ||
int24 tickLower; | ||
int24 tickUpper; | ||
uint256 tokensOwed0; | ||
uint256 tokensOwed1; | ||
} | ||
|
||
function getPositionInfo( | ||
uint256 positionId | ||
) external view returns (PositionInfo memory positionInfo); | ||
|
||
struct MintParams { | ||
address token0; | ||
address token1; | ||
uint24 fee; | ||
int8 positionType; // lower:-1; medium:0; upper:1 | ||
uint256 amount0Desired; | ||
uint256 amount1Desired; | ||
address recipient; | ||
uint256 deadline; | ||
} | ||
|
||
function mint( | ||
MintParams calldata params | ||
) | ||
external | ||
payable | ||
returns ( | ||
uint256 positionId, | ||
uint128 liquidity, | ||
uint256 amount0, | ||
uint256 amount1 | ||
); | ||
|
||
function burn( | ||
uint256 positionId | ||
) external returns (uint256 amount0, uint256 amount1); | ||
|
||
function collect( | ||
uint256 positionId, | ||
address recipient | ||
) external returns (uint256 amount0, uint256 amount1); | ||
} |
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,55 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.24; | ||
pragma abicoder v2; | ||
|
||
interface ISwapRouter { | ||
struct ExactInputParams { | ||
address tokenIn; | ||
address tokenOut; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountIn; | ||
uint256 amountOutMinimum; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
function exactInput( | ||
ExactInputParams calldata params | ||
) external payable returns (uint256 amountOut); | ||
|
||
struct ExactOutputParams { | ||
address tokenIn; | ||
address tokenOut; | ||
address recipient; | ||
uint256 deadline; | ||
uint256 amountOut; | ||
uint256 amountInMaximum; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
function exactOutput( | ||
ExactOutputParams calldata params | ||
) external payable returns (uint256 amountIn); | ||
|
||
struct QuoteExactInputParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint256 amountIn; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
function quoteExactInput( | ||
QuoteExactInputParams memory params | ||
) external returns (uint256 amountOut); | ||
|
||
struct QuoteExactOutputParams { | ||
address tokenIn; | ||
address tokenOut; | ||
uint256 amount; | ||
uint160 sqrtPriceLimitX96; | ||
} | ||
|
||
function quoteExactOutput( | ||
QuoteExactOutputParams memory params | ||
) external returns (uint256 amountIn); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.