diff --git a/src/adaptors/primex-finance/abi.js b/src/adaptors/primex-finance/abi.js index a3e7d4e5c0..78aa5c6039 100644 --- a/src/adaptors/primex-finance/abi.js +++ b/src/adaptors/primex-finance/abi.js @@ -1,537 +1,564 @@ const abi = { getAllBucketsFactory: { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "_bucketFactory", - "type": "address" + internalType: 'address[]', + name: '_bucketFactories', + type: 'address[]', }, { - "internalType": "address", - "name": "_user", - "type": "address" + internalType: 'address', + name: '_user', + type: 'address', }, { - "internalType": "address", - "name": "_positionManager", - "type": "address" + internalType: 'address', + name: '_positionManager', + type: 'address', }, { - "internalType": "bool", - "name": "_showDeprecated", - "type": "bool" - } + internalType: 'bool', + name: '_showDeprecated', + type: 'bool', + }, + { + internalType: 'uint256', + name: '_cursor', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_count', + type: 'uint256', + }, ], - "name": "getAllBucketsFactory", - "outputs": [ + name: 'getAllBucketsFactory', + outputs: [ { - "components": [ + components: [ { - "internalType": "address", - "name": "bucketAddress", - "type": "address" + internalType: 'address', + name: 'bucketAddress', + type: 'address', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "tokenAddress", - "type": "address" + internalType: 'address', + name: 'tokenAddress', + type: 'address', }, { - "internalType": "string", - "name": "symbol", - "type": "string" + internalType: 'string', + name: 'symbol', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "uint256", - "name": "decimals", - "type": "uint256" + internalType: 'uint256', + name: 'decimals', + type: 'uint256', }, { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } + internalType: 'uint256', + name: 'balance', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.TokenMetadata", - "name": "asset", - "type": "tuple" + internalType: 'struct IPrimexLens.TokenMetadata', + name: 'asset', + type: 'tuple', }, { - "internalType": "uint128", - "name": "bar", - "type": "uint128" + internalType: 'uint128', + name: 'bar', + type: 'uint128', }, { - "internalType": "uint128", - "name": "lar", - "type": "uint128" + internalType: 'uint128', + name: 'lar', + type: 'uint128', }, { - "internalType": "uint256", - "name": "supply", - "type": "uint256" + internalType: 'uint256', + name: 'supply', + type: 'uint256', }, { - "internalType": "uint256", - "name": "demand", - "type": "uint256" + internalType: 'uint256', + name: 'demand', + type: 'uint256', }, { - "internalType": "uint256", - "name": "availableLiquidity", - "type": "uint256" + internalType: 'uint256', + name: 'availableLiquidity', + type: 'uint256', }, { - "internalType": "uint256", - "name": "utilizationRatio", - "type": "uint256" + internalType: 'uint256', + name: 'utilizationRatio', + type: 'uint256', }, { - "components": [ + components: [ { - "components": [ + components: [ { - "internalType": "address", - "name": "tokenAddress", - "type": "address" + internalType: 'address', + name: 'tokenAddress', + type: 'address', }, { - "internalType": "string", - "name": "symbol", - "type": "string" + internalType: 'string', + name: 'symbol', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "uint256", - "name": "decimals", - "type": "uint256" + internalType: 'uint256', + name: 'decimals', + type: 'uint256', }, { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } + internalType: 'uint256', + name: 'balance', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.TokenMetadata", - "name": "asset", - "type": "tuple" + internalType: 'struct IPrimexLens.TokenMetadata', + name: 'asset', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "id", - "type": "uint256" + internalType: 'uint256', + name: 'id', + type: 'uint256', }, { - "internalType": "bool", - "name": "isSupported", - "type": "bool" + internalType: 'bool', + name: 'isSupported', + type: 'bool', }, { - "internalType": "uint256", - "name": "pairPriceDrop", - "type": "uint256" + internalType: 'uint256', + name: 'pairPriceDrop', + type: 'uint256', }, { - "internalType": "uint256", - "name": "maxLeverage", - "type": "uint256" - } + internalType: 'uint256', + name: 'maxLeverage', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.BucketTokenMetadata", - "name": "properties", - "type": "tuple" - } + internalType: 'struct IPrimexLens.BucketTokenMetadata', + name: 'properties', + type: 'tuple', + }, ], - "internalType": "struct IPrimexLens.SupportedAsset[]", - "name": "supportedAssets", - "type": "tuple[]" + internalType: 'struct IPrimexLens.SupportedAsset[]', + name: 'supportedAssets', + type: 'tuple[]', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "tokenAddress", - "type": "address" + internalType: 'address', + name: 'tokenAddress', + type: 'address', }, { - "internalType": "string", - "name": "symbol", - "type": "string" + internalType: 'string', + name: 'symbol', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "uint256", - "name": "decimals", - "type": "uint256" + internalType: 'uint256', + name: 'decimals', + type: 'uint256', }, { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } + internalType: 'uint256', + name: 'balance', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.TokenMetadata", - "name": "pToken", - "type": "tuple" + internalType: 'struct IPrimexLens.TokenMetadata', + name: 'pToken', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "address", - "name": "tokenAddress", - "type": "address" + internalType: 'address', + name: 'tokenAddress', + type: 'address', }, { - "internalType": "string", - "name": "symbol", - "type": "string" + internalType: 'string', + name: 'symbol', + type: 'string', }, { - "internalType": "string", - "name": "name", - "type": "string" + internalType: 'string', + name: 'name', + type: 'string', }, { - "internalType": "uint256", - "name": "decimals", - "type": "uint256" + internalType: 'uint256', + name: 'decimals', + type: 'uint256', }, { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - } + internalType: 'uint256', + name: 'balance', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.TokenMetadata", - "name": "debtToken", - "type": "tuple" + internalType: 'struct IPrimexLens.TokenMetadata', + name: 'debtToken', + type: 'tuple', }, { - "internalType": "uint256", - "name": "feeBuffer", - "type": "uint256" + internalType: 'uint256', + name: 'feeBuffer', + type: 'uint256', }, { - "internalType": "uint256", - "name": "withdrawalFeeRate", - "type": "uint256" + internalType: 'uint256', + name: 'withdrawalFeeRate', + type: 'uint256', }, { - "components": [ + components: [ { - "internalType": "contract ILiquidityMiningRewardDistributor", - "name": "liquidityMiningRewardDistributor", - "type": "address" + internalType: 'contract ILiquidityMiningRewardDistributor', + name: 'liquidityMiningRewardDistributor', + type: 'address', }, { - "internalType": "bool", - "name": "isBucketLaunched", - "type": "bool" + internalType: 'bool', + name: 'isBucketLaunched', + type: 'bool', }, { - "internalType": "uint256", - "name": "accumulatingAmount", - "type": "uint256" + internalType: 'uint256', + name: 'accumulatingAmount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "deadlineTimestamp", - "type": "uint256" + internalType: 'uint256', + name: 'deadlineTimestamp', + type: 'uint256', }, { - "internalType": "uint256", - "name": "stabilizationDuration", - "type": "uint256" + internalType: 'uint256', + name: 'stabilizationDuration', + type: 'uint256', }, { - "internalType": "uint256", - "name": "stabilizationEndTimestamp", - "type": "uint256" + internalType: 'uint256', + name: 'stabilizationEndTimestamp', + type: 'uint256', }, { - "internalType": "uint256", - "name": "maxAmountPerUser", - "type": "uint256" + internalType: 'uint256', + name: 'maxAmountPerUser', + type: 'uint256', }, { - "internalType": "uint256", - "name": "maxDuration", - "type": "uint256" + internalType: 'uint256', + name: 'maxDuration', + type: 'uint256', }, { - "internalType": "uint256", - "name": "maxStabilizationEndTimestamp", - "type": "uint256" - } + internalType: 'uint256', + name: 'maxStabilizationEndTimestamp', + type: 'uint256', + }, ], - "internalType": "struct IBucketStorage.LiquidityMiningParams", - "name": "miningParams", - "type": "tuple" + internalType: 'struct IBucketStorage.LiquidityMiningParams', + name: 'miningParams', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "amountInMining", - "type": "uint256" + internalType: 'uint256', + name: 'amountInMining', + type: 'uint256', }, { - "internalType": "uint256", - "name": "currentPercent", - "type": "uint256" + internalType: 'uint256', + name: 'currentPercent', + type: 'uint256', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "minReward", - "type": "uint256" + internalType: 'uint256', + name: 'minReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "maxReward", - "type": "uint256" + internalType: 'uint256', + name: 'maxReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "extraReward", - "type": "uint256" - } + internalType: 'uint256', + name: 'extraReward', + type: 'uint256', + }, ], - "internalType": "struct ILiquidityMiningRewardDistributor.RewardsInPMX", - "name": "rewardsInPMX", - "type": "tuple" - } + internalType: + 'struct ILiquidityMiningRewardDistributor.RewardsInPMX', + name: 'rewardsInPMX', + type: 'tuple', + }, ], - "internalType": "struct IPrimexLens.LenderInfo", - "name": "lenderInfo", - "type": "tuple" + internalType: 'struct IPrimexLens.LenderInfo', + name: 'lenderInfo', + type: 'tuple', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "pmxAmount", - "type": "uint256" + internalType: 'uint256', + name: 'pmxAmount', + type: 'uint256', }, { - "internalType": "uint256", - "name": "withdrawnRewards", - "type": "uint256" + internalType: 'uint256', + name: 'withdrawnRewards', + type: 'uint256', }, { - "internalType": "uint256", - "name": "totalPoints", - "type": "uint256" - } + internalType: 'uint256', + name: 'totalPoints', + type: 'uint256', + }, ], - "internalType": "struct IPrimexLens.LiquidityMiningBucketInfo", - "name": "lmBucketInfo", - "type": "tuple" + internalType: 'struct IPrimexLens.LiquidityMiningBucketInfo', + name: 'lmBucketInfo', + type: 'tuple', }, { - "internalType": "uint128", - "name": "estimatedBar", - "type": "uint128" + internalType: 'uint128', + name: 'estimatedBar', + type: 'uint128', }, { - "internalType": "uint128", - "name": "estimatedLar", - "type": "uint128" + internalType: 'uint128', + name: 'estimatedLar', + type: 'uint128', }, { - "internalType": "bool", - "name": "isDeprecated", - "type": "bool" + internalType: 'bool', + name: 'isDeprecated', + type: 'bool', }, { - "internalType": "bool", - "name": "isDelisted", - "type": "bool" + internalType: 'bool', + name: 'isDelisted', + type: 'bool', }, { - "components": [ + components: [ { - "internalType": "uint256", - "name": "urOptimal", - "type": "uint256" + internalType: 'uint256', + name: 'urOptimal', + type: 'uint256', }, { - "internalType": "uint256", - "name": "k0", - "type": "uint256" + internalType: 'uint256', + name: 'k0', + type: 'uint256', }, { - "internalType": "uint256", - "name": "k1", - "type": "uint256" + internalType: 'uint256', + name: 'k1', + type: 'uint256', }, { - "internalType": "uint256", - "name": "b0", - "type": "uint256" + internalType: 'uint256', + name: 'b0', + type: 'uint256', }, { - "internalType": "int256", - "name": "b1", - "type": "int256" - } + internalType: 'int256', + name: 'b1', + type: 'int256', + }, ], - "internalType": "struct IInterestRateStrategy.BarCalculationParams", - "name": "barCalcParams", - "type": "tuple" + internalType: 'struct IInterestRateStrategy.BarCalculationParams', + name: 'barCalcParams', + type: 'tuple', }, { - "internalType": "uint256", - "name": "maxTotalDeposit", - "type": "uint256" - } + internalType: 'uint256', + name: 'maxTotalDeposit', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'liquidityIndex', + type: 'uint256', + }, + { + internalType: 'enum IPrimexDNSStorage.Status', + name: 'currentStatus', + type: 'uint8', + }, ], - "internalType": "struct IPrimexLens.BucketMetaData[]", - "name": "", - "type": "tuple[]" - } + internalType: 'struct IPrimexLensPart2.BucketMetaDataPart2[]', + name: '', + type: 'tuple[]', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "stateMutability": "view", - "type": "function" + + stateMutability: 'view', + type: 'function', }, activityRewardDistributorBuckets: { - "inputs": [ + inputs: [ { - "internalType": "address", - "name": "", - "type": "address" + internalType: 'address', + name: '', + type: 'address', }, { - "internalType": "uint256", - "name": "", - "type": "uint256" - } + internalType: 'uint256', + name: '', + type: 'uint256', + }, ], - "name": "buckets", - "outputs": [ + name: 'buckets', + outputs: [ { - "internalType": "uint256", - "name": "rewardIndex", - "type": "uint256" + internalType: 'uint256', + name: 'rewardIndex', + type: 'uint256', }, { - "internalType": "uint256", - "name": "lastUpdatedTimestamp", - "type": "uint256" + internalType: 'uint256', + name: 'lastUpdatedTimestamp', + type: 'uint256', }, { - "internalType": "uint256", - "name": "rewardPerToken", - "type": "uint256" + internalType: 'uint256', + name: 'rewardPerToken', + type: 'uint256', }, { - "internalType": "uint256", - "name": "scaledTotalSupply", - "type": "uint256" + internalType: 'uint256', + name: 'scaledTotalSupply', + type: 'uint256', }, { - "internalType": "bool", - "name": "isFinished", - "type": "bool" + internalType: 'bool', + name: 'isFinished', + type: 'bool', }, { - "internalType": "uint256", - "name": "fixedReward", - "type": "uint256" + internalType: 'uint256', + name: 'fixedReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "lastUpdatedRewardTimestamp", - "type": "uint256" + internalType: 'uint256', + name: 'lastUpdatedRewardTimestamp', + type: 'uint256', }, { - "internalType": "uint256", - "name": "rewardPerDay", - "type": "uint256" + internalType: 'uint256', + name: 'rewardPerDay', + type: 'uint256', }, { - "internalType": "uint256", - "name": "totalReward", - "type": "uint256" + internalType: 'uint256', + name: 'totalReward', + type: 'uint256', }, { - "internalType": "uint256", - "name": "endTimestamp", - "type": "uint256" - } + internalType: 'uint256', + name: 'endTimestamp', + type: 'uint256', + }, ], - "stateMutability": "view", - "type": "function" + stateMutability: 'view', + type: 'function', }, getChainlinkLatestRoundData: { - "inputs": [ + inputs: [ { - "internalType": "address[]", - "name": "_feeds", - "type": "address[]" - } + internalType: 'address[]', + name: '_feeds', + type: 'address[]', + }, ], - "name": "getChainlinkLatestRoundData", - "outputs": [ + name: 'getChainlinkLatestRoundData', + outputs: [ { - "components": [ + components: [ { - "internalType": "uint80", - "name": "roundId", - "type": "uint80" + internalType: 'uint80', + name: 'roundId', + type: 'uint80', }, { - "internalType": "int256", - "name": "answer", - "type": "int256" + internalType: 'int256', + name: 'answer', + type: 'int256', }, { - "internalType": "uint256", - "name": "startedAt", - "type": "uint256" + internalType: 'uint256', + name: 'startedAt', + type: 'uint256', }, { - "internalType": "uint256", - "name": "updatedAt", - "type": "uint256" + internalType: 'uint256', + name: 'updatedAt', + type: 'uint256', }, { - "internalType": "uint80", - "name": "answeredInRound", - "type": "uint80" - } + internalType: 'uint80', + name: 'answeredInRound', + type: 'uint80', + }, ], - "internalType": "struct IPrimexLens.RoundData[]", - "name": "", - "type": "tuple[]" - } + internalType: 'struct IPrimexLens.RoundData[]', + name: '', + type: 'tuple[]', + }, ], - "stateMutability": "view", - "type": "function" - } -} + stateMutability: 'view', + type: 'function', + }, +}; -module.exports = { abi } \ No newline at end of file +module.exports = { abi }; diff --git a/src/adaptors/primex-finance/index.js b/src/adaptors/primex-finance/index.js index 1d237e429d..dc2b0d0d48 100644 --- a/src/adaptors/primex-finance/index.js +++ b/src/adaptors/primex-finance/index.js @@ -1,6 +1,7 @@ const sdk = require('@defillama/sdk'); const superagent = require('superagent'); const { abi } = require('./abi'); +const { ethers } = require('ethers'); const utils = require('../utils'); const { CHAIN_IDS, @@ -13,7 +14,7 @@ const { getPoolUrl, } = require('./utils'); -const formatPool = async (bucket, config, EPMXPrice) => { +const formatPool = async (bucket, config) => { const { bucketAddress, asset, @@ -27,35 +28,23 @@ const formatPool = async (bucket, config, EPMXPrice) => { miningParams, name, } = bucket; - const { chain, activityRewardDistributor, EPMX, USDCE, apyRewardBySymbol } = - config; - - const [rewardPerTokenLender, rewardPerTokenTrader] = ( - await Promise.all( - Object.values(ROLES).map((r) => { - return sdk.api.abi.call({ - abi: abi.activityRewardDistributorBuckets, - target: activityRewardDistributor, - chain: chain.toLowerCase(), - params: [bucketAddress, r], - }); - }) - ) - ).map((v) => { - return v.output.isFinished ? 0 : v.output.rewardPerToken; - }); - const symbol = addressEq(asset.tokenAddress, USDCE) ? 'USDC.E' : asset.symbol; - const underlyingTokens = [asset.tokenAddress]; + const { chain, EPMX, USDCE, apyRewardBySymbol } = config; + + const symbol = addressEq(asset?.tokenAddress, USDCE) + ? 'USDC.E' + : asset?.symbol; + const underlyingTokens = [asset?.tokenAddress]; const priceKeys = underlyingTokens .map((t) => `${chain.toLowerCase()}:${t}`) .join(','); + const prices = ( await superagent.get(`https://coins.llama.fi/prices/current/${priceKeys}`) ).body.coins; - const assetPrice = prices[`${chain.toLowerCase()}:${asset.tokenAddress}`]; + const assetPrice = prices[`${chain.toLowerCase()}:${asset?.tokenAddress}`]; const totalSupplyUsd = (supply / 10 ** assetPrice?.decimals) * assetPrice?.price; const totalBorrowUsd = @@ -63,8 +52,8 @@ const formatPool = async (bucket, config, EPMXPrice) => { const tvlUsd = totalSupplyUsd - totalBorrowUsd; const isMiningPhase = - !miningParams.isBucketLaunched && - miningParams.deadlineTimestamp * 1000 > Date.now(); + !miningParams?.isBucketLaunched && + miningParams?.deadlineTimestamp * 1000 > Date.now(); const apyBaseCalculated = (Math.pow(1 + lar / 10 ** 27 / SECONDS_PER_YEAR, SECONDS_PER_YEAR) - 1) * @@ -75,13 +64,7 @@ const formatPool = async (bucket, config, EPMXPrice) => { (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.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.price / 10 ** 18) * 100; - // const apyRewardBorrow = isMiningPhase ? 0 : apyRewardBorrowCalculated const apyRewardBorrow = 0; return { @@ -92,7 +75,6 @@ const formatPool = async (bucket, config, EPMXPrice) => { tvlUsd, apyBase, apyReward, - rewardTokens: [EPMX], underlyingTokens, url: getPoolUrl(bucketAddress, chain), apyBaseBorrow, @@ -108,41 +90,72 @@ const getPools = async (config) => { lensAddress, bucketsFactory, positionManager, - EPMX, - EPMXPriceFeed, - EPMXPriceFeedDecimals, } = config; - const buckets = ( - await sdk.api.abi.call({ - abi: abi.getAllBucketsFactory, - target: lensAddress, - chain: chain.toLowerCase(), - params: [bucketsFactory, DEAD_ADDRESS, positionManager, false], - }) - ).output; - - const EPMXPrice = - ( - await sdk.api.abi.call({ - abi: abi.getChainlinkLatestRoundData, - target: lensAddress, - chain: chain.toLowerCase(), - params: [[EPMXPriceFeed]], - }) - ).output[0].answer / - 10 ** EPMXPriceFeedDecimals; - + if (chain === 'Ethereum') { + sdk.api.config.setProvider( + 'ethereum', + new ethers.providers.JsonRpcProvider( + "https://lb.drpc.org/ogrpc?network=ethereum&dkey=AhjAIUax7EMFtu9ErxcXVpjOZcogyegR77I1IlZWwHzR" + ) + ); + } + + if (chain === 'Base') { + sdk.api.config.setProvider( + 'base', + new ethers.providers.JsonRpcProvider( + 'https://lb.drpc.org/ogrpc?network=base&dkey=AhjAIUax7EMFtu9ErxcXVpjOZcogyegR77I1IlZWwHzR' + ) + ); + } + let bucketsArr = []; + let offset = 0; + const limit = 3; + + while (true) { + try { + const result = ( + await sdk.api.abi.call({ + abi: abi.getAllBucketsFactory, + target: lensAddress, + chain: chain.toLowerCase(), + params: [ + bucketsFactory, + DEAD_ADDRESS, + positionManager, + false, + offset, + limit, + ], + }) + ).output; + + if (result[0].length !== 0) { + bucketsArr = bucketsArr.concat(result[0]); + } + + if (result[1] === '0') { + break; + } + + offset += limit; + } catch (error) { + console.error(error); + break; + } + } + return await Promise.all( - buckets - .filter(({ miningParams }) => { + bucketsArr + .filter((bucket) => { + const miningParams = bucket.miningParams; const isMiningFailed = - !miningParams.isBucketLaunched && - miningParams.deadlineTimestamp * 1000 <= Date.now(); - + !miningParams?.isBucketLaunched && + miningParams?.deadlineTimestamp * 1000 <= Date.now(); return !isMiningFailed; }) - .map((b) => formatPool(b, config, EPMXPrice)) + .map((b) => formatPool(b, config)) ); }; diff --git a/src/adaptors/primex-finance/utils.js b/src/adaptors/primex-finance/utils.js index 0e7186f870..6f62dc4db2 100644 --- a/src/adaptors/primex-finance/utils.js +++ b/src/adaptors/primex-finance/utils.js @@ -1,81 +1,85 @@ -const DEAD_ADDRESS = '0x000000000000000000000000000000000000dEaD' +const DEAD_ADDRESS = '0x000000000000000000000000000000000000dEaD'; const SECONDS_PER_YEAR = 31536000; const ROLES = { LENDER: 0, - TRADER: 1 -} + TRADER: 1, +}; const CHAIN_IDS = { + Ethereum: 'ethereum', + Arbitrum: 'arbitrum_one', Polygon: 'polygon_mainnet', - Arbitrum: 'arbitrum_one' + Base: 'base', }; const APY_REWARD_BONUS = 7; const config = [ + { + chain: 'Base', + lensAddress: '0x636177fa2629927500f0d7946b46d6275d2b01d2', + bucketsFactory: [ + '0xcf552c38a0ecb51982af28d4e475bef27ac2dd25', + '0x8e8792881227e8fee8a9e05a567a44d3fa04a7f0', + ], + positionManager: '0x01ed183275956dbd0064b789b778ca0921e695e9', + }, { chain: 'Polygon', - lensAddress: '0xCbaEc4b0683Ed6F2C2C318500962857768Fc1366', - bucketsFactory: '0x7E6915D307F434E4171cCee90e180f5021c60089', + lensAddress: '0xfd5BB42E9B647d316c9c0356D368F09505D0F584', + bucketsFactory: [ + '0x7E6915D307F434E4171cCee90e180f5021c60089', + '0x9649CfDCfAa9c80907e63dD9Cb161cBA2033F3A0', + ], positionManager: '0x02bcaA4633E466d151b34112608f60A82a4F6035', - activityRewardDistributor: '0x156e2fC8e1906507412BEeEB6640Bf999a1Ea76b', - USDCE: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", - EPMX: "0xDc6D1bd104E1efa4A1bf0BBCf6E0BD093614E31A", - EPMXPriceFeed: "0x103A9FF33c709405DF58f8f209C53f6B5c5eA2BE", + 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', + lensAddress: '0xa057c1464dD31B3Aacf72Ef3470E0dA9548e551f', + bucketsFactory: [ + '0x4e6f7372bCE4083c779c17B240A94dc2EA57AE67', + '0xB4d3A9f10D3D687FaF3b05b9aa3054856A1d7be8', + ], positionManager: '0x86890E30cE9E1e13Db5560BbEb435c55567Af1cd', - activityRewardDistributor: '0x38D94212AAe3f4aB3E4fE801d9021ab0aA371DaB', - USDCE: "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", - EPMX: "0xA533f744B179F2431f5395978e391107DC76e103", - EPMXPriceFeed: "0x053FB5b7c555FC0d9Bc49118023d6B6A4019168f", + 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, - } }, { chain: 'Ethereum', - lensAddress: '0xBF7259d41af428642140C88a10db6921a383FCC1', - bucketsFactory: '0x7dE8607157124c894Ba9F18dd6138B5E8AAd5890', + lensAddress: '0xa5b9Fc7038d5e3b054249cf89A065b3Bb15D0d28', + bucketsFactory: [ + '0x7dE8607157124c894Ba9F18dd6138B5E8AAd5890', + '0x55120da310A0c5fd81Fd3bb8C177F6649bE30ACc', + ], positionManager: '0x99d63fEA4b3Ef6ca77941df3C5740dAd1586f0B8', - activityRewardDistributor: '0xA622b8DfC3B5Ec283CEefd37768F5B3b3E316730', - EPMX: "0xA533f744B179F2431f5395978e391107DC76e103", - EPMXPriceFeed: "0xF146a76F3Aa82D4cEa3eaB44932b7eE75737E11a", + EPMX: '0xA533f744B179F2431f5395978e391107DC76e103', + EPMXPriceFeed: '0xF146a76F3Aa82D4cEa3eaB44932b7eE75737E11a', EPMXPriceFeedDecimals: 8, - apyRewardBySymbol: { - ['WETH']: 24, - ['WBTC']: 2.4, - ['USDC']: 44.4, - ['USDT']: 43.2, - ['MATIC']: 21.6, - ['DAI']: 39.6, - } }, -] +]; -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, APY_REWARD_BONUS, config, getPoolUrl, addressEq } \ No newline at end of file +module.exports = { + DEAD_ADDRESS, + SECONDS_PER_YEAR, + ROLES, + CHAIN_IDS, + APY_REWARD_BONUS, + config, + getPoolUrl, + addressEq, +};