Sherlock V1 – 夏洛克V1区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Sherlock V1 – 夏洛克V1区块链毕设代写 是一篇很好的国外资料

Sherlock V1

Sherlock V1 - 夏洛克V1

Sherlock protocol is built using EIP-2535: Diamonds. Sherlock’s PoolStorage uses a token address to calculate the pointer to the storage position. This allows Sherlock to easily support more tokens.

Sherlock has three agents interacting with the protocol.

  • Stakers
  • Protocols
  • Governance

Protocols are identified by a bytes32 variable. Calculated by hashing a certain string (e.g. keccak(sherlock.protocol)). Governance can set/update the rate of accruing debt of the protocol to Sherlock. Protocols are expected to have an active balance deposited. Governance is able to make a payout to the protocol in the event of a covered exploit at that protocol. Funds staked by the stakers can be used for that payout. Stakers receive “interest” by way of the protocol payments and in the form of SherX. SherX is a single ERC-20 token that represents all the underlying balances paid by protocols in varying tokens.

Token Lifetime

A single token can be used by stakers to stake (i.e. provide liquidity to Sherlock) and/or as payment by protocols. A token can also be in an inactive state where it isn’t used by any agent.

Adding

Tokens are added using the tokeninit() function. The function parameters can be used to whitelist the token for stakers and/or protocols. This function can also be used to reinitialize a token (e.g. re-enabling for stakers and/or protocols).

Staking

Once added and initialized as a staking token, stakers can provide liquidity using the token. Based on the sherXWeight, sherXPerBlock and stakeBalance the compensation is calculated for the provided stake. Stakers can remove their stake at any time. Using activateCooldown(), stakers can start the countdown for unstaking. After the specified number of blocks stored in unstakeCooldown, stakers can withdraw their stake and earned interest using unstake().

Premiums

Accounts can deposit balance on behalf of a protocol using depositProtocolBalance() once a token has been added and initialized as a protocol token, and once the protocol is added to the registry with the token whitelisted as a payment method (using protocolAdd()). Governance can set/update the rate of accruing debt (i.e. the price the protocol pays) using the Manager.sol facet. Multiple functions are defined so that premiums can be updated as gas efficiently as possible.

Disable/remove

All good things come to an end, as do some tokens.

For the longevity of the protocol it is important that tokens can be removed. This is done in multiple steps:

  1. tokenDisableStakers() is the first step towards completely removing a token. This function can also be called if governance decides to temporarily halt new deposits by stakers.
  2. strategyRemove() needs to be called if the token still has an active strategy.
  3. tokenUnload() swaps/removes all the active tokens (of the type to be removed) for another token in the protocol. This way there will be zero balance of the token (to be removed) underlying SHERX.
  4. tokenDisableProtocol() requires no protocols to be actively accruing debt (i.e. paying in the token to be removed). It cleans up storage and removes the ability for any protocol to accrue debt in this token.
  5. tokenRemove() Removes the main storage in GovStorage.

Re-enable

Re-enabling needs a custom crafted re-enabling plan. Although most storage is deleted, the sWithdrawn and sWeight ─ used for SherX rewards ─ is kept. Potential solutions are creating a custom storage pointer or creating a storage cleanup script.

Protocol Lifetime

Protocols are identified by a bytes32 variable. Governance adds an account as the _protocolAgent, this account is able to withdraw balances on behalf of the protocol.

Adding

Protocol are added using the protocolAdd() function. An array of tokens is provided that whitelist the protocol to pay in a certain token (or tokens). Eligible tokens need to be added with tokenInit() first. The array can be extended using protocolDepositAdd() and shortened using cleanProtocol().

Premiums

Governance can set/update the rate of accruing debt using the Manager.sol facet. The debt can be redeemed at any given block. If the protocols have insufficient balance deposited, the protocol defaults and some functions stop working for the protocol. Although this event is unfortunate, Governance can see it coming and act beforehand.

⚠️ Some functionality will be disabled if a protocol has insufficient balance. This can be mitigated using the cleanProtocol() call.

Cleaning

Cleaning a protocol from the poolStorage (for a single token at a time) is done using cleanProtocol(). This remove the possibility for the protocol to accrue debt in the token and cleans up storage.

Deleting

Deleting a protocol is done by cleaning the protocol from every token. Finally protocolRemove() is called to remove the protocol completely.

Price Decimals

Internal token prices (added/updated using the function in the Manager.sol contract) need to make a sum of 36 with the decimals of the token.

e.g.

TokenX = 18 decimals, price precision = 18 decimals TokenY = 8 decimals, price precision = 28 decimals TokenZ = 6 decimals, price precision = 30 decimals 

夏洛克V1

Sherlock协议是使用EIP-2535:Diamonds构建的。Sherlock的PoolStorage使用令牌地址来计算指向存储位置的指针。这使得Sherlock可以轻松地支持更多令牌

Sherlock有三个代理与协议交互

协议由bytes32变量标识。通过对特定字符串进行散列计算(例如keccak(sherlock.protocol))。治理可以设置/更新协议对Sherlock的累积债务率。协议预计会有一笔有效余额。治理能够在协议中发生被覆盖的漏洞时向协议支付费用。押注者押注的资金可以用于支付。储户通过协议付款和SHRX的形式获得“利息”。SherX是单个ERC-20代币,代表协议以不同代币支付的所有基础余额

  • 如果令牌仍然具有活动策略,则需要调用strategyRemove()
  • tokenUnload()为协议中的另一个令牌交换/移除所有活动令牌(要移除的类型)。这样一来,作为SHRX基础的令牌(将被移除)的余额将为零
  • tokenDisableProtocol()不要求协议主动累积债务(即支付要移除的令牌)。它会清理存储并消除任何协议在此令牌中累积债务的能力

单一代币可由押注者用于押注(即向夏洛克提供流动性)和/或作为协议支付。令牌也可以处于非活动状态,任何代理都不会使用它

添加

使用tokeninit()函数添加令牌。功能参数可用于将标记和/或协议的令牌列入白名单。此功能还可用于重新初始化令牌(例如重新启用标记和/或协议)

保险费

一旦添加并初始化为赌注代币,赌客可以使用代币提供流动性。根据sherXWeight、sherXPerBlock和stakeBalance,计算所提供桩的补偿。桩工可以随时移除桩。使用ActivateColdOwn(),桩工可以开始取消桩号的倒计时。在unstake冷却中存储指定数量的区块后,赌徒可以使用unstake()收回其赌注和赚取的利息

Staking

添加令牌并将其初始化为协议令牌后,以及将令牌作为支付方法(使用protocolAdd())白名单添加到注册表后,帐户可以使用depositProtocolBalance()代表协议存款余额。治理可以使用Manager.sol facet设置/更新应计债务率(即协议支付的价格)。定义了多个功能,以便尽可能高效地更新保费

Premiums

所有美好的事物都会结束,一些象征也会结束

Disable/remove

为了延长协议的使用寿命,可以删除令牌非常重要。这是通过多个步骤完成的:

重新启用需要一个定制的重新启用计划。虽然删除了大部分存储,但swithdraw和sWeight─ 用于SherX奖励─ 这是保留的。潜在的解决方案是创建自定义存储指针或创建存储清理脚本

  1. tokenRemove()删除GovStorage中的主存储
  2. strategyRemove() needs to be called if the token still has an active strategy.
  3. tokenUnload() swaps/removes all the active tokens (of the type to be removed) for another token in the protocol. This way there will be zero balance of the token (to be removed) underlying SHERX.
  4. tokenDisableProtocol() requires no protocols to be actively accruing debt (i.e. paying in the token to be removed). It cleans up storage and removes the ability for any protocol to accrue debt in this token.
  5. tokenRemove() Removes the main storage in GovStorage.

Re-enable

协议由bytes32变量标识。治理添加一个帐户作为_协议代理,该帐户能够代表协议提取余额

Protocol Lifetime

治理可以使用Manager.sol facet设置/更新应计债务率。债务可以在任何特定区块赎回。如果协议的存款余额不足,则协议将默认,并且某些功能将停止该协议的工作。尽管这一事件是不幸的,但治理可以预见它的到来并提前采取行动

Adding

⚠️ 如果协议的平衡不足,某些功能将被禁用。这可以使用cleanProtocol()调用来缓解

Premiums

使用cleanProtocol()从池存储中清除协议(一次针对单个令牌)。这消除了协议在令牌中累积债务的可能性,并清理了存储

删除协议是通过清除每个令牌中的协议来完成的。最后调用protocolRemove()以完全删除协议

Cleaning

内部代币价格(使用Manager.sol合同中的函数添加/更新)需要将代币的小数加成36

Deleting

例如

Price Decimals

Internal token prices (added/updated using the function in the Manager.sol contract) need to make a sum of 36 with the decimals of the token.

e.g.

TokenX = 18 decimals, price precision = 18 decimals TokenY = 8 decimals, price precision = 28 decimals TokenZ = 6 decimals, price precision = 30 decimals 

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情