Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,6 @@
"zklink",
"zksync",
"zora",
"zyx"
"zyx",
"xone"
]
9 changes: 9 additions & 0 deletions projects/helper/coreAssets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2621,5 +2621,14 @@
},
"bitci": {
"WBITCI": "0xe0d0f25b5fcfa4d3edd9c2186451d9e04c4b9f11"
},
"xone": {
"WXOC": "0x4eabbaBeBbb358660cA080e8F2bb09E4a911AB4E",
"WETH": "0x8F2C3ab64976F2e69a788C04C956f661619c4066",
"WBNB": "0xE3159D4753C4126aFe1F5cCaf4D90ae2524Bf7E9",
"WTRX":"0x1b2bE62A0da2Dc8Cb725Fe6cCb8282160D017b9B",
"USDC": "0x02D45d684A233F3bA0C55fE941854FC0E5235fE1",
"USDT": "0xb575796D293f37F112f3694b8ff48D711FE67EC7",
"USDH": "0x26df50102098C19aB4374b2D5572a1bCde38f160"
}
}
1 change: 1 addition & 0 deletions projects/helper/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DEFAULTS = {
TAC_RPC_MULTICALL: "0xcA11bde05977b3631167028862bE2a173976CA11",
ABSTRACT_RPC_MULTICALL: "0xcA11bde05977b3631167028862bE2a173976CA11",
BITCI_RPC_MULTICALL: "0x777238B119cD07e6849b0817f284532DC0F9F8D9", // bitci multicall3
XONE_RPC: 'https://rpc.xone.org',
}

const ENV_KEYS = [
Expand Down
9 changes: 9 additions & 0 deletions projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ const fixBalancesTokens = {
YLDS: { coingeckoId: 'usd-coin', decimals: 0 },
'pm.sale.pool.3dxq3fk9llvhrqqwhodiap': { coingeckoId: 'usd-coin', decimals: 0 },
},
xone: {
[ADDRESSES.xone.WXOC]: { coingeckoId: "xone", decimals: 18 }, // Wrapped XOC (ERC-20 wrapper of native Xone Coin)
[ADDRESSES.xone.ETH]: { coingeckoId: "ethereum", decimals: 18 }, // Wrapped ETH
[ADDRESSES.xone.USDC]: { coingeckoId: "usdc", decimals: 18 }, // Wrapped USDC
[ADDRESSES.xone.USDT]: { coingeckoId: "tether", decimals: 6 }, // Wrapped USDT
[ADDRESSES.xone.BNB]: { coingeckoId: "binancecoin", decimals: 18 }, // Wrapped BNB
[ADDRESSES.xone.TRX]: { coingeckoId: "tron", decimals: 6 }, // Wrapped TRX
[ADDRESSES.xone.USDH]: { coingeckoId: "xone", decimals: 6 }, // Wrapped USDH
},
}

ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) })
Expand Down
69 changes: 69 additions & 0 deletions projects/swapx-v3/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const sdk = require('@defillama/sdk')
const { getLogs } = require('../helper/cache/getLogs')

// Xone / SwapX V3 factory
const FACTORY = '0xd357373500c6E5ce3A4CfA966b56F5241C7Af3c4'

const startBlocks = {
xone: 3752039,
}

function chainTvl(chain) {
return async (api) => {
const START_BLOCK = startBlocks[chain]
if (!Number.isInteger(START_BLOCK)) throw new Error(`missing START_BLOCK for ${chain}`)

const logs = await getLogs({
api,
target: FACTORY,
fromBlock: START_BLOCK,
topic: 'PoolCreated(address,address,uint24,int24,address)',
})

const pairAddresses = []
const token0Addresses = []
const token1Addresses = []

for (const log of logs) {
token0Addresses.push(`0x${log.topics[1].slice(-40)}`.toLowerCase())
token1Addresses.push(`0x${log.topics[2].slice(-40)}`.toLowerCase())
pairAddresses.push(`0x${log.data.slice(-40)}`.toLowerCase())
}

// 组装 pair -> token0/token1
const pairs = {}
token0Addresses.forEach((t0, i) => { pairs[pairAddresses[i]] = { token0Address: t0 } })
token1Addresses.forEach((t1, i) => {
const addr = pairAddresses[i]
pairs[addr] = { ...(pairs[addr] || {}), token1Address: t1 }
})

// 读池子里两侧代币余额
const balanceCalls = []
const exclude = [] // 如需排除问题池可写在这里
for (const pair of Object.keys(pairs)) {
if (exclude.includes(pair)) continue
balanceCalls.push({ target: pairs[pair].token0Address, params: pair })
balanceCalls.push({ target: pairs[pair].token1Address, params: pair })
}

const block = await api.getBlock()
const tokenBalances = await sdk.api.abi.multiCall({
abi: 'erc20:balanceOf',
calls: balanceCalls,
block,
chain,
})

const balances = {}
sdk.util.sumMultiBalanceOf(balances, tokenBalances, true, (i) => i)
return balances
}
}

module.exports = {
misrepresentedTokens: true,
xone: {
tvl: chainTvl('xone'),
},
}
5 changes: 5 additions & 0 deletions projects/swapx/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { uniTvlExport } = require('../helper/unknownTokens')

// Xone / SwapX v2 factory
// 0x76bDc5a6190Ea31A6D5C7e93a8a2ff4dD15080A6
module.exports = uniTvlExport('xone', '0x76bDc5a6190Ea31A6D5C7e93a8a2ff4dD15080A6')
Loading