[v1] On-chain price feeds

Intro

In order to simulate the order book from centralized exchanges without sacrificing capital efficiency, WOOFi created a custom on-chain price fee which works along side with the sPMM algorithm. This price feed considers multiple parameters including mid-price pp, spread ss, and liquidity coefficient kk.

WOOFi's on-chain price feeds are deployed on multiple blockchains. Users can call price to get priceNow and feasible of token. If feasible is false, do not use priceNow value. All prices are USDT/USDC-based, and the decimal of priceNow is 18 - base_decimal + quote_decimal.

Code Example

Contract ABI

[
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "base",
                "type": "address"
            }
        ],
        "name": "price",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "priceNow",
                "type": "uint256"
            },
            {
                "internalType": "bool",
                "name": "feasible",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }
]

Python Example (python 3.8)

  • Query price

  • Response

Last updated

Was this helpful?