DAO/DAPP去中心化流動性質押挖礦分紅系統開發(穩定版)丨案例原始碼

xiaofufu發表於2023-03-15

  notice Convert Tokens to ETH.


  dev User specifies exact input and minimum output.


  param tokens_sold Amount of Tokens sold.tokens_sold為要支付的代幣數量


  param min_eth Minimum ETH purchased.min_eth為要購買的ETH的最小值


  param deadline Time after which this transaction can no longer be executed.


    return Amount of ETH bought.返回最終購買到的ETH數量


  #函式功能:指定輸入的代幣數量,根據代幣數量兌換ETH併傳送給訊息呼叫者


  public關於區塊鏈專案技術開發唯:MrsFu123,代幣發行、dapp智慧合約開發、鏈遊開發、多鏈錢包開發


  交易所開發、量化合約開發、互助遊戲開發、Nft數字藏品開發、眾籌互助開發、元宇宙開發、swap開發、


  鏈上合約開發、ido開發、商城開發等,開發過各種各樣的系統模式,更有多種模式、制度、案例、後臺等,成熟技術團隊,歡迎實體參考。


  def tokenToEthSwapInput(tokens_sold:uint256,min_eth:uint256(wei),deadline:timestamp)->uint256(wei):


  return self.tokenToEthInput(tokens_sold,min_eth,deadline,msg.sender,msg.sender)


  


  notice Convert Tokens to ETH and transfers ETH to recipient.


  dev User specifies exact input and minimum output.


  param tokens_sold Amount of Tokens sold.


  param min_eth Minimum ETH purchased.


  param deadline Time after which this transaction can no longer be executed.


  param recipient The address that receives output ETH.


  return Amount of ETH bought.


  #函式功能:指定輸入的代幣數量,根據代幣數量兌換ETH併傳送給指定接收者


  比tokenToEthSwapInput函式多了一個接收者,指定用來接收所兌換的ETH的地址


  public


  def tokenToEthTransferInput(tokens_sold:uint256,min_eth:uint256(wei),deadline:timestamp,recipient:address)->uint256(wei):


  assert recipient!=self and recipient!=ZERO_ADDRESS


  return self.tokenToEthInput(tokens_sold,min_eth,deadline,msg.sender,recipient)


  


  notice Convert Tokens to ETH.


  dev User specifies maximum input and exact output.


  param eth_bought Amount of ETH purchased.#想要購買的ETH的數量


  param max_tokens Maximum Tokens sold.#最大能接受的支付的代幣數量


  param deadline Time after which this transaction can no longer be executed.


  return Amount of Tokens sold.#最終消耗的代幣數量


  #函式功能:指定所想要兌換到的ETH數量並將ETH傳送給訊息呼叫者,函式根據要兌換的ETH計算扣除代幣


  public


  def tokenToEthSwapOutput(eth_bought:uint256(wei),max_tokens:uint256,deadline:timestamp)->uint256:


  return self.tokenToEthOutput(eth_bought,max_tokens,deadline,msg.sender,msg.sender)


  


  notice Convert Tokens to ETH and transfers ETH to recipient.


  dev User specifies maximum input and exact output.


  param eth_bought Amount of ETH purchased.


  param max_tokens Maximum Tokens sold.


  param deadline Time after which this transaction can no longer be executed.


  param recipient The address that receives output ETH.


  return Amount of Tokens sold.


  #函式功能:指定所想要兌換到的ETH數量並將ETH傳送給指定接收者,函式根據要兌換的ETH計算扣除代幣


  public


  def tokenToEthTransferOutput(eth_bought:uint256(wei),max_tokens:uint256,deadline:timestamp,recipient:address)->uint256:


  assert recipient!=self and recipient!=ZERO_ADDRESS


  return self.tokenToEthOutput(eth_bought,max_tokens,deadline,msg.sender,recipient)


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

相關文章