@ethersproject/contracts#PayableOverrides TypeScript Examples

The following examples show how to use @ethersproject/contracts#PayableOverrides. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
exactInput(
    params: {
      path: BytesLike
      recipient: string
      deadline: BigNumberish
      amountIn: BigNumberish
      amountOutMinimum: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #2
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
'exactInput(tuple)'(
    params: {
      path: BytesLike
      recipient: string
      deadline: BigNumberish
      amountIn: BigNumberish
      amountOutMinimum: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #3
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
exactInputSingle(
    params: {
      tokenIn: string
      tokenOut: string
      fee: BigNumberish
      recipient: string
      deadline: BigNumberish
      amountIn: BigNumberish
      amountOutMinimum: BigNumberish
      sqrtPriceLimitX96: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #4
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
'exactInputSingle(tuple)'(
    params: {
      tokenIn: string
      tokenOut: string
      fee: BigNumberish
      recipient: string
      deadline: BigNumberish
      amountIn: BigNumberish
      amountOutMinimum: BigNumberish
      sqrtPriceLimitX96: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #5
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
exactOutput(
    params: {
      path: BytesLike
      recipient: string
      deadline: BigNumberish
      amountOut: BigNumberish
      amountInMaximum: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #6
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
'exactOutput(tuple)'(
    params: {
      path: BytesLike
      recipient: string
      deadline: BigNumberish
      amountOut: BigNumberish
      amountInMaximum: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #7
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
exactOutputSingle(
    params: {
      tokenIn: string
      tokenOut: string
      fee: BigNumberish
      recipient: string
      deadline: BigNumberish
      amountOut: BigNumberish
      amountInMaximum: BigNumberish
      sqrtPriceLimitX96: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #8
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
'exactOutputSingle(tuple)'(
    params: {
      tokenIn: string
      tokenOut: string
      fee: BigNumberish
      recipient: string
      deadline: BigNumberish
      amountOut: BigNumberish
      amountInMaximum: BigNumberish
      sqrtPriceLimitX96: BigNumberish
    },
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>
Example #9
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 6 votes vote down vote up
estimateGas: {
    allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<BigNumber>

    'allowance(address,address)'(owner: string, spender: string, overrides?: CallOverrides): Promise<BigNumber>

    approve(spender: string, amount: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    'approve(address,uint256)'(spender: string, amount: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    balanceOf(account: string, overrides?: CallOverrides): Promise<BigNumber>

    'balanceOf(address)'(account: string, overrides?: CallOverrides): Promise<BigNumber>

    deposit(overrides?: PayableOverrides): Promise<BigNumber>

    'deposit()'(overrides?: PayableOverrides): Promise<BigNumber>

    totalSupply(overrides?: CallOverrides): Promise<BigNumber>

    'totalSupply()'(overrides?: CallOverrides): Promise<BigNumber>

    transfer(recipient: string, amount: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    'transfer(address,uint256)'(recipient: string, amount: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    transferFrom(sender: string, recipient: string, amount: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    'transferFrom(address,address,uint256)'(
      sender: string,
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>

    withdraw(arg0: BigNumberish, overrides?: Overrides): Promise<BigNumber>

    'withdraw(uint256)'(arg0: BigNumberish, overrides?: Overrides): Promise<BigNumber>
  }
Example #10
Source File: UnchainedCryptoMarket.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
mintAndBuy(
    to: string,
    contentHash: BytesLike,
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>;
Example #11
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 5 votes vote down vote up
populateTransaction: {
    allowance(owner: string, spender: string, overrides?: CallOverrides): Promise<PopulatedTransaction>

    'allowance(address,address)'(
      owner: string,
      spender: string,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>

    approve(spender: string, amount: BigNumberish, overrides?: Overrides): Promise<PopulatedTransaction>

    'approve(address,uint256)'(
      spender: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>

    balanceOf(account: string, overrides?: CallOverrides): Promise<PopulatedTransaction>

    'balanceOf(address)'(account: string, overrides?: CallOverrides): Promise<PopulatedTransaction>

    deposit(overrides?: PayableOverrides): Promise<PopulatedTransaction>

    'deposit()'(overrides?: PayableOverrides): Promise<PopulatedTransaction>

    totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>

    'totalSupply()'(overrides?: CallOverrides): Promise<PopulatedTransaction>

    transfer(recipient: string, amount: BigNumberish, overrides?: Overrides): Promise<PopulatedTransaction>

    'transfer(address,uint256)'(
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>

    transferFrom(
      sender: string,
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>

    'transferFrom(address,address,uint256)'(
      sender: string,
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>

    withdraw(arg0: BigNumberish, overrides?: Overrides): Promise<PopulatedTransaction>

    'withdraw(uint256)'(arg0: BigNumberish, overrides?: Overrides): Promise<PopulatedTransaction>
  }
Example #12
Source File: UnchainedCryptoMarket.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
"mintAndBuy(address,bytes32)"(
    to: string,
    contentHash: BytesLike,
    overrides?: PayableOverrides
  ): Promise<ContractTransaction>;
Example #13
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 5 votes vote down vote up
'deposit()'(overrides?: PayableOverrides): Promise<ContractTransaction>
Example #14
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 5 votes vote down vote up
deposit(overrides?: PayableOverrides): Promise<ContractTransaction>
Example #15
Source File: UnchainedCryptoMarket.d.ts    From nft-marketplace with European Union Public License 1.2 4 votes vote down vote up
functions: {
    approve(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    "approve(address,uint256)"(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    balanceOf(owner: string, overrides?: CallOverrides): Promise<[BigNumber]>;

    "balanceOf(address)"(
      owner: string,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    baseURI(overrides?: CallOverrides): Promise<[string]>;

    "baseURI()"(overrides?: CallOverrides): Promise<[string]>;

    contentHashes(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    "contentHashes(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    getApproved(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    "getApproved(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    hashToTokenId(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    "hashToTokenId(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    isApprovedForAll(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    "isApprovedForAll(address,address)"(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    mintAndBuy(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>;

    "mintAndBuy(address,bytes32)"(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>;

    name(overrides?: CallOverrides): Promise<[string]>;

    "name()"(overrides?: CallOverrides): Promise<[string]>;

    owner(overrides?: CallOverrides): Promise<[string]>;

    "owner()"(overrides?: CallOverrides): Promise<[string]>;

    ownerOf(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    "ownerOf(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    pricePerToken(overrides?: CallOverrides): Promise<[BigNumber]>;

    "pricePerToken()"(overrides?: CallOverrides): Promise<[BigNumber]>;

    renounceOwnership(overrides?: Overrides): Promise<ContractTransaction>;

    "renounceOwnership()"(overrides?: Overrides): Promise<ContractTransaction>;

    "safeTransferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    "safeTransferFrom(address,address,uint256,bytes)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      _data: BytesLike,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    setApprovalForAll(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    "setApprovalForAll(address,bool)"(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    supportsInterface(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    "supportsInterface(bytes4)"(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<[boolean]>;

    symbol(overrides?: CallOverrides): Promise<[string]>;

    "symbol()"(overrides?: CallOverrides): Promise<[string]>;

    tokenByIndex(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    "tokenByIndex(uint256)"(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    tokenContentHashes(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    "tokenContentHashes(uint256)"(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    tokenOfOwnerByIndex(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    "tokenOfOwnerByIndex(address,uint256)"(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[BigNumber]>;

    tokenURI(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    "tokenURI(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<[string]>;

    totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;

    "totalSupply()"(overrides?: CallOverrides): Promise<[BigNumber]>;

    transferFrom(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    "transferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    transferOwnership(
      newOwner: string,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    "transferOwnership(address)"(
      newOwner: string,
      overrides?: Overrides
    ): Promise<ContractTransaction>;

    withdraw(overrides?: Overrides): Promise<ContractTransaction>;

    "withdraw()"(overrides?: Overrides): Promise<ContractTransaction>;
  };
Example #16
Source File: UnchainedCryptoMarket.d.ts    From nft-marketplace with European Union Public License 1.2 4 votes vote down vote up
estimateGas: {
    approve(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>;

    "approve(address,uint256)"(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>;

    balanceOf(owner: string, overrides?: CallOverrides): Promise<BigNumber>;

    "balanceOf(address)"(
      owner: string,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    baseURI(overrides?: CallOverrides): Promise<BigNumber>;

    "baseURI()"(overrides?: CallOverrides): Promise<BigNumber>;

    contentHashes(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "contentHashes(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    getApproved(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "getApproved(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    hashToTokenId(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "hashToTokenId(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    isApprovedForAll(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "isApprovedForAll(address,address)"(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    mintAndBuy(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<BigNumber>;

    "mintAndBuy(address,bytes32)"(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<BigNumber>;

    name(overrides?: CallOverrides): Promise<BigNumber>;

    "name()"(overrides?: CallOverrides): Promise<BigNumber>;

    owner(overrides?: CallOverrides): Promise<BigNumber>;

    "owner()"(overrides?: CallOverrides): Promise<BigNumber>;

    ownerOf(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "ownerOf(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    pricePerToken(overrides?: CallOverrides): Promise<BigNumber>;

    "pricePerToken()"(overrides?: CallOverrides): Promise<BigNumber>;

    renounceOwnership(overrides?: Overrides): Promise<BigNumber>;

    "renounceOwnership()"(overrides?: Overrides): Promise<BigNumber>;

    "safeTransferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>;

    "safeTransferFrom(address,address,uint256,bytes)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      _data: BytesLike,
      overrides?: Overrides
    ): Promise<BigNumber>;

    setApprovalForAll(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<BigNumber>;

    "setApprovalForAll(address,bool)"(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<BigNumber>;

    supportsInterface(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "supportsInterface(bytes4)"(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    symbol(overrides?: CallOverrides): Promise<BigNumber>;

    "symbol()"(overrides?: CallOverrides): Promise<BigNumber>;

    tokenByIndex(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "tokenByIndex(uint256)"(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    tokenContentHashes(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "tokenContentHashes(uint256)"(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    tokenOfOwnerByIndex(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "tokenOfOwnerByIndex(address,uint256)"(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    tokenURI(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    "tokenURI(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<BigNumber>;

    totalSupply(overrides?: CallOverrides): Promise<BigNumber>;

    "totalSupply()"(overrides?: CallOverrides): Promise<BigNumber>;

    transferFrom(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>;

    "transferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<BigNumber>;

    transferOwnership(
      newOwner: string,
      overrides?: Overrides
    ): Promise<BigNumber>;

    "transferOwnership(address)"(
      newOwner: string,
      overrides?: Overrides
    ): Promise<BigNumber>;

    withdraw(overrides?: Overrides): Promise<BigNumber>;

    "withdraw()"(overrides?: Overrides): Promise<BigNumber>;
  };
Example #17
Source File: Swap.tsx    From hypertext with GNU General Public License v3.0 4 votes vote down vote up
export default function Swap({ buy }: { buy: boolean }): JSX.Element {
  const { query, pathname, replace } = useRouter()

  const queryParameters = useQueryParameters()

  const { account, chainId, library } = useWeb3React()

  const [approveMax] = useApproveMax()
  const [deadlineDelta] = useDeadline()
  const [slippage] = useSlippage()
  const [, { addTransaction }] = useTransactions()

  // reducer state
  const [state, dispatch] = useReducer(
    reducer,
    {
      independentField: buy ? Field.OUTPUT : Field.INPUT,
      [Field.INPUT]: {
        address: queryParameters[QueryParameters.INPUT],
      },
      [Field.OUTPUT]: {
        address: queryParameters[QueryParameters.OUTPUT],
      },
    },
    initializeSentenceState
  )
  const { independentField, value, ...tokenAddresses } = state

  // derived state
  const dependentField = independentField === Field.INPUT ? Field.OUTPUT : Field.INPUT
  const tradeType = independentField === Field.INPUT ? TradeType.EXACT_INPUT : TradeType.EXACT_OUTPUT

  // sdk tokens
  const tokens = {
    [Field.INPUT]: useTokenByAddressAndAutomaticallyAdd(tokenAddresses[Field.INPUT].address),
    [Field.OUTPUT]: useTokenByAddressAndAutomaticallyAdd(tokenAddresses[Field.OUTPUT].address),
  }

  // keep global token state in sync
  const [, setFirstToken] = useFirstToken()
  const [, setSecondToken] = useSecondToken()
  useEffect(() => {
    setFirstToken(tokens[buy ? Field.OUTPUT : Field.INPUT])
    setSecondToken(tokens[buy ? Field.INPUT : Field.OUTPUT])
  })

  // sdk route
  const [naiveRoute, allPairs] = useRoute(tokens[Field.INPUT], tokens[Field.OUTPUT])

  // parse user value
  const parsed: { [field: number]: TokenAmount } = {}
  if (value !== '' && value !== '.' && tokens[independentField]) {
    try {
      const valueParsed = parseUnits(value, tokens[independentField]?.decimals).toString()
      if (valueParsed !== '0') {
        parsed[independentField] = new TokenAmount(tokens[independentField] as Token, valueParsed)
      }
    } catch {
      // should only fail if the user specifies too many decimal places of precision (or maybe exceed max uint?)
    }
  }

  // sdk trade
  const trade = useTrade(tokens[Field.INPUT], tokens[Field.OUTPUT], allPairs, parsed[independentField], tradeType)

  const route = trade ? trade.route : naiveRoute

  // populate the parsed dependent field
  if (trade) {
    if (tradeType === TradeType.EXACT_INPUT) {
      parsed[dependentField] = trade.minimumAmountOut(new Percent(`${slippage}`, `${10000}`))
    } else {
      parsed[dependentField] = trade.maximumAmountIn(new Percent(`${slippage}`, `${10000}`))
    }
  }

  // usd values
  const [showUSD] = useShowUSD()
  const USDPrices = {
    [Field.INPUT]: useUSDTokenPrice(tokens[Field.INPUT]),
    [Field.OUTPUT]: useUSDTokenPrice(tokens[Field.OUTPUT]),
  }
  const USDAmountsFormatted = {
    [Field.INPUT]:
      parsed[Field.INPUT] && USDPrices[Field.INPUT]
        ? parsed[Field.INPUT].multiply(USDPrices[Field.INPUT] as Fraction).toFixed(2, { groupSeparator: ',' })
        : undefined,
    [Field.OUTPUT]:
      parsed[Field.OUTPUT] && USDPrices[Field.OUTPUT]
        ? parsed[Field.OUTPUT].multiply(USDPrices[Field.OUTPUT] as Fraction).toFixed(2, { groupSeparator: ',' })
        : undefined,
  }

  // calculate the formatted values from the parsed
  const formatted = {
    [independentField]: value,
    [dependentField]: parsed[dependentField] ? parsed[dependentField].toSignificant(4, { groupSeparator: ',' }) : '',
  }

  // reset when the network changes
  useEffect(() => {
    if (typeof chainId === 'number') {
      return (): void => {
        dispatch({
          type: ActionType.RESET,
          payload: { field: buy ? Field.OUTPUT : Field.INPUT },
        })
      }
    }
  }, [chainId, buy])

  // clear url params
  useEffect(() => {
    if (Object.keys(query).length > 0) {
      if (isIPFS) {
        window.history.replaceState(null, '', `.${pathname}.html`)
      } else {
        replace(pathname, undefined, { shallow: true })
      }
    }
  })

  // get input allowance for validation purposes
  const { data: _allowance } = useTokenAllowance(tokens[Field.INPUT], account, ROUTER_ADDRESS)
  const allowance = tokens[Field.INPUT]?.equals(WETH[(tokens[Field.INPUT] as Token).chainId])
    ? new TokenAmount(WETH[(tokens[Field.INPUT] as Token).chainId], MAX_UINT256)
    : _allowance

  // get permitAndCall allowance if the input token supports permit
  const { data: permitAndCallAllowance } = useTokenAllowance(
    canPermit(tokens[Field.INPUT]) ? tokens[Field.INPUT] : undefined,
    account,
    PERMIT_AND_CALL_ADDRESS
  )

  // get input balance for validation purposes
  const ETHBalance = useETHBalance(account)
  const _balance = useTokenBalance(tokens[Field.INPUT], account)
  const balance = tokens[Field.INPUT]?.equals(WETH[(tokens[Field.INPUT] as Token)?.chainId])
    ? ETHBalance.data
    : _balance.data

  // compute flags for warning states
  const warning = !!trade && Number.parseFloat(trade.slippage.toSignificant(2)) >= 5
  const danger = !!trade && Number.parseFloat(trade.slippage.toSignificant(2)) >= 10

  // compute validation flags
  const isInvalidBalance =
    parsed[Field.INPUT] && balance ? JSBI.greaterThan(parsed[Field.INPUT].raw, balance.raw) : false
  const isInvalidRoute = route === null && value.length > 0
  const isInvalidTrade = route && parsed[independentField] ? !!!trade : false

  // compute flag for whether maxing is allowed
  const canMax =
    !tokens[Field.INPUT]?.equals(WETH[(tokens[Field.INPUT] as Token).chainId]) &&
    !isInvalidRoute &&
    formatted[Field.INPUT]?.length === 0 &&
    !!balance &&
    JSBI.greaterThan(balance.raw, ZERO)

  // function to perform the swap
  const [swapping, setSwapping] = useState(false)
  const inputToken = useContract(tokens[Field.INPUT]?.address, IERC20.abi, true)
  const router = useContract(ROUTER_ADDRESS, IUniswapV2Router02ABI, true)
  async function swap(): Promise<void> {
    setSwapping(true)

    async function innerSwap(deadline: number, mockGas = false, permit?: Permit): Promise<{ hash: string }> {
      let routerFunctionNames: string[]
      let routerArguments: any[] // eslint-disable-line @typescript-eslint/no-explicit-any
      let value: Required<PayableOverrides>['value'] = 0

      if (trade?.tradeType === TradeType.EXACT_INPUT) {
        if ((tokens[Field.INPUT] as Token).equals(WETH[(tokens[Field.INPUT] as Token).chainId])) {
          routerFunctionNames = ['swapExactETHForTokens', 'swapExactETHForTokensSupportingFeeOnTransferTokens']
          routerArguments = [
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
          value = `0x${parsed[Field.INPUT].raw.toString(16)}`
        } else if ((tokens[Field.OUTPUT] as Token).equals(WETH[(tokens[Field.OUTPUT] as Token).chainId])) {
          routerFunctionNames = ['swapExactTokensForETH', 'swapExactTokensForETHSupportingFeeOnTransferTokens']
          routerArguments = [
            `0x${parsed[Field.INPUT].raw.toString(16)}`,
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
        } else {
          routerFunctionNames = ['swapExactTokensForTokens', 'swapExactTokensForTokensSupportingFeeOnTransferTokens']
          routerArguments = [
            `0x${parsed[Field.INPUT].raw.toString(16)}`,
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
        }
      } else {
        if ((tokens[Field.INPUT] as Token).equals(WETH[(tokens[Field.INPUT] as Token).chainId])) {
          routerFunctionNames = ['swapETHForExactTokens']
          routerArguments = [
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
          value = `0x${parsed[Field.INPUT].raw.toString(16)}`
        } else if ((tokens[Field.OUTPUT] as Token).equals(WETH[(tokens[Field.OUTPUT] as Token).chainId])) {
          routerFunctionNames = ['swapTokensForExactETH']
          routerArguments = [
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            `0x${parsed[Field.INPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
        } else {
          routerFunctionNames = ['swapTokensForExactTokens']
          routerArguments = [
            `0x${parsed[Field.OUTPUT].raw.toString(16)}`,
            `0x${parsed[Field.INPUT].raw.toString(16)}`,
            (route as Route).path.map((token) => token.address),
            account,
            deadline,
          ]
        }
      }

      // we have an approve tx pending
      if (mockGas) {
        // because we can't estimate gas, as it will fail b/c of the approve, we are forced to use the first function
        const routerFunctionName = routerFunctionNames[0]
        return await (router as Contract)
          [routerFunctionName](...routerArguments, {
            value,
            gasLimit: GAS_LIMIT_WHEN_MOCKING,
          })
          .catch((error: ErrorWithCode) => {
            if (error?.code !== 4001) {
              console.log(`${routerFunctionName} failed with a mocked gas limit.`, error)
            }
            throw error
          })
      }

      // we have permit data
      if (permit) {
        const permitAndCall = new Contract(
          PERMIT_AND_CALL_ADDRESS,
          [
            'function permitAndCall(address token, uint256 value, bytes4 permitSelector, bytes calldata permitData, bytes4 routerFunctionSelector, bytes calldata routerFunctionData)',
          ],
          library.getSigner(account).connectUnchecked()
        )

        // try to get a gas limit for each function name in turn
        for (const routerFunctionName of routerFunctionNames) {
          const routerFunctionFragment = (router as Contract).interface.fragments.filter(
            ({ name }) => name === routerFunctionName
          )[0]
          const routerFunctionSelector = hexDataSlice(
            id(`${routerFunctionName}(${routerFunctionFragment?.inputs.map(({ type }) => type).join(',')})`),
            0,
            4
          )
          const permitAndCallArguments = [
            (tokens[Field.INPUT] as Token).address,
            `0x${parsed[Field.INPUT].raw.toString(16)}`,
            permit.permitSelector,
            permit.permitData,
            routerFunctionSelector,
            defaultAbiCoder.encode(routerFunctionFragment.inputs, routerArguments),
          ]
          const gasLimit: BigNumber | void = await permitAndCall.estimateGas
            .permitAndCall(...permitAndCallArguments, { value })
            .then((gasLimit) => gasLimit.mul(105).div(100))
            .catch((error) => {
              console.log(`estimateGas failed for ${routerFunctionName} via permitAndCall.`, error)
            })
          if (BigNumber.isBigNumber(gasLimit)) {
            return await permitAndCall
              .permitAndCall(...permitAndCallArguments, {
                value,
                gasLimit,
              })
              .catch((error: ErrorWithCode) => {
                if (error?.code !== 4001) {
                  console.log(`${routerFunctionName} failed via permitAndCall.`, error)
                }
                throw error
              })
          }
        }
        // if we're here, it means all estimateGas calls failed
        console.log(
          routerFunctionNames.length === 1
            ? "If you're trying to swap a token that takes a transfer fee, you must specify an exact input amount."
            : "If you're trying to swap a token that takes a transfer fee, ensure your slippage tolerance is higher than the fee."
        )
        throw Error()
      }

      // try to get a gas limit for each function name in turn
      for (const routerFunctionName of routerFunctionNames) {
        const gasLimit: BigNumber | void = await (router as Contract).estimateGas[
          routerFunctionName
        ](...routerArguments, { value })
          .then((gasLimit) => gasLimit.mul(105).div(100))
          .catch((error) => {
            console.log(`estimateGas failed for ${routerFunctionName}.`, error)
          })
        if (BigNumber.isBigNumber(gasLimit)) {
          return await (router as Contract)
            [routerFunctionName](...routerArguments, { value, gasLimit })
            .catch((error: ErrorWithCode) => {
              if (error?.code !== 4001) {
                console.log(`${routerFunctionName} failed.`, error)
              }
              throw error
            })
        }
      }
      // if we're here, it means all estimateGas calls failed
      console.log(
        routerFunctionNames.length === 1
          ? "If you're trying to swap a token that takes a transfer fee, you must specify an exact input amount."
          : "If you're trying to swap a token that takes a transfer fee, ensure your slippage tolerance is higher than the fee."
      )
      throw Error()
    }

    const deadline = Math.floor(Date.now() / 1000) + deadlineDelta
    let approved = JSBI.greaterThanOrEqual((allowance as TokenAmount).raw, parsed[Field.INPUT].raw)
    let mockGas = false
    let permit: Permit | undefined
    if (!approved) {
      let tryToManuallyApprove = true

      // attempt to gather a permit signature where possible
      if (canPermit(tokens[Field.INPUT])) {
        // in the slightly weird case where the user has already approved PermitAndCall, just fake the permit
        if (permitAndCallAllowance && JSBI.greaterThanOrEqual(permitAndCallAllowance.raw, parsed[Field.INPUT].raw)) {
          approved = true
          tryToManuallyApprove = false
          permit = {
            permitSelector: '0x00000000',
            permitData: '0x',
          }
        } else {
          await gatherPermit(
            account as string,
            deadline,
            approveMax ? MAX_UINT256 : parsed[Field.INPUT].raw,
            tokens[Field.INPUT] as Token,
            library
          )
            .then((gatheredPermit) => {
              approved = true
              tryToManuallyApprove = false
              permit = gatheredPermit
            })
            .catch((error) => {
              // if the error code is 4001 (EIP-1193 user rejected request), we don't want to try a manual approve
              if (error?.code === 4001) {
                tryToManuallyApprove = false
              } else {
                console.log(`permit failed.`, error)
              }
            })
        }
      }

      if (tryToManuallyApprove) {
        await (inputToken as Contract)
          .approve(ROUTER_ADDRESS, `0x${(approveMax ? MAX_UINT256 : parsed[Field.INPUT].raw).toString(16)}`)
          .then(({ hash }: { hash: string }) => {
            addTransaction(chainId as number, hash)
            approved = true
            mockGas = true
          })
          .catch((error: ErrorWithCode) => {
            if (error?.code !== 4001) {
              console.log(`approve failed.`, error)
            }
          })
      }
    }

    if (approved) {
      return (
        innerSwap(deadline, mockGas, permit)
          .then(({ hash }) => {
            addTransaction(chainId as number, hash)
            dispatch({
              type: ActionType.TYPE,
              payload: { field: independentField, value: '' },
            })
            setSwapping(false)
          })
          // we don't do anything with the error here, innerSwap is responsible for handling it
          .catch(() => {
            setSwapping(false)
          })
      )
    } else {
      setSwapping(false)
    }
  }

  const formattedQueryParams = formatQueryParams({
    ...(tokens[Field.INPUT]?.address ? { [QueryParameters.INPUT]: (tokens[Field.INPUT] as Token).address } : {}),
    ...(tokens[Field.OUTPUT]?.address ? { [QueryParameters.OUTPUT]: (tokens[Field.OUTPUT] as Token).address } : {}),
  })

  return (
    <Stack
      direction="column"
      align="center"
      spacing="6rem"
      flexGrow={1}
      justifyContent="center"
      px="2.5rem"
      py="8rem"
      shouldWrapChildren
    >
      <Stack direction="row" align="flex-start" spacing="1rem" flexWrap="wrap" shouldWrapChildren>
        <SwapText>I want to</SwapText>

        {!!!trade ? (
          isIPFS ? (
            <Button
              as="a"
              {...{
                href: `./${buy ? 'sell' : 'buy'}.html${formattedQueryParams}`,
              }}
              variant="ghost"
              variantColor={buy ? 'green' : 'red'}
              p="0.5rem"
              mt="-0.2rem"
              fontSize="3xl"
              lineHeight={1}
              height="min-content"
            >
              {buy ? 'Buy' : 'Sell'}
            </Button>
          ) : (
            <NextLink href={`/${buy ? 'sell' : 'buy'}${formattedQueryParams}`} passHref>
              <Button
                as="a"
                variant="ghost"
                variantColor={buy ? 'green' : 'red'}
                p="0.5rem"
                mt="-0.2rem"
                fontSize="3xl"
                lineHeight={1}
                height="min-content"
              >
                {buy ? 'Buy' : 'Sell'}
              </Button>
            </NextLink>
          )
        ) : (
          <Button
            variant="solid"
            variantColor={!warning ? (buy ? 'green' : 'red') : 'yellow'}
            p="0.75rem"
            mt="-0.45rem"
            fontSize="3xl"
            lineHeight={1}
            height="min-content"
            leftIcon={!warning ? undefined : !danger ? 'warning-2' : 'not-allowed'}
            isDisabled={!account || isInvalidBalance || isInvalidTrade}
            isLoading={swapping}
            cursor={warning ? 'not-allowed' : 'pointer'}
            onClick={swap}
          >
            {buy ? 'Buy' : 'Sell'}
          </Button>
        )}

        {trade && independentField === (buy ? Field.INPUT : Field.OUTPUT) ? (
          <SwapText>{buy ? 'at least' : 'at most'}</SwapText>
        ) : null}

        <AmountInput
          controlled={independentField === (buy ? Field.OUTPUT : Field.INPUT)}
          isDisabled={showUSD || swapping}
          isInvalid={isInvalidTrade || (!buy && isInvalidBalance)}
          value={
            showUSD && USDAmountsFormatted[buy ? Field.OUTPUT : Field.INPUT]
              ? `$${USDAmountsFormatted[buy ? Field.OUTPUT : Field.INPUT]}`
              : formatted[buy ? Field.OUTPUT : Field.INPUT]
          }
          onChange={(value): void => {
            dispatch({
              type: ActionType.TYPE,
              payload: { field: buy ? Field.OUTPUT : Field.INPUT, value },
            })
          }}
        />

        {!buy && canMax ? (
          <Button
            size="sm"
            mt="0.3rem"
            onClick={(): void => {
              dispatch({
                type: ActionType.TYPE,
                payload: { field: Field.INPUT, value: balance?.toExact() },
              })
            }}
          >
            Max
          </Button>
        ) : null}

        <TokenSelect
          tokenAddress={tokenAddresses[buy ? Field.OUTPUT : Field.INPUT].address}
          isInvalid={isInvalidRoute}
          isDisabled={swapping}
          onAddressSelect={(address): void => {
            dispatch({
              type: ActionType.SELECT_TOKEN,
              payload: { field: buy ? Field.OUTPUT : Field.INPUT, address },
            })
          }}
        />

        <SwapText>
          {buy ? 'with' : 'for'}
          {trade && independentField === (buy ? Field.OUTPUT : Field.INPUT) ? (buy ? ' at most' : ' at least') : ''}
        </SwapText>

        <AmountInput
          controlled={independentField === (buy ? Field.INPUT : Field.OUTPUT)}
          isDisabled={showUSD || swapping}
          isInvalid={isInvalidTrade || (buy && isInvalidBalance)}
          value={
            showUSD && USDAmountsFormatted[buy ? Field.INPUT : Field.OUTPUT]
              ? `$${USDAmountsFormatted[buy ? Field.INPUT : Field.OUTPUT]}`
              : formatted[buy ? Field.INPUT : Field.OUTPUT]
          }
          onChange={(value): void => {
            dispatch({
              type: ActionType.TYPE,
              payload: { field: buy ? Field.INPUT : Field.OUTPUT, value },
            })
          }}
        />

        {buy && canMax ? (
          <Button
            size="sm"
            mt="0.3rem"
            onClick={(): void => {
              dispatch({
                type: ActionType.TYPE,
                payload: { field: Field.INPUT, value: balance?.toExact() },
              })
            }}
          >
            Max
          </Button>
        ) : null}

        <TokenSelect
          tokenAddress={tokenAddresses[buy ? Field.INPUT : Field.OUTPUT].address}
          isInvalid={isInvalidRoute}
          isDisabled={swapping}
          onAddressSelect={(address): void => {
            dispatch({
              type: ActionType.SELECT_TOKEN,
              payload: { field: buy ? Field.INPUT : Field.OUTPUT, address },
            })
          }}
        />

        <SwapText fontSize="3xl" lineHeight={1} pt="0.3rem">
          .
        </SwapText>
      </Stack>

      <TradeSummary route={route} trade={trade} warning={warning} danger={danger} />
    </Stack>
  )
}
Example #18
Source File: UnchainedCryptoMarket.d.ts    From nft-marketplace with European Union Public License 1.2 4 votes vote down vote up
populateTransaction: {
    approve(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    "approve(address,uint256)"(
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    balanceOf(
      owner: string,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "balanceOf(address)"(
      owner: string,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    baseURI(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "baseURI()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    contentHashes(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "contentHashes(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    getApproved(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "getApproved(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    hashToTokenId(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "hashToTokenId(bytes32)"(
      arg0: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    isApprovedForAll(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "isApprovedForAll(address,address)"(
      owner: string,
      operator: string,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    mintAndBuy(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>;

    "mintAndBuy(address,bytes32)"(
      to: string,
      contentHash: BytesLike,
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>;

    name(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "name()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "owner()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    ownerOf(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "ownerOf(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    pricePerToken(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "pricePerToken()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    renounceOwnership(overrides?: Overrides): Promise<PopulatedTransaction>;

    "renounceOwnership()"(overrides?: Overrides): Promise<PopulatedTransaction>;

    "safeTransferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    "safeTransferFrom(address,address,uint256,bytes)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      _data: BytesLike,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    setApprovalForAll(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    "setApprovalForAll(address,bool)"(
      operator: string,
      approved: boolean,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    supportsInterface(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "supportsInterface(bytes4)"(
      interfaceId: BytesLike,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    symbol(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "symbol()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    tokenByIndex(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "tokenByIndex(uint256)"(
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    tokenContentHashes(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "tokenContentHashes(uint256)"(
      arg0: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    tokenOfOwnerByIndex(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "tokenOfOwnerByIndex(address,uint256)"(
      owner: string,
      index: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    tokenURI(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    "tokenURI(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): Promise<PopulatedTransaction>;

    totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    "totalSupply()"(overrides?: CallOverrides): Promise<PopulatedTransaction>;

    transferFrom(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    "transferFrom(address,address,uint256)"(
      from: string,
      to: string,
      tokenId: BigNumberish,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    transferOwnership(
      newOwner: string,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    "transferOwnership(address)"(
      newOwner: string,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>;

    withdraw(overrides?: Overrides): Promise<PopulatedTransaction>;

    "withdraw()"(overrides?: Overrides): Promise<PopulatedTransaction>;
  };
Example #19
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 4 votes vote down vote up
functions: {
    allowance(
      owner: string,
      spender: string,
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    'allowance(address,address)'(
      owner: string,
      spender: string,
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    approve(spender: string, amount: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>

    'approve(address,uint256)'(
      spender: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>

    balanceOf(
      account: string,
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    'balanceOf(address)'(
      account: string,
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    deposit(overrides?: PayableOverrides): Promise<ContractTransaction>

    'deposit()'(overrides?: PayableOverrides): Promise<ContractTransaction>

    totalSupply(
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    'totalSupply()'(
      overrides?: CallOverrides
    ): Promise<{
      0: BigNumber
    }>

    transfer(recipient: string, amount: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>

    'transfer(address,uint256)'(
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>

    transferFrom(
      sender: string,
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>

    'transferFrom(address,address,uint256)'(
      sender: string,
      recipient: string,
      amount: BigNumberish,
      overrides?: Overrides
    ): Promise<ContractTransaction>

    withdraw(arg0: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>

    'withdraw(uint256)'(arg0: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>
  }
Example #20
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 4 votes vote down vote up
populateTransaction: {
    exactInput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    'exactInput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    exactInputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    'exactInputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    exactOutput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    'exactOutput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    exactOutputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    'exactOutputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<PopulatedTransaction>

    uniswapV3SwapCallback(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>

    'uniswapV3SwapCallback(int256,int256,bytes)'(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<PopulatedTransaction>
  }
Example #21
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 4 votes vote down vote up
estimateGas: {
    exactInput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    'exactInput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    exactInputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    'exactInputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    exactOutput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    'exactOutput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    exactOutputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    'exactOutputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<BigNumber>

    uniswapV3SwapCallback(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<BigNumber>

    'uniswapV3SwapCallback(int256,int256,bytes)'(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<BigNumber>
  }
Example #22
Source File: ISwapRouter.d.ts    From hardhat-v3-deploy with MIT License 4 votes vote down vote up
functions: {
    exactInput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    'exactInput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    exactInputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    'exactInputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountIn: BigNumberish
        amountOutMinimum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    exactOutput(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    'exactOutput(tuple)'(
      params: {
        path: BytesLike
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    exactOutputSingle(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    'exactOutputSingle(tuple)'(
      params: {
        tokenIn: string
        tokenOut: string
        fee: BigNumberish
        recipient: string
        deadline: BigNumberish
        amountOut: BigNumberish
        amountInMaximum: BigNumberish
        sqrtPriceLimitX96: BigNumberish
      },
      overrides?: PayableOverrides
    ): Promise<ContractTransaction>

    uniswapV3SwapCallback(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<ContractTransaction>

    'uniswapV3SwapCallback(int256,int256,bytes)'(
      amount0Delta: BigNumberish,
      amount1Delta: BigNumberish,
      data: BytesLike,
      overrides?: Overrides
    ): Promise<ContractTransaction>
  }