diff --git a/src/adaptors/primex-finance/index.js b/src/adaptors/primex-finance/index.js index 51473d178b..2f143a55a5 100644 --- a/src/adaptors/primex-finance/index.js +++ b/src/adaptors/primex-finance/index.js @@ -1,13 +1,11 @@ const sdk = require('@defillama/sdk'); const superagent = require('superagent'); const { abi } = require('./abi'); -const { APYREWARD_BY_SYMBOL, CHAIN_IDS, DEAD_ADDRESS, ROLES, SECONDS_PER_YEAR, APY_REWARD_BONUS, config } = require('./utils') - -const getPoolUrl = (address, chain) => `https://app.primex.finance/#/bucket-details/${address}?network=${CHAIN_IDS[chain]}` +const { CHAIN_IDS, DEAD_ADDRESS, ROLES, SECONDS_PER_YEAR, APY_REWARD_BONUS, config, addressEq, getPoolUrl } = require('./utils') const formatPool = async (bucket, config, EPMXPrice) => { const { bucketAddress, asset, supportedAssets, supply, demand, bar, lar, estimatedBar, estimatedLar, miningParams, name } = bucket; - const { chain, activityRewardDistributor, EPMX } = config + const { chain, activityRewardDistributor, EPMX, USDCE, apyRewardBySymbol } = config const [rewardPerTokenLender, rewardPerTokenTrader] = (await Promise.all( Object.values(ROLES).map((r) => { @@ -20,9 +18,11 @@ const formatPool = async (bucket, config, EPMXPrice) => { }) ) }) - )).map(v => v.output.isFinished ? 0 : v.output.rewardPerToken) + )).map(v => { + return v.output.isFinished ? 0 : v.output.rewardPerToken + }) - const symbol = asset.symbol + const symbol = addressEq(asset.tokenAddress, USDCE) ? 'USDC.E' : asset.symbol const underlyingTokens = [asset.tokenAddress] const priceKeys = underlyingTokens.map((t) => `${chain.toLowerCase()}:${t}`).join(',') @@ -43,11 +43,13 @@ const formatPool = async (bucket, config, EPMXPrice) => { const apyBaseBorrowCalculated = (Math.pow(1 + (bar / 10 ** 27) / SECONDS_PER_YEAR, SECONDS_PER_YEAR) - 1) * 100 const apyBaseBorrow = isMiningPhase ? 0 : apyBaseBorrowCalculated - const apyRewardCalculated = rewardPerTokenLender * 10 ** asset.decimals / 10 ** 18 * SECONDS_PER_YEAR * EPMXPrice / assetPrice / 10 ** 18 * 100; - const apyReward = isMiningPhase ? APYREWARD_BY_SYMBOL[symbol] + APY_REWARD_BONUS : apyRewardCalculated + // const apyRewardCalculated = (rewardPerTokenLender * 10 ** asset.decimals / 10 ** 18 * SECONDS_PER_YEAR * EPMXPrice / assetPrice.price / 10 ** 18) * 100; + // const apyReward = isMiningPhase ? apyRewardBySymbol[symbol] + APY_REWARD_BONUS : apyRewardCalculated + const apyReward = isMiningPhase ? APY_REWARD_BONUS : 0 - const apyRewardBorrowCalculated = rewardPerTokenTrader * 10 ** asset.decimals / 10 ** 18 * SECONDS_PER_YEAR * EPMXPrice / assetPrice / 10 ** 18 * 100; - const apyRewardBorrow = isMiningPhase ? 0 : apyRewardBorrowCalculated + // const apyRewardBorrowCalculated = (rewardPerTokenTrader * 10 ** asset.decimals / 10 ** 18 * SECONDS_PER_YEAR * EPMXPrice / assetPrice.price / 10 ** 18) * 100; + // const apyRewardBorrow = isMiningPhase ? 0 : apyRewardBorrowCalculated + const apyRewardBorrow = 0 return { pool: `${bucketAddress}-${chain}`.toLowerCase(), diff --git a/src/adaptors/primex-finance/utils.js b/src/adaptors/primex-finance/utils.js index b88c4a0d36..8867d4bc6f 100644 --- a/src/adaptors/primex-finance/utils.js +++ b/src/adaptors/primex-finance/utils.js @@ -7,32 +7,57 @@ const ROLES = { } const CHAIN_IDS = { - Polygon: 137, + Polygon: 'polygon_mainnet', + Arbitrum: 'arbitrum_one' }; -const APYREWARD_BY_SYMBOL = { - ['WETH']: 18, - ['WBTC']: 1, - ['USDC']: 31, - ['USDT']: 20, - ['WMATIC']: 21, -} - const APY_REWARD_BONUS = 7; const config = [ { chain: 'Polygon', - lensAddress: '0xA37a23C5Eb527985caae2a710a0F0De7C49ACb9d', + lensAddress: '0xCbaEc4b0683Ed6F2C2C318500962857768Fc1366', bucketsFactory: '0x7E6915D307F434E4171cCee90e180f5021c60089', positionManager: '0x02bcaA4633E466d151b34112608f60A82a4F6035', activityRewardDistributor: '0x156e2fC8e1906507412BEeEB6640Bf999a1Ea76b', + USDCE: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", EPMX: "0xDc6D1bd104E1efa4A1bf0BBCf6E0BD093614E31A", EPMXPriceFeed: "0x103A9FF33c709405DF58f8f209C53f6B5c5eA2BE", EPMXPriceFeedDecimals: 8, + apyRewardBySymbol: { + ['WETH']: 18, + ['WBTC']: 1, + ['USDC.E']: 31, + ['USDT']: 20, + ['WMATIC']: 21, + } + }, + { + chain: 'Arbitrum', + lensAddress: '0x3a5CAdB5eDF17876fD2518AEC3a4d804964aA89e', + bucketsFactory: '0x4e6f7372bCE4083c779c17B240A94dc2EA57AE67', + positionManager: '0x86890E30cE9E1e13Db5560BbEb435c55567Af1cd', + activityRewardDistributor: '0x38D94212AAe3f4aB3E4fE801d9021ab0aA371DaB', + USDCE: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", + EPMX: "0xA533f744B179F2431f5395978e391107DC76e103", + EPMXPriceFeed: "0x053FB5b7c555FC0d9Bc49118023d6B6A4019168f", + EPMXPriceFeedDecimals: 8, + apyRewardBySymbol: { + ['WETH']: 23.5, + ['WBTC']: 1.25, + ['USDC']: 39.5, + ['USDT']: 41, + ['ARB']: 1, + ['USDC.E']: 39.5, + } }, ] -const getPoolUrl = (address, chain) => `https://app.primex.finance/#/bucket-details/${address}?network=${CHAIN_IDS[chain]}` +const getPoolUrl = (address, chain) => `https://app.primex.finance/#/bucket-details/${address}?network=${CHAIN_IDS[chain]}`; + +const addressEq = (addressA, addressB) => { + if (!addressA || !addressB) return false; + return addressA.toLowerCase() === addressB.toLowerCase(); +} -module.exports = { DEAD_ADDRESS, SECONDS_PER_YEAR, ROLES, CHAIN_IDS, APYREWARD_BY_SYMBOL, APY_REWARD_BONUS, config } \ No newline at end of file +module.exports = { DEAD_ADDRESS, SECONDS_PER_YEAR, ROLES, CHAIN_IDS, APY_REWARD_BONUS, config, getPoolUrl, addressEq } \ No newline at end of file