Skip to content

Commit

Permalink
add a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Oct 9, 2023
1 parent 3372e2e commit 6643c52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class RamsesV2EventPool extends UniswapV3EventPool {
const newFee = bigIntify(event.args.newFee);

pool.fee = newFee;
this.currentFeeCodeAsString = newFee.toString();

return pool;
}
Expand Down Expand Up @@ -98,7 +97,6 @@ export class RamsesV2EventPool extends UniswapV3EventPool {
const tickBitmap = {};
const ticks = {};

this.currentFeeCodeAsString = fee.toString();
_reduceTickBitmap(tickBitmap, _state.tickBitmap);
_reduceTicks(ticks, _state.ticks);

Expand Down
2 changes: 0 additions & 2 deletions src/dex/uniswap-v3/uniswap-v3-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export class UniswapV3EventPool extends StatefulEventSubscriber<PoolState> {

private _poolAddress?: Address;

public currentFeeCodeAsString: string | undefined;

protected _stateRequestCallData?: MultiCallParams<
bigint | DecodedStateMultiCallResultWithRelativeBitmaps
>[];
Expand Down
51 changes: 20 additions & 31 deletions src/dex/uniswap-v3/uniswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@ import { defaultAbiCoder, Interface } from '@ethersproject/abi';
import _ from 'lodash';
import { pack } from '@ethersproject/solidity';
import {
Token,
AdapterExchangeParam,
Address,
ExchangePrices,
AdapterExchangeParam,
SimpleExchangeParam,
PoolLiquidity,
ExchangeTxInfo,
Logger,
NumberAsString,
PoolLiquidity,
PoolPrices,
TxInfo,
PreprocessTransactionOptions,
ExchangeTxInfo,
SimpleExchangeParam,
Token,
TxInfo,
} from '../../types';
import { SwapSide, Network, CACHE_PREFIX } from '../../constants';
import { CACHE_PREFIX, Network, SwapSide } from '../../constants';
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
import {
getBigIntPow,
getDexKeysWithNetwork,
interpolate,
isTruthy,
uuidToBytes16,
} from '../../utils';
import { getBigIntPow, getDexKeysWithNetwork, interpolate, isTruthy, uuidToBytes16, } from '../../utils';
import { IDex } from '../../dex/idex';
import { IDexHelper } from '../../dex-helper/idex-helper';
import {
Expand All @@ -35,11 +29,8 @@ import {
UniswapV3Param,
UniswapV3SimpleSwapParams,
} from './types';
import {
getLocalDeadlineAsFriendlyPlaceholder,
SimpleExchange,
} from '../simple-exchange';
import { UniswapV3Config, Adapters, PoolsToPreload } from './config';
import { getLocalDeadlineAsFriendlyPlaceholder, SimpleExchange, } from '../simple-exchange';
import { Adapters, PoolsToPreload, UniswapV3Config } from './config';
import { UniswapV3EventPool } from './uniswap-v3-pool';
import UniswapV3RouterABI from '../../abi/uniswap-v3/UniswapV3Router.abi.json';
import UniswapV3QuoterV2ABI from '../../abi/uniswap-v3/UniswapV3QuoterV2.abi.json';
Expand All @@ -58,11 +49,7 @@ import { uniswapV3Math } from './contract-math/uniswap-v3-math';
import { Contract } from 'web3-eth-contract';
import { AbiItem } from 'web3-utils';
import { BalanceRequest, getBalances } from '../../lib/tokens/balancer-fetcher';
import {
AssetType,
DEFAULT_ID_ERC20,
DEFAULT_ID_ERC20_AS_STRING,
} from '../../lib/tokens/types';
import { AssetType, DEFAULT_ID_ERC20, DEFAULT_ID_ERC20_AS_STRING, } from '../../lib/tokens/types';
import { OptimalSwapExchange } from '@paraswap/core';
import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory';

Expand Down Expand Up @@ -424,6 +411,7 @@ export class UniswapV3
amounts: bigint[],
side: SwapSide,
pools: UniswapV3EventPool[],
states: PoolState[],
): Promise<ExchangePrices<UniswapV3Data> | null> {
if (pools.length === 0) {
return null;
Expand Down Expand Up @@ -521,7 +509,7 @@ export class UniswapV3
};

let i = 0;
const result = pools.map(pool => {
const result = pools.map((pool, index) => {
const _rates = _amounts.map(() => decode(i++));
const unit: bigint = _rates[0];

Expand All @@ -541,7 +529,7 @@ export class UniswapV3
tokenIn: from.address,
tokenOut: to.address,
fee: pool.feeCodeAsString,
currentFee: pool.currentFeeCodeAsString,
currentFee: states[index].fee.toString(),
},
],
exchange: pool.poolAddress,
Expand Down Expand Up @@ -653,16 +641,17 @@ export class UniswapV3
},
);

const states = poolsToUse.poolWithState.map(
p => p.getState(blockNumber)!,
);

const rpcResultsPromise = this.getPricingFromRpc(
_srcToken,
_destToken,
amounts,
side,
this.network === Network.ZKEVM ? [] : poolsToUse.poolWithoutState,
);

const states = poolsToUse.poolWithState.map(
p => p.getState(blockNumber)!,
this.network === Network.ZKEVM ? [] : states,
);

const unitAmount = getBigIntPow(
Expand Down Expand Up @@ -736,7 +725,7 @@ export class UniswapV3
tokenIn: _srcAddress,
tokenOut: _destAddress,
fee: pool.feeCode.toString(),
currentFee: pool.currentFeeCodeAsString,
currentFee: state.fee.toString(),
},
],
},
Expand Down

0 comments on commit 6643c52

Please sign in to comment.