Compare commits
2 Commits
08635da692
...
0f72702650
Author | SHA1 | Date | |
---|---|---|---|
0f72702650 | |||
c27d5e638c |
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,7 +14,7 @@ pids
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib
|
||||
#lib
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
|
File diff suppressed because one or more lines are too long
36
lib/config.d.ts
vendored
Normal file
36
lib/config.d.ts
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import { LegacyGasPrices } from './types';
|
||||
export declare enum ChainId {
|
||||
MAINNET = 1,
|
||||
GOERLI = 5,
|
||||
BSC = 56,
|
||||
XDAI = 100,
|
||||
POLYGON = 137,
|
||||
OPTIMISM = 10,
|
||||
ARBITRUM = 42161,
|
||||
AVAX = 43114,
|
||||
SEPOLIA = 11155111
|
||||
}
|
||||
export declare enum InstanceTokenSymbol {
|
||||
DAI = "dai",
|
||||
cDAI = "cdai",
|
||||
WBTC = "wbtc",
|
||||
USDT = "usdt",
|
||||
USDC = "usdc"
|
||||
}
|
||||
export type GasPricesConfig = {
|
||||
[chainId in ChainId]: LegacyGasPrices;
|
||||
};
|
||||
export declare const defaultGasPrices: GasPricesConfig;
|
||||
type GasLimitConfig = {
|
||||
[chainId in ChainId]: number;
|
||||
};
|
||||
export declare const defaultWithdrawalGasLimit: GasLimitConfig;
|
||||
type InstanceTokenGasLimitConfig = {
|
||||
[tokenSymbol in InstanceTokenSymbol]: number;
|
||||
};
|
||||
export declare const defaultInstanceTokensGasLimit: InstanceTokenGasLimitConfig;
|
||||
export declare const optimismL1FeeOracleAddress = "0x420000000000000000000000000000000000000F";
|
||||
export declare const offchainOracleAddress = "0x00000000000D6FFc74A8feb35aF5827bf57f6786";
|
||||
export declare const sepoliaOffchainOracleAddress = "0x1f89EAF03E5b260Bc6D4Ae3c3334b1B750F3e127";
|
||||
export declare const multiCallAddress = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
||||
export {};
|
103
lib/config.js
Normal file
103
lib/config.js
Normal file
@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
var _a, _b, _c;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.multiCallAddress = exports.sepoliaOffchainOracleAddress = exports.offchainOracleAddress = exports.optimismL1FeeOracleAddress = exports.defaultInstanceTokensGasLimit = exports.defaultWithdrawalGasLimit = exports.defaultGasPrices = exports.InstanceTokenSymbol = exports.ChainId = void 0;
|
||||
var ChainId;
|
||||
(function (ChainId) {
|
||||
ChainId[ChainId["MAINNET"] = 1] = "MAINNET";
|
||||
ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
|
||||
ChainId[ChainId["BSC"] = 56] = "BSC";
|
||||
ChainId[ChainId["XDAI"] = 100] = "XDAI";
|
||||
ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
|
||||
ChainId[ChainId["OPTIMISM"] = 10] = "OPTIMISM";
|
||||
ChainId[ChainId["ARBITRUM"] = 42161] = "ARBITRUM";
|
||||
ChainId[ChainId["AVAX"] = 43114] = "AVAX";
|
||||
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
||||
})(ChainId || (exports.ChainId = ChainId = {}));
|
||||
var InstanceTokenSymbol;
|
||||
(function (InstanceTokenSymbol) {
|
||||
InstanceTokenSymbol["DAI"] = "dai";
|
||||
InstanceTokenSymbol["cDAI"] = "cdai";
|
||||
InstanceTokenSymbol["WBTC"] = "wbtc";
|
||||
InstanceTokenSymbol["USDT"] = "usdt";
|
||||
InstanceTokenSymbol["USDC"] = "usdc";
|
||||
})(InstanceTokenSymbol || (exports.InstanceTokenSymbol = InstanceTokenSymbol = {}));
|
||||
exports.defaultGasPrices = (_a = {},
|
||||
_a[ChainId.MAINNET] = {
|
||||
instant: 80,
|
||||
fast: 50,
|
||||
standard: 25,
|
||||
low: 8,
|
||||
},
|
||||
_a[ChainId.GOERLI] = {
|
||||
instant: 80,
|
||||
fast: 50,
|
||||
standard: 25,
|
||||
low: 8,
|
||||
},
|
||||
_a[ChainId.OPTIMISM] = {
|
||||
instant: 0.001,
|
||||
fast: 0.001,
|
||||
standard: 0.001,
|
||||
low: 0.001,
|
||||
},
|
||||
_a[ChainId.XDAI] = {
|
||||
instant: 6,
|
||||
fast: 5,
|
||||
standard: 4,
|
||||
low: 1,
|
||||
},
|
||||
_a[ChainId.BSC] = {
|
||||
instant: 5,
|
||||
fast: 4,
|
||||
standard: 3,
|
||||
low: 3,
|
||||
},
|
||||
_a[ChainId.POLYGON] = {
|
||||
instant: 100,
|
||||
fast: 75,
|
||||
standard: 50,
|
||||
low: 30,
|
||||
},
|
||||
_a[ChainId.ARBITRUM] = {
|
||||
instant: 4,
|
||||
fast: 3,
|
||||
standard: 2.52,
|
||||
low: 2.29,
|
||||
},
|
||||
_a[ChainId.AVAX] = {
|
||||
instant: 225,
|
||||
fast: 35,
|
||||
standard: 25,
|
||||
low: 25,
|
||||
},
|
||||
_a[ChainId.SEPOLIA] = {
|
||||
instant: 80,
|
||||
fast: 50,
|
||||
standard: 25,
|
||||
low: 8,
|
||||
},
|
||||
_a);
|
||||
exports.defaultWithdrawalGasLimit = (_b = {},
|
||||
_b[ChainId.MAINNET] = 550000,
|
||||
_b[ChainId.GOERLI] = 550000,
|
||||
_b[ChainId.ARBITRUM] = 1900000,
|
||||
_b[ChainId.OPTIMISM] = 440000,
|
||||
_b[ChainId.AVAX] = 390000,
|
||||
_b[ChainId.BSC] = 390000,
|
||||
_b[ChainId.POLYGON] = 390000,
|
||||
_b[ChainId.XDAI] = 390000,
|
||||
_b[ChainId.SEPOLIA] = 550000,
|
||||
_b);
|
||||
exports.defaultInstanceTokensGasLimit = (_c = {},
|
||||
_c[InstanceTokenSymbol.DAI] = 55000,
|
||||
_c[InstanceTokenSymbol.cDAI] = 425000,
|
||||
_c[InstanceTokenSymbol.WBTC] = 85000,
|
||||
_c[InstanceTokenSymbol.USDT] = 100000,
|
||||
_c[InstanceTokenSymbol.USDC] = 80000,
|
||||
_c);
|
||||
exports.optimismL1FeeOracleAddress = '0x420000000000000000000000000000000000000F';
|
||||
exports.offchainOracleAddress = '0x00000000000D6FFc74A8feb35aF5827bf57f6786';
|
||||
exports.sepoliaOffchainOracleAddress = '0x1f89EAF03E5b260Bc6D4Ae3c3334b1B750F3e127';
|
||||
exports.multiCallAddress = '0xcA11bde05977b3631167028862bE2a173976CA11';
|
||||
//# sourceMappingURL=config.js.map
|
1
lib/config.js.map
Normal file
1
lib/config.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;AAEA,IAAY,OAUX;AAVD,WAAY,OAAO;IACjB,2CAAW,CAAA;IACX,yCAAU,CAAA;IACV,oCAAQ,CAAA;IACR,uCAAU,CAAA;IACV,6CAAa,CAAA;IACb,8CAAa,CAAA;IACb,iDAAgB,CAAA;IAChB,yCAAY,CAAA;IACZ,kDAAkB,CAAA;AACpB,CAAC,EAVW,OAAO,uBAAP,OAAO,QAUlB;AAED,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,oCAAa,CAAA;IACb,oCAAa,CAAA;IACb,oCAAa,CAAA;IACb,oCAAa,CAAA;AACf,CAAC,EANW,mBAAmB,mCAAnB,mBAAmB,QAM9B;AAMY,QAAA,gBAAgB;IAC3B,GAAC,OAAO,CAAC,OAAO,IAAG;QACjB,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,CAAC;KACP;IACD,GAAC,OAAO,CAAC,MAAM,IAAG;QAChB,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,CAAC;KACP;IACD,GAAC,OAAO,CAAC,QAAQ,IAAG;QAClB,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE,KAAK;QACf,GAAG,EAAE,KAAK;KACX;IACD,GAAC,OAAO,CAAC,IAAI,IAAG;QACd,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,GAAG,EAAE,CAAC;KACP;IACD,GAAC,OAAO,CAAC,GAAG,IAAG;QACb,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,GAAG,EAAE,CAAC;KACP;IACD,GAAC,OAAO,CAAC,OAAO,IAAG;QACjB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,EAAE;KACR;IACD,GAAC,OAAO,CAAC,QAAQ,IAAG;QAClB,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,IAAI;KACV;IACD,GAAC,OAAO,CAAC,IAAI,IAAG;QACd,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,EAAE;KACR;IACD,GAAC,OAAO,CAAC,OAAO,IAAG;QACjB,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;QACZ,GAAG,EAAE,CAAC;KACP;QACD;AAMW,QAAA,yBAAyB;IACpC,GAAC,OAAO,CAAC,OAAO,IAAG,MAAM;IACzB,GAAC,OAAO,CAAC,MAAM,IAAG,MAAM;IACxB,GAAC,OAAO,CAAC,QAAQ,IAAG,OAAO;IAC3B,GAAC,OAAO,CAAC,QAAQ,IAAG,MAAM;IAC1B,GAAC,OAAO,CAAC,IAAI,IAAG,MAAM;IACtB,GAAC,OAAO,CAAC,GAAG,IAAG,MAAM;IACrB,GAAC,OAAO,CAAC,OAAO,IAAG,MAAM;IACzB,GAAC,OAAO,CAAC,IAAI,IAAG,MAAM;IACtB,GAAC,OAAO,CAAC,OAAO,IAAG,MAAM;QACzB;AAMW,QAAA,6BAA6B;IACxC,GAAC,mBAAmB,CAAC,GAAG,IAAG,KAAK;IAChC,GAAC,mBAAmB,CAAC,IAAI,IAAG,MAAM;IAClC,GAAC,mBAAmB,CAAC,IAAI,IAAG,KAAK;IACjC,GAAC,mBAAmB,CAAC,IAAI,IAAG,MAAM;IAClC,GAAC,mBAAmB,CAAC,IAAI,IAAG,KAAK;QACjC;AAEW,QAAA,0BAA0B,GAAG,4CAA4C,CAAC;AAC1E,QAAA,qBAAqB,GAAG,4CAA4C,CAAC;AACrE,QAAA,4BAA4B,GAAG,4CAA4C,CAAC;AAC5E,QAAA,gBAAgB,GAAG,4CAA4C,CAAC"}
|
289
lib/contracts/MulticallAbi.d.ts
vendored
Normal file
289
lib/contracts/MulticallAbi.d.ts
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, PayableOverrides, PopulatedTransaction, Signer, utils } from 'ethers';
|
||||
import type { FunctionFragment, Result } from '@ethersproject/abi';
|
||||
import type { Listener, Provider } from '@ethersproject/providers';
|
||||
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common';
|
||||
export declare namespace Multicall3 {
|
||||
type CallStruct = {
|
||||
target: string;
|
||||
callData: BytesLike;
|
||||
};
|
||||
type CallStructOutput = [string, string] & {
|
||||
target: string;
|
||||
callData: string;
|
||||
};
|
||||
type Call3Struct = {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
callData: BytesLike;
|
||||
};
|
||||
type Call3StructOutput = [string, boolean, string] & {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
callData: string;
|
||||
};
|
||||
type ResultStruct = {
|
||||
success: boolean;
|
||||
returnData: BytesLike;
|
||||
};
|
||||
type ResultStructOutput = [boolean, string] & {
|
||||
success: boolean;
|
||||
returnData: string;
|
||||
};
|
||||
type Call3ValueStruct = {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
value: BigNumberish;
|
||||
callData: BytesLike;
|
||||
};
|
||||
type Call3ValueStructOutput = [string, boolean, BigNumber, string] & {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
value: BigNumber;
|
||||
callData: string;
|
||||
};
|
||||
}
|
||||
export interface MulticallAbiInterface extends utils.Interface {
|
||||
functions: {
|
||||
'aggregate((address,bytes)[])': FunctionFragment;
|
||||
'aggregate3((address,bool,bytes)[])': FunctionFragment;
|
||||
'aggregate3Value((address,bool,uint256,bytes)[])': FunctionFragment;
|
||||
'blockAndAggregate((address,bytes)[])': FunctionFragment;
|
||||
'getBasefee()': FunctionFragment;
|
||||
'getBlockHash(uint256)': FunctionFragment;
|
||||
'getBlockNumber()': FunctionFragment;
|
||||
'getChainId()': FunctionFragment;
|
||||
'getCurrentBlockCoinbase()': FunctionFragment;
|
||||
'getCurrentBlockDifficulty()': FunctionFragment;
|
||||
'getCurrentBlockGasLimit()': FunctionFragment;
|
||||
'getCurrentBlockTimestamp()': FunctionFragment;
|
||||
'getEthBalance(address)': FunctionFragment;
|
||||
'getLastBlockHash()': FunctionFragment;
|
||||
'tryAggregate(bool,(address,bytes)[])': FunctionFragment;
|
||||
'tryBlockAndAggregate(bool,(address,bytes)[])': FunctionFragment;
|
||||
};
|
||||
getFunction(nameOrSignatureOrTopic: 'aggregate' | 'aggregate3' | 'aggregate3Value' | 'blockAndAggregate' | 'getBasefee' | 'getBlockHash' | 'getBlockNumber' | 'getChainId' | 'getCurrentBlockCoinbase' | 'getCurrentBlockDifficulty' | 'getCurrentBlockGasLimit' | 'getCurrentBlockTimestamp' | 'getEthBalance' | 'getLastBlockHash' | 'tryAggregate' | 'tryBlockAndAggregate'): FunctionFragment;
|
||||
encodeFunctionData(functionFragment: 'aggregate', values: [Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'aggregate3', values: [Multicall3.Call3Struct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'aggregate3Value', values: [Multicall3.Call3ValueStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'blockAndAggregate', values: [Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'getBasefee', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getBlockHash', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'getBlockNumber', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getChainId', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockCoinbase', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockDifficulty', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockGasLimit', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockTimestamp', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getEthBalance', values: [string]): string;
|
||||
encodeFunctionData(functionFragment: 'getLastBlockHash', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'tryAggregate', values: [boolean, Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'tryBlockAndAggregate', values: [boolean, Multicall3.CallStruct[]]): string;
|
||||
decodeFunctionResult(functionFragment: 'aggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'aggregate3', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'aggregate3Value', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'blockAndAggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBasefee', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBlockHash', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBlockNumber', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getChainId', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockCoinbase', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockDifficulty', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockGasLimit', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockTimestamp', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getEthBalance', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getLastBlockHash', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'tryAggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'tryBlockAndAggregate', data: BytesLike): Result;
|
||||
events: {};
|
||||
}
|
||||
export interface MulticallAbi extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
interface: MulticallAbiInterface;
|
||||
queryFilter<TEvent extends TypedEvent>(event: TypedEventFilter<TEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TEvent>>;
|
||||
listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
functions: {
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
aggregate3Value(calls: Multicall3.Call3ValueStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
blockAndAggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
getBasefee(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
basefee: BigNumber;
|
||||
}>;
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<[string] & {
|
||||
blockHash: string;
|
||||
}>;
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
blockNumber: BigNumber;
|
||||
}>;
|
||||
getChainId(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
chainid: BigNumber;
|
||||
}>;
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<[string] & {
|
||||
coinbase: string;
|
||||
}>;
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
difficulty: BigNumber;
|
||||
}>;
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
gaslimit: BigNumber;
|
||||
}>;
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
timestamp: BigNumber;
|
||||
}>;
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
balance: BigNumber;
|
||||
}>;
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<[string] & {
|
||||
blockHash: string;
|
||||
}>;
|
||||
tryAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
tryBlockAndAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
};
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
aggregate3Value(calls: Multicall3.Call3ValueStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
blockAndAggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<string>;
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<string>;
|
||||
tryAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
tryBlockAndAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
callStatic: {
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: CallOverrides): Promise<[BigNumber, string[]] & {
|
||||
blockNumber: BigNumber;
|
||||
returnData: string[];
|
||||
}>;
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: CallOverrides): Promise<Multicall3.ResultStructOutput[]>;
|
||||
aggregate3Value(calls: Multicall3.Call3ValueStruct[], overrides?: CallOverrides): Promise<Multicall3.ResultStructOutput[]>;
|
||||
blockAndAggregate(calls: Multicall3.CallStruct[], overrides?: CallOverrides): Promise<[
|
||||
BigNumber,
|
||||
string,
|
||||
Multicall3.ResultStructOutput[]
|
||||
] & {
|
||||
blockNumber: BigNumber;
|
||||
blockHash: string;
|
||||
returnData: Multicall3.ResultStructOutput[];
|
||||
}>;
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<string>;
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<string>;
|
||||
tryAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: CallOverrides): Promise<Multicall3.ResultStructOutput[]>;
|
||||
tryBlockAndAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: CallOverrides): Promise<[
|
||||
BigNumber,
|
||||
string,
|
||||
Multicall3.ResultStructOutput[]
|
||||
] & {
|
||||
blockNumber: BigNumber;
|
||||
blockHash: string;
|
||||
returnData: Multicall3.ResultStructOutput[];
|
||||
}>;
|
||||
};
|
||||
filters: {};
|
||||
estimateGas: {
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
aggregate3Value(calls: Multicall3.Call3ValueStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
blockAndAggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
tryAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
tryBlockAndAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
};
|
||||
populateTransaction: {
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
aggregate3Value(calls: Multicall3.Call3ValueStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
blockAndAggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
getBasefee(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getChainId(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
tryAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
tryBlockAndAggregate(requireSuccess: boolean, calls: Multicall3.CallStruct[], overrides?: PayableOverrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
3
lib/contracts/MulticallAbi.js
Normal file
3
lib/contracts/MulticallAbi.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=MulticallAbi.js.map
|
1
lib/contracts/MulticallAbi.js.map
Normal file
1
lib/contracts/MulticallAbi.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"MulticallAbi.js","sourceRoot":"","sources":["../../src/contracts/MulticallAbi.ts"],"names":[],"mappings":""}
|
268
lib/contracts/OffchainOracleAbi.d.ts
vendored
Normal file
268
lib/contracts/OffchainOracleAbi.d.ts
vendored
Normal file
@ -0,0 +1,268 @@
|
||||
import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PopulatedTransaction, Signer, utils } from 'ethers';
|
||||
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi';
|
||||
import type { Listener, Provider } from '@ethersproject/providers';
|
||||
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common';
|
||||
export interface OffchainOracleAbiInterface extends utils.Interface {
|
||||
functions: {
|
||||
'addConnector(address)': FunctionFragment;
|
||||
'addOracle(address,uint8)': FunctionFragment;
|
||||
'connectors()': FunctionFragment;
|
||||
'getRate(address,address,bool)': FunctionFragment;
|
||||
'getRateToEth(address,bool)': FunctionFragment;
|
||||
'multiWrapper()': FunctionFragment;
|
||||
'oracles()': FunctionFragment;
|
||||
'owner()': FunctionFragment;
|
||||
'removeConnector(address)': FunctionFragment;
|
||||
'removeOracle(address,uint8)': FunctionFragment;
|
||||
'renounceOwnership()': FunctionFragment;
|
||||
'setMultiWrapper(address)': FunctionFragment;
|
||||
'transferOwnership(address)': FunctionFragment;
|
||||
};
|
||||
getFunction(nameOrSignatureOrTopic: 'addConnector' | 'addOracle' | 'connectors' | 'getRate' | 'getRateToEth' | 'multiWrapper' | 'oracles' | 'owner' | 'removeConnector' | 'removeOracle' | 'renounceOwnership' | 'setMultiWrapper' | 'transferOwnership'): FunctionFragment;
|
||||
encodeFunctionData(functionFragment: 'addConnector', values: [string]): string;
|
||||
encodeFunctionData(functionFragment: 'addOracle', values: [string, BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'connectors', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getRate', values: [string, string, boolean]): string;
|
||||
encodeFunctionData(functionFragment: 'getRateToEth', values: [string, boolean]): string;
|
||||
encodeFunctionData(functionFragment: 'multiWrapper', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'oracles', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'owner', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'removeConnector', values: [string]): string;
|
||||
encodeFunctionData(functionFragment: 'removeOracle', values: [string, BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'renounceOwnership', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'setMultiWrapper', values: [string]): string;
|
||||
encodeFunctionData(functionFragment: 'transferOwnership', values: [string]): string;
|
||||
decodeFunctionResult(functionFragment: 'addConnector', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'addOracle', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'connectors', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getRate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getRateToEth', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'multiWrapper', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'oracles', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'removeConnector', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'removeOracle', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'renounceOwnership', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setMultiWrapper', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'transferOwnership', data: BytesLike): Result;
|
||||
events: {
|
||||
'ConnectorAdded(address)': EventFragment;
|
||||
'ConnectorRemoved(address)': EventFragment;
|
||||
'MultiWrapperUpdated(address)': EventFragment;
|
||||
'OracleAdded(address,uint8)': EventFragment;
|
||||
'OracleRemoved(address,uint8)': EventFragment;
|
||||
'OwnershipTransferred(address,address)': EventFragment;
|
||||
};
|
||||
getEvent(nameOrSignatureOrTopic: 'ConnectorAdded'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'ConnectorRemoved'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'MultiWrapperUpdated'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'OracleAdded'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'OracleRemoved'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment;
|
||||
}
|
||||
export interface ConnectorAddedEventObject {
|
||||
connector: string;
|
||||
}
|
||||
export type ConnectorAddedEvent = TypedEvent<[string], ConnectorAddedEventObject>;
|
||||
export type ConnectorAddedEventFilter = TypedEventFilter<ConnectorAddedEvent>;
|
||||
export interface ConnectorRemovedEventObject {
|
||||
connector: string;
|
||||
}
|
||||
export type ConnectorRemovedEvent = TypedEvent<[string], ConnectorRemovedEventObject>;
|
||||
export type ConnectorRemovedEventFilter = TypedEventFilter<ConnectorRemovedEvent>;
|
||||
export interface MultiWrapperUpdatedEventObject {
|
||||
multiWrapper: string;
|
||||
}
|
||||
export type MultiWrapperUpdatedEvent = TypedEvent<[string], MultiWrapperUpdatedEventObject>;
|
||||
export type MultiWrapperUpdatedEventFilter = TypedEventFilter<MultiWrapperUpdatedEvent>;
|
||||
export interface OracleAddedEventObject {
|
||||
oracle: string;
|
||||
oracleType: number;
|
||||
}
|
||||
export type OracleAddedEvent = TypedEvent<[string, number], OracleAddedEventObject>;
|
||||
export type OracleAddedEventFilter = TypedEventFilter<OracleAddedEvent>;
|
||||
export interface OracleRemovedEventObject {
|
||||
oracle: string;
|
||||
oracleType: number;
|
||||
}
|
||||
export type OracleRemovedEvent = TypedEvent<[string, number], OracleRemovedEventObject>;
|
||||
export type OracleRemovedEventFilter = TypedEventFilter<OracleRemovedEvent>;
|
||||
export interface OwnershipTransferredEventObject {
|
||||
previousOwner: string;
|
||||
newOwner: string;
|
||||
}
|
||||
export type OwnershipTransferredEvent = TypedEvent<[string, string], OwnershipTransferredEventObject>;
|
||||
export type OwnershipTransferredEventFilter = TypedEventFilter<OwnershipTransferredEvent>;
|
||||
export interface OffchainOracleAbi extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
interface: OffchainOracleAbiInterface;
|
||||
queryFilter<TEvent extends TypedEvent>(event: TypedEventFilter<TEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TEvent>>;
|
||||
listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
functions: {
|
||||
addConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
addOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
connectors(overrides?: CallOverrides): Promise<[string[]] & {
|
||||
allConnectors: string[];
|
||||
}>;
|
||||
getRate(srcToken: string, dstToken: string, useWrappers: boolean, overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
weightedRate: BigNumber;
|
||||
}>;
|
||||
getRateToEth(srcToken: string, useSrcWrappers: boolean, overrides?: CallOverrides): Promise<[BigNumber] & {
|
||||
weightedRate: BigNumber;
|
||||
}>;
|
||||
multiWrapper(overrides?: CallOverrides): Promise<[string]>;
|
||||
oracles(overrides?: CallOverrides): Promise<[string[], number[]] & {
|
||||
allOracles: string[];
|
||||
oracleTypes: number[];
|
||||
}>;
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
removeConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
removeOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setMultiWrapper(_multiWrapper: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
};
|
||||
addConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
addOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
connectors(overrides?: CallOverrides): Promise<string[]>;
|
||||
getRate(srcToken: string, dstToken: string, useWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getRateToEth(srcToken: string, useSrcWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
multiWrapper(overrides?: CallOverrides): Promise<string>;
|
||||
oracles(overrides?: CallOverrides): Promise<[string[], number[]] & {
|
||||
allOracles: string[];
|
||||
oracleTypes: number[];
|
||||
}>;
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
removeConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
removeOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setMultiWrapper(_multiWrapper: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
callStatic: {
|
||||
addConnector(connector: string, overrides?: CallOverrides): Promise<void>;
|
||||
addOracle(oracle: string, oracleKind: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
connectors(overrides?: CallOverrides): Promise<string[]>;
|
||||
getRate(srcToken: string, dstToken: string, useWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getRateToEth(srcToken: string, useSrcWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
multiWrapper(overrides?: CallOverrides): Promise<string>;
|
||||
oracles(overrides?: CallOverrides): Promise<[string[], number[]] & {
|
||||
allOracles: string[];
|
||||
oracleTypes: number[];
|
||||
}>;
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
removeConnector(connector: string, overrides?: CallOverrides): Promise<void>;
|
||||
removeOracle(oracle: string, oracleKind: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
renounceOwnership(overrides?: CallOverrides): Promise<void>;
|
||||
setMultiWrapper(_multiWrapper: string, overrides?: CallOverrides): Promise<void>;
|
||||
transferOwnership(newOwner: string, overrides?: CallOverrides): Promise<void>;
|
||||
};
|
||||
filters: {
|
||||
'ConnectorAdded(address)'(connector?: null): ConnectorAddedEventFilter;
|
||||
ConnectorAdded(connector?: null): ConnectorAddedEventFilter;
|
||||
'ConnectorRemoved(address)'(connector?: null): ConnectorRemovedEventFilter;
|
||||
ConnectorRemoved(connector?: null): ConnectorRemovedEventFilter;
|
||||
'MultiWrapperUpdated(address)'(multiWrapper?: null): MultiWrapperUpdatedEventFilter;
|
||||
MultiWrapperUpdated(multiWrapper?: null): MultiWrapperUpdatedEventFilter;
|
||||
'OracleAdded(address,uint8)'(oracle?: null, oracleType?: null): OracleAddedEventFilter;
|
||||
OracleAdded(oracle?: null, oracleType?: null): OracleAddedEventFilter;
|
||||
'OracleRemoved(address,uint8)'(oracle?: null, oracleType?: null): OracleRemovedEventFilter;
|
||||
OracleRemoved(oracle?: null, oracleType?: null): OracleRemovedEventFilter;
|
||||
'OwnershipTransferred(address,address)'(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter;
|
||||
OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter;
|
||||
};
|
||||
estimateGas: {
|
||||
addConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
addOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
connectors(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getRate(srcToken: string, dstToken: string, useWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getRateToEth(srcToken: string, useSrcWrappers: boolean, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
multiWrapper(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
oracles(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
removeConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
removeOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
setMultiWrapper(_multiWrapper: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
};
|
||||
populateTransaction: {
|
||||
addConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
addOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
connectors(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getRate(srcToken: string, dstToken: string, useWrappers: boolean, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getRateToEth(srcToken: string, useSrcWrappers: boolean, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
multiWrapper(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
oracles(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
removeConnector(connector: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
removeOracle(oracle: string, oracleKind: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
setMultiWrapper(_multiWrapper: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
3
lib/contracts/OffchainOracleAbi.js
Normal file
3
lib/contracts/OffchainOracleAbi.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=OffchainOracleAbi.js.map
|
1
lib/contracts/OffchainOracleAbi.js.map
Normal file
1
lib/contracts/OffchainOracleAbi.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"OffchainOracleAbi.js","sourceRoot":"","sources":["../../src/contracts/OffchainOracleAbi.ts"],"names":[],"mappings":""}
|
267
lib/contracts/OptimismL1FeeOracleAbi.d.ts
vendored
Normal file
267
lib/contracts/OptimismL1FeeOracleAbi.d.ts
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PopulatedTransaction, Signer, utils } from 'ethers';
|
||||
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi';
|
||||
import type { Listener, Provider } from '@ethersproject/providers';
|
||||
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common';
|
||||
export interface OptimismL1FeeOracleAbiInterface extends utils.Interface {
|
||||
functions: {
|
||||
'decimals()': FunctionFragment;
|
||||
'gasPrice()': FunctionFragment;
|
||||
'getL1Fee(bytes)': FunctionFragment;
|
||||
'getL1GasUsed(bytes)': FunctionFragment;
|
||||
'l1BaseFee()': FunctionFragment;
|
||||
'overhead()': FunctionFragment;
|
||||
'owner()': FunctionFragment;
|
||||
'renounceOwnership()': FunctionFragment;
|
||||
'scalar()': FunctionFragment;
|
||||
'setDecimals(uint256)': FunctionFragment;
|
||||
'setGasPrice(uint256)': FunctionFragment;
|
||||
'setL1BaseFee(uint256)': FunctionFragment;
|
||||
'setOverhead(uint256)': FunctionFragment;
|
||||
'setScalar(uint256)': FunctionFragment;
|
||||
'transferOwnership(address)': FunctionFragment;
|
||||
};
|
||||
getFunction(nameOrSignatureOrTopic: 'decimals' | 'gasPrice' | 'getL1Fee' | 'getL1GasUsed' | 'l1BaseFee' | 'overhead' | 'owner' | 'renounceOwnership' | 'scalar' | 'setDecimals' | 'setGasPrice' | 'setL1BaseFee' | 'setOverhead' | 'setScalar' | 'transferOwnership'): FunctionFragment;
|
||||
encodeFunctionData(functionFragment: 'decimals', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'gasPrice', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getL1Fee', values: [BytesLike]): string;
|
||||
encodeFunctionData(functionFragment: 'getL1GasUsed', values: [BytesLike]): string;
|
||||
encodeFunctionData(functionFragment: 'l1BaseFee', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'overhead', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'owner', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'renounceOwnership', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'scalar', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'setDecimals', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'setGasPrice', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'setL1BaseFee', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'setOverhead', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'setScalar', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'transferOwnership', values: [string]): string;
|
||||
decodeFunctionResult(functionFragment: 'decimals', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'gasPrice', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getL1Fee', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getL1GasUsed', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'l1BaseFee', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'overhead', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'owner', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'renounceOwnership', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'scalar', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setDecimals', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setGasPrice', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setL1BaseFee', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setOverhead', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'setScalar', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'transferOwnership', data: BytesLike): Result;
|
||||
events: {
|
||||
'DecimalsUpdated(uint256)': EventFragment;
|
||||
'GasPriceUpdated(uint256)': EventFragment;
|
||||
'L1BaseFeeUpdated(uint256)': EventFragment;
|
||||
'OverheadUpdated(uint256)': EventFragment;
|
||||
'OwnershipTransferred(address,address)': EventFragment;
|
||||
'ScalarUpdated(uint256)': EventFragment;
|
||||
};
|
||||
getEvent(nameOrSignatureOrTopic: 'DecimalsUpdated'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'GasPriceUpdated'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'L1BaseFeeUpdated'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'OverheadUpdated'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'OwnershipTransferred'): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: 'ScalarUpdated'): EventFragment;
|
||||
}
|
||||
export interface DecimalsUpdatedEventObject {
|
||||
arg0: BigNumber;
|
||||
}
|
||||
export type DecimalsUpdatedEvent = TypedEvent<[BigNumber], DecimalsUpdatedEventObject>;
|
||||
export type DecimalsUpdatedEventFilter = TypedEventFilter<DecimalsUpdatedEvent>;
|
||||
export interface GasPriceUpdatedEventObject {
|
||||
arg0: BigNumber;
|
||||
}
|
||||
export type GasPriceUpdatedEvent = TypedEvent<[BigNumber], GasPriceUpdatedEventObject>;
|
||||
export type GasPriceUpdatedEventFilter = TypedEventFilter<GasPriceUpdatedEvent>;
|
||||
export interface L1BaseFeeUpdatedEventObject {
|
||||
arg0: BigNumber;
|
||||
}
|
||||
export type L1BaseFeeUpdatedEvent = TypedEvent<[BigNumber], L1BaseFeeUpdatedEventObject>;
|
||||
export type L1BaseFeeUpdatedEventFilter = TypedEventFilter<L1BaseFeeUpdatedEvent>;
|
||||
export interface OverheadUpdatedEventObject {
|
||||
arg0: BigNumber;
|
||||
}
|
||||
export type OverheadUpdatedEvent = TypedEvent<[BigNumber], OverheadUpdatedEventObject>;
|
||||
export type OverheadUpdatedEventFilter = TypedEventFilter<OverheadUpdatedEvent>;
|
||||
export interface OwnershipTransferredEventObject {
|
||||
previousOwner: string;
|
||||
newOwner: string;
|
||||
}
|
||||
export type OwnershipTransferredEvent = TypedEvent<[string, string], OwnershipTransferredEventObject>;
|
||||
export type OwnershipTransferredEventFilter = TypedEventFilter<OwnershipTransferredEvent>;
|
||||
export interface ScalarUpdatedEventObject {
|
||||
arg0: BigNumber;
|
||||
}
|
||||
export type ScalarUpdatedEvent = TypedEvent<[BigNumber], ScalarUpdatedEventObject>;
|
||||
export type ScalarUpdatedEventFilter = TypedEventFilter<ScalarUpdatedEvent>;
|
||||
export interface OptimismL1FeeOracleAbi extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
interface: OptimismL1FeeOracleAbiInterface;
|
||||
queryFilter<TEvent extends TypedEvent>(event: TypedEventFilter<TEvent>, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise<Array<TEvent>>;
|
||||
listeners<TEvent extends TypedEvent>(eventFilter?: TypedEventFilter<TEvent>): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
functions: {
|
||||
decimals(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
gasPrice(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
getL1Fee(_data: BytesLike, overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
getL1GasUsed(_data: BytesLike, overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
l1BaseFee(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
overhead(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
scalar(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
setDecimals(_decimals: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setGasPrice(_gasPrice: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setL1BaseFee(_baseFee: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setOverhead(_overhead: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setScalar(_scalar: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
};
|
||||
decimals(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
gasPrice(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1Fee(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1GasUsed(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
l1BaseFee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
overhead(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
scalar(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
setDecimals(_decimals: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setGasPrice(_gasPrice: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setL1BaseFee(_baseFee: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setOverhead(_overhead: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
setScalar(_scalar: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<ContractTransaction>;
|
||||
callStatic: {
|
||||
decimals(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
gasPrice(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1Fee(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1GasUsed(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
l1BaseFee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
overhead(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
renounceOwnership(overrides?: CallOverrides): Promise<void>;
|
||||
scalar(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
setDecimals(_decimals: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
setGasPrice(_gasPrice: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
setL1BaseFee(_baseFee: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
setOverhead(_overhead: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
setScalar(_scalar: BigNumberish, overrides?: CallOverrides): Promise<void>;
|
||||
transferOwnership(newOwner: string, overrides?: CallOverrides): Promise<void>;
|
||||
};
|
||||
filters: {
|
||||
'DecimalsUpdated(uint256)'(arg0?: null): DecimalsUpdatedEventFilter;
|
||||
DecimalsUpdated(arg0?: null): DecimalsUpdatedEventFilter;
|
||||
'GasPriceUpdated(uint256)'(arg0?: null): GasPriceUpdatedEventFilter;
|
||||
GasPriceUpdated(arg0?: null): GasPriceUpdatedEventFilter;
|
||||
'L1BaseFeeUpdated(uint256)'(arg0?: null): L1BaseFeeUpdatedEventFilter;
|
||||
L1BaseFeeUpdated(arg0?: null): L1BaseFeeUpdatedEventFilter;
|
||||
'OverheadUpdated(uint256)'(arg0?: null): OverheadUpdatedEventFilter;
|
||||
OverheadUpdated(arg0?: null): OverheadUpdatedEventFilter;
|
||||
'OwnershipTransferred(address,address)'(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter;
|
||||
OwnershipTransferred(previousOwner?: string | null, newOwner?: string | null): OwnershipTransferredEventFilter;
|
||||
'ScalarUpdated(uint256)'(arg0?: null): ScalarUpdatedEventFilter;
|
||||
ScalarUpdated(arg0?: null): ScalarUpdatedEventFilter;
|
||||
};
|
||||
estimateGas: {
|
||||
decimals(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
gasPrice(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1Fee(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
getL1GasUsed(_data: BytesLike, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
l1BaseFee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
overhead(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
scalar(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
setDecimals(_decimals: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
setGasPrice(_gasPrice: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
setL1BaseFee(_baseFee: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
setOverhead(_overhead: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
setScalar(_scalar: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<BigNumber>;
|
||||
};
|
||||
populateTransaction: {
|
||||
decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
gasPrice(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getL1Fee(_data: BytesLike, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
getL1GasUsed(_data: BytesLike, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
l1BaseFee(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
overhead(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
renounceOwnership(overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
scalar(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
setDecimals(_decimals: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
setGasPrice(_gasPrice: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
setL1BaseFee(_baseFee: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
setOverhead(_overhead: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
setScalar(_scalar: BigNumberish, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
transferOwnership(newOwner: string, overrides?: Overrides & {
|
||||
from?: string;
|
||||
}): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
3
lib/contracts/OptimismL1FeeOracleAbi.js
Normal file
3
lib/contracts/OptimismL1FeeOracleAbi.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=OptimismL1FeeOracleAbi.js.map
|
1
lib/contracts/OptimismL1FeeOracleAbi.js.map
Normal file
1
lib/contracts/OptimismL1FeeOracleAbi.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"OptimismL1FeeOracleAbi.js","sourceRoot":"","sources":["../../src/contracts/OptimismL1FeeOracleAbi.ts"],"names":[],"mappings":""}
|
21
lib/contracts/common.d.ts
vendored
Normal file
21
lib/contracts/common.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import type { Listener } from '@ethersproject/providers';
|
||||
import type { Event, EventFilter } from 'ethers';
|
||||
export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = any> extends Event {
|
||||
args: TArgsArray & TArgsObject;
|
||||
}
|
||||
export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {
|
||||
}
|
||||
export interface TypedListener<TEvent extends TypedEvent> {
|
||||
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
|
||||
}
|
||||
type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
|
||||
export interface OnEvent<TRes> {
|
||||
<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>, listener: TypedListener<TEvent>): TRes;
|
||||
(eventName: string, listener: Listener): TRes;
|
||||
}
|
||||
export type MinEthersFactory<C, ARGS> = {
|
||||
deploy(...a: ARGS[]): Promise<C>;
|
||||
};
|
||||
export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<infer C, any> ? C : never;
|
||||
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any> ? Parameters<F['deploy']> : never;
|
||||
export {};
|
3
lib/contracts/common.js
Normal file
3
lib/contracts/common.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=common.js.map
|
1
lib/contracts/common.js.map
Normal file
1
lib/contracts/common.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/contracts/common.ts"],"names":[],"mappings":""}
|
5
lib/contracts/factories.d.ts
vendored
Normal file
5
lib/contracts/factories.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { Provider } from '@ethersproject/abstract-provider';
|
||||
import { ChainId } from '../config';
|
||||
export declare const getOptimismL1FeeOracle: (provider: Provider) => import("./OptimismL1FeeOracleAbi").OptimismL1FeeOracleAbi;
|
||||
export declare const getOffchainOracleContract: (provider: Provider, chainId?: ChainId) => import("./OffchainOracleAbi").OffchainOracleAbi;
|
||||
export declare const getMultiCallContract: (provider: Provider) => import("./MulticallAbi").MulticallAbi;
|
22
lib/contracts/factories.js
Normal file
22
lib/contracts/factories.js
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMultiCallContract = exports.getOffchainOracleContract = exports.getOptimismL1FeeOracle = void 0;
|
||||
var _1 = require("./");
|
||||
var config_1 = require("../config");
|
||||
var config_2 = require("../config");
|
||||
var getOptimismL1FeeOracle = function (provider) {
|
||||
return _1.OptimismL1FeeOracleAbi__factory.connect(config_1.optimismL1FeeOracleAddress, provider);
|
||||
};
|
||||
exports.getOptimismL1FeeOracle = getOptimismL1FeeOracle;
|
||||
var getOffchainOracleContract = function (provider, chainId) {
|
||||
if (chainId === config_2.ChainId.SEPOLIA) {
|
||||
return _1.OffchainOracleAbi__factory.connect(config_1.sepoliaOffchainOracleAddress, provider);
|
||||
}
|
||||
return _1.OffchainOracleAbi__factory.connect(config_1.offchainOracleAddress, provider);
|
||||
};
|
||||
exports.getOffchainOracleContract = getOffchainOracleContract;
|
||||
var getMultiCallContract = function (provider) {
|
||||
return _1.MulticallAbi__factory.connect(config_1.multiCallAddress, provider);
|
||||
};
|
||||
exports.getMultiCallContract = getMultiCallContract;
|
||||
//# sourceMappingURL=factories.js.map
|
1
lib/contracts/factories.js.map
Normal file
1
lib/contracts/factories.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../src/contracts/factories.ts"],"names":[],"mappings":";;;AAAA,uBAAwG;AACxG,oCAKmB;AAEnB,oCAAoC;AAE7B,IAAM,sBAAsB,GAAG,UAAC,QAAkB;IACvD,OAAO,kCAA+B,CAAC,OAAO,CAAC,mCAA0B,EAAE,QAAQ,CAAC,CAAC;AACvF,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAEK,IAAM,yBAAyB,GAAG,UAAC,QAAkB,EAAE,OAAiB;IAC7E,IAAI,OAAO,KAAK,gBAAO,CAAC,OAAO,EAAE;QAC/B,OAAO,6BAA0B,CAAC,OAAO,CAAC,qCAA4B,EAAE,QAAQ,CAAC,CAAC;KACnF;IACD,OAAO,6BAA0B,CAAC,OAAO,CAAC,8BAAqB,EAAE,QAAQ,CAAC,CAAC;AAC7E,CAAC,CAAC;AALW,QAAA,yBAAyB,6BAKpC;AAEK,IAAM,oBAAoB,GAAG,UAAC,QAAkB;IACrD,OAAO,wBAAqB,CAAC,OAAO,CAAC,yBAAgB,EAAE,QAAQ,CAAC,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B"}
|
339
lib/contracts/factories/MulticallAbi__factory.d.ts
vendored
Normal file
339
lib/contracts/factories/MulticallAbi__factory.d.ts
vendored
Normal file
@ -0,0 +1,339 @@
|
||||
import { Signer } from 'ethers';
|
||||
import type { Provider } from '@ethersproject/providers';
|
||||
import type { MulticallAbi, MulticallAbiInterface } from '../MulticallAbi';
|
||||
export declare class MulticallAbi__factory {
|
||||
static readonly abi: readonly [{
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "aggregate";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "blockNumber";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bytes[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "allowFailure";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call3[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "aggregate3";
|
||||
readonly outputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Result[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "allowFailure";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "value";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call3Value[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "aggregate3Value";
|
||||
readonly outputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Result[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "blockAndAggregate";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "blockNumber";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "blockHash";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Result[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getBasefee";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "basefee";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "blockNumber";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "getBlockHash";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "blockHash";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getBlockNumber";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "blockNumber";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getChainId";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "chainid";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getCurrentBlockCoinbase";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "coinbase";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getCurrentBlockDifficulty";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "difficulty";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getCurrentBlockGasLimit";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "gaslimit";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getCurrentBlockTimestamp";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "timestamp";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "addr";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "getEthBalance";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "balance";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "getLastBlockHash";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "blockHash";
|
||||
readonly type: "bytes32";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "requireSuccess";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "tryAggregate";
|
||||
readonly outputs: readonly [{
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Result[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "requireSuccess";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "target";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "callData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Call[]";
|
||||
readonly name: "calls";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly name: "tryBlockAndAggregate";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "blockNumber";
|
||||
readonly type: "uint256";
|
||||
}, {
|
||||
readonly internalType: "bytes32";
|
||||
readonly name: "blockHash";
|
||||
readonly type: "bytes32";
|
||||
}, {
|
||||
readonly components: readonly [{
|
||||
readonly internalType: "bool";
|
||||
readonly name: "success";
|
||||
readonly type: "bool";
|
||||
}, {
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "returnData";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly internalType: "struct Multicall3.Result[]";
|
||||
readonly name: "returnData";
|
||||
readonly type: "tuple[]";
|
||||
}];
|
||||
readonly stateMutability: "payable";
|
||||
readonly type: "function";
|
||||
}];
|
||||
static createInterface(): MulticallAbiInterface;
|
||||
static connect(address: string, signerOrProvider: Signer | Provider): MulticallAbi;
|
||||
}
|
460
lib/contracts/factories/MulticallAbi__factory.js
Normal file
460
lib/contracts/factories/MulticallAbi__factory.js
Normal file
@ -0,0 +1,460 @@
|
||||
"use strict";
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MulticallAbi__factory = void 0;
|
||||
var ethers_1 = require("ethers");
|
||||
var _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'aggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes[]',
|
||||
name: 'returnData',
|
||||
type: 'bytes[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'allowFailure',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call3[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'aggregate3',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'allowFailure',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'value',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call3Value[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'aggregate3Value',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'blockAndAggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getBasefee',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'basefee',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'getBlockHash',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getBlockNumber',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getChainId',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'chainid',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockCoinbase',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'coinbase',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockDifficulty',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'difficulty',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockGasLimit',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'gaslimit',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockTimestamp',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'timestamp',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'addr',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'getEthBalance',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'balance',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getLastBlockHash',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'requireSuccess',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'tryAggregate',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'requireSuccess',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'tryBlockAndAggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
||||
var MulticallAbi__factory = exports.MulticallAbi__factory = /** @class */ (function () {
|
||||
function MulticallAbi__factory() {
|
||||
}
|
||||
MulticallAbi__factory.createInterface = function () {
|
||||
return new ethers_1.utils.Interface(_abi);
|
||||
};
|
||||
MulticallAbi__factory.connect = function (address, signerOrProvider) {
|
||||
return new ethers_1.Contract(address, _abi, signerOrProvider);
|
||||
};
|
||||
MulticallAbi__factory.abi = _abi;
|
||||
return MulticallAbi__factory;
|
||||
}());
|
||||
//# sourceMappingURL=MulticallAbi__factory.js.map
|
1
lib/contracts/factories/MulticallAbi__factory.js.map
Normal file
1
lib/contracts/factories/MulticallAbi__factory.js.map
Normal file
File diff suppressed because one or more lines are too long
265
lib/contracts/factories/OffchainOracleAbi__factory.d.ts
vendored
Normal file
265
lib/contracts/factories/OffchainOracleAbi__factory.d.ts
vendored
Normal file
@ -0,0 +1,265 @@
|
||||
import { Signer } from 'ethers';
|
||||
import type { Provider } from '@ethersproject/providers';
|
||||
import type { OffchainOracleAbi, OffchainOracleAbiInterface } from '../OffchainOracleAbi';
|
||||
export declare class OffchainOracleAbi__factory {
|
||||
static readonly abi: readonly [{
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract MultiWrapper";
|
||||
readonly name: "_multiWrapper";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "contract IOracle[]";
|
||||
readonly name: "existingOracles";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "enum OffchainOracle.OracleType[]";
|
||||
readonly name: "oracleTypes";
|
||||
readonly type: "uint8[]";
|
||||
}, {
|
||||
readonly internalType: "contract IERC20[]";
|
||||
readonly name: "existingConnectors";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "wBase";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "constructor";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "connector";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "ConnectorAdded";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "connector";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "ConnectorRemoved";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "contract MultiWrapper";
|
||||
readonly name: "multiWrapper";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "MultiWrapperUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "contract IOracle";
|
||||
readonly name: "oracle";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly internalType: "enum OffchainOracle.OracleType";
|
||||
readonly name: "oracleType";
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
readonly name: "OracleAdded";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "contract IOracle";
|
||||
readonly name: "oracle";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: false;
|
||||
readonly internalType: "enum OffchainOracle.OracleType";
|
||||
readonly name: "oracleType";
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
readonly name: "OracleRemoved";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly internalType: "address";
|
||||
readonly name: "previousOwner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly internalType: "address";
|
||||
readonly name: "newOwner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "OwnershipTransferred";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "connector";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "addConnector";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IOracle";
|
||||
readonly name: "oracle";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "enum OffchainOracle.OracleType";
|
||||
readonly name: "oracleKind";
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
readonly name: "addOracle";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "connectors";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "contract IERC20[]";
|
||||
readonly name: "allConnectors";
|
||||
readonly type: "address[]";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "srcToken";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "dstToken";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "useWrappers";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly name: "getRate";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "weightedRate";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "srcToken";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "bool";
|
||||
readonly name: "useSrcWrappers";
|
||||
readonly type: "bool";
|
||||
}];
|
||||
readonly name: "getRateToEth";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "weightedRate";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "multiWrapper";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "contract MultiWrapper";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "oracles";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "contract IOracle[]";
|
||||
readonly name: "allOracles";
|
||||
readonly type: "address[]";
|
||||
}, {
|
||||
readonly internalType: "enum OffchainOracle.OracleType[]";
|
||||
readonly name: "oracleTypes";
|
||||
readonly type: "uint8[]";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "owner";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IERC20";
|
||||
readonly name: "connector";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "removeConnector";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract IOracle";
|
||||
readonly name: "oracle";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly internalType: "enum OffchainOracle.OracleType";
|
||||
readonly name: "oracleKind";
|
||||
readonly type: "uint8";
|
||||
}];
|
||||
readonly name: "removeOracle";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "renounceOwnership";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "contract MultiWrapper";
|
||||
readonly name: "_multiWrapper";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "setMultiWrapper";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "newOwner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "transferOwnership";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}];
|
||||
static createInterface(): OffchainOracleAbiInterface;
|
||||
static connect(address: string, signerOrProvider: Signer | Provider): OffchainOracleAbi;
|
||||
}
|
354
lib/contracts/factories/OffchainOracleAbi__factory.js
Normal file
354
lib/contracts/factories/OffchainOracleAbi__factory.js
Normal file
@ -0,0 +1,354 @@
|
||||
"use strict";
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OffchainOracleAbi__factory = void 0;
|
||||
var ethers_1 = require("ethers");
|
||||
var _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract MultiWrapper',
|
||||
name: '_multiWrapper',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'contract IOracle[]',
|
||||
name: 'existingOracles',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'enum OffchainOracle.OracleType[]',
|
||||
name: 'oracleTypes',
|
||||
type: 'uint8[]',
|
||||
},
|
||||
{
|
||||
internalType: 'contract IERC20[]',
|
||||
name: 'existingConnectors',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'wBase',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'contract IERC20',
|
||||
name: 'connector',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'ConnectorAdded',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'contract IERC20',
|
||||
name: 'connector',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'ConnectorRemoved',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'contract MultiWrapper',
|
||||
name: 'multiWrapper',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'MultiWrapperUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'contract IOracle',
|
||||
name: 'oracle',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'enum OffchainOracle.OracleType',
|
||||
name: 'oracleType',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'OracleAdded',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'contract IOracle',
|
||||
name: 'oracle',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'enum OffchainOracle.OracleType',
|
||||
name: 'oracleType',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'OracleRemoved',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'previousOwner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'OwnershipTransferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'connector',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addConnector',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IOracle',
|
||||
name: 'oracle',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'enum OffchainOracle.OracleType',
|
||||
name: 'oracleKind',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'addOracle',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'connectors',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'contract IERC20[]',
|
||||
name: 'allConnectors',
|
||||
type: 'address[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'srcToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'dstToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'useWrappers',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
name: 'getRate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'weightedRate',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'srcToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'useSrcWrappers',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
name: 'getRateToEth',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'weightedRate',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'multiWrapper',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'contract MultiWrapper',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'oracles',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'contract IOracle[]',
|
||||
name: 'allOracles',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'enum OffchainOracle.OracleType[]',
|
||||
name: 'oracleTypes',
|
||||
type: 'uint8[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'owner',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IERC20',
|
||||
name: 'connector',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeConnector',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract IOracle',
|
||||
name: 'oracle',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'enum OffchainOracle.OracleType',
|
||||
name: 'oracleKind',
|
||||
type: 'uint8',
|
||||
},
|
||||
],
|
||||
name: 'removeOracle',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'renounceOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'contract MultiWrapper',
|
||||
name: '_multiWrapper',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'setMultiWrapper',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'transferOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
||||
var OffchainOracleAbi__factory = exports.OffchainOracleAbi__factory = /** @class */ (function () {
|
||||
function OffchainOracleAbi__factory() {
|
||||
}
|
||||
OffchainOracleAbi__factory.createInterface = function () {
|
||||
return new ethers_1.utils.Interface(_abi);
|
||||
};
|
||||
OffchainOracleAbi__factory.connect = function (address, signerOrProvider) {
|
||||
return new ethers_1.Contract(address, _abi, signerOrProvider);
|
||||
};
|
||||
OffchainOracleAbi__factory.abi = _abi;
|
||||
return OffchainOracleAbi__factory;
|
||||
}());
|
||||
//# sourceMappingURL=OffchainOracleAbi__factory.js.map
|
File diff suppressed because one or more lines are too long
235
lib/contracts/factories/OptimismL1FeeOracleAbi__factory.d.ts
vendored
Normal file
235
lib/contracts/factories/OptimismL1FeeOracleAbi__factory.d.ts
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
import { Signer } from 'ethers';
|
||||
import type { Provider } from '@ethersproject/providers';
|
||||
import type { OptimismL1FeeOracleAbi, OptimismL1FeeOracleAbiInterface } from '../OptimismL1FeeOracleAbi';
|
||||
export declare class OptimismL1FeeOracleAbi__factory {
|
||||
static readonly abi: readonly [{
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "_owner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "constructor";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "DecimalsUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "GasPriceUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "L1BaseFeeUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "OverheadUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: true;
|
||||
readonly internalType: "address";
|
||||
readonly name: "previousOwner";
|
||||
readonly type: "address";
|
||||
}, {
|
||||
readonly indexed: true;
|
||||
readonly internalType: "address";
|
||||
readonly name: "newOwner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "OwnershipTransferred";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly anonymous: false;
|
||||
readonly inputs: readonly [{
|
||||
readonly indexed: false;
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "ScalarUpdated";
|
||||
readonly type: "event";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "decimals";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "gasPrice";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "_data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly name: "getL1Fee";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "bytes";
|
||||
readonly name: "_data";
|
||||
readonly type: "bytes";
|
||||
}];
|
||||
readonly name: "getL1GasUsed";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "l1BaseFee";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "overhead";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "owner";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "renounceOwnership";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [];
|
||||
readonly name: "scalar";
|
||||
readonly outputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly stateMutability: "view";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "_decimals";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "setDecimals";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "_gasPrice";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "setGasPrice";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "_baseFee";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "setL1BaseFee";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "_overhead";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "setOverhead";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "uint256";
|
||||
readonly name: "_scalar";
|
||||
readonly type: "uint256";
|
||||
}];
|
||||
readonly name: "setScalar";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}, {
|
||||
readonly inputs: readonly [{
|
||||
readonly internalType: "address";
|
||||
readonly name: "newOwner";
|
||||
readonly type: "address";
|
||||
}];
|
||||
readonly name: "transferOwnership";
|
||||
readonly outputs: readonly [];
|
||||
readonly stateMutability: "nonpayable";
|
||||
readonly type: "function";
|
||||
}];
|
||||
static createInterface(): OptimismL1FeeOracleAbiInterface;
|
||||
static connect(address: string, signerOrProvider: Signer | Provider): OptimismL1FeeOracleAbi;
|
||||
}
|
318
lib/contracts/factories/OptimismL1FeeOracleAbi__factory.js
Normal file
318
lib/contracts/factories/OptimismL1FeeOracleAbi__factory.js
Normal file
@ -0,0 +1,318 @@
|
||||
"use strict";
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OptimismL1FeeOracleAbi__factory = void 0;
|
||||
var ethers_1 = require("ethers");
|
||||
var _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_owner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'DecimalsUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'GasPriceUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'L1BaseFeeUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'OverheadUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'previousOwner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'OwnershipTransferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'ScalarUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'decimals',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'gasPrice',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: '_data',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'getL1Fee',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: '_data',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'getL1GasUsed',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'l1BaseFee',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'overhead',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'owner',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'renounceOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'scalar',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_decimals',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setDecimals',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_gasPrice',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setGasPrice',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_baseFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setL1BaseFee',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_overhead',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setOverhead',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_scalar',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setScalar',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'transferOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
||||
var OptimismL1FeeOracleAbi__factory = exports.OptimismL1FeeOracleAbi__factory = /** @class */ (function () {
|
||||
function OptimismL1FeeOracleAbi__factory() {
|
||||
}
|
||||
OptimismL1FeeOracleAbi__factory.createInterface = function () {
|
||||
return new ethers_1.utils.Interface(_abi);
|
||||
};
|
||||
OptimismL1FeeOracleAbi__factory.connect = function (address, signerOrProvider) {
|
||||
return new ethers_1.Contract(address, _abi, signerOrProvider);
|
||||
};
|
||||
OptimismL1FeeOracleAbi__factory.abi = _abi;
|
||||
return OptimismL1FeeOracleAbi__factory;
|
||||
}());
|
||||
//# sourceMappingURL=OptimismL1FeeOracleAbi__factory.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"OptimismL1FeeOracleAbi__factory.js","sourceRoot":"","sources":["../../../src/contracts/factories/OptimismL1FeeOracleAbi__factory.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,oBAAoB;AACpB,oBAAoB;;;AAEpB,iCAAiD;AAIjD,IAAM,IAAI,GAAG;IACX;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,aAAa;KACpB;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,OAAO;KACd;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,OAAO;KACd;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,OAAO;KACd;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,OAAO;KACd;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,OAAO;KACd;IACD;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,OAAO;KACd;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aACd;SACF;QACD,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aACd;SACF;QACD,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,OAAO;QACb,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;CACO,CAAC;AAEX;IAAA;IAQA,CAAC;IANQ,+CAAe,GAAtB;QACE,OAAO,IAAI,cAAK,CAAC,SAAS,CAAC,IAAI,CAAoC,CAAC;IACtE,CAAC;IACM,uCAAO,GAAd,UAAe,OAAe,EAAE,gBAAmC;QACjE,OAAO,IAAI,iBAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAA2B,CAAC;IACjF,CAAC;IANe,mCAAG,GAAG,IAAI,CAAC;IAO7B,sCAAC;CAAA,AARD,IAQC"}
|
3
lib/contracts/factories/index.d.ts
vendored
Normal file
3
lib/contracts/factories/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export { MulticallAbi__factory } from './MulticallAbi__factory';
|
||||
export { OffchainOracleAbi__factory } from './OffchainOracleAbi__factory';
|
||||
export { OptimismL1FeeOracleAbi__factory } from './OptimismL1FeeOracleAbi__factory';
|
13
lib/contracts/factories/index.js
Normal file
13
lib/contracts/factories/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OptimismL1FeeOracleAbi__factory = exports.OffchainOracleAbi__factory = exports.MulticallAbi__factory = void 0;
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
var MulticallAbi__factory_1 = require("./MulticallAbi__factory");
|
||||
Object.defineProperty(exports, "MulticallAbi__factory", { enumerable: true, get: function () { return MulticallAbi__factory_1.MulticallAbi__factory; } });
|
||||
var OffchainOracleAbi__factory_1 = require("./OffchainOracleAbi__factory");
|
||||
Object.defineProperty(exports, "OffchainOracleAbi__factory", { enumerable: true, get: function () { return OffchainOracleAbi__factory_1.OffchainOracleAbi__factory; } });
|
||||
var OptimismL1FeeOracleAbi__factory_1 = require("./OptimismL1FeeOracleAbi__factory");
|
||||
Object.defineProperty(exports, "OptimismL1FeeOracleAbi__factory", { enumerable: true, get: function () { return OptimismL1FeeOracleAbi__factory_1.OptimismL1FeeOracleAbi__factory; } });
|
||||
//# sourceMappingURL=index.js.map
|
1
lib/contracts/factories/index.js.map
Normal file
1
lib/contracts/factories/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contracts/factories/index.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,oBAAoB;AACpB,oBAAoB;AACpB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2EAA0E;AAAjE,wIAAA,0BAA0B,OAAA;AACnC,qFAAoF;AAA3E,kJAAA,+BAA+B,OAAA"}
|
7
lib/contracts/index.d.ts
vendored
Normal file
7
lib/contracts/index.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
export type { MulticallAbi } from './MulticallAbi';
|
||||
export type { OffchainOracleAbi } from './OffchainOracleAbi';
|
||||
export type { OptimismL1FeeOracleAbi } from './OptimismL1FeeOracleAbi';
|
||||
export * as factories from './factories';
|
||||
export { MulticallAbi__factory } from './factories/MulticallAbi__factory';
|
||||
export { OffchainOracleAbi__factory } from './factories/OffchainOracleAbi__factory';
|
||||
export { OptimismL1FeeOracleAbi__factory } from './factories/OptimismL1FeeOracleAbi__factory';
|
34
lib/contracts/index.js
Normal file
34
lib/contracts/index.js
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OptimismL1FeeOracleAbi__factory = exports.OffchainOracleAbi__factory = exports.MulticallAbi__factory = exports.factories = void 0;
|
||||
exports.factories = __importStar(require("./factories"));
|
||||
var MulticallAbi__factory_1 = require("./factories/MulticallAbi__factory");
|
||||
Object.defineProperty(exports, "MulticallAbi__factory", { enumerable: true, get: function () { return MulticallAbi__factory_1.MulticallAbi__factory; } });
|
||||
var OffchainOracleAbi__factory_1 = require("./factories/OffchainOracleAbi__factory");
|
||||
Object.defineProperty(exports, "OffchainOracleAbi__factory", { enumerable: true, get: function () { return OffchainOracleAbi__factory_1.OffchainOracleAbi__factory; } });
|
||||
var OptimismL1FeeOracleAbi__factory_1 = require("./factories/OptimismL1FeeOracleAbi__factory");
|
||||
Object.defineProperty(exports, "OptimismL1FeeOracleAbi__factory", { enumerable: true, get: function () { return OptimismL1FeeOracleAbi__factory_1.OptimismL1FeeOracleAbi__factory; } });
|
||||
//# sourceMappingURL=index.js.map
|
1
lib/contracts/index.js.map
Normal file
1
lib/contracts/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,yDAAyC;AACzC,2EAA0E;AAAjE,8HAAA,qBAAqB,OAAA;AAC9B,qFAAoF;AAA3E,wIAAA,0BAA0B,OAAA;AACnC,+FAA8F;AAArF,kJAAA,+BAA+B,OAAA"}
|
122
lib/feeOracle.d.ts
vendored
Normal file
122
lib/feeOracle.d.ts
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
import { BigNumberish } from 'ethers';
|
||||
import { TransactionData, TxType, ITornadoFeeOracle, LegacyGasPriceKey, GasPriceParams, GetGasParamsRes, HexadecimalStringifiedNumber, GetGasInput, GetGasParamsInput } from './types';
|
||||
import { JsonRpcProvider } from '@ethersproject/providers';
|
||||
import { ChainId, InstanceTokenSymbol } from './config';
|
||||
import { GetWithdrawalFeeViaRelayerInput } from './types';
|
||||
export declare abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
version: 4 | 5 | 6;
|
||||
protected chainId: ChainId;
|
||||
protected provider: JsonRpcProvider;
|
||||
constructor(version: 4 | 5 | 6, chainId: ChainId, rpcUrl: string);
|
||||
/**
|
||||
* Because Optimism transaction published on Mainnet, for each OP transaction we need to calculate L1 security fee:
|
||||
* https://community.optimism.io/docs/developers/build/transaction-fees/#priority-fee
|
||||
* @param {TransactionData} [tx] Transaction data to estimate L1 additional fee
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (MATIC), '0' if chain is not Optimism
|
||||
*/
|
||||
fetchL1OptimismFee(tx?: TransactionData): Promise<HexadecimalStringifiedNumber>;
|
||||
/**
|
||||
* Estimate gas price, gas limit and l1Fee for sidechain (if exists)
|
||||
* @param {GetGasParamsInput} [params] Function input arguments object
|
||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||
* @param {TxType} [params.txType=other] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.predefinedGasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
* @param {number} [params.bumpGasLimitPercent] Gas limit bump percent to prioritize transaction (if gas limit not predefined, recenlty used)
|
||||
* @param {number} [params.bumpGasPricePercent] Gas price bump percent to prioritize transaction (if gas limit not predefined, rarely used)
|
||||
* @param {LegacyGasPriceKey} [params.speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {boolean} [params.includeL1FeeToGasLimit=true] Include L1 additional fee on Optimism to gas limit (get fee and divide by gas price)
|
||||
* @returns {Promise<GetGasParamsRes>} Object with fields 'gasPrice' and 'gasLimit', L1 fee, if exists, included in gasLimit
|
||||
*/
|
||||
getGasParams(params?: GetGasParamsInput): Promise<GetGasParamsRes>;
|
||||
/**
|
||||
* Estimates next block gas for signed, unsigned or incomplete Tornado transaction
|
||||
* @param {GetGasInput} [params] Function input arguments object
|
||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||
* @param {TxType} [params.txType] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.predefinedGasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
* @param {number} [params.bumpGasLimitPercent] Gas limit bump percent to prioritize transaction (if gas limit not predefined, recenlty used)
|
||||
* @param {number} [params.bumpGasPricePercent] Gas price bump percent to prioritize transaction (if gas price not predefined, rarely used)
|
||||
* @param {LegacyGasPriceKey} [params.speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Gas value in WEI (hex-format)
|
||||
*/
|
||||
getGas(params?: GetGasInput): Promise<HexadecimalStringifiedNumber>;
|
||||
/**
|
||||
* Estimate next block gas price
|
||||
* @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {number} [bumpPercent=0] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<GasPriceParams>} Estimated gas price info in WEI (hexed) - legacy object with gasPrice property or
|
||||
* EIP-1559 object with maxFeePerGas and maxPriorityFeePerGas properties
|
||||
* NOTICE: It is recommended to bump fees for EIP-1559 transactions, because they can bump 12.5% per block
|
||||
*/
|
||||
getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams>;
|
||||
/**
|
||||
* Estimate next block gas price
|
||||
* @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {number} [bumpPercent] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Gas price in WEI (hex string)
|
||||
*/
|
||||
getGasPrice(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<HexadecimalStringifiedNumber>;
|
||||
/**
|
||||
* Estimates gas limit for transaction (or basic gas limit, if no tx data provided)
|
||||
* @param {TransactionData} [tx] Transaction data (object in web3 / ethers format)
|
||||
* @param {TxType} [type] Tornado transaction type: withdrawal by user, withdrawal by relayer, relayer fee check or 'other'
|
||||
* @param {number} [bumpPercent] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<number>} Gas limit
|
||||
*/
|
||||
abstract getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||
/**
|
||||
* If user withdraw non-native tokens on ETH or Goerli, we need to calculate refund value:
|
||||
* if the withdrawal is successful, this amount will be returned to the user after the transfer to the relayer,
|
||||
* and if the relayer pays a commission and the transfer of tokens fails, this commission will remain to the relayer.
|
||||
*
|
||||
* Refund needed that recipient can use tokens after withdrawal (covers gas fee for send/swap)
|
||||
* @param {BigNumberish} gasPrice Actual gas price
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {HexadecimalStringifiedNumber} Refund amount in WEI (in hex format)
|
||||
*/
|
||||
calculateRefundInETH(gasPrice: BigNumberish, tokenSymbol: InstanceTokenSymbol): HexadecimalStringifiedNumber;
|
||||
/**
|
||||
* Fetched actual gas price and calculates refund amount
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Refund amount in WEI (in hex format)
|
||||
*/
|
||||
fetchRefundInETH(tokenSymbol: InstanceTokenSymbol): Promise<HexadecimalStringifiedNumber>;
|
||||
/**
|
||||
* Get refund amount on ETH or Goerli in non-native token
|
||||
* @param {BigNumberish} gasPrice Actual gas price in ETH
|
||||
* @param {BigNumberish} tokenPriceInEth Token price in WEI in ETH
|
||||
* @param {HexadecimalStringifiedNumber | number} tokenDecimals Token (currency) decimals
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {HexadecimalStringifiedNumber} Refund amount in WEI in selected token (hexed number)
|
||||
*/
|
||||
calculateRefundInToken(gasPrice: BigNumberish, tokenPriceInEth: BigNumberish, tokenDecimals: HexadecimalStringifiedNumber | number, tokenSymbol: InstanceTokenSymbol): HexadecimalStringifiedNumber;
|
||||
/**
|
||||
* Calculates relayer fee in selected currency (ETH, DAI, BNB etc) in WEI
|
||||
* @param {number | string} relayerFeePercent Relayer percent (0.4 for ETH Mainnet, for example)
|
||||
* @param {HexadecimalStringifiedNumber | number} amount Amount in selected currency (10 for 10 ETH, 1000 for 1000 DAI)
|
||||
* @param {string | number} decimals Decimal places in selected token (currency)
|
||||
* @returns {HexadecimalStringifiedNumber} Fee in WEI (hexed stingified number)
|
||||
*/
|
||||
calculateRelayerFeeInWei(relayerFeePercent: number | string, amount: HexadecimalStringifiedNumber | number, decimals: string | number): HexadecimalStringifiedNumber;
|
||||
/**
|
||||
* Estimates fee for withdrawal via relayer depending on type: gas bump percent is bigger, if it calculates by user,
|
||||
* so that the real commission from the relayer side is a little less,
|
||||
* in order to the relayer can send a transaction without fear that he will go into the red
|
||||
* @param {GetWithdrawalFeeViaRelayerInput} params Function input arguments object
|
||||
* @param {TxType} params.txType Tornado transaction type: withdrawal costs calculation from user side or from relayer side
|
||||
* @param {TransactionData} [params.tx] Transaction data (object in web3 / ethers format)
|
||||
* @param {number} params.relayerFeePercent Relayer fee percent from the transaction amount (for example, 0.15 for BNB or 0.4 for ETH Mainnet)
|
||||
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
||||
* @param {number | HexadecimalStringifiedNumber } params.amount Withdrawal amount in selected currency
|
||||
* @param {number | HexadecimalStringifiedNumber } params.decimals Token (currency) decimals
|
||||
* @param {BigNumberish} [params.refundInEth] Refund in ETH, if withdrawed other tokens on Mainnet (not ETH). Can not be provided, if user-side calculation
|
||||
* @param {BigNumberish} [params.tokenPriceInEth] If withdrawing other token on Mainnet or Goerli, need to provide token price in ETH (in WEI)
|
||||
* @param {number} [params.gasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.gasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
*
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
|
||||
*/
|
||||
calculateWithdrawalFeeViaRelayer({ tx, txType, relayerFeePercent, currency, amount, decimals, refundInEth, tokenPriceInEth, predefinedGasLimit, predefinedGasPrice, }: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber>;
|
||||
}
|
374
lib/feeOracle.js
Normal file
374
lib/feeOracle.js
Normal file
@ -0,0 +1,374 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TornadoFeeOracle = void 0;
|
||||
var ethers_1 = require("ethers");
|
||||
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
var utils_1 = require("ethers/lib/utils");
|
||||
var config_1 = require("./config");
|
||||
var utils_2 = require("./utils");
|
||||
var factories_1 = require("./contracts/factories");
|
||||
var TornadoFeeOracle = /** @class */ (function () {
|
||||
function TornadoFeeOracle(version, chainId, rpcUrl) {
|
||||
this.version = version;
|
||||
this.chainId = chainId;
|
||||
this.provider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrl);
|
||||
}
|
||||
/**
|
||||
* Because Optimism transaction published on Mainnet, for each OP transaction we need to calculate L1 security fee:
|
||||
* https://community.optimism.io/docs/developers/build/transaction-fees/#priority-fee
|
||||
* @param {TransactionData} [tx] Transaction data to estimate L1 additional fee
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (MATIC), '0' if chain is not Optimism
|
||||
*/
|
||||
TornadoFeeOracle.prototype.fetchL1OptimismFee = function (tx) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var optimismL1FeeOracle, l1Fee;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (this.chainId != config_1.ChainId.OPTIMISM)
|
||||
return [2 /*return*/, ethers_1.BigNumber.from(0).toHexString()];
|
||||
optimismL1FeeOracle = (0, factories_1.getOptimismL1FeeOracle)(this.provider);
|
||||
return [4 /*yield*/, optimismL1FeeOracle.getL1Fee((0, utils_2.serializeTx)(tx))];
|
||||
case 1:
|
||||
l1Fee = _a.sent();
|
||||
return [2 /*return*/, l1Fee.toHexString()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Estimate gas price, gas limit and l1Fee for sidechain (if exists)
|
||||
* @param {GetGasParamsInput} [params] Function input arguments object
|
||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||
* @param {TxType} [params.txType=other] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.predefinedGasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
* @param {number} [params.bumpGasLimitPercent] Gas limit bump percent to prioritize transaction (if gas limit not predefined, recenlty used)
|
||||
* @param {number} [params.bumpGasPricePercent] Gas price bump percent to prioritize transaction (if gas limit not predefined, rarely used)
|
||||
* @param {LegacyGasPriceKey} [params.speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {boolean} [params.includeL1FeeToGasLimit=true] Include L1 additional fee on Optimism to gas limit (get fee and divide by gas price)
|
||||
* @returns {Promise<GetGasParamsRes>} Object with fields 'gasPrice' and 'gasLimit', L1 fee, if exists, included in gasLimit
|
||||
*/
|
||||
TornadoFeeOracle.prototype.getGasParams = function (params) {
|
||||
if (params === void 0) { params = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var tx, _a, txType, bumpGasLimitPercent, bumpGasPricePercent, gasLimit, gasPrice, speed, _b, includeL1FeeToGasLimit, l1Fee;
|
||||
var _c, _d;
|
||||
return __generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
tx = params.tx, _a = params.txType, txType = _a === void 0 ? 'other' : _a, bumpGasLimitPercent = params.bumpGasLimitPercent, bumpGasPricePercent = params.bumpGasPricePercent, gasLimit = params.predefinedGasLimit, gasPrice = params.predefinedGasPrice, speed = params.speed, _b = params.includeL1FeeToGasLimit, includeL1FeeToGasLimit = _b === void 0 ? true : _b;
|
||||
l1Fee = '0';
|
||||
if (!(!gasLimit && !gasPrice)) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, Promise.all([
|
||||
this.getGasPrice(speed, bumpGasPricePercent),
|
||||
this.getGasLimit(tx, txType, bumpGasLimitPercent),
|
||||
this.fetchL1OptimismFee(tx),
|
||||
])];
|
||||
case 1:
|
||||
_c = _e.sent(), gasPrice = _c[0], gasLimit = _c[1], l1Fee = _c[2];
|
||||
_e.label = 2;
|
||||
case 2:
|
||||
if (!!gasLimit) return [3 /*break*/, 4];
|
||||
return [4 /*yield*/, Promise.all([
|
||||
this.getGasLimit(tx, txType, bumpGasLimitPercent),
|
||||
this.fetchL1OptimismFee(tx),
|
||||
])];
|
||||
case 3:
|
||||
_d = _e.sent(), gasLimit = _d[0], l1Fee = _d[1];
|
||||
_e.label = 4;
|
||||
case 4:
|
||||
if (!!gasPrice) return [3 /*break*/, 6];
|
||||
return [4 /*yield*/, this.getGasPrice(speed, bumpGasPricePercent)];
|
||||
case 5:
|
||||
gasPrice = _e.sent();
|
||||
_e.label = 6;
|
||||
case 6:
|
||||
if (includeL1FeeToGasLimit)
|
||||
// Include L1 fee in gas limit (divide by gas price before), if l1 fee is 0, gas limit wont change
|
||||
gasLimit = (0, bignumber_js_1.default)(gasLimit)
|
||||
.plus((0, bignumber_js_1.default)(l1Fee).div((0, bignumber_js_1.default)(gasPrice)))
|
||||
.decimalPlaces(0, 1)
|
||||
.toNumber();
|
||||
return [2 /*return*/, { gasLimit: gasLimit, gasPrice: gasPrice }];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Estimates next block gas for signed, unsigned or incomplete Tornado transaction
|
||||
* @param {GetGasInput} [params] Function input arguments object
|
||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||
* @param {TxType} [params.txType] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.predefinedGasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
* @param {number} [params.bumpGasLimitPercent] Gas limit bump percent to prioritize transaction (if gas limit not predefined, recenlty used)
|
||||
* @param {number} [params.bumpGasPricePercent] Gas price bump percent to prioritize transaction (if gas price not predefined, rarely used)
|
||||
* @param {LegacyGasPriceKey} [params.speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Gas value in WEI (hex-format)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.getGas = function (params) {
|
||||
if (params === void 0) { params = {}; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a, gasPrice, gasLimit;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0: return [4 /*yield*/, this.getGasParams(__assign(__assign({}, params), { includeL1FeeToGasLimit: true }))];
|
||||
case 1:
|
||||
_a = _b.sent(), gasPrice = _a.gasPrice, gasLimit = _a.gasLimit;
|
||||
return [2 /*return*/, ethers_1.BigNumber.from(gasPrice).mul(gasLimit).toHexString()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Estimate next block gas price
|
||||
* @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {number} [bumpPercent=0] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<GasPriceParams>} Estimated gas price info in WEI (hexed) - legacy object with gasPrice property or
|
||||
* EIP-1559 object with maxFeePerGas and maxPriorityFeePerGas properties
|
||||
* NOTICE: It is recommended to bump fees for EIP-1559 transactions, because they can bump 12.5% per block
|
||||
*/
|
||||
TornadoFeeOracle.prototype.getGasPriceParams = function (speed, bumpPercent) {
|
||||
var _a;
|
||||
if (bumpPercent === void 0) { bumpPercent = 0; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _b, block, gasPrice, priorityFee, maxPriorityFeePerGas, maxFeePerGas, e_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
// Use instant for BSC, because on this chain "fast" and "instant" differs more than third and "fast" transaction can take hours
|
||||
if (!speed)
|
||||
speed = this.chainId === config_1.ChainId.BSC ? 'instant' : 'fast';
|
||||
_c.label = 1;
|
||||
case 1:
|
||||
_c.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, Promise.all([
|
||||
this.provider.getBlock('latest'),
|
||||
this.provider.getGasPrice(),
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var _a, _b, _c;
|
||||
return __generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
case 0:
|
||||
_d.trys.push([0, 2, , 3]);
|
||||
_b = (_a = ethers_1.BigNumber).from;
|
||||
return [4 /*yield*/, this.provider.send('eth_maxPriorityFeePerGas', [])];
|
||||
case 1: return [2 /*return*/, _b.apply(_a, [(_d.sent()) || (0, utils_1.parseUnits)('1.5', 'gwei')])];
|
||||
case 2:
|
||||
_c = _d.sent();
|
||||
return [2 /*return*/, (0, utils_1.parseUnits)('1.5', 'gwei')];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })(),
|
||||
])];
|
||||
case 2:
|
||||
_b = _c.sent(), block = _b[0], gasPrice = _b[1], priorityFee = _b[2];
|
||||
if ((_a = block === null || block === void 0 ? void 0 : block.baseFeePerGas) === null || _a === void 0 ? void 0 : _a.gt(0)) {
|
||||
maxPriorityFeePerGas = priorityFee.toHexString();
|
||||
maxFeePerGas = (0, utils_2.bump)(block.baseFeePerGas, bumpPercent)
|
||||
.add(priorityFee)
|
||||
.toHexString();
|
||||
return [2 /*return*/, {
|
||||
maxFeePerGas: maxFeePerGas,
|
||||
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
||||
}];
|
||||
}
|
||||
return [2 /*return*/, {
|
||||
gasPrice: (0, utils_2.bump)(gasPrice, bumpPercent).toHexString(),
|
||||
}];
|
||||
case 3:
|
||||
e_1 = _c.sent();
|
||||
return [2 /*return*/, { gasPrice: (0, utils_2.bump)((0, utils_2.fromGweiToWeiHex)(config_1.defaultGasPrices[this.chainId][speed]), bumpPercent).toHexString() }];
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Estimate next block gas price
|
||||
* @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||
* @param {number} [bumpPercent] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Gas price in WEI (hex string)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.getGasPrice = function (speed, bumpPercent) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var gasPriceParams;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getGasPriceParams(speed, bumpPercent)];
|
||||
case 1:
|
||||
gasPriceParams = _a.sent();
|
||||
return [2 /*return*/, (0, utils_2.calculateGasPriceInWei)(gasPriceParams).toHexString()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* If user withdraw non-native tokens on ETH or Goerli, we need to calculate refund value:
|
||||
* if the withdrawal is successful, this amount will be returned to the user after the transfer to the relayer,
|
||||
* and if the relayer pays a commission and the transfer of tokens fails, this commission will remain to the relayer.
|
||||
*
|
||||
* Refund needed that recipient can use tokens after withdrawal (covers gas fee for send/swap)
|
||||
* @param {BigNumberish} gasPrice Actual gas price
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {HexadecimalStringifiedNumber} Refund amount in WEI (in hex format)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.calculateRefundInETH = function (gasPrice, tokenSymbol) {
|
||||
// Refund only available for non-native tokens on Ethereum Mainnet and Goerli
|
||||
if (![config_1.ChainId.MAINNET, config_1.ChainId.GOERLI].includes(this.chainId) || tokenSymbol === 'eth')
|
||||
return '0';
|
||||
// Notify user about error if incorrect token symbol provided
|
||||
if (!Object.values(config_1.InstanceTokenSymbol).includes(tokenSymbol)) {
|
||||
console.error("Invalid token symbol: ".concat(tokenSymbol, ", must be lowercase token from one of Tornado ETH Mainnet pools"));
|
||||
return '0';
|
||||
}
|
||||
// In Tornado we need to calculate refund only on user side, relayer get refund value in proof
|
||||
var gasLimit = config_1.defaultInstanceTokensGasLimit[tokenSymbol];
|
||||
return ethers_1.BigNumber.from(gasPrice).mul(gasLimit).mul(2).toHexString();
|
||||
};
|
||||
/**
|
||||
* Fetched actual gas price and calculates refund amount
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Refund amount in WEI (in hex format)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.fetchRefundInETH = function (tokenSymbol) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var gasPrice;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.getGasPrice()];
|
||||
case 1:
|
||||
gasPrice = _a.sent();
|
||||
return [2 /*return*/, this.calculateRefundInETH(gasPrice, tokenSymbol)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Get refund amount on ETH or Goerli in non-native token
|
||||
* @param {BigNumberish} gasPrice Actual gas price in ETH
|
||||
* @param {BigNumberish} tokenPriceInEth Token price in WEI in ETH
|
||||
* @param {HexadecimalStringifiedNumber | number} tokenDecimals Token (currency) decimals
|
||||
* @param {InstanceTokenSymbol} tokenSymbol Withdrawal token (currency) symbol - for example, 'dai'
|
||||
* @returns {HexadecimalStringifiedNumber} Refund amount in WEI in selected token (hexed number)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.calculateRefundInToken = function (gasPrice, tokenPriceInEth, tokenDecimals, tokenSymbol) {
|
||||
var refundInEth = this.calculateRefundInETH(gasPrice, tokenSymbol);
|
||||
return (0, utils_2.convertETHToToken)(refundInEth, tokenDecimals, tokenPriceInEth).toHexString();
|
||||
};
|
||||
/**
|
||||
* Calculates relayer fee in selected currency (ETH, DAI, BNB etc) in WEI
|
||||
* @param {number | string} relayerFeePercent Relayer percent (0.4 for ETH Mainnet, for example)
|
||||
* @param {HexadecimalStringifiedNumber | number} amount Amount in selected currency (10 for 10 ETH, 1000 for 1000 DAI)
|
||||
* @param {string | number} decimals Decimal places in selected token (currency)
|
||||
* @returns {HexadecimalStringifiedNumber} Fee in WEI (hexed stingified number)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.calculateRelayerFeeInWei = function (relayerFeePercent, amount, decimals) {
|
||||
return (0, utils_1.parseUnits)(amount.toString(), decimals)
|
||||
.mul("".concat(Math.floor(Number(relayerFeePercent) * 1e10)))
|
||||
.div("".concat(100 * 1e10))
|
||||
.toHexString();
|
||||
};
|
||||
/**
|
||||
* Estimates fee for withdrawal via relayer depending on type: gas bump percent is bigger, if it calculates by user,
|
||||
* so that the real commission from the relayer side is a little less,
|
||||
* in order to the relayer can send a transaction without fear that he will go into the red
|
||||
* @param {GetWithdrawalFeeViaRelayerInput} params Function input arguments object
|
||||
* @param {TxType} params.txType Tornado transaction type: withdrawal costs calculation from user side or from relayer side
|
||||
* @param {TransactionData} [params.tx] Transaction data (object in web3 / ethers format)
|
||||
* @param {number} params.relayerFeePercent Relayer fee percent from the transaction amount (for example, 0.15 for BNB or 0.4 for ETH Mainnet)
|
||||
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
||||
* @param {number | HexadecimalStringifiedNumber } params.amount Withdrawal amount in selected currency
|
||||
* @param {number | HexadecimalStringifiedNumber } params.decimals Token (currency) decimals
|
||||
* @param {BigNumberish} [params.refundInEth] Refund in ETH, if withdrawed other tokens on Mainnet (not ETH). Can not be provided, if user-side calculation
|
||||
* @param {BigNumberish} [params.tokenPriceInEth] If withdrawing other token on Mainnet or Goerli, need to provide token price in ETH (in WEI)
|
||||
* @param {number} [params.gasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||
* @param {number} [params.gasPrice] Predefined gas price, if already calculated (no refetching)
|
||||
*
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.calculateWithdrawalFeeViaRelayer = function (_a) {
|
||||
var tx = _a.tx, txType = _a.txType, relayerFeePercent = _a.relayerFeePercent, currency = _a.currency, amount = _a.amount, decimals = _a.decimals, refundInEth = _a.refundInEth, tokenPriceInEth = _a.tokenPriceInEth, predefinedGasLimit = _a.predefinedGasLimit, predefinedGasPrice = _a.predefinedGasPrice;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var relayerFee, _b, gasPrice, gasLimit, gasCosts, hasTokenPrice, feeInEth;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
relayerFee = this.calculateRelayerFeeInWei(relayerFeePercent, amount, decimals);
|
||||
return [4 /*yield*/, this.getGasParams({ tx: tx, txType: txType, predefinedGasLimit: predefinedGasLimit, predefinedGasPrice: predefinedGasPrice })];
|
||||
case 1:
|
||||
_b = _c.sent(), gasPrice = _b.gasPrice, gasLimit = _b.gasLimit;
|
||||
gasCosts = ethers_1.BigNumber.from(gasPrice).mul(gasLimit);
|
||||
hasTokenPrice = typeof tokenPriceInEth === 'object' && typeof (tokenPriceInEth === null || tokenPriceInEth === void 0 ? void 0 : tokenPriceInEth.gt) === 'function'
|
||||
? Boolean(tokenPriceInEth.gt(0))
|
||||
: Boolean(tokenPriceInEth);
|
||||
if (hasTokenPrice) {
|
||||
if (txType === 'user_withdrawal' && refundInEth === undefined)
|
||||
refundInEth = this.calculateRefundInETH(gasPrice, currency.toLowerCase());
|
||||
feeInEth = ethers_1.BigNumber.from(gasCosts).add(refundInEth || 0);
|
||||
return [2 /*return*/, (0, utils_2.convertETHToToken)(feeInEth, decimals, tokenPriceInEth)
|
||||
.add(relayerFee)
|
||||
.toHexString()];
|
||||
}
|
||||
return [2 /*return*/, ethers_1.BigNumber.from(gasCosts).add(relayerFee).toHexString()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return TornadoFeeOracle;
|
||||
}());
|
||||
exports.TornadoFeeOracle = TornadoFeeOracle;
|
||||
//# sourceMappingURL=feeOracle.js.map
|
1
lib/feeOracle.js.map
Normal file
1
lib/feeOracle.js.map
Normal file
File diff suppressed because one or more lines are too long
9
lib/feeOracleV4.d.ts
vendored
Normal file
9
lib/feeOracleV4.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType } from './types';
|
||||
/**
|
||||
* Oracle for V4 (old-version) transactions - estimates fee with predefined gas limit and without smart bumping
|
||||
*/
|
||||
export declare class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
constructor(chainId: number, rpcUrl: string);
|
||||
getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||
}
|
96
lib/feeOracleV4.js
Normal file
96
lib/feeOracleV4.js
Normal file
@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TornadoFeeOracleV4 = void 0;
|
||||
var config_1 = require("./config");
|
||||
var feeOracle_1 = require("./feeOracle");
|
||||
var utils_1 = require("./utils");
|
||||
/**
|
||||
* Oracle for V4 (old-version) transactions - estimates fee with predefined gas limit and without smart bumping
|
||||
*/
|
||||
var TornadoFeeOracleV4 = /** @class */ (function (_super) {
|
||||
__extends(TornadoFeeOracleV4, _super);
|
||||
function TornadoFeeOracleV4(chainId, rpcUrl) {
|
||||
return _super.call(this, 4, chainId, rpcUrl) || this;
|
||||
}
|
||||
TornadoFeeOracleV4.prototype.getGasLimit = function (tx, type, bumpPercent) {
|
||||
if (type === void 0) { type = 'other'; }
|
||||
if (bumpPercent === void 0) { bumpPercent = 0; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
if (type === 'user_withdrawal')
|
||||
return [2 /*return*/, (0, utils_1.bump)(config_1.defaultWithdrawalGasLimit[this.chainId], bumpPercent).toNumber()];
|
||||
// Need to bump relayer gas limit for transaction, because predefined gas limit to small to be 100% sure that transaction will be sent
|
||||
// This leads to fact that relayer often pays extra for gas from his own funds, however, this was designed by previous developers
|
||||
if (type === 'relayer_withdrawal')
|
||||
return [2 /*return*/, (0, utils_1.bump)(config_1.defaultWithdrawalGasLimit[this.chainId], bumpPercent || 25).toNumber()];
|
||||
// For compatibility reasons, when wee check user-provided fee for V4 withdrawal transaction, we need dump gas limit
|
||||
// for about 20 percent,so that the transaction will be sent, even if it results in some loss for the relayer
|
||||
if (type === 'relayer_withdrawal_check_v4')
|
||||
return [2 /*return*/, (0, utils_1.bump)(config_1.defaultWithdrawalGasLimit[this.chainId], -25).toNumber()];
|
||||
if (!tx || Object.keys(tx).length === 0)
|
||||
return [2 /*return*/, (0, utils_1.bump)(23000, bumpPercent).toNumber()];
|
||||
_a = utils_1.bump;
|
||||
return [4 /*yield*/, this.provider.estimateGas(tx)];
|
||||
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), bumpPercent]).toNumber()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return TornadoFeeOracleV4;
|
||||
}(feeOracle_1.TornadoFeeOracle));
|
||||
exports.TornadoFeeOracleV4 = TornadoFeeOracleV4;
|
||||
//# sourceMappingURL=feeOracleV4.js.map
|
1
lib/feeOracleV4.js.map
Normal file
1
lib/feeOracleV4.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"feeOracleV4.js","sourceRoot":"","sources":["../src/feeOracleV4.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqD;AACrD,yCAA+C;AAE/C,iCAA+B;AAE/B;;GAEG;AACH;IAAwC,sCAAgB;IACtD,4BAAmB,OAAe,EAAE,MAAc;eAChD,kBAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC;IAC3B,CAAC;IAEK,wCAAW,GAAjB,UAAkB,EAAoB,EAAE,IAAsB,EAAE,WAAuB;QAA/C,qBAAA,EAAA,cAAsB;QAAE,4BAAA,EAAA,eAAuB;;;;;;wBACrF,IAAI,IAAI,KAAK,iBAAiB;4BAAE,sBAAO,IAAA,YAAI,EAAC,kCAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAC;wBAE7G,sIAAsI;wBACtI,iIAAiI;wBACjI,IAAI,IAAI,KAAK,oBAAoB;4BAC/B,sBAAO,IAAA,YAAI,EAAC,kCAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC;wBACrF,oHAAoH;wBACpH,6GAA6G;wBAC7G,IAAI,IAAI,KAAK,6BAA6B;4BAAE,sBAAO,IAAA,YAAI,EAAC,kCAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC;wBACjH,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC;4BAAE,sBAAO,IAAA,YAAI,EAAC,KAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAC;wBAE9E,KAAA,YAAI,CAAA;wBAAC,qBAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAA;4BAA/C,sBAAO,kBAAK,SAAmC,EAAE,WAAW,EAAC,CAAC,QAAQ,EAAE,EAAC;;;;KAC1E;IACH,yBAAC;AAAD,CAAC,AAnBD,CAAwC,4BAAgB,GAmBvD;AAnBY,gDAAkB"}
|
11
lib/feeOracleV5.d.ts
vendored
Normal file
11
lib/feeOracleV5.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPriceKey, GasPriceParams } from './types';
|
||||
/**
|
||||
* Oracle for new V5 version - estimates transaction fees with smart gas limit & bumping
|
||||
*/
|
||||
export declare class TornadoFeeOracleV5 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
private fallbackFeeOracle;
|
||||
constructor(chainId: number, rpcUrl: string);
|
||||
getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||
getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams>;
|
||||
}
|
127
lib/feeOracleV5.js
Normal file
127
lib/feeOracleV5.js
Normal file
@ -0,0 +1,127 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TornadoFeeOracleV5 = void 0;
|
||||
var config_1 = require("./config");
|
||||
var feeOracle_1 = require("./feeOracle");
|
||||
var utils_1 = require("./utils");
|
||||
var feeOracleV4_1 = require("./feeOracleV4");
|
||||
/**
|
||||
* Oracle for new V5 version - estimates transaction fees with smart gas limit & bumping
|
||||
*/
|
||||
var TornadoFeeOracleV5 = /** @class */ (function (_super) {
|
||||
__extends(TornadoFeeOracleV5, _super);
|
||||
function TornadoFeeOracleV5(chainId, rpcUrl) {
|
||||
var _this = _super.call(this, 5, chainId, rpcUrl) || this;
|
||||
_this.fallbackFeeOracle = new feeOracleV4_1.TornadoFeeOracleV4(chainId, rpcUrl);
|
||||
return _this;
|
||||
}
|
||||
TornadoFeeOracleV5.prototype.getGasLimit = function (tx, type, bumpPercent) {
|
||||
if (type === void 0) { type = 'other'; }
|
||||
if (bumpPercent === void 0) { bumpPercent = 20; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var fetchedGasLimit, e_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!tx || Object.keys(tx).length === 0)
|
||||
return [2 /*return*/, this.fallbackFeeOracle.getGasLimit(tx, type, bumpPercent)];
|
||||
/* Relayer gas limit must be lower so that fluctuations in gas price cannot lead to the fact that
|
||||
* the relayer will actually pay for gas more than the money allocated for this by the user
|
||||
* (that is, in fact, relayer will pay for gas from his own money, unless we make the bump percent less for him)
|
||||
*/
|
||||
if (type === 'relayer_withdrawal')
|
||||
bumpPercent = 10;
|
||||
if (type === 'user_withdrawal')
|
||||
bumpPercent = 30;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.provider.estimateGas(tx)];
|
||||
case 2:
|
||||
fetchedGasLimit = _a.sent();
|
||||
return [2 /*return*/, (0, utils_1.bump)(fetchedGasLimit, bumpPercent).toNumber()];
|
||||
case 3:
|
||||
e_1 = _a.sent();
|
||||
return [2 /*return*/, this.fallbackFeeOracle.getGasLimit(tx, type, bumpPercent)];
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
TornadoFeeOracleV5.prototype.getGasPriceParams = function (speed, bumpPercent) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
// Only if bump percent didn't provided (if user provides 0, no need to recalculate)
|
||||
if (bumpPercent === undefined) {
|
||||
switch (this.chainId) {
|
||||
case config_1.ChainId.GOERLI:
|
||||
bumpPercent = 100;
|
||||
break;
|
||||
case config_1.ChainId.POLYGON:
|
||||
case config_1.ChainId.AVAX:
|
||||
case config_1.ChainId.XDAI:
|
||||
bumpPercent = 30;
|
||||
break;
|
||||
default:
|
||||
bumpPercent = 10;
|
||||
}
|
||||
}
|
||||
return [2 /*return*/, _super.prototype.getGasPriceParams.call(this, speed, bumpPercent)];
|
||||
});
|
||||
});
|
||||
};
|
||||
return TornadoFeeOracleV5;
|
||||
}(feeOracle_1.TornadoFeeOracle));
|
||||
exports.TornadoFeeOracleV5 = TornadoFeeOracleV5;
|
||||
//# sourceMappingURL=feeOracleV5.js.map
|
1
lib/feeOracleV5.js.map
Normal file
1
lib/feeOracleV5.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"feeOracleV5.js","sourceRoot":"","sources":["../src/feeOracleV5.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,yCAA+C;AAE/C,iCAA+B;AAC/B,6CAAmD;AAEnD;;GAEG;AACH;IAAwC,sCAAgB;IAGtD,4BAAmB,OAAe,EAAE,MAAc;QAAlD,YACE,kBAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,SAG1B;QADC,KAAI,CAAC,iBAAiB,GAAG,IAAI,gCAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;;IACnE,CAAC;IAEK,wCAAW,GAAjB,UAAkB,EAAoB,EAAE,IAAsB,EAAE,WAAwB;QAAhD,qBAAA,EAAA,cAAsB;QAAE,4BAAA,EAAA,gBAAwB;;;;;;wBACtF,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC;4BAAE,sBAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,EAAC;wBAE1G;;;2BAGG;wBACH,IAAI,IAAI,KAAK,oBAAoB;4BAAE,WAAW,GAAG,EAAE,CAAC;wBACpD,IAAI,IAAI,KAAK,iBAAiB;4BAAE,WAAW,GAAG,EAAE,CAAC;;;;wBAGvB,qBAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAA;;wBAArD,eAAe,GAAG,SAAmC;wBAC3D,sBAAO,IAAA,YAAI,EAAC,eAAe,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAC;;;wBAErD,sBAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,EAAC;;;;;KAEpE;IAEK,8CAAiB,GAAvB,UAAwB,KAAyB,EAAE,WAAoB;;;gBACrE,oFAAoF;gBACpF,IAAI,WAAW,KAAK,SAAS,EAAE;oBAC7B,QAAQ,IAAI,CAAC,OAAO,EAAE;wBACpB,KAAK,gBAAO,CAAC,MAAM;4BACjB,WAAW,GAAG,GAAG,CAAC;4BAClB,MAAM;wBACR,KAAK,gBAAO,CAAC,OAAO,CAAC;wBACrB,KAAK,gBAAO,CAAC,IAAI,CAAC;wBAClB,KAAK,gBAAO,CAAC,IAAI;4BACf,WAAW,GAAG,EAAE,CAAC;4BACjB,MAAM;wBACR;4BACE,WAAW,GAAG,EAAE,CAAC;qBACpB;iBACF;gBAED,sBAAO,iBAAM,iBAAiB,YAAC,KAAK,EAAE,WAAW,CAAC,EAAC;;;KACpD;IACH,yBAAC;AAAD,CAAC,AA9CD,CAAwC,4BAAgB,GA8CvD;AA9CY,gDAAkB"}
|
31
lib/feeOracleV6.d.ts
vendored
Normal file
31
lib/feeOracleV6.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPriceKey, GasPriceParams, GetWithdrawalFeeViaRelayerInput, HexadecimalStringifiedNumber } from './types';
|
||||
/**
|
||||
* V6 version that would cover every available networks and relayers
|
||||
*
|
||||
* Ported from https://git.tornado.ws/tornadocontrib/tornado-core/src/branch/main/src/fees.ts and has been verified over time
|
||||
*/
|
||||
export declare class TornadoFeeOracleV6 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
private fallbackFeeOracle;
|
||||
constructor(chainId: number, rpcUrl: string);
|
||||
/**
|
||||
* Apply static 10% gasLimit premium as it wouldn't change across nodes or relayers
|
||||
*/
|
||||
getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||
/**
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams>;
|
||||
/**
|
||||
* Apply 20% premium from the calculated fee from UI, applies 5% fee from relayer to prevent arbitrage from refund
|
||||
*/
|
||||
calculateWithdrawalFeeViaRelayer(params: GetWithdrawalFeeViaRelayerInput & {
|
||||
premium?: number;
|
||||
}): Promise<HexadecimalStringifiedNumber>;
|
||||
}
|
131
lib/feeOracleV6.js
Normal file
131
lib/feeOracleV6.js
Normal file
@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TornadoFeeOracleV6 = void 0;
|
||||
var config_1 = require("./config");
|
||||
var feeOracle_1 = require("./feeOracle");
|
||||
var utils_1 = require("./utils");
|
||||
var feeOracleV5_1 = require("./feeOracleV5");
|
||||
/**
|
||||
* V6 version that would cover every available networks and relayers
|
||||
*
|
||||
* Ported from https://git.tornado.ws/tornadocontrib/tornado-core/src/branch/main/src/fees.ts and has been verified over time
|
||||
*/
|
||||
var TornadoFeeOracleV6 = /** @class */ (function (_super) {
|
||||
__extends(TornadoFeeOracleV6, _super);
|
||||
function TornadoFeeOracleV6(chainId, rpcUrl) {
|
||||
var _this = _super.call(this, 6, chainId, rpcUrl) || this;
|
||||
_this.fallbackFeeOracle = new feeOracleV5_1.TornadoFeeOracleV5(chainId, rpcUrl);
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Apply static 10% gasLimit premium as it wouldn't change across nodes or relayers
|
||||
*/
|
||||
TornadoFeeOracleV6.prototype.getGasLimit = function (tx, type, bumpPercent) {
|
||||
if (type === void 0) { type = 'other'; }
|
||||
if (bumpPercent === void 0) { bumpPercent = 10; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var fetchedGasLimit;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!tx || Object.keys(tx).length === 0)
|
||||
return [2 /*return*/, this.fallbackFeeOracle.getGasLimit(tx, type, bumpPercent)];
|
||||
return [4 /*yield*/, this.provider.estimateGas(tx)];
|
||||
case 1:
|
||||
fetchedGasLimit = _a.sent();
|
||||
return [2 /*return*/, (0, utils_1.bump)(fetchedGasLimit, bumpPercent).toNumber()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
TornadoFeeOracleV6.prototype.getGasPriceParams = function (speed, bumpPercent) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
if (typeof bumpPercent === 'undefined') {
|
||||
bumpPercent = this.chainId === config_1.ChainId.BSC ? undefined : 30;
|
||||
}
|
||||
return [2 /*return*/, _super.prototype.getGasPriceParams.call(this, speed, bumpPercent)];
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Apply 20% premium from the calculated fee from UI, applies 5% fee from relayer to prevent arbitrage from refund
|
||||
*/
|
||||
TornadoFeeOracleV6.prototype.calculateWithdrawalFeeViaRelayer = function (params) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var fees, premium;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, _super.prototype.calculateWithdrawalFeeViaRelayer.call(this, params)];
|
||||
case 1:
|
||||
fees = _a.sent();
|
||||
premium = params.premium || (params.txType === 'user_withdrawal' ? 20 : 5);
|
||||
return [2 /*return*/, (0, utils_1.bump)(fees, premium).toHexString()];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return TornadoFeeOracleV6;
|
||||
}(feeOracle_1.TornadoFeeOracle));
|
||||
exports.TornadoFeeOracleV6 = TornadoFeeOracleV6;
|
||||
//# sourceMappingURL=feeOracleV6.js.map
|
1
lib/feeOracleV6.js.map
Normal file
1
lib/feeOracleV6.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"feeOracleV6.js","sourceRoot":"","sources":["../src/feeOracleV6.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,yCAA+C;AAU/C,iCAA+B;AAC/B,6CAAmD;AAEnD;;;;GAIG;AACH;IAAwC,sCAAgB;IAGtD,4BAAmB,OAAe,EAAE,MAAc;QAAlD,YACE,kBAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,SAG1B;QADC,KAAI,CAAC,iBAAiB,GAAG,IAAI,gCAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;;IACnE,CAAC;IAED;;OAEG;IACG,wCAAW,GAAjB,UAAkB,EAAoB,EAAE,IAAsB,EAAE,WAAwB;QAAhD,qBAAA,EAAA,cAAsB;QAAE,4BAAA,EAAA,gBAAwB;;;;;;wBACtF,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC;4BAAE,sBAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,EAAC;wBAElF,qBAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAA;;wBAArD,eAAe,GAAG,SAAmC;wBAC3D,sBAAO,IAAA,YAAI,EAAC,eAAe,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,EAAC;;;;KACtD;IAED;;;;;;;;OAQG;IACG,8CAAiB,GAAvB,UAAwB,KAAyB,EAAE,WAAoB;;;gBACrE,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;oBACtC,WAAW,GAAG,IAAI,CAAC,OAAO,KAAK,gBAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC7D;gBACD,sBAAO,iBAAM,iBAAiB,YAAC,KAAK,EAAE,WAAW,CAAC,EAAC;;;KACpD;IAED;;OAEG;IACG,6DAAgC,GAAtC,UACE,MAA8D;;;;;4BAEjD,qBAAM,iBAAM,gCAAgC,YAAC,MAAM,CAAC,EAAA;;wBAA3D,IAAI,GAAG,SAAoD;wBAE3D,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAEjF,sBAAO,IAAA,YAAI,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,EAAC;;;;KAC1C;IACH,yBAAC;AAAD,CAAC,AA/CD,CAAwC,4BAAgB,GA+CvD;AA/CY,gDAAkB"}
|
4
lib/index.d.ts
vendored
Normal file
4
lib/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export * from './feeOracleV4';
|
||||
export * from './feeOracleV5';
|
||||
export * from './feeOracleV6';
|
||||
export * from './tokenPriceOracle';
|
21
lib/index.js
Normal file
21
lib/index.js
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./feeOracleV4"), exports);
|
||||
__exportStar(require("./feeOracleV5"), exports);
|
||||
__exportStar(require("./feeOracleV6"), exports);
|
||||
__exportStar(require("./tokenPriceOracle"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
1
lib/index.js.map
Normal file
1
lib/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,gDAA8B;AAC9B,qDAAmC"}
|
29
lib/tokenPriceOracle.d.ts
vendored
Normal file
29
lib/tokenPriceOracle.d.ts
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import { ITornadoPriceOracle, Token, TokenPrices } from './types';
|
||||
import { ChainId } from './config';
|
||||
export declare class TokenPriceOracle implements ITornadoPriceOracle {
|
||||
private tokens;
|
||||
private defaultTokenPrices;
|
||||
private oracle;
|
||||
private multiCall;
|
||||
private provider;
|
||||
/**
|
||||
* Constructs TokenPriceOracle class instance
|
||||
* @param {string} rpcUrl http RPC (Ethereum Mainnet) url to fetch token prices from contract
|
||||
* @param {Token[]} [tokens] Array of tokens
|
||||
* @param {TokenPrices} [defaultTokenPrices] Default token prices, fallback if nothing loaded from contract
|
||||
*/
|
||||
constructor(rpcUrl: string, tokens?: Token[], defaultTokenPrices?: TokenPrices, chainId?: ChainId);
|
||||
get defaultPrices(): TokenPrices;
|
||||
/**
|
||||
* Prepare data for MultiCall contract
|
||||
* @param {Token[]} [tokens] Tokens array
|
||||
* @returns Valid structure to provide to MultiCall contract
|
||||
*/
|
||||
private prepareCallData;
|
||||
/**
|
||||
* Fetch actual tokens price rate to ETH from offchain oracles
|
||||
* @param {Token[]} [tokens] Token array
|
||||
* @returns {TokenPrices} Object with token price rate to ETH in WEI
|
||||
*/
|
||||
fetchPrices(tokens?: Token[]): Promise<TokenPrices>;
|
||||
}
|
161
lib/tokenPriceOracle.js
Normal file
161
lib/tokenPriceOracle.js
Normal file
@ -0,0 +1,161 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TokenPriceOracle = void 0;
|
||||
var factories_1 = require("./contracts/factories");
|
||||
var ethers_1 = require("ethers");
|
||||
var utils_1 = require("ethers/lib/utils");
|
||||
var tornado_config_1 = require("@tornado/tornado-config");
|
||||
var config_1 = require("./config");
|
||||
/**
|
||||
* Filter non-native tokens from Tornado instances config
|
||||
* @param instances Tornado instances from torn-token config ('@tornado/tornado-config' library)
|
||||
* @returns Array of non-native tokens
|
||||
*/
|
||||
function filterTokensFromTornadoInstances(instances) {
|
||||
var ethInstances = Object.values(instances[config_1.ChainId.MAINNET]);
|
||||
return ethInstances.filter(function (tokenInstance) { return !!tokenInstance.tokenAddress; });
|
||||
}
|
||||
var tornToken = {
|
||||
tokenAddress: '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
||||
symbol: 'torn',
|
||||
decimals: 18,
|
||||
};
|
||||
var tornadoTokens = __spreadArray([tornToken], filterTokensFromTornadoInstances(tornado_config_1.instances), true);
|
||||
var defaultTornadoTokenPrices = {
|
||||
torn: '1689423546359032',
|
||||
dai: '598416104472725',
|
||||
cdai: '13384388487019',
|
||||
usdc: '599013776676721',
|
||||
usdt: '599323410893614',
|
||||
wbtc: '15659889148334216720',
|
||||
};
|
||||
var TokenPriceOracle = /** @class */ (function () {
|
||||
/**
|
||||
* Constructs TokenPriceOracle class instance
|
||||
* @param {string} rpcUrl http RPC (Ethereum Mainnet) url to fetch token prices from contract
|
||||
* @param {Token[]} [tokens] Array of tokens
|
||||
* @param {TokenPrices} [defaultTokenPrices] Default token prices, fallback if nothing loaded from contract
|
||||
*/
|
||||
function TokenPriceOracle(rpcUrl, tokens, defaultTokenPrices, chainId) {
|
||||
if (tokens === void 0) { tokens = tornadoTokens; }
|
||||
if (defaultTokenPrices === void 0) { defaultTokenPrices = defaultTornadoTokenPrices; }
|
||||
this.tokens = tokens;
|
||||
this.defaultTokenPrices = defaultTokenPrices;
|
||||
this.provider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrl);
|
||||
this.oracle = (0, factories_1.getOffchainOracleContract)(this.provider, chainId);
|
||||
this.multiCall = (0, factories_1.getMultiCallContract)(this.provider);
|
||||
}
|
||||
Object.defineProperty(TokenPriceOracle.prototype, "defaultPrices", {
|
||||
// Instant return default token prices
|
||||
get: function () {
|
||||
return this.defaultTokenPrices;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* Prepare data for MultiCall contract
|
||||
* @param {Token[]} [tokens] Tokens array
|
||||
* @returns Valid structure to provide to MultiCall contract
|
||||
*/
|
||||
TokenPriceOracle.prototype.prepareCallData = function (tokens) {
|
||||
var _this = this;
|
||||
if (tokens === void 0) { tokens = this.tokens; }
|
||||
return tokens.map(function (token) { return ({
|
||||
target: _this.oracle.address,
|
||||
allowFailure: true,
|
||||
callData: _this.oracle.interface.encodeFunctionData('getRateToEth', [token.tokenAddress, true]),
|
||||
}); });
|
||||
};
|
||||
/**
|
||||
* Fetch actual tokens price rate to ETH from offchain oracles
|
||||
* @param {Token[]} [tokens] Token array
|
||||
* @returns {TokenPrices} Object with token price rate to ETH in WEI
|
||||
*/
|
||||
TokenPriceOracle.prototype.fetchPrices = function (tokens) {
|
||||
if (tokens === void 0) { tokens = this.tokens; }
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var callData, results, prices, i, tokenSymbol, decodedRate, tokenDecimals, ethDecimals, price, e_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
if (!(tokens === null || tokens === void 0 ? void 0 : tokens.length))
|
||||
return [2 /*return*/, {}];
|
||||
callData = this.prepareCallData(tokens);
|
||||
return [4 /*yield*/, this.multiCall.callStatic.aggregate3(callData)];
|
||||
case 1:
|
||||
results = _a.sent();
|
||||
prices = {};
|
||||
for (i = 0; i < results.length; i++) {
|
||||
tokenSymbol = tokens[i].symbol.toLowerCase();
|
||||
if (!results[i].success) {
|
||||
if (this.defaultTokenPrices[tokenSymbol])
|
||||
prices[tokenSymbol] = this.defaultTokenPrices[tokenSymbol];
|
||||
continue;
|
||||
}
|
||||
decodedRate = utils_1.defaultAbiCoder.decode(['uint256'], results[i].returnData).toString();
|
||||
tokenDecimals = ethers_1.BigNumber.from(10).pow(tokens[i].decimals);
|
||||
ethDecimals = ethers_1.BigNumber.from(10).pow(18);
|
||||
price = ethers_1.BigNumber.from(decodedRate).mul(tokenDecimals).div(ethDecimals);
|
||||
prices[tokenSymbol] = price.toString();
|
||||
}
|
||||
return [2 /*return*/, prices];
|
||||
case 2:
|
||||
e_1 = _a.sent();
|
||||
console.error('Cannot get token prices, return default: ' + e_1);
|
||||
return [2 /*return*/, this.defaultTokenPrices];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return TokenPriceOracle;
|
||||
}());
|
||||
exports.TokenPriceOracle = TokenPriceOracle;
|
||||
//# sourceMappingURL=tokenPriceOracle.js.map
|
1
lib/tokenPriceOracle.js.map
Normal file
1
lib/tokenPriceOracle.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"tokenPriceOracle.js","sourceRoot":"","sources":["../src/tokenPriceOracle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,mDAAwF;AAExF,iCAA2C;AAC3C,0CAAmD;AACnD,0DAA+D;AAC/D,mCAAmC;AAEnC;;;;GAIG;AACH,SAAS,gCAAgC,CAAC,SAAoB;IAC5D,IAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,OAAO,YAAY,CAAC,MAAM,CAAC,UAAC,aAAa,IAAK,OAAA,CAAC,CAAC,aAAa,CAAC,YAAY,EAA5B,CAA4B,CAAY,CAAC;AACzF,CAAC;AAED,IAAM,SAAS,GAAU;IACvB,YAAY,EAAE,4CAA4C;IAC1D,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,EAAE;CACb,CAAC;AACF,IAAM,aAAa,kBAAI,SAAS,GAAK,gCAAgC,CAAC,0BAAS,CAAC,OAAC,CAAC;AAElF,IAAM,yBAAyB,GAAgB;IAC7C,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,sBAAsB;CAC7B,CAAC;AAEF;IAKE;;;;;OAKG;IACH,0BACE,MAAc,EACN,MAA+B,EAC/B,kBAA2D,EACnE,OAAiB;QAFT,uBAAA,EAAA,sBAA+B;QAC/B,mCAAA,EAAA,8CAA2D;QAD3D,WAAM,GAAN,MAAM,CAAyB;QAC/B,uBAAkB,GAAlB,kBAAkB,CAAyC;QAGnE,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,GAAG,IAAA,qCAAyB,EAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,GAAG,IAAA,gCAAoB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IAGD,sBAAI,2CAAa;QADjB,sCAAsC;aACtC;YACE,OAAO,IAAI,CAAC,kBAAkB,CAAC;QACjC,CAAC;;;OAAA;IAED;;;;OAIG;IACK,0CAAe,GAAvB,UAAwB,MAA6B;QAArD,iBAMC;QANuB,uBAAA,EAAA,SAAkB,IAAI,CAAC,MAAM;QACnD,OAAO,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,CAAC;YAC5B,MAAM,EAAE,KAAI,CAAC,MAAM,CAAC,OAAO;YAC3B,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;SAC/F,CAAC,EAJ2B,CAI3B,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACG,sCAAW,GAAjB,UAAkB,MAA6B;QAA7B,uBAAA,EAAA,SAAkB,IAAI,CAAC,MAAM;;;;;;;wBAE3C,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA;4BAAE,sBAAO,EAAE,EAAC;wBAEzB,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;wBAC9B,qBAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAA;;wBAA9D,OAAO,GAAG,SAAoD;wBAC9D,MAAM,GAAgB,EAAE,CAAC;wBAE/B,KAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BACjC,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAiB,CAAC;4BAClE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;gCACvB,IAAI,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC;oCAAE,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;gCACrG,SAAS;6BACV;4BAEK,WAAW,GAAG,uBAAe,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;4BACpF,aAAa,GAAG,kBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;4BAC3D,WAAW,GAAG,kBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;4BACzC,KAAK,GAAG,kBAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;4BAC9E,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;yBACxC;wBACD,sBAAO,MAAM,EAAC;;;wBAEd,OAAO,CAAC,KAAK,CAAC,2CAA2C,GAAG,GAAC,CAAC,CAAC;wBAC/D,sBAAO,IAAI,CAAC,kBAAkB,EAAC;;;;;KAElC;IACH,uBAAC;AAAD,CAAC,AAxED,IAwEC;AAxEY,4CAAgB"}
|
92
lib/types.d.ts
vendored
Normal file
92
lib/types.d.ts
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
import { BigNumberish, BytesLike } from 'ethers';
|
||||
import { AvailableTokenSymbols } from '@tornado/tornado-config';
|
||||
import { InstanceTokenSymbol } from './config';
|
||||
export type HexadecimalStringifiedNumber = string;
|
||||
export type LegacyGasPriceKey = 'instant' | 'fast' | 'standard' | 'low';
|
||||
export type GasPriceParams = {
|
||||
gasPrice: string;
|
||||
} | {
|
||||
maxFeePerGas: string;
|
||||
maxPriorityFeePerGas: string;
|
||||
};
|
||||
export type LegacyGasPrices = {
|
||||
[gasPriceType in LegacyGasPriceKey]: number;
|
||||
};
|
||||
export type WithdrawalTxType = 'user_withdrawal' | 'relayer_withdrawal' | 'relayer_withdrawal_check_v4';
|
||||
export type TxType = WithdrawalTxType | 'other';
|
||||
export interface TransactionData {
|
||||
to: string;
|
||||
from?: string;
|
||||
nonce?: number;
|
||||
gasLimit?: BigNumberish;
|
||||
gasPrice?: BigNumberish;
|
||||
data?: string;
|
||||
value: BigNumberish;
|
||||
chainId?: number;
|
||||
type?: number;
|
||||
maxFeePerGas?: BigNumberish;
|
||||
maxPriorityFeePerGas?: BigNumberish;
|
||||
}
|
||||
export interface ITornadoFeeOracle {
|
||||
getGasParams: (params?: GetGasParamsInput) => Promise<GetGasParamsRes>;
|
||||
getGas: (params?: GetGasInput) => Promise<HexadecimalStringifiedNumber>;
|
||||
getGasPriceParams: (speed?: LegacyGasPriceKey, bumpPercent?: number) => Promise<GasPriceParams>;
|
||||
getGasPrice: (speed?: LegacyGasPriceKey, bumpPercent?: number) => Promise<HexadecimalStringifiedNumber>;
|
||||
getGasLimit: (tx?: TransactionData, type?: TxType, bumpPercent?: number) => Promise<number>;
|
||||
fetchL1OptimismFee: (tx?: TransactionData) => Promise<HexadecimalStringifiedNumber>;
|
||||
calculateRefundInETH: (gasPrice: BigNumberish, tokenSymbol: InstanceTokenSymbol) => HexadecimalStringifiedNumber;
|
||||
fetchRefundInETH: (tokenSymbol: InstanceTokenSymbol) => Promise<HexadecimalStringifiedNumber>;
|
||||
calculateRefundInToken: (gasPrice: BigNumberish, tokenPriceInEth: BigNumberish, tokenDecimals: HexadecimalStringifiedNumber | number, tokenSymbol: InstanceTokenSymbol) => HexadecimalStringifiedNumber;
|
||||
calculateWithdrawalFeeViaRelayer: (params: GetWithdrawalFeeViaRelayerInput) => Promise<HexadecimalStringifiedNumber>;
|
||||
}
|
||||
export interface ITornadoPriceOracle {
|
||||
defaultPrices: TokenPrices;
|
||||
fetchPrices: (tokens?: Token[]) => Promise<TokenPrices>;
|
||||
}
|
||||
export type WithdrawalData = {
|
||||
contract: string;
|
||||
proof: BytesLike;
|
||||
args: [BytesLike, BytesLike, string, string, BigNumberish, BigNumberish];
|
||||
};
|
||||
export type TornadoPoolInstance = {
|
||||
currency: AvailableTokenSymbols;
|
||||
amount: number;
|
||||
decimals: number;
|
||||
};
|
||||
export type TokenSymbol = 'dai' | 'cdai' | 'usdc' | 'usdt' | 'wbtc' | 'torn';
|
||||
export type Token = {
|
||||
tokenAddress: string;
|
||||
symbol: TokenSymbol;
|
||||
decimals: number;
|
||||
};
|
||||
export type TokenPrices = {
|
||||
[tokenSymbol in TokenSymbol]?: BigNumberish;
|
||||
};
|
||||
export type GetGasParamsRes = {
|
||||
gasLimit: number;
|
||||
gasPrice: HexadecimalStringifiedNumber;
|
||||
};
|
||||
export type GetGasInput = {
|
||||
txType?: TxType;
|
||||
tx?: TransactionData;
|
||||
predefinedGasPrice?: HexadecimalStringifiedNumber;
|
||||
predefinedGasLimit?: number;
|
||||
bumpGasLimitPercent?: number;
|
||||
bumpGasPricePercent?: number;
|
||||
speed?: LegacyGasPriceKey;
|
||||
};
|
||||
export type GetGasParamsInput = GetGasInput & {
|
||||
includeL1FeeToGasLimit?: boolean;
|
||||
};
|
||||
export type GetWithdrawalFeeViaRelayerInput = {
|
||||
txType: WithdrawalTxType;
|
||||
tx?: TransactionData;
|
||||
relayerFeePercent: number | string;
|
||||
currency: AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>;
|
||||
amount: string | number;
|
||||
decimals: string | number;
|
||||
refundInEth?: HexadecimalStringifiedNumber;
|
||||
tokenPriceInEth?: HexadecimalStringifiedNumber | string;
|
||||
predefinedGasPrice?: HexadecimalStringifiedNumber;
|
||||
predefinedGasLimit?: number;
|
||||
};
|
3
lib/types.js
Normal file
3
lib/types.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
1
lib/types.js.map
Normal file
1
lib/types.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
7
lib/utils.d.ts
vendored
Normal file
7
lib/utils.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { GasPriceParams, TransactionData } from './types';
|
||||
import { BigNumber, BigNumberish } from 'ethers';
|
||||
export declare function serializeTx(tx?: TransactionData | string): string;
|
||||
export declare function calculateGasPriceInWei(gasPrice: GasPriceParams): BigNumber;
|
||||
export declare function bump(value: BigNumberish, percent: number): BigNumber;
|
||||
export declare function fromGweiToWeiHex(value: number | string): BigNumberish;
|
||||
export declare function convertETHToToken(amountInWEI: BigNumberish, tokenDecimals: number | string, tokenPriceInWei: BigNumberish): BigNumber;
|
43
lib/utils.js
Normal file
43
lib/utils.js
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convertETHToToken = exports.fromGweiToWeiHex = exports.bump = exports.calculateGasPriceInWei = exports.serializeTx = void 0;
|
||||
var transactions_1 = require("@ethersproject/transactions");
|
||||
var ethers_1 = require("ethers");
|
||||
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
bignumber_js_1.default.config({ EXPONENTIAL_AT: 100 });
|
||||
var GWEI = 1e9;
|
||||
function serializeTx(tx) {
|
||||
if (!tx)
|
||||
tx = '0x';
|
||||
if (typeof tx === 'string')
|
||||
return tx;
|
||||
return (0, transactions_1.serialize)(tx);
|
||||
}
|
||||
exports.serializeTx = serializeTx;
|
||||
function calculateGasPriceInWei(gasPrice) {
|
||||
// @ts-ignore
|
||||
return ethers_1.BigNumber.from(gasPrice.gasPrice || gasPrice.maxFeePerGas);
|
||||
}
|
||||
exports.calculateGasPriceInWei = calculateGasPriceInWei;
|
||||
function bump(value, percent) {
|
||||
var hundredPercents = (0, bignumber_js_1.default)(100);
|
||||
return ethers_1.BigNumber.from((0, bignumber_js_1.default)(ethers_1.BigNumber.from(value).toHexString())
|
||||
.times(hundredPercents.plus((0, bignumber_js_1.default)(percent)))
|
||||
.div(hundredPercents)
|
||||
.decimalPlaces(0, 1)
|
||||
.toString());
|
||||
}
|
||||
exports.bump = bump;
|
||||
function fromGweiToWeiHex(value) {
|
||||
return ethers_1.BigNumber.from((0, bignumber_js_1.default)(value).times(GWEI).toString()).toHexString();
|
||||
}
|
||||
exports.fromGweiToWeiHex = fromGweiToWeiHex;
|
||||
function convertETHToToken(amountInWEI, tokenDecimals, tokenPriceInWei) {
|
||||
var tokenDecimalsMultiplier = ethers_1.BigNumber.from(10).pow(tokenDecimals);
|
||||
return ethers_1.BigNumber.from(amountInWEI).mul(tokenDecimalsMultiplier).div(tokenPriceInWei);
|
||||
}
|
||||
exports.convertETHToToken = convertETHToToken;
|
||||
//# sourceMappingURL=utils.js.map
|
1
lib/utils.js.map
Normal file
1
lib/utils.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAwD;AAExD,iCAAiD;AACjD,8DAA0C;AAC1C,sBAAc,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;AAE/C,IAAM,IAAI,GAAG,GAAG,CAAC;AAEjB,SAAgB,WAAW,CAAC,EAA6B;IACvD,IAAI,CAAC,EAAE;QAAE,EAAE,GAAG,IAAI,CAAC;IACnB,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAEtC,OAAO,IAAA,wBAAS,EAAC,EAAE,CAAC,CAAC;AACvB,CAAC;AALD,kCAKC;AAED,SAAgB,sBAAsB,CAAC,QAAwB;IAC7D,aAAa;IACb,OAAO,kBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAC;AACpE,CAAC;AAHD,wDAGC;AAED,SAAgB,IAAI,CAAC,KAAmB,EAAE,OAAe;IACvD,IAAM,eAAe,GAAG,IAAA,sBAAc,EAAC,GAAG,CAAC,CAAC;IAE5C,OAAO,kBAAS,CAAC,IAAI,CACnB,IAAA,sBAAc,EAAC,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;SAChD,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAC,CAAC;SACpD,GAAG,CAAC,eAAe,CAAC;SACpB,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,QAAQ,EAAE,CACd,CAAC;AACJ,CAAC;AAVD,oBAUC;AAED,SAAgB,gBAAgB,CAAC,KAAsB;IACrD,OAAO,kBAAS,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACpF,CAAC;AAFD,4CAEC;AAED,SAAgB,iBAAiB,CAC/B,WAAyB,EACzB,aAA8B,EAC9B,eAA6B;IAE7B,IAAM,uBAAuB,GAAG,kBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtE,OAAO,kBAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACvF,CAAC;AAPD,8CAOC"}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tornado/tornado-oracles",
|
||||
"version": "3.3.0",
|
||||
"version": "3.4.0",
|
||||
"description": "Oracles for Tornado-specific transactions & actions",
|
||||
"main": "./lib/index.js",
|
||||
"types": "./lib/index.d.ts",
|
||||
@ -29,7 +29,6 @@
|
||||
"author": "Theo",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tornado/gas-price-oracle": "^0.5.3",
|
||||
"@tornado/tornado-config": "^2.0.0",
|
||||
"@types/node": "^20.5.1",
|
||||
"bignumber.js": "^9.1.1",
|
||||
|
@ -9,6 +9,7 @@ export enum ChainId {
|
||||
OPTIMISM = 10,
|
||||
ARBITRUM = 42161,
|
||||
AVAX = 43114,
|
||||
SEPOLIA = 11155111,
|
||||
}
|
||||
|
||||
export enum InstanceTokenSymbol {
|
||||
@ -72,6 +73,12 @@ export const defaultGasPrices: GasPricesConfig = {
|
||||
standard: 25,
|
||||
low: 25,
|
||||
},
|
||||
[ChainId.SEPOLIA]: {
|
||||
instant: 80,
|
||||
fast: 50,
|
||||
standard: 25,
|
||||
low: 8,
|
||||
},
|
||||
};
|
||||
|
||||
type GasLimitConfig = {
|
||||
@ -87,6 +94,7 @@ export const defaultWithdrawalGasLimit: GasLimitConfig = {
|
||||
[ChainId.BSC]: 390000,
|
||||
[ChainId.POLYGON]: 390000,
|
||||
[ChainId.XDAI]: 390000,
|
||||
[ChainId.SEPOLIA]: 550000,
|
||||
};
|
||||
|
||||
type InstanceTokenGasLimitConfig = {
|
||||
@ -102,5 +110,6 @@ export const defaultInstanceTokensGasLimit: InstanceTokenGasLimitConfig = {
|
||||
};
|
||||
|
||||
export const optimismL1FeeOracleAddress = '0x420000000000000000000000000000000000000F';
|
||||
export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';
|
||||
export const multiCallAddress = '0xda3c19c6fe954576707fa24695efb830d9cca1ca';
|
||||
export const offchainOracleAddress = '0x00000000000D6FFc74A8feb35aF5827bf57f6786';
|
||||
export const sepoliaOffchainOracleAddress = '0x1f89EAF03E5b260Bc6D4Ae3c3334b1B750F3e127';
|
||||
export const multiCallAddress = '0xcA11bde05977b3631167028862bE2a173976CA11';
|
||||
|
@ -1,30 +1,137 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { BaseContract, BigNumber, BytesLike, CallOverrides, PopulatedTransaction, Signer, utils } from 'ethers';
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
PayableOverrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from 'ethers';
|
||||
import type { FunctionFragment, Result } from '@ethersproject/abi';
|
||||
import type { Listener, Provider } from '@ethersproject/providers';
|
||||
import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from './common';
|
||||
|
||||
export declare namespace MultiCall {
|
||||
export type CallStruct = { to: string; data: BytesLike };
|
||||
export declare namespace Multicall3 {
|
||||
export type CallStruct = { target: string; callData: BytesLike };
|
||||
|
||||
export type CallStructOutput = [string, string] & {
|
||||
to: string;
|
||||
data: string;
|
||||
target: string;
|
||||
callData: string;
|
||||
};
|
||||
|
||||
export type Call3Struct = {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
callData: BytesLike;
|
||||
};
|
||||
|
||||
export type Call3StructOutput = [string, boolean, string] & {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
callData: string;
|
||||
};
|
||||
|
||||
export type ResultStruct = { success: boolean; returnData: BytesLike };
|
||||
|
||||
export type ResultStructOutput = [boolean, string] & {
|
||||
success: boolean;
|
||||
returnData: string;
|
||||
};
|
||||
|
||||
export type Call3ValueStruct = {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
value: BigNumberish;
|
||||
callData: BytesLike;
|
||||
};
|
||||
|
||||
export type Call3ValueStructOutput = [string, boolean, BigNumber, string] & {
|
||||
target: string;
|
||||
allowFailure: boolean;
|
||||
value: BigNumber;
|
||||
callData: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface MulticallAbiInterface extends utils.Interface {
|
||||
functions: {
|
||||
'multicall((address,bytes)[])': FunctionFragment;
|
||||
'aggregate((address,bytes)[])': FunctionFragment;
|
||||
'aggregate3((address,bool,bytes)[])': FunctionFragment;
|
||||
'aggregate3Value((address,bool,uint256,bytes)[])': FunctionFragment;
|
||||
'blockAndAggregate((address,bytes)[])': FunctionFragment;
|
||||
'getBasefee()': FunctionFragment;
|
||||
'getBlockHash(uint256)': FunctionFragment;
|
||||
'getBlockNumber()': FunctionFragment;
|
||||
'getChainId()': FunctionFragment;
|
||||
'getCurrentBlockCoinbase()': FunctionFragment;
|
||||
'getCurrentBlockDifficulty()': FunctionFragment;
|
||||
'getCurrentBlockGasLimit()': FunctionFragment;
|
||||
'getCurrentBlockTimestamp()': FunctionFragment;
|
||||
'getEthBalance(address)': FunctionFragment;
|
||||
'getLastBlockHash()': FunctionFragment;
|
||||
'tryAggregate(bool,(address,bytes)[])': FunctionFragment;
|
||||
'tryBlockAndAggregate(bool,(address,bytes)[])': FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(nameOrSignatureOrTopic: 'multicall'): FunctionFragment;
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| 'aggregate'
|
||||
| 'aggregate3'
|
||||
| 'aggregate3Value'
|
||||
| 'blockAndAggregate'
|
||||
| 'getBasefee'
|
||||
| 'getBlockHash'
|
||||
| 'getBlockNumber'
|
||||
| 'getChainId'
|
||||
| 'getCurrentBlockCoinbase'
|
||||
| 'getCurrentBlockDifficulty'
|
||||
| 'getCurrentBlockGasLimit'
|
||||
| 'getCurrentBlockTimestamp'
|
||||
| 'getEthBalance'
|
||||
| 'getLastBlockHash'
|
||||
| 'tryAggregate'
|
||||
| 'tryBlockAndAggregate',
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(functionFragment: 'multicall', values: [MultiCall.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'aggregate', values: [Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'aggregate3', values: [Multicall3.Call3Struct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'aggregate3Value', values: [Multicall3.Call3ValueStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'blockAndAggregate', values: [Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'getBasefee', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getBlockHash', values: [BigNumberish]): string;
|
||||
encodeFunctionData(functionFragment: 'getBlockNumber', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getChainId', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockCoinbase', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockDifficulty', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockGasLimit', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getCurrentBlockTimestamp', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'getEthBalance', values: [string]): string;
|
||||
encodeFunctionData(functionFragment: 'getLastBlockHash', values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: 'tryAggregate', values: [boolean, Multicall3.CallStruct[]]): string;
|
||||
encodeFunctionData(functionFragment: 'tryBlockAndAggregate', values: [boolean, Multicall3.CallStruct[]]): string;
|
||||
|
||||
decodeFunctionResult(functionFragment: 'multicall', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'aggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'aggregate3', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'aggregate3Value', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'blockAndAggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBasefee', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBlockHash', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getBlockNumber', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getChainId', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockCoinbase', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockDifficulty', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockGasLimit', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getCurrentBlockTimestamp', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getEthBalance', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'getLastBlockHash', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'tryAggregate', data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: 'tryBlockAndAggregate', data: BytesLike): Result;
|
||||
|
||||
events: {};
|
||||
}
|
||||
@ -52,31 +159,275 @@ export interface MulticallAbi extends BaseContract {
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
multicall(
|
||||
calls: MultiCall.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<[string[], boolean[]] & { results: string[]; success: boolean[] }>;
|
||||
aggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
aggregate3(
|
||||
calls: Multicall3.Call3Struct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
aggregate3Value(
|
||||
calls: Multicall3.Call3ValueStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
blockAndAggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
getBasefee(overrides?: CallOverrides): Promise<[BigNumber] & { basefee: BigNumber }>;
|
||||
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<[string] & { blockHash: string }>;
|
||||
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<[BigNumber] & { blockNumber: BigNumber }>;
|
||||
|
||||
getChainId(overrides?: CallOverrides): Promise<[BigNumber] & { chainid: BigNumber }>;
|
||||
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<[string] & { coinbase: string }>;
|
||||
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<[BigNumber] & { difficulty: BigNumber }>;
|
||||
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<[BigNumber] & { gaslimit: BigNumber }>;
|
||||
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<[BigNumber] & { timestamp: BigNumber }>;
|
||||
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<[BigNumber] & { balance: BigNumber }>;
|
||||
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<[string] & { blockHash: string }>;
|
||||
|
||||
tryAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
tryBlockAndAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
multicall(
|
||||
calls: MultiCall.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<[string[], boolean[]] & { results: string[]; success: boolean[] }>;
|
||||
aggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
aggregate3(
|
||||
calls: Multicall3.Call3Struct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
aggregate3Value(
|
||||
calls: Multicall3.Call3ValueStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
blockAndAggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
tryAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
tryBlockAndAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
multicall(
|
||||
calls: MultiCall.CallStruct[],
|
||||
aggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<[string[], boolean[]] & { results: string[]; success: boolean[] }>;
|
||||
): Promise<[BigNumber, string[]] & { blockNumber: BigNumber; returnData: string[] }>;
|
||||
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: CallOverrides): Promise<Multicall3.ResultStructOutput[]>;
|
||||
|
||||
aggregate3Value(
|
||||
calls: Multicall3.Call3ValueStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<Multicall3.ResultStructOutput[]>;
|
||||
|
||||
blockAndAggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<
|
||||
[BigNumber, string, Multicall3.ResultStructOutput[]] & {
|
||||
blockNumber: BigNumber;
|
||||
blockHash: string;
|
||||
returnData: Multicall3.ResultStructOutput[];
|
||||
}
|
||||
>;
|
||||
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
tryAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<Multicall3.ResultStructOutput[]>;
|
||||
|
||||
tryBlockAndAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: CallOverrides,
|
||||
): Promise<
|
||||
[BigNumber, string, Multicall3.ResultStructOutput[]] & {
|
||||
blockNumber: BigNumber;
|
||||
blockHash: string;
|
||||
returnData: Multicall3.ResultStructOutput[];
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
filters: {};
|
||||
|
||||
estimateGas: {
|
||||
multicall(calls: MultiCall.CallStruct[], overrides?: CallOverrides): Promise<BigNumber>;
|
||||
aggregate(calls: Multicall3.CallStruct[], overrides?: PayableOverrides & { from?: string }): Promise<BigNumber>;
|
||||
|
||||
aggregate3(calls: Multicall3.Call3Struct[], overrides?: PayableOverrides & { from?: string }): Promise<BigNumber>;
|
||||
|
||||
aggregate3Value(
|
||||
calls: Multicall3.Call3ValueStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<BigNumber>;
|
||||
|
||||
blockAndAggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<BigNumber>;
|
||||
|
||||
getBasefee(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getChainId(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
tryAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<BigNumber>;
|
||||
|
||||
tryBlockAndAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
multicall(calls: MultiCall.CallStruct[], overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
aggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
aggregate3(
|
||||
calls: Multicall3.Call3Struct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
aggregate3Value(
|
||||
calls: Multicall3.Call3ValueStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
blockAndAggregate(
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
getBasefee(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getBlockHash(blockNumber: BigNumberish, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getBlockNumber(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getChainId(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getCurrentBlockCoinbase(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getCurrentBlockDifficulty(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getCurrentBlockGasLimit(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getCurrentBlockTimestamp(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getEthBalance(addr: string, overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
getLastBlockHash(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
tryAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
tryBlockAndAggregate(
|
||||
requireSuccess: boolean,
|
||||
calls: Multicall3.CallStruct[],
|
||||
overrides?: PayableOverrides & { from?: string },
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
import { OptimismL1FeeOracleAbi__factory, OffchainOracleAbi__factory, MulticallAbi__factory } from './';
|
||||
import { optimismL1FeeOracleAddress, offchainOracleAddress, multiCallAddress } from '../config';
|
||||
import {
|
||||
optimismL1FeeOracleAddress,
|
||||
offchainOracleAddress,
|
||||
multiCallAddress,
|
||||
sepoliaOffchainOracleAddress,
|
||||
} from '../config';
|
||||
import { Provider } from '@ethersproject/abstract-provider';
|
||||
import { ChainId } from '../config';
|
||||
|
||||
export const getOptimismL1FeeOracle = (provider: Provider) => {
|
||||
return OptimismL1FeeOracleAbi__factory.connect(optimismL1FeeOracleAddress, provider);
|
||||
};
|
||||
|
||||
export const getOffchainOracleContract = (provider: Provider) => {
|
||||
export const getOffchainOracleContract = (provider: Provider, chainId?: ChainId) => {
|
||||
if (chainId === ChainId.SEPOLIA) {
|
||||
return OffchainOracleAbi__factory.connect(sepoliaOffchainOracleAddress, provider);
|
||||
}
|
||||
return OffchainOracleAbi__factory.connect(offchainOracleAddress, provider);
|
||||
};
|
||||
|
||||
|
@ -13,36 +13,438 @@ const _abi = [
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'to',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'data',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct MultiCall.Call[]',
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'multicall',
|
||||
name: 'aggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes[]',
|
||||
name: 'results',
|
||||
type: 'bytes[]',
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bool[]',
|
||||
internalType: 'bytes[]',
|
||||
name: 'returnData',
|
||||
type: 'bytes[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'allowFailure',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call3[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'aggregate3',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool[]',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'allowFailure',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'value',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call3Value[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'aggregate3Value',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'blockAndAggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getBasefee',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'basefee',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'getBlockHash',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getBlockNumber',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getChainId',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'chainid',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockCoinbase',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'coinbase',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockDifficulty',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'difficulty',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockGasLimit',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'gaslimit',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getCurrentBlockTimestamp',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'timestamp',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'addr',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'getEthBalance',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'balance',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getLastBlockHash',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'requireSuccess',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'tryAggregate',
|
||||
outputs: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'requireSuccess',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'target',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'callData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Call[]',
|
||||
name: 'calls',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
name: 'tryBlockAndAggregate',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'blockNumber',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'blockHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
components: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: 'success',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'returnData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
internalType: 'struct Multicall3.Result[]',
|
||||
name: 'returnData',
|
||||
type: 'tuple[]',
|
||||
},
|
||||
],
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
] as const;
|
||||
|
||||
export class MulticallAbi__factory {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
||||
import { BigNumber, BigNumberish, ethers } from 'ethers';
|
||||
import BigNumberFloat from 'bignumber.js';
|
||||
import { parseUnits } from 'ethers/lib/utils';
|
||||
@ -24,10 +23,9 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
protected provider: JsonRpcProvider;
|
||||
|
||||
public constructor(
|
||||
public version: 4 | 5,
|
||||
public version: 4 | 5 | 6,
|
||||
protected chainId: ChainId,
|
||||
rpcUrl: string,
|
||||
protected oracle: GasPriceOracle,
|
||||
) {
|
||||
this.provider = new ethers.providers.JsonRpcProvider(rpcUrl);
|
||||
}
|
||||
@ -122,12 +120,41 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
* @param {number} [bumpPercent=0] Gas bump percent to prioritize transaction
|
||||
* @returns {Promise<GasPriceParams>} Estimated gas price info in WEI (hexed) - legacy object with gasPrice property or
|
||||
* EIP-1559 object with maxFeePerGas and maxPriorityFeePerGas properties
|
||||
* NOTICE: It is recommended to bump fees for EIP-1559 transactions, because they can bump 12.5% per block
|
||||
*/
|
||||
async getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent: number = 0): Promise<GasPriceParams> {
|
||||
// Use instant for BSC, because on this chain "fast" and "instant" differs more than third and "fast" transaction can take hours
|
||||
if (!speed) speed = this.chainId === ChainId.BSC ? 'instant' : 'fast';
|
||||
try {
|
||||
return await this.oracle.getTxGasParams({ legacySpeed: speed, bumpPercent });
|
||||
const [block, gasPrice, priorityFee] = await Promise.all([
|
||||
this.provider.getBlock('latest'),
|
||||
this.provider.getGasPrice(),
|
||||
(async () => {
|
||||
try {
|
||||
return BigNumber.from(
|
||||
(await this.provider.send('eth_maxPriorityFeePerGas', [])) || parseUnits('1.5', 'gwei'),
|
||||
);
|
||||
} catch {
|
||||
return parseUnits('1.5', 'gwei');
|
||||
}
|
||||
})(),
|
||||
]);
|
||||
|
||||
if (block?.baseFeePerGas?.gt(0)) {
|
||||
const maxPriorityFeePerGas = priorityFee.toHexString();
|
||||
const maxFeePerGas = bump(block.baseFeePerGas as BigNumber, bumpPercent)
|
||||
.add(priorityFee)
|
||||
.toHexString();
|
||||
|
||||
return {
|
||||
maxFeePerGas,
|
||||
maxPriorityFeePerGas,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
gasPrice: bump(gasPrice, bumpPercent).toHexString(),
|
||||
};
|
||||
} catch (e) {
|
||||
return { gasPrice: bump(fromGweiToWeiHex(defaultGasPrices[this.chainId][speed]), bumpPercent).toHexString() };
|
||||
}
|
||||
@ -261,17 +288,19 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
const { gasPrice, gasLimit } = await this.getGasParams({ tx, txType, predefinedGasLimit, predefinedGasPrice });
|
||||
const gasCosts = BigNumber.from(gasPrice).mul(gasLimit);
|
||||
|
||||
if ((this.chainId === ChainId.MAINNET || this.chainId === ChainId.GOERLI) && currency.toLowerCase() != 'eth') {
|
||||
if (!tokenPriceInEth) {
|
||||
console.error('Token price is required argument, if not native chain token is withdrawed');
|
||||
return '0';
|
||||
}
|
||||
const hasTokenPrice =
|
||||
typeof tokenPriceInEth === 'object' && typeof (tokenPriceInEth as BigNumber)?.gt === 'function'
|
||||
? Boolean((tokenPriceInEth as BigNumber).gt(0))
|
||||
: Boolean(tokenPriceInEth);
|
||||
|
||||
if (hasTokenPrice) {
|
||||
if (txType === 'user_withdrawal' && refundInEth === undefined)
|
||||
refundInEth = this.calculateRefundInETH(gasPrice, currency.toLowerCase() as InstanceTokenSymbol);
|
||||
|
||||
const feeInEth = BigNumber.from(gasCosts).add(refundInEth || 0);
|
||||
return convertETHToToken(feeInEth, decimals, tokenPriceInEth).add(relayerFee).toHexString();
|
||||
return convertETHToToken(feeInEth, decimals, tokenPriceInEth as BigNumberish)
|
||||
.add(relayerFee)
|
||||
.toHexString();
|
||||
}
|
||||
|
||||
return BigNumber.from(gasCosts).add(relayerFee).toHexString();
|
||||
|
@ -1,22 +1,14 @@
|
||||
import { defaultWithdrawalGasLimit } from './config';
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPrices } from './types';
|
||||
import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType } from './types';
|
||||
import { bump } from './utils';
|
||||
|
||||
/**
|
||||
* Oracle for V4 (old-version) transactions - estimates fee with predefined gas limit and without smart bumping
|
||||
*/
|
||||
export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
public constructor(chainId: number, rpcUrl: string, defaultGasPrices?: LegacyGasPrices) {
|
||||
const oracleConfig = {
|
||||
chainId,
|
||||
defaultRpc: rpcUrl,
|
||||
defaultFallbackGasPrices: defaultGasPrices,
|
||||
};
|
||||
const gasPriceOracle = new GasPriceOracle(oracleConfig);
|
||||
|
||||
super(4, chainId, rpcUrl, gasPriceOracle);
|
||||
public constructor(chainId: number, rpcUrl: string) {
|
||||
super(4, chainId, rpcUrl);
|
||||
}
|
||||
|
||||
async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent: number = 0): Promise<number> {
|
||||
|
@ -1,14 +1,6 @@
|
||||
import { ChainId } from './config';
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import {
|
||||
ITornadoFeeOracle,
|
||||
TransactionData,
|
||||
TxType,
|
||||
LegacyGasPrices,
|
||||
LegacyGasPriceKey,
|
||||
GasPriceParams,
|
||||
} from './types';
|
||||
import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
||||
import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPriceKey, GasPriceParams } from './types';
|
||||
import { bump } from './utils';
|
||||
import { TornadoFeeOracleV4 } from './feeOracleV4';
|
||||
|
||||
@ -18,20 +10,10 @@ import { TornadoFeeOracleV4 } from './feeOracleV4';
|
||||
export class TornadoFeeOracleV5 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
private fallbackFeeOracle: TornadoFeeOracleV4;
|
||||
|
||||
public constructor(chainId: number, rpcUrl: string, defaultGasPrices?: LegacyGasPrices) {
|
||||
const oracleConfig = {
|
||||
chainId,
|
||||
defaultRpc: rpcUrl,
|
||||
minPriority: chainId === ChainId.MAINNET || chainId === ChainId.GOERLI ? 2 : chainId === ChainId.BSC ? 3 : 0.05,
|
||||
percentile: 5,
|
||||
blocksCount: 20,
|
||||
defaultFallbackGasPrices: defaultGasPrices,
|
||||
};
|
||||
const gasPriceOracle = new GasPriceOracle(oracleConfig);
|
||||
public constructor(chainId: number, rpcUrl: string) {
|
||||
super(5, chainId, rpcUrl);
|
||||
|
||||
super(5, chainId, rpcUrl, gasPriceOracle);
|
||||
|
||||
this.fallbackFeeOracle = new TornadoFeeOracleV4(chainId, rpcUrl, defaultGasPrices);
|
||||
this.fallbackFeeOracle = new TornadoFeeOracleV4(chainId, rpcUrl);
|
||||
}
|
||||
|
||||
async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent: number = 20): Promise<number> {
|
||||
|
67
src/feeOracleV6.ts
Normal file
67
src/feeOracleV6.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { ChainId } from './config';
|
||||
import { TornadoFeeOracle } from './feeOracle';
|
||||
import {
|
||||
ITornadoFeeOracle,
|
||||
TransactionData,
|
||||
TxType,
|
||||
LegacyGasPriceKey,
|
||||
GasPriceParams,
|
||||
GetWithdrawalFeeViaRelayerInput,
|
||||
HexadecimalStringifiedNumber,
|
||||
} from './types';
|
||||
import { bump } from './utils';
|
||||
import { TornadoFeeOracleV5 } from './feeOracleV5';
|
||||
|
||||
/**
|
||||
* V6 version that would cover every available networks and relayers
|
||||
*
|
||||
* Ported from https://git.tornado.ws/tornadocontrib/tornado-core/src/branch/main/src/fees.ts and has been verified over time
|
||||
*/
|
||||
export class TornadoFeeOracleV6 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
private fallbackFeeOracle: TornadoFeeOracleV5;
|
||||
|
||||
public constructor(chainId: number, rpcUrl: string) {
|
||||
super(6, chainId, rpcUrl);
|
||||
|
||||
this.fallbackFeeOracle = new TornadoFeeOracleV5(chainId, rpcUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply static 10% gasLimit premium as it wouldn't change across nodes or relayers
|
||||
*/
|
||||
async getGasLimit(tx?: TransactionData, type: TxType = 'other', bumpPercent: number = 10): Promise<number> {
|
||||
if (!tx || Object.keys(tx).length === 0) return this.fallbackFeeOracle.getGasLimit(tx, type, bumpPercent);
|
||||
|
||||
const fetchedGasLimit = await this.provider.estimateGas(tx);
|
||||
return bump(fetchedGasLimit, bumpPercent).toNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
async getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams> {
|
||||
if (typeof bumpPercent === 'undefined') {
|
||||
bumpPercent = this.chainId === ChainId.BSC ? undefined : 30;
|
||||
}
|
||||
return super.getGasPriceParams(speed, bumpPercent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply 20% premium from the calculated fee from UI, applies 5% fee from relayer to prevent arbitrage from refund
|
||||
*/
|
||||
async calculateWithdrawalFeeViaRelayer(
|
||||
params: GetWithdrawalFeeViaRelayerInput & { premium?: number },
|
||||
): Promise<HexadecimalStringifiedNumber> {
|
||||
const fees = await super.calculateWithdrawalFeeViaRelayer(params);
|
||||
|
||||
const premium = params.premium || (params.txType === 'user_withdrawal' ? 20 : 5);
|
||||
|
||||
return bump(fees, premium).toHexString();
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
export * from './feeOracleV4';
|
||||
export * from './feeOracleV5';
|
||||
export * from './feeOracleV6';
|
||||
export * from './tokenPriceOracle';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MultiCall } from './contracts/MulticallAbi';
|
||||
import { Multicall3 } from './contracts/MulticallAbi';
|
||||
import { ITornadoPriceOracle, Token, TokenPrices, TokenSymbol } from './types';
|
||||
import { MulticallAbi, OffchainOracleAbi } from './contracts';
|
||||
import { getMultiCallContract, getOffchainOracleContract } from './contracts/factories';
|
||||
@ -49,9 +49,10 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
||||
rpcUrl: string,
|
||||
private tokens: Token[] = tornadoTokens,
|
||||
private defaultTokenPrices: TokenPrices = defaultTornadoTokenPrices,
|
||||
chainId?: ChainId,
|
||||
) {
|
||||
this.provider = new ethers.providers.JsonRpcProvider(rpcUrl);
|
||||
this.oracle = getOffchainOracleContract(this.provider);
|
||||
this.oracle = getOffchainOracleContract(this.provider, chainId);
|
||||
this.multiCall = getMultiCallContract(this.provider);
|
||||
}
|
||||
|
||||
@ -65,10 +66,11 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
||||
* @param {Token[]} [tokens] Tokens array
|
||||
* @returns Valid structure to provide to MultiCall contract
|
||||
*/
|
||||
private prepareCallData(tokens: Token[] = this.tokens): MultiCall.CallStruct[] {
|
||||
private prepareCallData(tokens: Token[] = this.tokens): Multicall3.Call3Struct[] {
|
||||
return tokens.map((token) => ({
|
||||
to: this.oracle.address,
|
||||
data: this.oracle.interface.encodeFunctionData('getRateToEth', [token.tokenAddress, true]),
|
||||
target: this.oracle.address,
|
||||
allowFailure: true,
|
||||
callData: this.oracle.interface.encodeFunctionData('getRateToEth', [token.tokenAddress, true]),
|
||||
}));
|
||||
}
|
||||
|
||||
@ -82,17 +84,17 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
||||
if (!tokens?.length) return {};
|
||||
|
||||
const callData = this.prepareCallData(tokens);
|
||||
const { results, success } = await this.multiCall.multicall(callData);
|
||||
const results = await this.multiCall.callStatic.aggregate3(callData);
|
||||
const prices: TokenPrices = {};
|
||||
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const tokenSymbol = tokens[i].symbol.toLowerCase() as TokenSymbol;
|
||||
if (!success[i]) {
|
||||
if (!results[i].success) {
|
||||
if (this.defaultTokenPrices[tokenSymbol]) prices[tokenSymbol] = this.defaultTokenPrices[tokenSymbol];
|
||||
continue;
|
||||
}
|
||||
|
||||
const decodedRate = defaultAbiCoder.decode(['uint256'], results[i]).toString();
|
||||
const decodedRate = defaultAbiCoder.decode(['uint256'], results[i].returnData).toString();
|
||||
const tokenDecimals = BigNumber.from(10).pow(tokens[i].decimals);
|
||||
const ethDecimals = BigNumber.from(10).pow(18);
|
||||
const price = BigNumber.from(decodedRate).mul(tokenDecimals).div(ethDecimals);
|
||||
|
12
src/types.ts
12
src/types.ts
@ -1,13 +1,19 @@
|
||||
import { BigNumberish, BytesLike } from 'ethers';
|
||||
import { GasPriceKey, GetTxGasParamsRes } from '@tornado/gas-price-oracle/lib/services';
|
||||
import { AvailableTokenSymbols } from '@tornado/tornado-config';
|
||||
import { InstanceTokenSymbol } from './config';
|
||||
|
||||
// Type for big hexadecimal numbers, like 0x1eff87f47e37a0
|
||||
export type HexadecimalStringifiedNumber = string;
|
||||
|
||||
export type LegacyGasPriceKey = GasPriceKey;
|
||||
export type GasPriceParams = GetTxGasParamsRes;
|
||||
export type LegacyGasPriceKey = 'instant' | 'fast' | 'standard' | 'low';
|
||||
export type GasPriceParams =
|
||||
| {
|
||||
gasPrice: string;
|
||||
}
|
||||
| {
|
||||
maxFeePerGas: string;
|
||||
maxPriorityFeePerGas: string;
|
||||
};
|
||||
export type LegacyGasPrices = {
|
||||
[gasPriceType in LegacyGasPriceKey]: number;
|
||||
};
|
||||
|
35
yarn.lock
35
yarn.lock
@ -369,15 +369,6 @@
|
||||
"@jridgewell/resolve-uri" "^3.0.3"
|
||||
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||
|
||||
"@tornado/gas-price-oracle@^0.5.3":
|
||||
version "0.5.3"
|
||||
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fgas-price-oracle/-/0.5.3/gas-price-oracle-0.5.3.tgz#fb5423dddee2f52edbc16174c5ddce90bea5413d"
|
||||
integrity sha512-LpVfPiPIz3FOmJdiqJf/yoeO5n9/Pd5jgtdY+6hB9lNW0AiWhylhpScojICViS+3OL9QC8CoTlgr+kbfGeO9pQ==
|
||||
dependencies:
|
||||
axios "^0.21.2"
|
||||
bignumber.js "^9.0.0"
|
||||
node-cache "^5.1.2"
|
||||
|
||||
"@tornado/tornado-config@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-config/-/2.0.0/tornado-config-2.0.0.tgz#52bbc179ecb2385f71b4d56e060b68e7dd6fb8b4"
|
||||
@ -478,13 +469,6 @@ array-back@^4.0.1, array-back@^4.0.2:
|
||||
resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e"
|
||||
integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==
|
||||
|
||||
axios@^0.21.2:
|
||||
version "0.21.4"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
||||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.0"
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
@ -495,7 +479,7 @@ bech32@1.1.4:
|
||||
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
|
||||
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==
|
||||
|
||||
bignumber.js@^9.0.0, bignumber.js@^9.1.1:
|
||||
bignumber.js@^9.1.1:
|
||||
version "9.1.1"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6"
|
||||
integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==
|
||||
@ -567,11 +551,6 @@ chokidar@^3.5.2:
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.2"
|
||||
|
||||
clone@2.x:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
|
||||
integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==
|
||||
|
||||
color-convert@^1.9.0:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
||||
@ -718,11 +697,6 @@ find-replace@^3.0.0:
|
||||
dependencies:
|
||||
array-back "^3.0.1"
|
||||
|
||||
follow-redirects@^1.14.0:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
|
||||
fs-extra@^7.0.0:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
||||
@ -901,13 +875,6 @@ ms@^2.1.1:
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
|
||||
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
|
||||
|
||||
node-cache@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/node-cache/-/node-cache-5.1.2.tgz#f264dc2ccad0a780e76253a694e9fd0ed19c398d"
|
||||
integrity sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==
|
||||
dependencies:
|
||||
clone "2.x"
|
||||
|
||||
nodemon@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.1.tgz#affe822a2c5f21354466b2fc8ae83277d27dadc7"
|
||||
|
Loading…
x
Reference in New Issue
Block a user