defi流动性质押挖矿系统丨defi流动性质押挖矿系统开发(dapp开发)丨defi流动性质押挖矿源码版

简介:  Liquidity mining,in short,is a token incentive plan designed to attract liquidity providers(LPs)to provide liquidity for specific transaction pairs/pools on AMM.

  

  Liquidity mining,in short,is a token incentive plan designed to attract liquidity providers(LPs)to provide liquidity for specific transaction pairs/pools on AMM.

  Synthetix is the first to distribute bonus tokens to LPs in its sETH Uniswap pool.To be more specific,in order to obtain rewards,LP needs to first provide liquidity for the sETH pool on Uniswap,and then pledge its Uniswap liquidity token into the pledge reward contract created in 2019.The reward tokens will be distributed to the LP fairly according to the percentage of the liquidity tokens pledged by the LP relative to the total pledge tokens of the LP.

  CREATE2:

  创建交易对,就是创建一个新的合约,作为流动池来提供交易功能。创建合约的步骤是:

  pool=address(new UniswapV3Pool{salt:keccak256(abi.encode(token0,token1,fee))}());

  这里先通过keccak256(abi.encode(token0,token1,fee)将token0,token1,fee作为输入,得到一个哈希值,并将其作为salt来创建合约。因为指定了salt,solidity会使用EVM的CREATE2指令来创建合约。使用CREATE2指令的好处是,只要合约的bytecode及salt不变,那么创建出来的地址也将不变。

  使用CREATE2的好处是:

  可以在链下计算出已经创建的交易池的地址

  其他合约不必通过UniswapV3Factory中的接口来查询交易池的地址,可以节省gas

  合约地址不会因为reorg而改变

  不需要通过UniswapV3Factory的接口来计算交易池合约地址的方法,可以看这段代码。

  新交易对合约的构造函数中会反向查询UniswapV3Factory中的parameters值来进行初始变量的赋值:

  constructor(){

  int24 _tickSpacing;

  (factory,token0,token1,fee,_tickSpacing)=IUniswapV3PoolDeployer(msg.sender).parameters();

  tickSpacing=_tickSpacing;

  maxLiquidityPerTick=Tick.tickSpacingToMaxLiquidityPerTick(_tickSpacing);

  }

  为什么不直接使用参数传递来对新合约的状态变量赋值呢。这是因为CREATE2会将合约的initcode和salt一起用来计算创建出的合约地址。而initcode是包含contructor code和其参数的,如果合约的constructor函数包含了参数,那么其initcode将因为其传入参数不同而不同。在off-chain计算合约地址时,也需要通过这些参数来查询对应的initcode。为了让合约地址的计算更简单,这里的constructor不包含参数(这样合约的initcode将时唯一的),而是使用动态call的方式来获取其创建参数。

  最后,对创建的交易对合约进行初始化:

  function initialize(uint160 sqrtPriceX96)external override{

  require(slot0.sqrtPriceX96==0,'AI');

  int24 tick=TickMath.getTickAtSqrtRatio(sqrtPriceX96);

  (uint16 cardinality,uint16 cardinalityNext)=observations.initialize(_blockTimestamp());

  slot0=Slot0({

  sqrtPriceX96:sqrtPriceX96,

  tick:tick,

  observationIndex:0,

  observationCardinality:cardinality,

  observationCardinalityNext:cardinalityNext,

  feeProtocol:0,

  unlocked:true

  });

  emit Initialize(sqrtPriceX96,tick);

  }

  初始化主要是设置了交易池的初始价格(注意,此时池子中还没有流动性),以及费率,tick等相关变量的初始化。完成之后一个交易池就创建好了。

  From the perspective of token economics incentive design,the liquidity mining method pioneered by Synthetix is to allocate reward tokens according to the size of the liquidity position.We can define this method as liquidity mining 1.0(LM1).As a result,such incentive plan has helped Synthetix achieve the goal of attracting more users and casting more sETH.

  LM1 has become the de facto design and implementation scheme of mobile mining.It enables many projects to be solved to some extent

相关文章
|
安全 区块链 Perl
LP流动性质押挖矿系统开发丨Defi质押流动性挖矿开发
LP流动性质押挖矿系统开发丨Defi质押流动性挖矿开发
LP流动性质押挖矿系统开发丨Defi质押流动性挖矿开发
NFT流动性质押挖矿开发功能丨NFT流动性质押挖矿系统开发(开发详细)丨NFT流动性质押挖矿系统源码部署
  Liquidity mining is an incentive mechanism to promote the use of DeFi and a new decentralized token distribution mechanism.Most DeFi applications require users to lock tokens into the contract.The larger the amount of lock-in the contract has,the better financial services can be obtained.Liquidity
流动性质押挖矿矿池系统开发(开发案例)丨流动性质押挖矿矿池系统开发(详细及源码)
? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated) (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);
|
供应链 区块链 数据安全/隐私保护
NFT质押挖矿Dapp开发及DeFi流动性技术
流动性挖矿(Liquidity Mining),也称收益农耕(Yield Farming),是通过利用加密货币向去中心化交易提供流动性的一种新方式。
NFT质押挖矿Dapp开发及DeFi流动性技术
|
存储 缓存 算法
流动性质押挖矿分红开发源码版,流动性质押挖矿分红系统开发技术详细及分析
共识模块主要由几个组件组成,世代epoch、提案消息缓存服务msgcache、共识消息处理引擎engine、共识消息验证器verifier、提案消息存储服务forest、投票处理器voter、共识活性服务pacemaker、wal存储wal、节点间共识信息同步服务compensator、各模块相互配合实现maxbft流水线共识算法
|
区块链
Dapp质押流动性挖矿系统开发项目
NFT通过向玩家提供可证明资产所有权,并分散传统游戏运营商的绝对权力,从而真正实现游戏资产的稀缺性。 而游戏资产的金融化,也极大促进了游戏资产在二级市场上的自由交易,从而提高玩家在游戏资产市场的创收潜力。 总的来说,我们即将迎来一场基于NFT的游戏世界的完美风暴,并刺激游戏的创新和潜力达到一个全新的高度
Dapp质押流动性挖矿系统开发项目
|
算法 区块链
Defi+NFT质押流动性挖矿系统开发/LP质押挖矿功能开发解析
Defi+NFT质押流动性挖矿系统开发/LP质押挖矿功能开发解析
|
开发工具
defi/nft流动性质押挖矿分红开发正式版,defi/nft流动性质押挖矿分红系统开发(成熟案例及源码)
Liquidity mining usually requires pledge of loan vouchers or LP vouchers. That is to say, instead of pledging the original token to get the reward of liquidity mining, users need to pledge the original token in DeFi first, and then pledge the voucher to the specified contract to get the reward of li
|
人工智能
DAPP流动性矿池挖矿分红开发丨DAPP流动性矿池挖矿分红系统开发详细及逻辑丨DAPP流动性矿池挖矿分行系统源码部署
  Smart contract:Smart contract is a program running on the ETH blockchain,which defines the logic behind the state changes on the blockchain.In abstract,smart contract is a rule that can be executed automatically.In real life,a contract needs to have a special execution role after the contract is f

热门文章

最新文章