Skip to content

Commit

Permalink
add getPosition (Uniswap#277)
Browse files Browse the repository at this point in the history
* add getPosition

* linting

* add snapshots

* snapshots
  • Loading branch information
emmaguo13 authored Jun 21, 2023
1 parent a70cc40 commit 86b3f65
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 1 token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131232
131234
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 2 tokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
185897
185921
2 changes: 1 addition & 1 deletion .forge-snapshots/gas overhead of no-op lock.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
61078
61036
2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37658
37613
2 changes: 1 addition & 1 deletion .forge-snapshots/mint with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
320430
320432
2 changes: 1 addition & 1 deletion .forge-snapshots/mint with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
294443
294445
2 changes: 1 addition & 1 deletion .forge-snapshots/mint.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
313107
313109
2 changes: 1 addition & 1 deletion .forge-snapshots/poolExtsloadSlot0.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1129
1151
2 changes: 1 addition & 1 deletion .forge-snapshots/poolExtsloadTickInfoStruct.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2763
2785
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67802
67737
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161636
161615
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146343
146322
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67777
67712
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67802
67737
9 changes: 9 additions & 0 deletions contracts/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ contract PoolManager is IPoolManager, Owned, NoDelegateCall, ERC1155, IERC1155Re
return pools[id].positions.get(owner, tickLower, tickUpper).liquidity;
}

function getPosition(PoolId id, address owner, int24 tickLower, int24 tickUpper)
external
view
override
returns (Position.Info memory position)
{
return pools[id].positions.get(owner, tickLower, tickUpper);
}

/// @inheritdoc IPoolManager
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external override returns (int24 tick) {
if (key.fee & Fees.STATIC_FEE_MASK >= 1000000) revert FeeTooLarge();
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/IPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IHooks} from "./IHooks.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {PoolId} from "../libraries/PoolId.sol";
import {Position} from "../libraries/Position.sol";

interface IPoolManager is IERC1155 {
/// @notice Thrown when currencies touched has exceeded max of 256
Expand Down Expand Up @@ -129,6 +130,12 @@ interface IPoolManager is IERC1155 {
view
returns (uint128 liquidity);

/// @notice Get the position struct for a specified pool and position
function getPosition(PoolId id, address owner, int24 tickLower, int24 tickUpper)
external
view
returns (Position.Info memory position);

/// @notice Given a currency address, returns the protocol fees accrued in that currency
function protocolFeesAccrued(Currency) external view returns (uint256);

Expand Down
Loading

0 comments on commit 86b3f65

Please sign in to comment.