# Equation equation平衡率市场做商(BRMM)模型的独特之处在于,它通过将永续合约的定价直接与流动性池的平衡率(BR)联系起来,创新性地解决了传统AMM模型在永续合约市场上的应用局限。这种模型使流动性提供者(LPs)能够通过承担流动性池临时不平衡的风险来参与市场的价格发现,并从中获得交易费收入。其核心特征是在用户交易导致流动性变化时,自动调整合约价格,以确保市场的稳定和流动性。这样的机制不仅提高了永续合约市场的效率和透明度,也为LPs创造了新的市场机会。 ## Workflow 1. for LP 授权token -> approvePlugin(授权router来对开平流动性进行操作) -> 用户发出createOpenLiquidityPosition信号,并将资金转移给PositionRouter -> executor执行 create信号,将资金从并将资金从PositionRouter中转移到pool当中,lp添加成功 2. for trading 授权token -> 用户发出createIncreasePosition信号,并将资金转移给PositionRouter -> executor执行 create信号,将资金从并将资金从PositionRouter中转移到pool当中,开仓成功 所有订单信息都存储在链上的PositionRouter,具体为`PositionRouter`当中 increasePositionRequests[index] = IncreasePositionRequest({ account: msg.sender, pool: _pool, side: _side, marginDelta: _marginDelta, sizeDelta: _sizeDelta, acceptableTradePriceX96: _acceptableTradePriceX96, executionFee: msg.value, blockNumber: block.number.toUint96(), blockTime: block.timestamp.toUint64() }); 当前用户衍生品的信息,存储在pools的`globalPosition`当中 struct GlobalPosition { uint128 longSize; uint128 shortSize; int192 longFundingRateGrowthX96; int192 shortFundingRateGrowthX96; } GlobalPosition public override globalPosition; lp的仓位信息存储在存储在pools的`GlobalLiquidityPosition`中` struct GlobalLiquidityPosition { uint128 netSize; uint128 liquidationBufferNetSize; uint160 entryPriceX96; Side side; uint128 liquidity; uint256 realizedProfitGrowthX64; } lp开仓 (int256 realizedPnL, uint160 entryPriceAfterX96) = LiquidityPositionUtil .calculateRealizedPnLAndNextEntryPriceX96(_positionCache, _side, _tradePriceX96, _sizeDelta); // 更新全球流动性位置的入场价格 globalLiquidityPosition.entryPriceX96 = entryPriceAfterX96; ## protocol协议组成组件 ### Executor *生产地址:⬇️ https://arbiscan.io/address/0x50c66c2299964882bd0e81112d305a970eb08d02* 负责捕捉用户发送的create信号(包括但不限于:添加/移除lp,开/平仓位),并将这些create信号执行,同时负责更新index price (Pi)。 价格来自于预言机(Chainlink)加上综合交易所 开仓case: 1. executor会先更新price 2. 将token 转移到 pool当中 3. 根据当前用户开仓仓位调整lp仓位 4. 将lp或者用户的未实现盈利以及费率收益更新 5. 计算出用户开仓手续费 6. 根据手续费重新计算用户的开仓价格 7. 完成用户开仓 ### PositionRouter *生产地址:⬇️ https://arbiscan.io/address/0xc3b609357539a35673cc50e5ca4fa57da1bfec7b#code* 负责接收来自用户的create信号,存储订单详情,并对pools进行路由,以及临时存储token。 ### Pools *生产地址:⬇️ https://arbiscan.io/address/0xe8489d514aef77c5730dde4eac46b8f2d9ffd21c#code* pools中实际存储lp的状态,如上述的GlobalLiquidityPosition,并实现具体的开平仓等逻辑。 ## 附加信息: 当前executor单笔交易执行在0.35美金左右 https://arbiscan.io/tx/0x51eb086eb65e5b1d866ad7a004f0cf62c8e0a7a7c6bffb289d804682b544466c