Uniswap / v3-sdk

🛠 An SDK for building applications on top of Uniswap V3
MIT License
547 stars 425 forks source link

Cannot find 'block' and 'sender' on Minting a new Position #128

Closed z0st closed 2 years ago

z0st commented 2 years ago

Hi there, I want to ask about the 'block' and 'sender' names when I run the code that appear on https://docs.uniswap.org/sdk/guides/liquidity/minting.

const deadline = block.timestamp + 200

const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, {
  slippageTolerance: new Percent(50, 10_000),
  recipient: sender,
  deadline: deadline,
})

I Googled about 'block.timestamp' and just found something about Web3JS package for node but it doesn't work too. And the same with the name 'sender'.

I have installed: ethers @uniswap/v3-sdk @uniswap/sdk-core Web3

I'm using node 16.15.0,

Thanks in advance, Alex

marktoda commented 2 years ago

Hey @z0st! The deadline is a flexible parameter, that just ensures the liquidity addition transaction only occurs before the given UNIX timestamp. If you specifically want to get the latest block timestamp, one option is to use ethers.js as seen here https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlock. Otherwise, you can just set it to a timestamp in the future that you want to keep the transaction valid for.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

z0st commented 2 years ago

Fixed! Thank you very much!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.