Skip to content

Commit

Permalink
remove lgos
Browse files Browse the repository at this point in the history
  • Loading branch information
ConjunctiveNormalForm committed Nov 15, 2023
1 parent 4f9519f commit 7823167
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
20 changes: 9 additions & 11 deletions contracts/lens/Quoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract Quoter is IQuoter {
}

function fillSlot0(PoolId id) private view returns (Pool.Slot0 memory slot0) {
//TODO: extsload when storage is stable
//TODO: extsload when storage is stable?
(slot0.sqrtPriceX96, slot0.tick,,) = poolManager.getSlot0(id);

return slot0;
Expand Down Expand Up @@ -106,14 +106,13 @@ contract Quoter is IQuoter {
) = _quoteExactInput(abi.decode(swapInfo.params, (ExactInputParams)));

assembly {
// function storeArray(offset, length) -> result {
// switch exponent
// case 0 { result := 1 }
// case 1 { result := base }
// default {
// result := power(mul(base, base), div(exponent, 2))
// switch mod(exponent, 2)
// case 1 { result := mul(base, result) }
// function storeArray(offset, length, array) {
// mstore(offset, length)
// offset := add(offset, 0x20)
// for { let i := 0 } lt(i, length) { i := add(i, 1) } {
// let value := mload(add(array, add(mul(i, 0x20), 0x20)))
// mstore(offset, value)
// offset := add(offset, 0x20)
// }
// }

Expand All @@ -136,7 +135,7 @@ contract Quoter is IQuoter {
mstore(ptr, initializedTicksOffset)
ptr := add(ptr, 0x20)

// storing length + contents of dynamic arrays
//storing length + contents of dynamic arrays
mstore(ptr, deltaLength)
ptr := add(ptr, 0x20)
for { let i := 0 } lt(i, deltaLength) { i := add(i, 1) } {
Expand All @@ -162,7 +161,6 @@ contract Quoter is IQuoter {
}

revert(originalPtr, sub(ptr, originalPtr))
//revert(ptr, add(mul(0x20, add(add(deltaLength, sqrtPriceLength), initializedTicksLength)), 0x60))
}
} else {
revert InvalidQuoteType();
Expand Down
10 changes: 0 additions & 10 deletions test/Quoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,14 @@ contract QuoterTest is Test, Deployers {
function testQuoter_quoteExactInput_2to1() public {
tokenPath.push(token2);
tokenPath.push(token1);
console.logString("===== testQuoter_quoteExactInput_2to1 ======");
console.logString("Token2: ");
console.logAddress(address(token2));
console.logString("Token1: ");
console.logAddress(address(token1));
ExactInputParams memory params = getExactInputParams(tokenPath, 10000);

(
int128[] memory deltaAmounts,
uint160[] memory sqrtPriceX96AfterList,
uint32[] memory initializedTicksCrossedList
) = quoter.quoteExactInput(params);
logDeltas(deltaAmounts);
assertEq(-deltaAmounts[1], 9871);
logSqrtPrices(sqrtPriceX96AfterList);
assertEq(sqrtPriceX96AfterList[0], 80018067294531553039351583520);
assertEq(initializedTicksCrossedList[0], 0);
}
Expand All @@ -302,9 +295,6 @@ contract QuoterTest is Test, Deployers {
uint32[] memory initializedTicksCrossedList
) = quoter.quoteExactInput(params);

logDeltas(deltaAmounts);
logSqrtPrices(sqrtPriceX96AfterList);

assertEq(-deltaAmounts[2], 9745);
assertEq(sqrtPriceX96AfterList[0], 78461846509168490764501028180);
assertEq(sqrtPriceX96AfterList[1], 80007846861567212939802016351);
Expand Down

0 comments on commit 7823167

Please sign in to comment.