Skip to content

Commit

Permalink
Uniswap v2 adapter (consensys-vertical-apps#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergarces authored Feb 23, 2024
1 parent 5b54ccd commit b6d0efa
Show file tree
Hide file tree
Showing 27 changed files with 25,185 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { StargatePoolAdapter } from './stargate/products/pool/stargatePoolAdapte
import { StargateVestingAdapter } from './stargate/products/vesting/stargateVestingAdapter'
import { SwellSwEthAdapter } from './swell/products/sw-eth/swellSwEthAdapter'
import { SyncswapPoolAdapter } from './syncswap/products/pool/syncswapPoolAdapter'
import { UniswapV2PoolAdapter } from './uniswap-v2/products/pool/uniswapV2PoolAdapter'
import { UniswapV3PoolAdapter } from './uniswap-v3/products/pool/uniswapV3PoolAdapter'

export const supportedProtocols: Record<
Expand Down Expand Up @@ -210,4 +211,14 @@ export const supportedProtocols: Record<
[Chain.Avalanche]: [PricesV2UsdAdapter],
[Chain.Base]: [PricesV2UsdAdapter],
},

[Protocol.UniswapV2]: {
[Chain.Ethereum]: [UniswapV2PoolAdapter],
[Chain.Optimism]: [UniswapV2PoolAdapter],
[Chain.Bsc]: [UniswapV2PoolAdapter],
[Chain.Polygon]: [UniswapV2PoolAdapter],
[Chain.Base]: [UniswapV2PoolAdapter],
[Chain.Arbitrum]: [UniswapV2PoolAdapter],
[Chain.Avalanche]: [UniswapV2PoolAdapter],
},
}
2 changes: 2 additions & 0 deletions src/adapters/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { testCases as rocketPoolTestCases } from './rocket-pool/tests/testCases'
import { testCases as stargateTestCases } from './stargate/tests/testCases'
import { testCases as swellTestCases } from './swell/tests/testCases'
import { testCases as syncSwapTestCases } from './syncswap/tests/testCases'
import { testCases as uniswapV2TestCases } from './uniswap-v2/tests/testCases'
import { testCases as uniswapV3TestCases } from './uniswap-v3/tests/testCases'

const TEST_TIMEOUT = 300000
Expand Down Expand Up @@ -63,6 +64,7 @@ function runAllTests() {
runProtocolTests(Protocol.CarbonDeFi, carbonDeFiTestCases)
runProtocolTests(Protocol.RocketPool, rocketPoolTestCases)
runProtocolTests(Protocol.PricesV2, pricesV2TestCases)
runProtocolTests(Protocol.UniswapV2, uniswapV2TestCases)
}

function runProtocolTests(protocolId: Protocol, testCases: TestCase[]) {
Expand Down
1 change: 1 addition & 0 deletions src/adapters/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export const Protocol = {
CarbonDeFi: 'carbon-defi',
RocketPool: 'rocket-pool',
PricesV2: 'prices-v2',
UniswapV2: 'uniswap-v2',
} as const
export type Protocol = (typeof Protocol)[keyof typeof Protocol]
243 changes: 243 additions & 0 deletions src/adapters/uniswap-v2/contracts/Factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumberish,
BytesLike,
FunctionFragment,
Result,
Interface,
EventFragment,
AddressLike,
ContractRunner,
ContractMethod,
Listener,
} from "ethers";
import type {
TypedContractEvent,
TypedDeferredTopicFilter,
TypedEventLog,
TypedLogDescription,
TypedListener,
TypedContractMethod,
} from "./common";

export interface FactoryInterface extends Interface {
getFunction(
nameOrSignature:
| "allPairs"
| "allPairsLength"
| "createPair"
| "feeTo"
| "feeToSetter"
| "getPair"
| "setFeeTo"
| "setFeeToSetter"
): FunctionFragment;

getEvent(nameOrSignatureOrTopic: "PairCreated"): EventFragment;

encodeFunctionData(
functionFragment: "allPairs",
values: [BigNumberish]
): string;
encodeFunctionData(
functionFragment: "allPairsLength",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "createPair",
values: [AddressLike, AddressLike]
): string;
encodeFunctionData(functionFragment: "feeTo", values?: undefined): string;
encodeFunctionData(
functionFragment: "feeToSetter",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "getPair",
values: [AddressLike, AddressLike]
): string;
encodeFunctionData(
functionFragment: "setFeeTo",
values: [AddressLike]
): string;
encodeFunctionData(
functionFragment: "setFeeToSetter",
values: [AddressLike]
): string;

decodeFunctionResult(functionFragment: "allPairs", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "allPairsLength",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "createPair", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "feeTo", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "feeToSetter",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "getPair", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "setFeeTo", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "setFeeToSetter",
data: BytesLike
): Result;
}

export namespace PairCreatedEvent {
export type InputTuple = [
token0: AddressLike,
token1: AddressLike,
pair: AddressLike,
arg3: BigNumberish
];
export type OutputTuple = [
token0: string,
token1: string,
pair: string,
arg3: bigint
];
export interface OutputObject {
token0: string;
token1: string;
pair: string;
arg3: bigint;
}
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
export type Filter = TypedDeferredTopicFilter<Event>;
export type Log = TypedEventLog<Event>;
export type LogDescription = TypedLogDescription<Event>;
}

export interface Factory extends BaseContract {
connect(runner?: ContractRunner | null): Factory;
waitForDeployment(): Promise<this>;

interface: FactoryInterface;

queryFilter<TCEvent extends TypedContractEvent>(
event: TCEvent,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TypedEventLog<TCEvent>>>;
queryFilter<TCEvent extends TypedContractEvent>(
filter: TypedDeferredTopicFilter<TCEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TypedEventLog<TCEvent>>>;

on<TCEvent extends TypedContractEvent>(
event: TCEvent,
listener: TypedListener<TCEvent>
): Promise<this>;
on<TCEvent extends TypedContractEvent>(
filter: TypedDeferredTopicFilter<TCEvent>,
listener: TypedListener<TCEvent>
): Promise<this>;

once<TCEvent extends TypedContractEvent>(
event: TCEvent,
listener: TypedListener<TCEvent>
): Promise<this>;
once<TCEvent extends TypedContractEvent>(
filter: TypedDeferredTopicFilter<TCEvent>,
listener: TypedListener<TCEvent>
): Promise<this>;

listeners<TCEvent extends TypedContractEvent>(
event: TCEvent
): Promise<Array<TypedListener<TCEvent>>>;
listeners(eventName?: string): Promise<Array<Listener>>;
removeAllListeners<TCEvent extends TypedContractEvent>(
event?: TCEvent
): Promise<this>;

allPairs: TypedContractMethod<[arg0: BigNumberish], [string], "view">;

allPairsLength: TypedContractMethod<[], [bigint], "view">;

createPair: TypedContractMethod<
[tokenA: AddressLike, tokenB: AddressLike],
[string],
"nonpayable"
>;

feeTo: TypedContractMethod<[], [string], "view">;

feeToSetter: TypedContractMethod<[], [string], "view">;

getPair: TypedContractMethod<
[arg0: AddressLike, arg1: AddressLike],
[string],
"view"
>;

setFeeTo: TypedContractMethod<[_feeTo: AddressLike], [void], "nonpayable">;

setFeeToSetter: TypedContractMethod<
[_feeToSetter: AddressLike],
[void],
"nonpayable"
>;

getFunction<T extends ContractMethod = ContractMethod>(
key: string | FunctionFragment
): T;

getFunction(
nameOrSignature: "allPairs"
): TypedContractMethod<[arg0: BigNumberish], [string], "view">;
getFunction(
nameOrSignature: "allPairsLength"
): TypedContractMethod<[], [bigint], "view">;
getFunction(
nameOrSignature: "createPair"
): TypedContractMethod<
[tokenA: AddressLike, tokenB: AddressLike],
[string],
"nonpayable"
>;
getFunction(
nameOrSignature: "feeTo"
): TypedContractMethod<[], [string], "view">;
getFunction(
nameOrSignature: "feeToSetter"
): TypedContractMethod<[], [string], "view">;
getFunction(
nameOrSignature: "getPair"
): TypedContractMethod<
[arg0: AddressLike, arg1: AddressLike],
[string],
"view"
>;
getFunction(
nameOrSignature: "setFeeTo"
): TypedContractMethod<[_feeTo: AddressLike], [void], "nonpayable">;
getFunction(
nameOrSignature: "setFeeToSetter"
): TypedContractMethod<[_feeToSetter: AddressLike], [void], "nonpayable">;

getEvent(
key: "PairCreated"
): TypedContractEvent<
PairCreatedEvent.InputTuple,
PairCreatedEvent.OutputTuple,
PairCreatedEvent.OutputObject
>;

filters: {
"PairCreated(address,address,address,uint256)": TypedContractEvent<
PairCreatedEvent.InputTuple,
PairCreatedEvent.OutputTuple,
PairCreatedEvent.OutputObject
>;
PairCreated: TypedContractEvent<
PairCreatedEvent.InputTuple,
PairCreatedEvent.OutputTuple,
PairCreatedEvent.OutputObject
>;
};
}
Loading

0 comments on commit b6d0efa

Please sign in to comment.