Skip to content

Conversation

@0xmer1in
Copy link

@0xmer1in 0xmer1in commented Aug 11, 2025

Pull Request Template: GlueX Liquidity Module Integration

Protocol Information


Summary of Integration

Provide a brief overview of your integration:

  • What does your protocol do?
    WOOFi's swap uses an onchain market-making algorithm called Synthetic Proactive Market Making (sPMM). The sPMM algorithm, which works in tandem with WOOFi's high-frequency onchain oracles allows professional market makers to simulate the price, spread, and depth of the order book on centralized exchanges onchain.
  • What type of liquidity does it provide (DEX, lending, yield farming, etc.)?
    DEX
  • Any unique features that GlueX should consider?

Implementation Details

Execution Functions Required

/// @dev the integration just like UniswapV2 pool, transfer fromToken into pool, then call this function to swap the toToken out.
/// @notice Swap `fromToken` to `toToken`.
/// @param fromToken the from token
/// @param toToken the to token
/// @param fromAmount the amount of `fromToken` to swap
/// @param minToAmount the minimum amount of `toToken` to receive
/// @param to the destination address
/// @param rebateTo the rebate address (optional, can be address ZERO)
/// @return realToAmount the amount of toToken to receive
function swap(
    address fromToken,
    address toToken,
    uint256 fromAmount,
    uint256 minToAmount,
    address to,
    address rebateTo
) external returns (uint256 realToAmount);

ABI

{"inputs": [{"internalType": "address","name": "fromToken","type": "address"},{"internalType": "address","name": "toToken","type": "address"},{"internalType": "uint256","name": "fromAmount","type": "uint256"},{"internalType": "uint256","name": "minToAmount","type": "uint256"},{"internalType": "address","name": "to","type": "address"},{"internalType": "address","name": "rebateTo","type": "address"}],"name": "swap","outputs": [{"internalType": "uint256","name": "realToAmount","type": "uint256"}],"stateMutability": "nonpayable","type": "function"}

Chain and Address

0x5520385bFcf07Ec87C4c53A7d8d65595Dff69FA4

Functions Implemented

  • get_amount_out(): uses the logic from the WOOFi Pool contract, solidity code is currently private
  • get_amount_in(): same as the above
  • get_apy(): N/A
  • get_tvl(): N/A

Dynamic States Required for AMM Calculations

Specify any on-chain values that change frequently and are required for accurate AMM computations, such as:

  • Current reserves
  • Current prices
  • Pending liquidity changes
  • Other time-sensitive variables

Pool States:

  • Pool Address:
    • BSC, Avalanche, Polygon, Arbitrum, Optimism, Linea, Base, Mantle, Sonic, Berachain, HyperEVM: 0x5520385bFcf07Ec87C4c53A7d8d65595Dff69FA4
  • Wooracle Address:
    • BSC, Avalanche, Linea, Base, Mantle, Sonic, Berachain, HyperEVM: 0x2A375567f5E13F6bd74fDa7627Df3b1Af6BfA5a6
    • Polygon: 0x2A8Ede62D0717C8C92b88639ecf603FDF31A8428
    • Arbitrum: 0xCf4EA1688bc23DD93D933edA535F8B72FC8934Ec
    • Optimism: 0xA43305Ce0164D87d7B2368f91a1dcC4eBdA75127

For Pool reserve, fee_rate, max_gamma, max_notional_swap state, use the Pool contract with token address as input

ABI

{inputs: [{internalType: "address",name: "",type: "address"}],name: "tokenInfos",outputs: [{internalType: "uint192",name: "reserve",type: "uint192"},{internalType: "uint16",name: "feeRate",type: "uint16"},{internalType: "uint128",name: "maxGamma",type: "uint128"},{internalType: "uint128",name: "maxNotionalSwap",type: "uint128"},{internalType: "uint192",name: "capBal",type: "uint192"}],stateMutability: "view",type: "function"}

Sample

# get cbBTC reserve on Base
Pool.tokenInfos(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).reserve

# get cbBTC fee_rate on Base
Pool.tokenInfos(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).feeRate

# get cbBTC max_gamma on Base
Pool.tokenInfos(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).maxGamma

# get cbBTC max_notional_swap on Base
Pool.tokenInfos(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).maxNotionalSwap

For Wooracle price, spread, coeff, wo_feasible, use the Wooracle contract with token address as input

ABI

{inputs: [{internalType: "address",name: "_base",type: "address"}],name: "state",outputs: [{components: [{internalType: "uint128",name: "price",type: "uint128"},{internalType: "uint64",name: "spread",type: "uint64"},{internalType: "uint64",name: "coeff",type: "uint64"},{internalType: "bool",name: "woFeasible",type: "bool"}],internalType: "struct IWooracleV2_2.State",name: "",type: "tuple"}],stateMutability: "view",type: "function"}

Sample

# get cbBTC price on Base
Wooracle.state(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).price

# get cbBTC spread on Base
Wooracle.state(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).spread

# get cbBTC coeff on Base
Wooracle.state(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).coeff

# get cbBTC wo_feasible on Base
Wooracle.state(0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf).woFeasible

Static States Required for AMM Calculations

Specify any on-chain values that remain constant such as:

  • Fee tiers
  • Immutable contract parameters
  • Other relevant constants

Dependencies

N/A

Other Requirements

  • API Keys: N/A
  • Special Access Requirements: N/A

Test Results

Provide details of tests performed, including:

..
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK
  • Tested getAmountOut and getAmountIn with some inputs

Copy link

@Pratham-gluex Pratham-gluex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses of hyperEvm doesnt seems right!
There are no read methods showing for the pool contract which you shared , also same case for ethereum as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants