Skip to content

Instantly share code, notes, and snippets.

@Ankarrr
Last active May 8, 2020 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ankarrr/e4616af70286b548185de9200aa156f8 to your computer and use it in GitHub Desktop.
Save Ankarrr/e4616af70286b548185de9200aa156f8 to your computer and use it in GitHub Desktop.

uToken Test Tutorial

Contract Info

How to use?

Mint()

  1. Caller 要有 USDC
  2. Caller 呼叫 approve(address _spender, uint256 _value) of USDC,_spender 設定為 uUSDC contract address
  3. Caller 呼叫 mint(uint256 underlyingToSupply) of uUSDC,uUSDC 會從 caller 轉出數量為 underlyingToSupply 的 USDC,並發行數量為 underlyingToSupply * 0.9 的 uUSDC Token 給 caller

balanceOf()

  1. Caller 呼叫 balanceOf(address _tokenHolder) of uUSDC,可以查詢 address 的 餘額

transfer()

  1. Caller 呼叫 transfer(address recipient, uint256 amount) of uUSDC,可以 transfer amount token to recipient
@m04120310
Copy link

打一下我想像的流程:

  1. caller 是 relayer address
  2. caller 先叫 USDC 的 approve(address _spender, uint256 _value),設定 uUSDC contract 為 _spender,並允許他動用 _value 的 usdc。
  3. caller 去叫 uUSDC contract 的 mint(uint256 underlyingToSupply)underlyingToSupply 是我要存入的 usdc 量嗎?
  4. 第 3 步之後,uUSDC 會做一些事(我不需要知道細節),然後最後 caller 會收到 underlyingToSupply * 0.9 的 uUSDC Token。
  5. caller 再把 underlyingToSupply * 0.9 轉到用戶的 proxy wallet。以上入金整個作業完畢。

balanceOf() 是查什麼的 balance?查用戶 proxy wallet 的 uUtoken 餘額嗎?還是換算回 usdc 的價格?

@Ankarrr
Copy link
Author

Ankarrr commented May 7, 2020

underlyingToSupply 是我要存入的 usdc 量嗎?是的
balanceOf() 是查什麼的 balance?查詢用戶的 uToken 餘額

@m04120310
Copy link

  1. 所以流程無誤囉~?
  2. 那為什麼只拿得回 0.9 * underlyingToSupply?
  3. 所以換回時價的部分我們還要另外算匯率得到結果?

@m04120310
Copy link

補問 所以沒意外的話 _value 會 == underlyingToSupply ?

@Ankarrr
Copy link
Author

Ankarrr commented May 8, 2020

  1. 流程 ok
  2. 模擬 0.1 是我們抽成,但實際上算法不是這樣
  3. 不用自己算,合約會算出目前價格。只要 call 一個類似 redeem() 的 method
  4. 對,沒意外的話。理論上 _value >= underlyingToSupply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment