Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Sep 18, 2024
1 parent 9b723c3 commit 7d69f53
Show file tree
Hide file tree
Showing 21 changed files with 166 additions and 171 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
159043
158920
Original file line number Diff line number Diff line change
@@ -1 +1 @@
166396
166238
2 changes: 1 addition & 1 deletion .forge-snapshots/Quoter_exactOutputSingle_oneForZero.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
93637
93496
2 changes: 1 addition & 1 deletion .forge-snapshots/Quoter_exactOutputSingle_zeroForOne.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100303
100134
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141321
141172
Original file line number Diff line number Diff line change
@@ -1 +1 @@
164528
164405
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98641
98506
2 changes: 1 addition & 1 deletion .forge-snapshots/Quoter_quoteExactInput_twoHops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
234806
234516
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161346
161139
Original file line number Diff line number Diff line change
@@ -1 +1 @@
191453
191214
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161661
161454
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136430
136248
2 changes: 1 addition & 1 deletion .forge-snapshots/Quoter_quoteExactOutput_twoHops.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
275720
275337
5 changes: 4 additions & 1 deletion script/DeployPosm.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ contract DeployPosmTest is Script {
vm.startBroadcast();

posm = new PositionManager{salt: hex"03"}(
IPoolManager(poolManager), IAllowanceTransfer(permit2), unsubscribeGasLimit, IPositionDescriptor(positionDescriptor)
IPoolManager(poolManager),
IAllowanceTransfer(permit2),
unsubscribeGasLimit,
IPositionDescriptor(positionDescriptor)
);
console2.log("PositionManager", address(posm));

Expand Down
10 changes: 7 additions & 3 deletions src/PositionDescriptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ contract PositionDescriptor is IPositionDescriptor {
}

/// @inheritdoc IPositionDescriptor
function tokenURI(IPositionManager positionManager, uint256 tokenId) external view override returns (string memory) {

function tokenURI(IPositionManager positionManager, uint256 tokenId)
external
view
override
returns (string memory)
{
(PoolKey memory poolKey, PositionInfo positionInfo) = positionManager.getPoolAndPositionInfo(tokenId);
(, int24 tick,,) = poolManager.getSlot0(poolKey.toId());

Expand Down Expand Up @@ -109,7 +113,7 @@ contract PositionDescriptor is IPositionDescriptor {
return currencyRatioPriority(currency0) > currencyRatioPriority(currency1);
}

/// @notice Returns the priority of a currency.
/// @notice Returns the priority of a currency.
/// For certain currencies on mainnet, the smaller the currency, the higher the priority
/// @param currency The currency
/// @return priority The priority of the currency
Expand Down
7 changes: 6 additions & 1 deletion src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ contract PositionManager is
mapping(uint256 tokenId => PositionInfo info) public positionInfo;
mapping(bytes25 poolId => PoolKey poolKey) public poolKeys;

constructor(IPoolManager _poolManager, IAllowanceTransfer _permit2, uint256 _unsubscribeGasLimit, IPositionDescriptor _tokenDescriptor)
constructor(
IPoolManager _poolManager,
IAllowanceTransfer _permit2,
uint256 _unsubscribeGasLimit,
IPositionDescriptor _tokenDescriptor
)
BaseActionsRouter(_poolManager)
Permit2Forwarder(_permit2)
ERC721Permit_v4("Uniswap V4 Positions NFT", "UNI-V4-POSM")
Expand Down
72 changes: 30 additions & 42 deletions src/libraries/Descriptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ library Descriptor {
bool isPercent;
}
function generateDecimalString(DecimalStringParams memory params) private pure returns (string memory) {
bytes memory buffer = new bytes(params.bufferLength);
if (params.isPercent) {
Expand Down Expand Up @@ -467,30 +466,29 @@ library Descriptor {
/// @param params Parameters needed to generate the SVG image
/// @return svg The SVG image as a string
function generateSVGImage(ConstructTokenURIParams memory params) internal pure returns (string memory svg) {
SVG.SVGParams memory svgParams =
SVG.SVGParams({
quoteCurrency: addressToString(Currency.unwrap(params.quoteCurrency)),
baseCurrency: addressToString(Currency.unwrap(params.baseCurrency)),
hooks: params.hooks,
quoteCurrencySymbol: params.quoteCurrencySymbol,
baseCurrencySymbol: params.baseCurrencySymbol,
feeTier: feeToPercentString(params.fee),
tickLower: params.tickLower,
tickUpper: params.tickUpper,
tickSpacing: params.tickSpacing,
overRange: overRange(params.tickLower, params.tickUpper, params.tickCurrent),
tokenId: params.tokenId,
color0: currencyToColorHex(params.quoteCurrency.toId(), 136),
color1: currencyToColorHex(params.baseCurrency.toId(), 136),
color2: currencyToColorHex(params.quoteCurrency.toId(), 0),
color3: currencyToColorHex(params.baseCurrency.toId(), 0),
x1: scale(getCircleCoord(params.quoteCurrency.toId(), 16, params.tokenId), 0, 255, 16, 274),
y1: scale(getCircleCoord(params.baseCurrency.toId(), 16, params.tokenId), 0, 255, 100, 484),
x2: scale(getCircleCoord(params.quoteCurrency.toId(), 32, params.tokenId), 0, 255, 16, 274),
y2: scale(getCircleCoord(params.baseCurrency.toId(), 32, params.tokenId), 0, 255, 100, 484),
x3: scale(getCircleCoord(params.quoteCurrency.toId(), 48, params.tokenId), 0, 255, 16, 274),
y3: scale(getCircleCoord(params.baseCurrency.toId(), 48, params.tokenId), 0, 255, 100, 484)
});
SVG.SVGParams memory svgParams = SVG.SVGParams({
quoteCurrency: addressToString(Currency.unwrap(params.quoteCurrency)),
baseCurrency: addressToString(Currency.unwrap(params.baseCurrency)),
hooks: params.hooks,
quoteCurrencySymbol: params.quoteCurrencySymbol,
baseCurrencySymbol: params.baseCurrencySymbol,
feeTier: feeToPercentString(params.fee),
tickLower: params.tickLower,
tickUpper: params.tickUpper,
tickSpacing: params.tickSpacing,
overRange: overRange(params.tickLower, params.tickUpper, params.tickCurrent),
tokenId: params.tokenId,
color0: currencyToColorHex(params.quoteCurrency.toId(), 136),
color1: currencyToColorHex(params.baseCurrency.toId(), 136),
color2: currencyToColorHex(params.quoteCurrency.toId(), 0),
color3: currencyToColorHex(params.baseCurrency.toId(), 0),
x1: scale(getCircleCoord(params.quoteCurrency.toId(), 16, params.tokenId), 0, 255, 16, 274),
y1: scale(getCircleCoord(params.baseCurrency.toId(), 16, params.tokenId), 0, 255, 100, 484),
x2: scale(getCircleCoord(params.quoteCurrency.toId(), 32, params.tokenId), 0, 255, 16, 274),
y2: scale(getCircleCoord(params.baseCurrency.toId(), 32, params.tokenId), 0, 255, 100, 484),
x3: scale(getCircleCoord(params.quoteCurrency.toId(), 48, params.tokenId), 0, 255, 16, 274),
y3: scale(getCircleCoord(params.baseCurrency.toId(), 48, params.tokenId), 0, 255, 100, 484)
});
return SVG.generateSVG(svgParams);
}
Expand All @@ -500,11 +498,7 @@ library Descriptor {
/// @param tickUpper The upper tick
/// @param tickCurrent The current tick
/// @return 0 if current tick is within range, -1 if below, 1 if above
function overRange(
int24 tickLower,
int24 tickUpper,
int24 tickCurrent
) private pure returns (int8) {
function overRange(int24 tickLower, int24 tickUpper, int24 tickCurrent) private pure returns (int8) {
if (tickCurrent < tickLower) {
return -1;
} else if (tickCurrent > tickUpper) {
Expand All @@ -521,13 +515,11 @@ library Descriptor {
/// @param outMn The minimum of the output range
/// @param outMx The maximum of the output range
/// @return The scaled number as a string
function scale(
uint256 n,
uint256 inMn,
uint256 inMx,
uint256 outMn,
uint256 outMx
) private pure returns (string memory) {
function scale(uint256 n, uint256 inMn, uint256 inMx, uint256 outMn, uint256 outMx)
private
pure
returns (string memory)
{
return (n - inMn * (outMx - outMn) / (inMx - inMn) + outMn).toString();
}
Expand All @@ -544,11 +536,7 @@ library Descriptor {
/// @param offset The offset to slice the token hex
/// @param tokenId The token ID
/// @return The coordinate
function getCircleCoord(
uint256 currency,
uint256 offset,
uint256 tokenId
) internal pure returns (uint256) {
function getCircleCoord(uint256 currency, uint256 offset, uint256 tokenId) internal pure returns (uint256) {
return (sliceCurrencyHex(currency, offset) * tokenId) % 255;
}
Expand Down
Loading

0 comments on commit 7d69f53

Please sign in to comment.