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#

Inputs: 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 check the proportion of locked funds to the total. This proportion represents the maximum potential loss you may face in the short term after investing (because lockedReserve may be consumed during this period, 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 represents the maximum potential loss for LPs against this condition. The sum of all conditions is the locked amount for LPs.

Core1.resolveCondition#

Only present in Core1

All conditions have only two sides, outcomeIndex can be either 0 or 1
Assuming 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, users increase their principal by adding funds to their side and deducting the opponent's side funds amplified by the odds.

LP.bet#

Transaction for user's bet: 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, both funds and virtualFunds are increased by 2u for this side, and the opponent 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#

First enters Core.resolvePayout

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

But Core2 also calls 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.