Skip to content
Merged
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
7,951 changes: 0 additions & 7,951 deletions src/adaptors/aura/abis.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/adaptors/aura/abis/balancerPool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"inputs": [],
"name": "getPoolId",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
}
]
59 changes: 59 additions & 0 deletions src/adaptors/aura/abis/booster.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"inputs": [],
"name": "poolLength",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "poolInfo",
"outputs": [
{
"internalType": "address",
"name": "lptoken",
"type": "address"
},
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "address",
"name": "gauge",
"type": "address"
},
{
"internalType": "address",
"name": "crvRewards",
"type": "address"
},
{
"internalType": "address",
"name": "stash",
"type": "address"
},
{
"internalType": "bool",
"name": "shutdown",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
9 changes: 9 additions & 0 deletions src/adaptors/aura/abis/l2coordinator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"inputs": [],
"name": "mintRate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
}
]
99 changes: 99 additions & 0 deletions src/adaptors/aura/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Chain-specific configuration
const CHAIN_CONFIG = {
ethereum: {
llamaChainName: 'Ethereum',
balancerChainName: 'MAINNET',
booster: '0xA57b8d98dAE62B26Ec3bcC4a365338157060B234',
chainId: 1,
tokens: {
AURA: '0xc0c293ce456ff0ed870add98a0828dd4d2903dbf',
BAL: '0xba100000625a3754423978a60c9317c58a424e3d',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-mainnet/api',
},
arbitrum: {
llamaChainName: 'Arbitrum',
balancerChainName: 'ARBITRUM',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 42161,
l2Coordinator: '0xeC1c780A275438916E7CEb174D80878f29580606',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0x040d1edc9569d4bab2d15287dc5a4f10f56a56b8',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-arbitrum/api',
},
base: {
llamaChainName: 'Base',
balancerChainName: 'BASE',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 8453,
l2Coordinator: '0x8b2970c237656d3895588B99a8bFe977D5618201',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0x4158734d47fc9692176b5085e0f52ee0da5d47f1',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-base/api',
},
avalanche: {
llamaChainName: 'Avalanche',
balancerChainName: 'AVALANCHE',
sdkChainName: 'avax',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 43114,
l2Coordinator: '0x8b2970c237656d3895588B99a8bFe977D5618201',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0xe15bcb9e0ea69e6ab9fa080c4c4a5632896298c3',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-avalanche/api',
},
gnosis: {
llamaChainName: 'xDai',
balancerChainName: 'GNOSIS',
sdkChainName: 'xdai',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 100,
l2Coordinator: '0x8b2970c237656d3895588B99a8bFe977D5618201',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0x7ef541e2a22058048904fe5744f9c7e4c57af717',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-gnosis/api',
},
optimism: {
llamaChainName: 'Optimism',
balancerChainName: 'OPTIMISM',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 10,
l2Coordinator: '0xeC1c780A275438916E7CEb174D80878f29580606',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0xfe8b128ba8c78aabc59d4c64cee7ff28e9379921',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-optimism/api',
},
polygon: {
llamaChainName: 'Polygon',
balancerChainName: 'POLYGON',
booster: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
chainId: 137,
l2Coordinator: '0x8b2970c237656d3895588B99a8bFe977D5618201',
tokens: {
AURA: '0x1509706a6c66ca549ff0cb464de88231ddbe213b',
BAL: '0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3',
},
subgraph:
'https://subgraph.satsuma-prod.com/65b10f149401/1xhub-ltd/aura-finance-polygon/api',
},
};

module.exports = {
CHAIN_CONFIG,
};
15 changes: 15 additions & 0 deletions src/adaptors/aura/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Common time and calculation constants
const COMMON_CONFIG = {
SECONDS_PER_YEAR: 365 * 24 * 60 * 60,
QUEUED_REWARDS_EXTENSION: 7 * 24 * 60 * 60,
DEFAULT_TOKEN_DECIMALS: 18,
AIP_42_ENABLED: true, // 40% reduction applied to most pools (AIP-42)
};

// Balancer V3 API endpoint
const BALANCER_API_ENDPOINT = 'https://api-v3.balancer.fi/graphql';

module.exports = {
COMMON_CONFIG,
BALANCER_API_ENDPOINT,
};
23 changes: 23 additions & 0 deletions src/adaptors/aura/data/get-active-pools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { getPoolCount, fetchPoolInfo } = require('./rpc/booster');

/**
* Get all active (non-shutdown) pools from the booster contract
*/
async function getActivePools(chainName, chainConfig) {
if (!chainConfig?.booster) return [];

const poolLength = await getPoolCount(chainConfig.booster, chainName);
const allPoolsRaw = await fetchPoolInfo(
chainConfig.booster,
poolLength,
chainName
);

return allPoolsRaw.flatMap(({ output }, index) =>
output && !output.shutdown ? [{ ...output, poolIndex: index }] : []
);
}

module.exports = {
getActivePools,
};
62 changes: 62 additions & 0 deletions src/adaptors/aura/data/get-balancer-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const { getPoolIds } = require('./rpc/balancer-pool');
const { getBalancerPoolsData } = require('./subgraph/balancer-pools');

/**
* Get Balancer pool data with processed APRs, staking rewards, and underlying tokens
*/
async function getBalancerData(activePools, sdkChainName, chainConfig) {
const poolIdResults = await getPoolIds(
activePools.map((pool) => pool.lptoken),
sdkChainName
);

const balancerPoolsDataMap = await getBalancerPoolsData(
activePools.map((pool, i) =>
poolIdResults[i]?.success && poolIdResults[i]?.output
? poolIdResults[i].output
: pool.lptoken
),
chainConfig.balancerChainName
);

return activePools.reduce((acc, pool, i) => {
const balancerPoolId =
poolIdResults[i]?.success && poolIdResults[i]?.output
? poolIdResults[i].output
: pool.lptoken;
const poolData = balancerPoolsDataMap[balancerPoolId.toLowerCase()];
if (!poolData) return acc;

const apyBase = poolData.dynamicData?.aprItems
? poolData.dynamicData.aprItems.reduce((aprAcc, item) => {
const aprValue = item.apr * 100 || 0;

if (
item.type === 'SWAP_FEE' ||
item.type === 'SWAP_FEE_24H' ||
item.type === 'IB_YIELD'
) {
aprAcc += aprValue;
}

return aprAcc;
}, 0)
: 0;

acc[pool.poolIndex] = {
apyBase,
underlyingTokens:
poolData.poolTokens?.flatMap((token) =>
token.underlyingToken && token.useUnderlyingForAddRemove
? [token.address, token.underlyingToken.address]
: [token.address]
) || [],
};

return acc;
}, {});
}

module.exports = {
getBalancerData,
};
43 changes: 43 additions & 0 deletions src/adaptors/aura/data/get-pool-tvls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { getTotalSupplies } = require('./rpc/erc20');
const utils = require('../../utils');

/**
* Get TVL for Aura pools
*/
async function getPoolTvls(pools, chainName) {
if (!pools?.length) return {};

try {
const [totalSupplyResults, tokenPrices] = await Promise.all([
getTotalSupplies(
pools.map((pool) => pool.token),
chainName
),
utils
.getData(
`https://coins.llama.fi/prices/current/${pools
.map((pool) => `${chainName}:${pool.lptoken}`)
.join(',')
.toLowerCase()}`
)
.then((data) => data.coins),
]);

return pools.reduce((acc, pool, index) => {
const priceKey = `${chainName}:${pool.lptoken.toLowerCase()}`;
const price = tokenPrices[priceKey]?.price;
const totalSupply = totalSupplyResults[index]?.output;

acc[pool.poolIndex] =
price && totalSupply ? (Number(totalSupply) / 1e18) * price : 0;

return acc;
}, {});
} catch {
return {};
}
}

module.exports = {
getPoolTvls,
};
Loading
Loading