Magma Developer SDK
  • Getting started
  • Prerequisites
  • Features Available
  • Retrieve clmm pools
  • Retrieve positions
  • Retrieve reward
  • Retrieve ticks
  • Create clmm pool
  • Open position
  • Add liquidity
  • Remove liquidity
  • Close position
  • Collect fees
  • Collect rewards
  • Preswap
  • Swap
  • Partner swap
  • Smart router
  • Price impact
  • Minimum received & Maximum sold
  • Fee
  • Liquidity correlation calculation
  • APR correlation calculation
Powered by GitBook
On this page
  • 1. Retrieve the position reward list of one pool
  • Example
  • 2. Retrieve the daily reward emission info for a pool
  • Example
  • 3. Retrieve rewards of position
  • Example

Retrieve reward

1. Retrieve the position reward list of one pool

Method: sdk.Pool.fetchPositionRewardList()

Params

  • poolID: The pool object ID.

  • coinTypeA: Coin A type.

  • coinTypeB: Coin B type.

Example

async function retrievalRewardListOfOnePool() {
  const poolId = '0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160'
  const pool = await TestnetSDK.Pool.getPool(poolId)
  const res = await TestnetSDK.Pool.fetchPositionRewardList({
    pool_id: pool.poolAddress,
    coinTypeA: pool.coinTypeA,
    coinTypeB: pool.coinTypeB,
  })
  console.log('retrieva reward list of one pool', res)
}

// retrievalRewardListOfOnePool()
/*
{
    liquidity: '1178890675',
    tick_lower_index: -2,
    tick_upper_index: 2,
    reward_amount_owed_0: '0',
    reward_amount_owed_1: '0',
    reward_amount_owed_2: '0',
    reward_growth_inside_0: '0',
    reward_growth_inside_1: '0',
    reward_growth_inside_2: '0',
    fee_growth_inside_a: '0',
    fee_owed_a: '0',
    fee_growth_inside_b: '0',
    fee_owed_b: '0',
    pos_object_id: '0x88e9779719cdb9d5e722267ca2ddd0681d6c845eadfe4f6e46f9e456b26ad15e'
  },

  ...

  {
    liquidity: '496569205127',
    tick_lower_index: -6,
    tick_upper_index: 4,
    reward_amount_owed_0: '0',
    reward_amount_owed_1: '0',
    reward_amount_owed_2: '0',
    reward_growth_inside_0: '0',
    reward_growth_inside_1: '0',
    reward_growth_inside_2: '0',
    fee_growth_inside_a: '0',
    fee_owed_a: '0',
    fee_growth_inside_b: '0',
    fee_owed_b: '0',
    pos_object_id: '0x004dcb4665475ed18b3327e35cdbd6360ce1028d08bec185bafdbfb57d2ef085'
  },
*/

2. Retrieve the daily reward emission info for a pool

Method: sdk.Rewarder.emissionsEveryDay()

Params:

  • poolID: The pool object ID.

Example

async function retrievalRewardEmissionInfosForOnePoolEveryDay() {
  const poolObjectId = '0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160'
  const emissionsEveryDay = await TestnetSDK.Rewarder.emissionsEveryDay(poolObjectId)
  console.log({ emissionsEveryDay })
}

3. Retrieve rewards of position

Method: sdk.Rewarder.betchFetchPositionRewarders()

Params:

  • positionIDs: Array of position object IDs.

Example

async function retrievalPositionRewardAmount() {
  const pool = await TestnetSDK.Pool.getPool('0x0128aade80123e3f6c5c0eac1a2dee2512bbdc92c9c1b386b0fd66e6cddfaa72')

  const posRewardersAmount = await TestnetSDK.Rewarder.batchFetchPositionRewarders(
    ['0xa3638d918aad92ba94b095e87a0f7227c9a4694d198429a3082f29cf62b927a9']
  )
  console.log({ posRewardersAmount })
}
PreviousRetrieve positionsNextRetrieve ticks

Last updated 4 months ago