慢雾:DeFi 当红项目 YAM 闪电折戟,一行代码如何蒸发数亿美元? (5)
时间:2020-08-14 18:05来源:未知 作者:admin 点击:
次
YAMTokenInterface ( yamAddress ); // get reserves ( uint256 token0Reserves , uint256 token1Reserves , ) = pair . getReserves (); // check if protocol has excess yam in the reserve uint256 excess = yam
YAMTokenInterface(yamAddress); // get reserves (uint256 token0Reserves, uint256 token1Reserves, ) = pair.getReserves(); // check if protocol has excess yam in the reserve uint256 excess = yam.balanceOf(reservesContract); //SlowMist// 计算用于 Uniswap 中兑换的 YAM 数量 uint256 tokens_to_max_slippage = uniswapMaxSlippage(token0Reserves, token1Reserves, offPegPerc); UniVars memory uniVars = UniVars({ yamsToUni: tokens_to_max_slippage, // how many yams uniswap needs amountFromReserves: excess, // how much of yamsToUni comes from reserves mintToReserves: 0 // how much yams protocol mints to reserves }); // tries to sell all mint + excess // falls back to selling some of mint and all of excess // if all else fails, sells portion of excess // upon pair.swap, `uniswapV2Call` is called by the uniswap pair contract if (isToken0) { if (tokens_to_max_slippage > mintAmount.add(excess)) { // we already have performed a safemath check on mintAmount+excess // so we dont need to continue using it in this code path
(责任编辑:admin1) |
织梦二维码生成器
------分隔线----------------------------