# Staking

# fetchAllApy

To get average APY for all dates

# Parameters:

Name Type
timestampFrom number
timestampTo number

# Code sample:

const now = Math.floor(new Date().getTime() / 1000)
const from = now - 7 * 24 * 60 * 60

const staking = new Staking(chainId)
const stakingList = await staking.fetchOneMonthApy(from, now)

# Response:

[
  {
    date: 1634774400,
    timestamp: 1634811459,
    apy: '39919.599025966433232'
  },
  ...
]

# fetchOneMonthApy

To get average APY for last month

# Parameters:

Name Type
timestampFrom number
timestampTo number

# Code sample:

const now = Math.floor(new Date().getTime() / 1000)
const from = now - 30 * 24 * 60 * 60

const staking = new Staking(chainId)
const stakingList = await staking.fetchOneMonthApy(from, now)

# Response:

[
  {
    date: 1634688000,
    timestamp: 1634688000,
    apy: '38627.6665750223508'
  },
  ...
]

# fetchOneWeekApy

To get average APY for last week

# Parameters:

Name Type
timestampFrom number
timestampTo number

# Code sample:

const now = Math.floor(new Date().getTime() / 1000)
const from = now - 7 * 24 * 60 * 60

const staking = new Staking(chainId)
const stakingList = await staking.fetchOneWeekApy(from, now)

# Response:

[
  {
    date: 1634688000,
    timestamp: 1634688000,
    apy: '1263.494407671863716775'
  },
  ...
]

# fetchStakingDashboard

To get total staked LON amount, and total xLON supply amount

# Code sample:

const staking = new Staking(chainId)
const stakingDashboard = await staking.fetchStakingDashboard()

# Response:

{
  totalStakedAmount: '23352.321682149767951884',
  totalXlonSupply: '102.4411015877287374773',
  scaleIndex: '227.9585178235442439676255335099622'
}

# fetchStakingList

To get Lon staking records for current account

# Parameters:

Name Type
userAddress string
page number
pageCount number

# Code sample:

const staking = new Staking(chainId)
const stakingList = await staking.fetchStakingList(
  '0xbC396689893D065F41bc2C6EcbeE5e0085233447',
  1,
  10,
)

# Response:

[]

# fetchXLon2LonScaleIndex

To get XLon to Lon scale index

# Parameters:

Name Type
timestampFrom number
timestampTo number

# Code sample:

const now = Math.floor(new Date().getTime() / 1000)
const from = now - 7 * 24 * 60 * 60

const staking = new Staking(chainId)
const stakingList = await staking.fetchXLon2LonScaleIndex(from, now)

# Response:

[
  {
    date: 1634774400,
    id: '18921',
    scaleIndex: '226.3126802927316291308433869733648'
  },
  ...
]