Trong giao dịch này tại sao lại có nhiều event chuyển tiền chỉ trong 1 giao dịch?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ví dụ với việc swap cặp tiền BNB/DOGE:
input = cặp tiền cần swap (10BNB = 20DOGE theo giá được tính tại thời điểm hiện tại) và số tiền cần trả tối thiểu (amountOutMin)
Step 1: gọi swap BNG sang DOGE: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L252
Step 2: tính tổng số DOGE cần phải trả: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/libraries/PancakeLibrary.sol#L63
if (tổng số DOGE cần phải trả < amountOutMin) báo lỗi ko đủ DOGE: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L262
Step 3: gọi _swap: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L265
Step 3.1: chạy vòng lặp 1 hoặc nhiều lần: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L213
Step 3.2: tạo pair và swap: https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/PancakeRouter.sol#L219
Step 4: pair swap: https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/PancakePair.sol#L159
Step 5: thực hiện việc transfer: https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/PancakePair.sol#L171
Như vậy việc có nhiều event trong 1 transaction là người dùng truyền vào biến path với nhiều contract address khác nhau