mookim

mookim

mookim.eth

Azure Code Analysis

https://azuro.org

Recent pool profit query for Dune: https://dune.com/queries/2513483

Pool profit dashboard: https://tools.defieye.io/superset/dashboard/azuro/?standalone=true

Contract Addresses#

Using Polygon code as an example

Oracle 0x94429f3d92ad38c70e44218460a97021548d17ad
LP 0x7043E4e1c4045424858ECBCED80989FeAfC11B36
Core1 0x3B182e9FbF50398A412d17D7969561E3BfcC4fA4 Core code
Core2 0xbb13f8981cefd19ddc5338f0f1e11de45e8a11ca BetExpress code is a combination bet for Core1

LP.addReserve#

Pass in gameId, lockedReserve, finalReserve, leaf

profit = finalReserve-lockedReserve
When profit>0, it is only distributed to nodes before the leaf
When profit<0, all LP providers will lose money

So if you want to invest, it is recommended to first look at the proportion of locked funds to the total. This proportion is the maximum loss you will face in the short term after investing (because lockedReserve may be consumed by the time you invest, resulting in a loss for all LPs, but if you make a profit, it will not be distributed to you)

Core1._calcReserve#

max( abs(reinforcement-funds[0]), abs(reinforcement-funds[1]) )

This is the maximum possible loss for LPs against this condition, and all conditions added together is the locked amount for LPs

Core1.resolveCondition#

Only in Core1

All conditions are only between two parties, and the outcomeIndex is either 0 or 1
Suppose 0 wins, how much funds can the pool obtain? It should be the amount invested minus the payout to be paid to 0

So here we have:

lockedReserve = _calcReserve(reinforcement, funds);
profitReserve = lockedReserve + funds[oppositeIndex] - reinforcement;
addReserve(condition.gameId, lockedReserve, profitReserve, condition.leaf)

It can be seen that the profit for the pool here is funds[oppositeIndex] - reinforcement; which is the principal portion invested by losing users minus the portion earned by winning users, because the default value of funds starts from reinforcement, and the user's principal increases the funds of the side they are on, deducting the opponent's funds amplified by the odds

LP.bet#

User's betting transaction: https://dashboard.tenderly.co/tx/polygon/0x97935416834c48f2bce822d1cd18ba01fb58e14b5191f8bd80f9f94a45dc6882

This is for Core1

The user gives USDT to LP and then enters Core.putBet
Based on the current virtualFunds, the amount the user invested, and the configured margin, the slippage is updated using CoreTools.calcOdds

In this transaction, the user bets 2u on 0, and both funds and virtualFunds are increased by 2u for this side, while the opposing side 1 decreases by the principal multiplied by the odds 2*1.219464097168=2.438928u

Core2's betData is SubBet[] memory subBets, uint64 minOdds

LP.withdrawPayout#

It will first enter Core.resolvePayout

Core1 directly returns the holder of the NFT and the result of viewPayout

But Core2 will also call lp.addReserve to deduct money from the pool

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.