Solidity, uniswapV3 swap - solidity

I have swept on uniswapV3 weth to DAI. The code first gets weth via contract and latter gets DAI on Uniswap.
The change is 0.005weth = 173.68 DAI
Is this normal??, I really don't understand this change and don't know if I did somthing wrong.
here is the tx: https://goerli.etherscan.io/tx/0x92f4d746b89f65a50e49657fb1fbe0a1d1446c1881210beac56ff5e9a7d90567

Related

I need to understand below smart contract code

Can you help me explain below smart contract code I found on tomb finance, tomb.sol contract?
// Initial distribution for the first 24h genesis pools
uint256 public constant INITIAL_GENESIS_POOL_DISTRIBUTION = 11000 ether;
// Initial distribution for the day 2-5 TOMB-WFTM LP -> TOMB pool
uint256 public constant INITIAL_TOMB_POOL_DISTRIBUTION = 140000 ether;
// Distribution for airdrops wallet
uint256 public constant INITIAL_AIRDROP_WALLET_DISTRIBUTION = 9000 ether;
Why do they distribute ether for the pools?
Why ether?
Can they do that?
What exactly is the value of 1 ether?
If they had deployed this on BNB Chain, will this code will change?
This snippet alone doesn't distribute any ether, it only declares 3 constants. It's likely that there's some other functions in the code, that wasn't shared, that make use of these constants.
ether in this case is a Solidity global unit. No matter on which network you deploy the contract, it multiplies the specified number by 10^18 (or 1000000000000000000). Current version of Solidity (0.8) is not able to store decimal numbers, so all native and ERC-20 balances are stored in the smallest units of the token. In case of native tokens (ETH on Ethereum, MATIC on Polygon, ...), that's wei. And 10^18 wei == 1 ETH (or 1 MATIC, etc - depending on the network).
If this code was deployed on other EVM network (such as Binance Smart Chain), the ether unit is the same. It doesn't work with ETH tokens, it "just" multiplies the number.

Difference of balance keyword between different blockchain

I know that the address(this).balance shows the eth balance of the target contract.
Does the balance keyword return the balance of the native currency of that blockchain, or always returns balance of the contract's eth's?
If my SC is deployed on the polygon, does the balance keyword return the matic balance of my contract?
It always returns native balance of the address on the specific network where the contract is deployed.
ETH on Ethereum
MATIC on Polygon
BNB on Binance Smart Chain
etc.

Uniswapv2 addLiquidity Decimal error in Remix (Bignumber)

I'm testing Uniswapv2 for a project and am getting this error:
transact to UniswapV2Router02.addLiquidity errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value=".004", code=INVALID_ARGUMENT, version=bignumber/5.1.1)
The Uniswapv2 code is normal and unedited. I tested these number on Uniswap itself to make sure the numbers worked before I tried them in Remix. These are what I tried to pass:
tokenA: 0xc778417e063141139fce010982780140aa0cd5ab (WETH since I can't find ETH address)
tokenB: 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 (UNI)
amountADesired: 0.004
amountBDesired: 0.03
amountAMin:1
amountBMin:2
to: 0xd50eCE9501a1f63e449DbBBbBdc5CB59f3e2c231
deadline: 255
Solidity contracts don't take decimal arguments. Instead, you need to pass the amount of smallest units.
WETH (note - you have an incorrect address in your question) has 18 decimals, UNI has 18 as well.
1 WETH is 1000000000000000000 (or 10^18) units.
So if you want to pass 0.004 WETH in the argument, you need to input the number 4000000000000000 (which is 0.004 * 10^18).
Note: ETH is the native currency of the Ethereum network, so there is no token address for ETH. Uniswap v2 Router 2 has a function addLiquidityETH() for when you want to add liquidity to a pair of a token to ETH.

Solidity code for getting raw data from blockchain based on blocknumber/Hash

will you please make a video/code or any samples for solidity code based on block number/Hash to get Raw data which is stored in Blockchain.And also please help if anyone knows.
There are no such functions in solidity to get raw block data.
But have a look on this Official documentation link which will help to get block info
blockhash(uint blockNumber) returns (bytes32): hash of the given block
block.coinbase (address payable): current block miner’s address
block.difficulty (uint): current block difficulty
block.gaslimit (uint): current block gaslimit block.number
(uint): current block number block.timestamp (uint): current
block timestamp as seconds since unix epoch

Low Level Events in Solidity and log3 - uint to byte32

I have a question regarding low level events in solidity I can't really wrap my head around.
So in theory an event that looks like this:
event MyEvent(address indexed oneAddress, bool isTrueOrNot, uint256 myUnsingedNumber);
inside a function I would use it like that for example:
MyEvent(msg.sender, true, 5);
But now going to low-level events with log2 (log_i = i+1 parameters = 3). How would that be used there? I've tried around a bit but couldn't come up with the right solution...
log2(??, sha3("MyEvent(address,bool,uint256)"), msg.sender, ??)
In the samples in the Docs its quite straight forward, but I have real trouble putting that into this example here.
Here's the link to the docs: http://solidity.readthedocs.io/en/develop/contracts.html#events
Especially together with indexed, and uint256 to byte32 conversion, as all the parameters must be in byte32. Hope I haven't overlooked something...
Thanks!
I think the usage is log1( value, 'log_topic'); and then log2(value, 'log-topic1', 'log-topic2')
So if msg.sender is the value analyzed put it first in both cases.