Sushiswap Settlement – 寿司交换结算区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Sushiswap Settlement – 寿司交换结算区块链毕设代写 是一篇很好的国外资料

Sushiswap Settlement

This repository contains solidity contracts to enable limit orders for Sushiswap.

Overview

On Sushiswap, you can swap any ERC20 token for another ERC20 token instantly.

However it does not support limit order feature. It only allows you to submit an order with a pair of amount and price. It will either succeed or fail instantly so that you cannot submit an order of a expectedly lower price than now and wait for it to be settled.

Contracts in this repo help you submit a limit order with a lower price than what it is now. Later, when the price gets lower enough to meet the requirement of your order, it gets settled.

Contracts

It works in a decentralized manner, without the need of any centralized authority.

OrderBook

OrderBook is deployed at 0x363a4d1500f15c0212995ecbd968291eded342ff on kovan and rinkeby testnets.

OrderBook keeps limit orders that users have submitted. Anyone can call createOrder() to create a limit order with the amount to sell and the minimum price. He/she needs to approve the amount to sell for the Settlement contract.

The maker of the order can cancel it with cancelOrder(). It accepts the hash of the order created.

To reduce users’ gas fee, OrderBook isn’t deployed on the mainnet. The one on kovan testnet is used for production.

Settlement

Settlement is deployed at 0x0a32167dfa4eada6758d77b7ac27f76e8a723df2 on the Ethereum mainnet, kovan and rinkeby testnets.

Settlement is in charge of swapping tokens for orders. Anyone can call fillOrder() to fill the order submitted. We’ll call this caller a ‘relayer’. Relayers need to call it with proper parameters to meet the minimum price requirement set in the order. If the call is successful, fee will be transferred to the relayer.

It is possible to fill only a certain amount of tokens, not all. In most cases, submitted orders will reside on the OrderBook and their amount will be filled by different callers in different blocks.

Incentives

Relayer

Settlement is a wrapper contract around UniswapV2Router02. Every function in this contract has a duplicated version in the Settlement with an extra parameter args. If args is not empty, it is used for filling orders; see Settlement.fillOrders() for details.

So, users for sushiswap can choose to be a relayer or not. If he/she decided to do so, calling any swap functions in Settlement will benefit them. Otherwise, he/she can just call functions in UniswapV2Router02 without receiving any fee.

Fee

For every fillOrder() call, 0.2% of fee for the amount sold is transferred to the relayer. The fee is deducted prior to the swap.

Let’s assume Alice created an order to sell 1 ETH with the minimum price of 500 DAI. Current price of ETH is 400 DAI so this order cannot be filled right away. Leter, when the market price goes up to 500 DAI, Bob is trying to fill the entire amount of this order as a relayer.

If the call is successful, amounts of tokens transferred are:

  • Limit Order Fee: 1 ETH x 0.2% = 0.002 ETH (goes to Bob; relayer)
  • Swap Fee: (1 ETH0.002 ETH) x 0.3% = 0.002994 ETH (goes to the liquidity provider)
  • ETH Amount Sold: 1 ETH0.002 ETH0.002994 ETH = 0.995006 ETH (goes to the liquidity pool)
  • DAI Amount Bought: 0.995006 ETH x 500 DAI = 497.503 DAI (goes to Alice; maker)

License

MIT

We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Learn more.


Sushiswap Settlement

限制寿司存储库的订单数量。

Overview

在Sushiswap上,您可以立即将任何ERC20代币换成另一个ERC20代币。

但不支持限价单功能。它只允许你提交一对金额和价格的订单。它要么成功,要么立即失败,这样你就不能以比现在更低的价格提交订单,然后等待结算。

本回购协议中的合同可帮助您以低于现在的价格提交限价订单。后来,当价格降到足以满足你的订单要求时,就可以结算了。

Contracts

它以分散的方式工作,不需要任何中央集权。

OrderBook

OrderBook部署在kovan和rinkeby testnets上的0x363a4d1500f15c0212995 ecbd968291eded342ff。

订单簿保存用户提交的限额订单。任何人都可以调用createOrder()来创建一个限价单,其中包含要出售的金额和最低价格。他/她需要批准结算合同的销售金额。

订单的创建者可以使用cancelOrder()取消订单。它接受所创建订单的哈希值。

为了减少用户的汽油费,主网上不部署OrderBook。科万测试网上的那个用于生产。

Settlement

结算部署在以太坊eth主网、科万和林克比测试网的0x0a32167dfa4eada6758d77b7ac27f76e8a723df2。

结算负责将代币换成订单。任何人都可以调用fillOrder()来填充提交的订单。我们叫这个叫“接线员”的人。继电器需要使用适当的参数来调用它,以满足订单中设置的最低价格要求。如果呼叫成功,费用将转移到中继层。

只能填充一定数量的代币,而不是全部。在大多数情况下,提交的医嘱将驻留在医嘱簿上,其金额将由不同区块中的不同调用者填写。

Incentives

Relayer

结算是围绕UniswapV2Router02的包装合同。此契约中的每个函数在结算中都有一个重复版本,并带有一个额外的参数args。如果args不为空,则用于填写订单;请参阅结算.fillOrders()了解详情。

因此,寿司交换的用户可以选择是否成为中继商。如果他/她决定这么做,在结算中调用任何掉期功能将使他们受益。否则,他/她可以在UniswapV2Router02中调用函数而不收取任何费用。

Fee

对于每个fillOrder()调用,销售金额的0.2%的费用将被转移到中继层。费用在交换前扣除。

假设Alice创建了一个订单,以500 DAI的最低价格销售1 ETH。目前以太币的价格是400代币,所以这个订单不能马上完成。Leter,当市场价格涨到500 DAI时,Bob作为接线员正试图把这批订单的全部金额都补上。

如果调用成功,则传输的令牌数量为:

  • 掉期费:(1以太币-0.002以太币)x 0.3%=0.002994以太币(转至流动性提供商)
  • 以太币卖出金额:1以太币-0.002以太币-0.002994以太币=0.995006以太币(进入流动性池)
  • 买入戴安币金额:0.995006以太币x 500道依特=497.503泰铢代币(支付给Alice;创客)
  • DAI Amount Bought: 0.995006 ETH x 500 DAI = 497.503 DAI (goes to Alice; maker)

License

MIT

我们使用可选的第三方分析cookie来了解您如何使用GitHub.com网站所以我们可以制造更好的产品。了解更多。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/17861.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Sushiswap Settlement – 寿司交换结算区块链毕设代写

提供最优质的资源集合

立即查看 了解详情