深入分析阿凡達Avatar泰山眾籌系統開發詳細方案及案例原始碼

xiaofufu發表於2023-03-01

  新零售,即個人、企業以網際網路為依託,透過運用大資料、人工智慧等先進技術手段,對商品的生產、流通與銷售過程進行升級改造,進而重塑業態結構與生態圈,並對線上服務、線下體驗以及現代物流進行深度融合的零售新模式。


  個人、企業以網際網路為依託,透過運用大資料、人工智慧等先進技術手段,對商品的生產、流通與銷售過程進行升級改造,進而重塑業態結構與生態圈,並對線上服務、線下體驗以及現代物流進行深度融合的零售新模式。


  原始碼說明:首次新增和二次新增lp演算法有點差別


  查詢pair和建立pair,使用了create2,有需要可以具體瞭解


  uniswap v2都是兩個erc20組合成一個交易對,跟eth相關的內部都是使用的weth交易


  交易方法中都是in/out,相對於pair,開發方案及案例I35功能7O98開發O7I8,方法中swapExactTokensForTokens,for的兩側帶有Exact的,表示該側的數是固定的精確數,另一邊的數量是需要看實際成交時交易池情況,所以也就有了amountOutMin,amountInMax


  _swap和_swapSupportingFeeOnTransferTokens的差別是前者是輸入引數的數計算得來的amounts,後者是以交易對實際得到的數去計算


  /**


  *Submitted for verification at Etherscan.io on 


  */


  pragma solidity=0.6.6;


  interface IUniswapV2Factory{需求及模式:MrsFu123


  event PairCreated(address indexed token0,address indexed token1,address pair,uint);


  function feeTo()external view returns(address);


  function feeToSetter()external view returns(address);


  function getPair(address tokenA,address tokenB)external view returns(address pair);


  function allPairs(uint)external view returns(address pair);


  function allPairsLength()external view returns(uint);


  function createPair(address tokenA,address tokenB)external returns(address pair);


  function setFeeTo(address)external;


  function setFeeToSetter(address)external;


  }


  interface IUniswapV2Pair{


  event Approval(address indexed owner,address indexed spender,uint value);


  event Transfer(address indexed from,address indexed to,uint value);


  function name()external pure returns(string memory);


  function symbol()external pure returns(string memory);


  function decimals()external pure returns(uint8);


  function totalSupply()external view returns(uint);


  function balanceOf(address owner)external view returns(uint);


  function allowance(address owner,address spender)external view returns(uint);


  function approve(address spender,uint value)external returns(bool);


  function transfer(address to,uint value)external returns(bool);


  function transferFrom(address from,address to,uint value)external returns(bool);


  function DOMAIN_SEPARATOR()external view returns(bytes32);


  function PERMIT_TYPEHASH()external pure returns(bytes32);


  function nonces(address owner)external view returns(uint);


  function permit(address owner,address spender,uint value,uint deadline,uint8 v,bytes32 r,bytes32 s)external;


  event Mint(address indexed sender,uint amount0,uint amount1);


  event Burn(address indexed sender,uint amount0,uint amount1,address indexed to);


  event Swap(


  address indexed sender,


  uint amount0In,


  uint amount1In,


  uint amount0Out,


  uint amount1Out,


  address indexed to


  );


  )external returns(uint[]memory amounts);


  function swapTokensForExactTokens(


  uint amountOut,


  uint amountInMax,


  address[]calldata path,


  address to,


  uint deadline


  )external returns(uint[]memory amounts);


  function swapExactETHForTokens(uint amountOutMin,address[]calldata path,address to,uint deadline)


  external


  payable


  returns(uint[]memory amounts);


  function swapTokensForExactETH(uint amountOut,uint amountInMax,address[]calldata path,address to,uint deadline)


  external


  returns(uint[]memory amounts);


  function swapExactTokensForETH(uint amountIn,uint amountOutMin,address[]calldata path,address to,uint deadline)


  external


  returns(uint[]memory amounts);


  function swapETHForExactTokens(uint amountOut,address[]calldata path,address to,uint deadline)


  external


  payable


  returns(uint[]memory amounts);


  function quote(uint amountA,uint reserveA,uint reserveB)external pure returns(uint amountB);


  function getAmountOut(uint amountIn,uint reserveIn,uint reserveOut)external pure returns(uint amountOut);


  function getAmountIn(uint amountOut,uint reserveIn,uint reserveOut)external pure returns(uint amountIn);


  function getAmountsOut(uint amountIn,address[]calldata path)external view returns(uint[]memory amounts);


  function getAmountsIn(uint amountOut,address[]calldata path)external view returns(uint[]memory amounts);


  }


  interface IUniswapV2Router02 is IUniswapV2Router01{


  function removeLiquidityETHSupportingFeeOnTransferTokens(


  address token,


  uint liquidity,


  uint amountTokenMin,


  uint amountETHMin,


  address to,


  uint deadline


  )external returns(uint amountETH);


  function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(


  address token,


  uint liquidity,


  uint amountTokenMin,


  uint amountETHMin,


  address to,


  uint deadline,


  bool approveMax,uint8 v,bytes32 r,bytes32 s


  )external returns(uint amountETH);


  function swapExactTokensForTokensSupportingFeeOnTransferTokens(


  uint amountIn,


  uint amountOutMin,


  address[]calldata path,


  address to,


  uint deadline


  )external;


  function swapExactETHForTokensSupportingFeeOnTransferTokens(


  uint amountOutMin,


  address[]calldata path,


  address to,


  uint deadline


  )external payable;


  function swapExactTokensForETHSupportingFeeOnTransferTokens(


  uint amountIn,


  uint amountOutMin,


  address[]calldata path,


  address to,


  uint deadline


  )external;


  }


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69956839/viewspace-2937542/,如需轉載,請註明出處,否則將追究法律責任。

相關文章