@ethersproject/contracts#Overrides TypeScript Examples

The following examples show how to use @ethersproject/contracts#Overrides. 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: PerpService.ts    From sakeperp-arbitrageur with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
async closePosition(
        trader: Wallet,
        exchangeAddr: string,
        exchangePair: string,
        minBaseAssetAmount: Big = Big(0),
        overrides?: Overrides,
    ): Promise<TransactionResponse> {
        const sakePerp = await this.createSakePerp(trader)
        const tx = await sakePerp.functions.closePosition(
            exchangeAddr,
            { d: PerpService.toWei(minBaseAssetAmount) },
            {
                gasLimit: 2_500_000,
                ...overrides,
            },
        )
        this.log.jinfo({
            event: "ClosePositionTxSent",
            params: {
                trader: trader.address,
                exchangePair: exchangePair,
                txHash: tx.hash,
                gasPrice: tx.gasPrice.toString(),
                nonce: tx.nonce,
            },
        })

        return tx
    }
Example #2
Source File: UnchainedCryptoMarket__factory.ts    From nft-marketplace with European Union Public License 1.2 6 votes vote down vote up
deploy(
    pricePerToken_: BigNumberish,
    overrides?: Overrides
  ): Promise<UnchainedCryptoMarket> {
    return super.deploy(
      pricePerToken_,
      overrides || {}
    ) as Promise<UnchainedCryptoMarket>;
  }
Example #3
Source File: ERC20Service.ts    From sakeperp-arbitrageur with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
async approve(
        tokenAddr: string,
        spenderAddr: string,
        amount: Big,
        from: Wallet,
        overrides?: Overrides,
    ): Promise<void> {
        const token = this.createErc20Contract(tokenAddr, from)
        const scaledAmount = await this.toScaled(tokenAddr, amount)
        const tx = await token.functions.approve(spenderAddr, scaledAmount, {
            ...overrides,
        })
        const receipt = await tx.wait()
        if (receipt.status !== 1) throw new Error(`transferError:${tx.hash}`)
    }
Example #4
Source File: Ownable.d.ts    From nft-marketplace with European Union Public License 1.2 6 votes vote down vote up
functions: {
    owner(overrides?: CallOverrides): Promise<[string]>;

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

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

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

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

    "transferOwnership(address)"(
      newOwner: string,
      overrides?: Overrides
    ): Promise<ContractTransaction>;
  };
Example #5
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 #6
Source File: IERC721Metadata.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
"transferFrom(address,address,uint256)"(
    from: string,
    to: string,
    tokenId: BigNumberish,
    overrides?: Overrides
  ): Promise<ContractTransaction>;
Example #7
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 5 votes vote down vote up
'withdraw(uint256)'(arg0: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>
Example #8
Source File: ERC721.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
"transferFrom(address,address,uint256)"(
    from: string,
    to: string,
    tokenId: BigNumberish,
    overrides?: Overrides
  ): Promise<ContractTransaction>;
Example #9
Source File: worker.ts    From noether with Apache License 2.0 5 votes vote down vote up
_hire = async (
    workerManager: WorkerManager,
    gasPriceProvider: GasPriceProvider,
    address: string
): Promise<string | undefined> => {
    const owned = await workerManager.isOwned(address);
    if (owned) {
        // already owned, just return the owner
        return workerManager.getOwner(address);
    }

    const user = await workerManager.getUser(address);
    if (await retire(workerManager, gasPriceProvider, address, user)) {
        // if retire returns true, exit
        process.exit(0);
    }

    let available = await workerManager.isAvailable(address);
    if (available) {
        log.info(`${address} available for hiring`);

        // loop while available
        do {
            await sleep(POLLING_INTERVAL);
            available = await workerManager.isAvailable(address);
            log.info(`${address} available for hiring`);
        } while (available);
    }

    let pending = await workerManager.isPending(address);
    if (pending) {
        // accept the job from user
        const user = await workerManager.getUser(address);
        log.info(`accepting job from ${user}...`);

        // evaluate the gas price
        const gasPrice = await gasPriceProvider.getGasPrice();
        const overrides: Overrides = { gasPrice };

        const tx = await workerManager.acceptJob(overrides);
        log.info(`transaction ${tx.hash}, waiting for confirmation...`);
        const receipt = await tx.wait(CONFIRMATIONS);
        log.debug(`gas used: ${receipt.gasUsed}`);
        return workerManager.getOwner(address);
    }
    return undefined;
}
Example #10
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 #11
Source File: ERC721.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
setApprovalForAll(
    operator: string,
    approved: boolean,
    overrides?: Overrides
  ): Promise<ContractTransaction>;
Example #12
Source File: IWETH9.d.ts    From hardhat-v3-deploy with MIT License 5 votes vote down vote up
withdraw(arg0: BigNumberish, overrides?: Overrides): Promise<ContractTransaction>
Example #13
Source File: PerpService.ts    From sakeperp-arbitrageur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
async openPosition(
        trader: Wallet,
        exchangePair: string,
        exchangeAddr: string,
        side: Side,
        quoteAssetAmount: Big,
        leverage: Big,
        minBaseAssetAmount: Big = Big(0),
        overrides?: Overrides,
    ): Promise<TransactionResponse> {
        const sakePerp = await this.createSakePerp(trader)

        // if the tx gonna fail it will throw here
        // const gasEstimate = await sakePerp.estimateGas.openPosition(
        //     exchangeAddr,
        //     side.valueOf(),
        //     { d: PerpService.toWei(quoteAssetAmount) },
        //     { d: PerpService.toWei(leverage) },
        //     { d: PerpService.toWei(minBaseAssetAmount) },
        // )

        const tx = await sakePerp.functions.openPosition(
            exchangeAddr,
            side.valueOf(),
            { d: PerpService.toWei(quoteAssetAmount) },
            { d: PerpService.toWei(leverage) },
            { d: PerpService.toWei(minBaseAssetAmount) },
            {
                // add a margin for gas limit since its estimation was sometimes too tight
                // gasLimit: BigNumber.from(
                //     Big(gasEstimate.toString())
                //         .mul(Big(1.2))
                //         .toFixed(0),
                // ),
                gasLimit: 2_500_000,
                ...overrides,
            },
        )
        this.log.jinfo({
            event: "OpenPositionTxSent",
            params: {
                exchangePair: exchangePair,
                trader: trader.address,
                amm: exchangeAddr,
                side,
                quoteAssetAmount: +quoteAssetAmount,
                leverage: +leverage,
                minBaseAssetAmount: +minBaseAssetAmount,
                txHash: tx.hash,
                gasPrice: tx.gasPrice.toString(),
                nonce: tx.nonce,
            },
        })

        return tx
    }
Example #14
Source File: IERC721.d.ts    From nft-marketplace with European Union Public License 1.2 5 votes vote down vote up
"transferFrom(address,address,uint256)"(
    from: string,
    to: string,
    tokenId: BigNumberish,
    overrides?: Overrides
  ): Promise<ContractTransaction>;
Example #15
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>
  }
Example #16
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 #17
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 #18
Source File: IERC721.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>;

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

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

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

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

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

    "ownerOf(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): 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>;

    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>;
  };
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: IERC721Metadata.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>;

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

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

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

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

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

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

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

    "ownerOf(uint256)"(
      tokenId: BigNumberish,
      overrides?: CallOverrides
    ): 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>;

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

    "tokenURI(uint256)"(
      tokenId: BigNumberish,
      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>;
  };
Example #21
Source File: useGelatoLimitOrdersHandlers.ts    From limit-orders-lib with GNU General Public License v3.0 4 votes vote down vote up
export default function useGelatoLimitOrdersHandlers(): GelatoLimitOrdersHandlers {
  const { chainId, account } = useWeb3();

  const gelatoLimitOrders = useGelatoLimitOrdersLib();

  const addTransaction = useTransactionAdder();

  const {
    onSwitchTokens,
    onCurrencySelection,
    onUserInput,
    onChangeRateType,
  } = useOrderActionHandlers();

  const handleLimitOrderSubmission = useCallback(
    async (
      orderToSubmit: {
        inputToken: string;
        outputToken: string;
        inputAmount: string;
        outputAmount: string;
        owner: string;
      },
      overrides?: Overrides
    ) => {
      if (!gelatoLimitOrders) {
        throw new Error("Could not reach Gelato Limit Orders library");
      }

      if (!chainId) {
        throw new Error("No chainId");
      }

      if (!gelatoLimitOrders?.signer) {
        throw new Error("No signer");
      }

      const {
        witness,
        payload,
        order,
      } = await gelatoLimitOrders.encodeLimitOrderSubmissionWithSecret(
        orderToSubmit.inputToken,
        orderToSubmit.outputToken,
        orderToSubmit.inputAmount,
        orderToSubmit.outputAmount,
        orderToSubmit.owner
      );

      const tx = await gelatoLimitOrders.signer.sendTransaction({
        ...(overrides ?? {}),
        to: payload.to,
        data: payload.data,
        value: BigNumber.from(payload.value),
      });

      const now = Math.round(Date.now() / 1000);

      addTransaction(tx, {
        summary: `Order submission`,
        type: "submission",
        order: {
          ...order,
          createdTxHash: tx?.hash.toLowerCase(),
          witness,
          status: "open",
          updatedAt: now.toString(),
        } as Order,
      });

      return tx;
    },
    [addTransaction, chainId, gelatoLimitOrders]
  );

  const handleLimitOrderCancellation = useCallback(
    async (
      orderToCancel: Order,
      orderDetails?: {
        inputTokenSymbol: string;
        outputTokenSymbol: string;
        inputAmount: string;
        outputAmount: string;
      },
      overrides?: Overrides
    ) => {
      if (!gelatoLimitOrders) {
        throw new Error("Could not reach Gelato Limit Orders library");
      }

      if (!chainId) {
        throw new Error("No chainId");
      }

      if (!account) {
        throw new Error("No account");
      }

      const checkIfOrderExists = Boolean(
        orderToCancel.module &&
          orderToCancel.inputToken &&
          orderToCancel.owner &&
          orderToCancel.witness &&
          orderToCancel.data
      );

      const tx = await gelatoLimitOrders.cancelLimitOrder(
        orderToCancel,
        checkIfOrderExists,
        overrides ?? {
          gasLimit: isEthereumChain(chainId) ? 600_000 : 2_000_000,
        }
      );

      const now = Math.round(Date.now() / 1000);

      const summary = orderDetails
        ? `Order cancellation: Swap ${orderDetails.inputAmount} ${orderDetails.inputTokenSymbol} for ${orderDetails.outputAmount} ${orderDetails.outputTokenSymbol}`
        : "Order cancellation";

      addTransaction(tx, {
        summary,
        type: "cancellation",
        order: {
          ...orderToCancel,
          updatedAt: now.toString(),
          status: "cancelled",
          cancelledTxHash: tx?.hash.toLowerCase(),
        },
      });

      return tx;
    },
    [gelatoLimitOrders, chainId, account, addTransaction]
  );

  const handleInput = useCallback(
    (field: Field, value: string) => {
      onUserInput(field, value);
    },
    [onUserInput]
  );

  const handleCurrencySelection = useCallback(
    (field: Field.INPUT | Field.OUTPUT, currency: Currency) => {
      onCurrencySelection(field, currency);
    },
    [onCurrencySelection]
  );

  const handleSwitchTokens = useCallback(() => {
    onSwitchTokens();
  }, [onSwitchTokens]);

  const handleRateType = useCallback(
    async (rateType: Rate, price?: Price<Currency, Currency>) => {
      if (rateType === Rate.MUL) {
        if (price) onUserInput(Field.PRICE, price.invert().toSignificant(6));
        onChangeRateType(Rate.DIV);
      } else {
        if (price) onUserInput(Field.PRICE, price.toSignificant(6));
        onChangeRateType(Rate.MUL);
      }
    },
    [onChangeRateType, onUserInput]
  );

  return {
    handleLimitOrderSubmission,
    handleLimitOrderCancellation,
    handleInput,
    handleCurrencySelection,
    handleSwitchTokens,
    handleRateType,
  };
}