Share & grow the worlds knowledge!
We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
1 Answer
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
-
0
- Reply
- Questions 1.0K
- Answers 2.2K
- Best Answers 131
- Users 486
Related Questions
Recent Activities
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm