Skip to content

Commit ce0add3

Browse files
committed
init files
1 parent 53288a3 commit ce0add3

File tree

3 files changed

+251
-0
lines changed

3 files changed

+251
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// SPDX-License-Identifier: Apache License, Version 2.0
2+
pragma solidity 0.6.10;
3+
4+
/// @title The interface for the Uniswap V3 Factory
5+
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
6+
interface IUniswapV3Factory {
7+
/// @notice Emitted when the owner of the factory is changed
8+
/// @param oldOwner The owner before the owner was changed
9+
/// @param newOwner The owner after the owner was changed
10+
event OwnerChanged(address indexed oldOwner, address indexed newOwner);
11+
12+
/// @notice Emitted when a pool is created
13+
/// @param token0 The first token of the pool by address sort order
14+
/// @param token1 The second token of the pool by address sort order
15+
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
16+
/// @param tickSpacing The minimum number of ticks between initialized ticks
17+
/// @param pool The address of the created pool
18+
event PoolCreated(
19+
address indexed token0,
20+
address indexed token1,
21+
uint24 indexed fee,
22+
int24 tickSpacing,
23+
address pool
24+
);
25+
26+
/// @notice Emitted when a new fee amount is enabled for pool creation via the factory
27+
/// @param fee The enabled fee, denominated in hundredths of a bip
28+
/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
29+
event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);
30+
31+
/// @notice Returns the current owner of the factory
32+
/// @dev Can be changed by the current owner via setOwner
33+
/// @return The address of the factory owner
34+
function owner() external view returns (address);
35+
36+
/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
37+
/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
38+
/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
39+
/// @return The tick spacing
40+
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
41+
42+
/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
43+
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
44+
/// @param tokenA The contract address of either token0 or token1
45+
/// @param tokenB The contract address of the other token
46+
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
47+
/// @return pool The pool address
48+
function getPool(
49+
address tokenA,
50+
address tokenB,
51+
uint24 fee
52+
) external view returns (address pool);
53+
54+
/// @notice Creates a pool for the given two tokens and fee
55+
/// @param tokenA One of the two tokens in the desired pool
56+
/// @param tokenB The other of the two tokens in the desired pool
57+
/// @param fee The desired fee for the pool
58+
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
59+
/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
60+
/// are invalid.
61+
/// @return pool The address of the newly created pool
62+
function createPool(
63+
address tokenA,
64+
address tokenB,
65+
uint24 fee
66+
) external returns (address pool);
67+
68+
/// @notice Updates the owner of the factory
69+
/// @dev Must be called by the current owner
70+
/// @param _owner The new owner of the factory
71+
function setOwner(address _owner) external;
72+
73+
/// @notice Enables a fee amount with the given tickSpacing
74+
/// @dev Fee amounts may never be removed once enabled
75+
/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
76+
/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
77+
function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
78+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
Copyright 2022 Set Labs Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache License, Version 2.0
17+
*/
18+
19+
pragma solidity 0.6.10;
20+
21+
import "../../../interfaces/external/IUniswapV3Factory.sol";
22+
import "../../../interfaces/IAmmAdapter.sol";
23+
import "@openzeppelin/contracts/math/Math.sol";
24+
import "@openzeppelin/contracts/math/SafeMath.sol";
25+
26+
/**
27+
* @title UniswapV3AmmAdapter
28+
* @author Zishan Sami
29+
*
30+
* Adapter for Uniswap V3 Router that encodes adding and removing liquidty
31+
*/
32+
contract UniswapV3AmmAdapter is IAmmAdapter {
33+
using SafeMath for uint256;
34+
35+
/* ============ External Getter Functions ============ */
36+
37+
/**
38+
* Return calldata for the add liquidity call
39+
*
40+
* @param _setToken Address of the SetToken
41+
* @param _pool Address of liquidity token
42+
* @param _components Address array required to add liquidity
43+
* @param _maxTokensIn AmountsIn desired to add liquidity
44+
* @param _minLiquidity Min liquidity amount to add
45+
*/
46+
function getProvideLiquidityCalldata(
47+
address _setToken,
48+
address _pool,
49+
address[] calldata _components,
50+
uint256[] calldata _maxTokensIn,
51+
uint256 _minLiquidity
52+
)
53+
external
54+
view
55+
override
56+
returns (address target, uint256 value, bytes memory data)
57+
{
58+
//TODO
59+
}
60+
61+
/**
62+
* Return calldata for the add liquidity call for a single asset
63+
*/
64+
function getProvideLiquiditySingleAssetCalldata(
65+
address /*_setToken*/,
66+
address /*_pool*/,
67+
address /*_component*/,
68+
uint256 /*_maxTokenIn*/,
69+
uint256 /*_minLiquidity*/
70+
)
71+
external
72+
view
73+
override
74+
returns (address /*target*/, uint256 /*value*/, bytes memory /*data*/)
75+
{
76+
//TODO
77+
}
78+
79+
/**
80+
* Return calldata for the remove liquidity call
81+
*
82+
* @param _setToken Address of the SetToken
83+
* @param _pool Address of liquidity token
84+
* @param _components Address array required to remove liquidity
85+
* @param _minTokensOut AmountsOut minimum to remove liquidity
86+
* @param _liquidity Liquidity amount to remove
87+
*/
88+
function getRemoveLiquidityCalldata(
89+
address _setToken,
90+
address _pool,
91+
address[] calldata _components,
92+
uint256[] calldata _minTokensOut,
93+
uint256 _liquidity
94+
)
95+
external
96+
view
97+
override
98+
returns (address target, uint256 value, bytes memory data)
99+
{
100+
//TODO
101+
}
102+
103+
/**
104+
* Return calldata for the remove liquidity single asset call
105+
*/
106+
function getRemoveLiquiditySingleAssetCalldata(
107+
address /* _setToken */,
108+
address /*_pool*/,
109+
address /*_component*/,
110+
uint256 /*_minTokenOut*/,
111+
uint256 /*_liquidity*/
112+
)
113+
external
114+
view
115+
override
116+
returns (address /*target*/, uint256 /*value*/, bytes memory /*data*/)
117+
{
118+
//TODO
119+
}
120+
121+
/**
122+
* Returns the address of the spender
123+
*/
124+
function getSpenderAddress(address /*_pool*/)
125+
external
126+
view
127+
override
128+
returns (address spender)
129+
{
130+
//TODO
131+
}
132+
133+
/**
134+
* Verifies that this is a valid Uniswap V3 pool
135+
*
136+
* @param _pool Address of liquidity token
137+
* @param _components Address array of supplied/requested tokens
138+
*/
139+
function isValidPool(address _pool, address[] memory _components)
140+
external
141+
view
142+
override
143+
returns (bool)
144+
{
145+
//TODO
146+
}
147+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import "module-alias/register";
2+
import { Account } from "@utils/test/types";
3+
// import DeployHelper from "@utils/deploys";
4+
import {
5+
getAccounts,
6+
getSystemFixture,
7+
} from "@utils/test/index";
8+
9+
import { SystemFixture } from "@utils/fixtures";
10+
11+
describe("UniswapV3AmmAdapter", () => {
12+
let owner: Account;
13+
// let deployer: DeployHelper;
14+
let setup: SystemFixture;
15+
16+
before(async () => {
17+
[
18+
owner,
19+
] = await getAccounts();
20+
21+
// deployer = new DeployHelper(owner.wallet);
22+
setup = getSystemFixture(owner.address);
23+
await setup.initialize();
24+
});
25+
26+
});

0 commit comments

Comments
 (0)