+关注继续查看

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

PtahDao/ProTradex/Meta2032流动性质押挖矿分红系统开发(NFT质押挖矿开发)丨成熟及源码
区块链技术由此可以从多方面为企业赋能:提供可靠的共享数据,在各方之间建立信任;消除数据孤岛,即通过去中心化的,在一个网络中共享并支持获许可方访问的账本将数据集成到一个系统中;为数据赋予高度安全性
defi/lp/nft/dapp代币预售合约流动性质押挖矿开发正式版,defi/lp/nft/dapp代币预售合约流动性质押挖矿系统开发(方案及详细)
智能合约(Smart contract)是依托计算机在网络空间运行的合约,它以信息化方式传播、验证或执行合同,由计算机读取、执行,具备自助的特点。而区块链的去中心化,数据的防篡改,决定了智能合约更加适合于在区块链上来实现
智能合约是运行在区块链系统可复制、共享账本上的计算机程序,可以处理信息,接收、储存和发送价值。基于区块链技术的智能合约,不仅可以发挥智能合约在成本效率方面的优势,而且可以避免恶意行为对合约正常执行的干扰。将智能合约以数字化的形式写入区块链中,由区块链技术的特性保障存储、读取、执行整个过程透明可跟踪、不可篡改。同时,由区块链自带的共识算法构建出一套状态机系统,使智能合约能够高效地运行。 dapp/defi/nft/lp借贷理财流动性质押挖矿开发功能版,dapp/defi/nft/lp借贷理财流动性质押挖矿系统开发(开发方案)
From the perspective of conceptual model,the metauniverse is the superposition of technology system,content system,economic system,cooperation system and governance system.The core of the technical system is integration,and its technical system should be characterized by open
DAPP智能合约流动性质押挖矿分红开发案例版丨DAPP智能合约流动性质押挖矿分红系统开发(开发案例及源码)
The metauniverse is an immersive digital world created by the combination of virtual reality,augmented reality and the Internet.The connotation and key technologies of the metauniverse require further breaking the space-time limit(5G and the Internet of Things),real immersion(VR),and value transmi
流动性质押挖矿矿池开发平台丨流动性质押挖矿矿池系统开发(开发原理)丨流动性质押挖矿矿池系统源码部署
amountIn.toInt256(),zeroForOne?MIN_SQRT_RATIO:MAX_SQRT_RATIO, bool zeroForOne=tokenIn<tokenOut;
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
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
defi丨dapp丨nft丨lp流动性质押挖矿分红开发详细,defi丨dapp丨nft丨lp流动性质押挖矿分红系统开发(源码版)
Liquidity mining encourages users to pledge tokens and pledge vouchers to liquidity mining contracts. For users, using DeFi will not only gain the original profits, but also obtain liquidity mining rewards. Inspired by liquidity mining, it has promoted users to become the LP of DeFi and promoted th
dapp/lp/defi/nft流动性质押挖矿稳定版,dapp/lp/defi/nft流动性质押挖矿分红系统开发详细案例及功能
Debit and credit voucher:When you deposit a token in Compound,you will get a credit voucher cToken.cToken is the ownership of the user's pledge token.You can exchange the original token and withdraw the corresponding profits in the Compound agreement.
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
流动性质押挖矿分红系统开发案例源码,dapp/lp流动性质押挖矿分红系统开发技术说明及方案
现阶段,Web3.0处于早期发展阶段。由于web3.0具有“智能机器广泛参与到网络过程”的鲜明特征,所以Web3.0的发展将离不开云计算、大数据、人工智能、物联网、区块链等相关技术。而区块链技术是Web3.0最关键的技术。
Uniswap去中心化交易所流动性挖矿开发功能丨Uniswap去中心化交易所流动性挖矿系统开发详细方案及代码分析
Web3.0:指移动互联网后下一阶段的互联网生态,主要通过区块链等技术手段实现去中心化的网络形式,实现可以模拟现实世界感受,能够打破虚拟与现实边界的互联网。
uniswap丨justswap丨pancakeswap去中心化交易所流动性质押挖矿开发源码,uniswap丨justswap丨pancakeswap去中心化交易所流动性质押挖矿系统开发实现技术分析
智能合约是基于区块链的,同时其本质是一系列代码的合集,用于自动完成某些特定的功能。由于Web 3.0网络将通过去中心化协议运行,它们将通过智能合约实现互操作、无缝集成、自动化。