UniswapV2配对合约里的函数选择器与事件选择器

Posted sanqima

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UniswapV2配对合约里的函数选择器与事件选择器相关的知识,希望对你有一定的参考价值。

    UniswapV2的配对合约UniswapV2Pair,继承IUniswapV2ERC20、IUniswapV2Pair这2个合约,如图(1)所示。

  • UniswapV2ERC20 是ERC20合约,用于设置配对合约的Token名称、精度、符号等。
  • IUniswapV2Pair用于获取交易对的价格、储备量、token0、token1的地址等
图(1) UniswapPair配对合约的继承表

IUniswapV2ERC20的函数选择器、事件选择器

functionselect
DOMAIN_SEPARATOR()0x3644e515
PERMIT_TYPEHASH()0x30adf81f
allowance(address,address)0xdd62ed3e
approve(address,uint256)0x095ea7b3
balanceOf(address)0x70a08231
decimals()0x313ce567
name()0x06fdde03
nonces(address)0x7ecebe00
permit(address,address,uint256,uint256,uint8,bytes32,bytes32)0xd505accf
symbol()0x95d89b41
totalSupply()0x18160ddd
transfer(address,uint256)0xa9059cbb
transferFrom(address,address,uint256)0x23b872dd
eventselect
Approval(address,address,uint256)0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925
Transfer(address,address,uint256)0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

UniswapV2Pair的函数选择器、事件选择器

functionselect
constructor()0x90fa17bb
DOMAIN_SEPARATOR()0x3644e515
MINIMUM_LIQUIDITY()0xba9a7a56
PERMIT_TYPEHASH()0x30adf81f
allowance(address,address)0xdd62ed3e
approve(address,uint256)0x095ea7b3
balanceOf(address)0x70a08231
burn(address)0x89afcb44
decimals()0x313ce567
factory()0xc45a0155
getReserves()0x0902f1ac
initialize(address,address)0x485cc955
kLast()0x7464fc3d
mint(address)0x6a627842
name()0x06fdde03
nonces(address)0x7ecebe00
permit(address,address,uint256,uint256,uint8,bytes32,bytes32)0xd505accf
price0CumulativeLast()0x5909c0d5
price1CumulativeLast()0x5a3d5493
skim(address)0xbc25cf77
swap(uint256,uint256,address,bytes)0x022c0d9f
symbol()0x95d89b41
sync()0xfff6cae9
token0()0x0dfe1681
token1()0xd21220a7
totalSupply()0x18160ddd
transfer(address,uint256)0xa9059cbb
transferFrom(address,address,uint256)0x23b872dd
eventselect
Approval(address,address,uint256)0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925
Burn(address,uint256,uint256,address)0xdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496
Mint(address,uint256,uint256)0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f
Swap(address,uint256,uint256,uint256,uint256,address)0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822
Sync(uint112,uint112)0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1
Transfer(address,address,uint256)0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

参考文献

    [1] ethers计算函数选择器和事件选择器

以上是关于UniswapV2配对合约里的函数选择器与事件选择器的主要内容,如果未能解决你的问题,请参考以下文章

UniswapV2路由合约的函数选择器和事件选择器

ethers计算函数选择器与事件选择器

检查ApeSwap工程

测试SushiSwap里的MasterChef合约

jQuery 选择器与事件

如何使用 UniswapV2Router02 合约用 swapExactTokensForETH() 将 Token 换成 ETH