Skip to content

Commit

Permalink
snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
fourlen committed Jun 7, 2024
1 parent b6b48cc commit 78d47e2
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/farming/contracts/FarmingCenter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract FarmingCenter is IFarmingCenter, IPositionFollower, Multicall {
bytes32 _eternalIncentiveId = deposits[tokenId];
if (_eternalIncentiveId != bytes32(0)) {
address tokenOwner = nonfungiblePositionManager.ownerOf(tokenId);
(, , , , , , uint128 liquidity, , , , ) = nonfungiblePositionManager.positions(tokenId);
(, , , , , , , uint128 liquidity, , , , ) = nonfungiblePositionManager.positions(tokenId);

IncentiveKey memory key = incentiveKeys[_eternalIncentiveId];

Expand Down Expand Up @@ -140,6 +140,6 @@ contract FarmingCenter is IFarmingCenter, IPositionFollower, Multicall {
require(msg.sender == address(eternalFarming), 'Only farming can call this');
require(virtualPool != address(0), 'Zero address as virtual pool');
pool = IAlgebraPool(plugin.pool());
require(address(pool) == PoolAddress.computeAddress(algebraPoolDeployer, PoolAddress.PoolKey(pool.token0(), pool.token1())), 'Invalid pool');
require(address(pool) == PoolAddress.computeAddress(algebraPoolDeployer, PoolAddress.PoolKey(pool.token0(), pool.token1(), address(0))), 'Invalid pool');
}
}
5 changes: 3 additions & 2 deletions src/farming/contracts/libraries/NFTPositionInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ library NFTPositionInfo {
) internal view returns (IAlgebraPool pool, int24 tickLower, int24 tickUpper, uint128 liquidity) {
address token0;
address token1;
(, , token0, token1, tickLower, tickUpper, liquidity, , , , ) = nonfungiblePositionManager.positions(tokenId);
address pluginDeployer;
(, , token0, token1, pluginDeployer, tickLower, tickUpper, liquidity, , , , ) = nonfungiblePositionManager.positions(tokenId);

pool = IAlgebraPool(PoolAddress.computeAddress(address(deployer), PoolAddress.PoolKey({token0: token0, token1: token1})));
pool = IAlgebraPool(PoolAddress.computeAddress(address(deployer), PoolAddress.PoolKey({token0: token0, token1: token1, deployer: pluginDeployer})));
}
}
50 changes: 50 additions & 0 deletions src/farming/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/farming/test/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Wallet, MaxUint256, Interface } from 'ethers';
import { blockTimestamp, BNe18, FeeAmount, getCurrentTick, maxGas, encodePath, arrayWrap, getMinTick, getMaxTick } from '../shared/index';
import { blockTimestamp, BNe18, FeeAmount, getCurrentTick, maxGas, encodePath, arrayWrap, getMinTick, getMaxTick, ZERO_ADDRESS } from '../shared/index';
import _ from 'lodash';
import { TestERC20, INonfungiblePositionManager, AlgebraEternalFarming, IAlgebraPool, TestIncentiveId, FarmingCenter } from '../../typechain';
import abi from '../../artifacts/contracts/farmings/EternalVirtualPool.sol/EternalVirtualPool.json';
Expand Down Expand Up @@ -343,7 +343,7 @@ export class HelperCommands {
const erc20Helper = new ERC20Helper();
await erc20Helper.ensureBalancesAndApprovals(actor, [tok0, tok1], amountIn, await this.router.getAddress());

const path = encodePath(MAKE_TICK_GO_UP ? [tok1Address, tok0Address] : [tok0Address, tok1Address]);
const path = encodePath(MAKE_TICK_GO_UP ? [tok1Address, ZERO_ADDRESS, tok0Address] : [tok0Address, ZERO_ADDRESS, tok1Address]);

await this.router.connect(actor).exactInput(
{
Expand Down Expand Up @@ -410,6 +410,7 @@ export class HelperCommands {
deadline: MaxUint256,
tokenIn: zto ? tok0Address : tok1Address,
tokenOut: zto ? tok1Address : tok0Address,
deployer: ZERO_ADDRESS,
amountIn: 2n ** 128n - 1n,
amountOutMinimum: 0,
limitSqrtPrice: priceAtTarget,
Expand Down
7 changes: 4 additions & 3 deletions src/farming/test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
TestIncentiveId,
FarmingCenter,
} from '../../typechain';
import { FeeAmount, encodePriceSqrt, MAX_GAS_LIMIT } from '../shared';
import { FeeAmount, encodePriceSqrt, MAX_GAS_LIMIT, ZERO_ADDRESS } from '../shared';
import { ActorFixture } from './actors';
import { IBasePluginV1Factory, IAlgebraBasePluginV1 } from '@cryptoalgebra/integral-base-plugin/typechain';

Expand Down Expand Up @@ -182,6 +182,7 @@ export const mintPosition = async (
{
token0: mintParams.token0,
token1: mintParams.token1,
deployer: ZERO_ADDRESS,
tickLower: mintParams.tickLower,
tickUpper: mintParams.tickUpper,
recipient: mintParams.recipient,
Expand Down Expand Up @@ -272,9 +273,9 @@ export const algebraFixture: () => Promise<AlgebraFixtureType> = async () => {

const fee = FeeAmount.MEDIUM;

await nft.createAndInitializePoolIfNecessary(tokens[0], tokens[1], encodePriceSqrt(1, 1));
await nft.createAndInitializePoolIfNecessary(tokens[0], tokens[1], ZERO_ADDRESS, encodePriceSqrt(1, 1));

await nft.createAndInitializePoolIfNecessary(tokens[1], tokens[2], encodePriceSqrt(1, 1));
await nft.createAndInitializePoolIfNecessary(tokens[1], tokens[2], ZERO_ADDRESS, encodePriceSqrt(1, 1));

const pool01 = await factory.poolByPair(tokens[0], tokens[1]);

Expand Down
4 changes: 2 additions & 2 deletions src/farming/test/unit/__snapshots__/EternalFarms.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`unit/EternalFarms #claimReward when requesting the full amount has gas cost [ @skip-on-coverage ] 1`] = `60772`;

exports[`unit/EternalFarms #enterFarming works and has gas cost [ @skip-on-coverage ] 1`] = `494839`;
exports[`unit/EternalFarms #enterFarming works and has gas cost [ @skip-on-coverage ] 1`] = `497382`;

exports[`unit/EternalFarms #exitFarming after end time works and has gas cost [ @skip-on-coverage ] 1`] = `169695`;
exports[`unit/EternalFarms #exitFarming after end time works and has gas cost [ @skip-on-coverage ] 1`] = `169629`;
7 changes: 0 additions & 7 deletions src/periphery/contracts/SwapRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import './libraries/Path.sol';
import './libraries/PoolAddress.sol';
import './libraries/CallbackValidation.sol';

import 'hardhat/console.sol';

/// @title Algebra Integral 1.1 Swap Router
/// @notice Router for stateless execution of swaps against Algebra
/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
Expand Down Expand Up @@ -93,8 +91,6 @@ contract SwapRouter is

bool zeroToOne = tokenIn < tokenOut;

console.log('deployer: ', deployer);

(int256 amount0, int256 amount1) = getPool(tokenIn, tokenOut, deployer).swap(
recipient,
zeroToOne,
Expand Down Expand Up @@ -237,9 +233,6 @@ contract SwapRouter is
// it's okay that the payer is fixed to msg.sender here, as they're only paying for the "final" exact output
// swap, which happens first, and subsequent swaps are paid for within nested callback frames

console.log('path');
console.logBytes(params.path);

exactOutputInternal(
params.amountOut,
params.recipient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`NonfungiblePositionManager #collect gas transfers token0 only [ @skip-o

exports[`NonfungiblePositionManager #collect gas transfers token1 only [ @skip-on-coverage ] 1`] = `119163`;

exports[`NonfungiblePositionManager #createAndInitializePoolIfNecessary gas [ @skip-on-coverage ] 1`] = `4813289`;
exports[`NonfungiblePositionManager #createAndInitializePoolIfNecessary gas [ @skip-on-coverage ] 1`] = `4813126`;

exports[`NonfungiblePositionManager #decreaseLiquidity gas complete decrease [ @skip-on-coverage ] 1`] = `169339`;

Expand Down
2 changes: 1 addition & 1 deletion src/periphery/test/__snapshots__/SwapRouter.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SwapRouter bytecode size [ @skip-on-coverage ] 1`] = `13667`;
exports[`SwapRouter bytecode size [ @skip-on-coverage ] 1`] = `12902`;

0 comments on commit 78d47e2

Please sign in to comment.