Skip to main content

Factory

Fetching Dyson Pairs from Factory

Our Dyson pairs on-chain were created by the Factory contract.

We can fetch Dyson pairs data from our Factory Contract.

Example:

import {
getPairsConfig,
preparePairLengths,
} from '@dyson-finance/dyson-interface-sdk/reads'
import { readContract } from '@wagmi/core'
import { getPublicClient } from 'wagmi/actions'

//... async function

const client = getPublicClient({
chainId,
})

const pairLength = await readContract({
...preparePairLengths(),
address: factoryAddress as Address,
chainId,
})


const swapConfigMap = await getPairsConfig(client, {
pairLength: Number(pairLength),
factoryAddress: factoryAddress as Address,
})

const swapPoolConfigList = Object.values(swapConfigMap)

//...


The swapConfigMap result example Polygon zkEVM:

{
"0xEce7244a0e861C841651401fC22cEE577fEE90AF": {
"token0Address": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
"token1Address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035",
"pairAddress": "0xEce7244a0e861C841651401fC22cEE577fEE90AF"
},
"0xC9001AFF3701e19C29E996D48e474Baf4C5eD006": {
"token0Address": "0x9CBD81b43ba263ca894178366Cfb89A246D1159C",
"token1Address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035",
"pairAddress": "0xC9001AFF3701e19C29E996D48e474Baf4C5eD006"
}
}

Now you can access the addresses of our Dyson pairs. For more Factory contract details, please check our contract document