BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

代码代写|Individual Coursework DAML Bitcoin Uniswap

代码代写|Individual Coursework DAML Bitcoin Uniswap

这是一篇关于完成在DAML市场的智能合约,比特币测试网交易与Uniswap交互3个任务的代码代写,具体详情可扫码咨询客服

 

Deliverables

Upload one PDF file that includes the following information:

Complete Python code (BTC transactions) and smart contract code (DAML and Solidity);

Screenshots of the transaction submitted on the BTC testnet;

Answers and explanations requested below.

Smart contract for marketplaces in DAML

In this exercise you have to build in a smart contract template in DAML that can be used for decentralized marketplaces. To do this, you are asked to create a new contract template called Itemtosell that the seller can use to advertise a certain item and transfer ownership to a buyer . We also wish to add an insurer that can only view the information about the trade (without being able to issue or modify the contract Itemtosell ).

Contract template

  1. Start by creating a new project and .daml file.
  2. Create a contract template called Itemtosell (3 points). In the contract you must specify the following:

Seller

Owner

Insurer

Type of item

Quantity

Price

Currency3. Then, define the roles of the parties. What type of party should the seller be? And the insurer? (2 points)

  1. Add a function ChangePrice to modify the price listed in the contract where the controller is the “owner” of the item. (2 points)
  1. Add a function Sell that modifies the owner of the item listed in the contract where the controller is the “owner” of the item. (2 points)

Scenario testing

In the scenario testing part, using the following structure

test = Script()

test = script do

— Add parties

— Create contract

— Transfer ownership

return()

you must:

  1. Create three parties: “Party 1” (the seller), “Party 2” (the buyer), “Party 3” (the insurer). (3 points)
  1. Let the seller “Party 1” issue a new contract where the seller “Party 1” wishes to sell 1 painting for 1000 GBP to “Party 2”. At this stage set the owner = the seller (2 points)
  1. Let the owner (=seller) of the painting transfer the ownership to “Party 2” (the buyer). (2 points)
  1. Take a screenshot of the state of the ledger (by looking at the scenario results). (2 points)
  1. Describe one example where the execution of the contract would fail automatically and explain why this would happen. (2 points)

Bitcoin Testnet Transaction

Use the Python code developed in the lab practical session.1. Create 4 Bitcoin Testnet addresses. Add below the addresses and the corresponding secrets, namely address1, address2, address3, address4. (2 points)

  1. From a BTC testnet faucet (e.g., https://bitcoinfaucet.uo1.net) send >5000 Satoshis to one of the addresses. (1 point)
  1. Create a 1-input 3-outputs transactions transferring 50%, 30%, 15% of the amount respectively into address2, address3, address4 respectively. (5 points)
  1. Sign the transaction and submit it into the Bitcoin testnet via

https://live.blockcypher.com/btc/pushtx/ (5 points)

  1. How much fees are transferred to the miner and how are they calculated? (2 points)

Interacting with Uniswap

Your submission should include answers to the following questions.

You are recommended to read through all the questions first before you start to attempt.

  1. Create a token with the following configuration using LuckyTokenSkeleton.sol on Remix:

name: LuckyCoin{your_initials}

symbol: LC{your_initials} (for simplification, we call it LC below) decimals: 18 Note: please make sure to read carefully the in-line comments and block comments in LuckyTokenSkeleton.sol which contain further, more detailed instructions on how to complete the contract. Also, read through the entire script to understand the structure of the code first before starting to attempt.

  1. What is the contract code? (10 points)
  2. Test the contract by deploying it on a Remix VM and interacting with the contract.

Include in your test at least the following steps:

mint 2 LC to some address X

[… some intermediary steps in between …]

use some other address Y to call transferFrom to transfer 0.48 LC from address X to some 3rd address Z

  1. Share a screenshot where you call balanceOf of address Z on Remix immediately after the transferFrom step described above. (5 points)
  1. Choose an EVM-testnet where Uniswap V3 and ChainLink are deployed. Tap enough native coins (e.g. ETH for Goerli, MATIC for Polygon Mumbai) to be used to pay gas as well some LINK .i. What is the test network that you choose?
  1. How did you obtain coins and tokens on this test network? (2 points)
  2. Specify an account address that will be used to sign transactions on the chosen testnet in this assignment (let’s call it address A below).
  1. What’s the address? (1 point)
  2. Deploy token LC onto the test network from address A.
  3. What is the token smart contract address?
  4. What is the transaction hash?

iii. Verify and Publish your contract source code. Share the code URL, e.g.

https://mumbai.polygonscan.com/address/0x326c977e6efc84e512bb9c30f76e30c1

60ed06fb#code (10 points)

  1. Create a liquidity pool with LINK and LC with the following configuration (slight numerical deviations enforced by the UI/UX can be tolerated). You can do so by directly interacting with the web interface of Uniswap:

fee tier: 0.3%

Current price: 500 LC / LINK

Min price: 400 LC / LINK

Max price: 600 LC / LINK

Deposit amount: 0.5 LINK

  1. What is the amount of LC that needs to be deposited?
  2. What is the pool URL?

iii. What is the pool smart contract address? (3 points)

  1. Try to buy 0.1 LINK with LC without confirming the transaction.
  2. What is the amount of LC expected to be paid?
  3. What is the maximum sent after slippage?

iii. What is the price impact? Note: in the rare case when Uniswap UI malfunctions and you cannot locate the tokens in the swap interface, you can manually type your tokens’ addresses in the URL as in https://app.uniswap.org/#/swap?outputCurrency=0x4BF3027C28Ca9001c6EF9700571922f3c2A0E854&inputCurrenc y=0x326C977E6efc84E512bB9C30f76E30c160eD06FB (3 points)

  1. Buy 0.05 LINK with LC with slippage tolerance of 1.2%.
  2. What does the app warn you with this slippage setting?ii. Briefly interpret the warning message.

iii. What is the amount of LC to be paid?

  1. What is the liquidity provider fee?
  2. What is the price impact?
  3. What is the transaction hash?

vii. What is the current price of LINK denominated in LC after the transaction? (7 points)

  1. Sell 0.05 LINK for LC with slippage tolerance of 0.02%.
  2. What does the app warn you with this slippage setting?
  3. Briefly interpret the warning message.

iii. What is the amount of LC to be received?

  1. What is the liquidity provider fee?
  2. What is the price impact?
  3. What is the transaction hash?

vii. What is the current price of LINK denominated in LC after the transaction? (points)

  1. Collect all the fees.
  2. How many fees are there?
  3. What is the transaction hash? (2 points)
  4. Add more liquidity to the pool with 0.1 LINK .
  5. What is the amount of LC to be added?
  6. What is the transaction hash? (2 points)
  7. Remove 25% of the liquidity from the pool.
  8. What is the respective amount of LC and ETH to be removed?
  9. What is the transaction hash?

iii. What is the current price of LINK denominated in LC after the transaction? (points)

  1. Based on the experiment above and your own understanding of Uniswap mechanism as well as AMM-based DEX in general, briefly generalize the relationships between spot price, liquidity depth, slippage tolerance, exchange volume, price impact and liquidity provider fee. (10 points)
bestdaixie

评论已关闭。