From 979beb3101d59ca586b0f464a9efd0f0a7e03fcc Mon Sep 17 00:00:00 2001 From: Samster91 Date: Mon, 6 Jun 2022 22:28:10 +0200 Subject: [PATCH 1/6] NEW: added polygon pools --- src/adaptors/idle-finance/index.js | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/adaptors/idle-finance/index.js diff --git a/src/adaptors/idle-finance/index.js b/src/adaptors/idle-finance/index.js new file mode 100644 index 0000000000..6a3afc9252 --- /dev/null +++ b/src/adaptors/idle-finance/index.js @@ -0,0 +1,49 @@ +const utils = require('../utils'); +const mainnetPoolsUrl = 'https://api.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; +const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; +const chains = { + "eth": "ethereum", + "matic": "polygon" +}; + +async function apy() { + const mainnetPoolsResponse = await utils.getData(mainnetPoolsUrl); + const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); + + const poolsResponse = { + 'matic':polygonPoolsResponse, + "eth":mainnetPoolsResponse + }; + + let allVaults = []; + + for (let chain of Object.keys(chains)) { + const chainPools = Object.values(poolsResponse[chain]); + + const pools = chainPools.map(v => { + var poolNameParts = v.poolName.split(' '); + let poolName = (utils.formatSymbol(poolNameParts[0].toUpperCase())+' '+poolNameParts.slice(1,poolNameParts.length).join(' ')).trim(); + return { + pool: v.address, + apy: Number(v.apr), + symbol: poolName, + tvlUsd: Number(v.tvl), + project: 'idle-finance', + chain: utils.formatChain(chains[chain]) + }; + }); + + allVaults = [...allVaults, ...pools]; + }; + + return allVaults; +}; + +const main = async () => { + return await apy(); +}; + +module.exports = { + apy: main, + timetravel: false, +}; \ No newline at end of file From 583ca3dacba9875baaaf2f5cef35a0d8efd9e4b9 Mon Sep 17 00:00:00 2001 From: Samster91 Date: Mon, 6 Jun 2022 22:28:58 +0200 Subject: [PATCH 2/6] FIX: new line --- src/adaptors/idle-finance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adaptors/idle-finance/index.js b/src/adaptors/idle-finance/index.js index 6a3afc9252..a182151237 100644 --- a/src/adaptors/idle-finance/index.js +++ b/src/adaptors/idle-finance/index.js @@ -46,4 +46,4 @@ const main = async () => { module.exports = { apy: main, timetravel: false, -}; \ No newline at end of file +}; From 7f8fcbb571e196a0ff808843e5f62ea9fc2fddda Mon Sep 17 00:00:00 2001 From: Samster91 Date: Fri, 9 Dec 2022 14:15:58 +0100 Subject: [PATCH 3/6] FIX: Idle endpoint Authentication --- src/adaptors/idle-finance/index.js | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/adaptors/idle-finance/index.js b/src/adaptors/idle-finance/index.js index a182151237..daf18c4375 100644 --- a/src/adaptors/idle-finance/index.js +++ b/src/adaptors/idle-finance/index.js @@ -1,12 +1,28 @@ const utils = require('../utils'); +<<<<<<< HEAD const mainnetPoolsUrl = 'https://api.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; +======= +const superagent = require('superagent'); + +const AUTH_TOKEN_ENCODED = 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmpiR2xsYm5SSlpDSTZJa0Z3Y0RZaUxDSnBZWFFpT2pFMk56QXlNemMxTWpkOS5rbnNtekVOSm40Yk5Ea0ZCM3h2eWZyaDBwVlFLTHY0NW9JanJQNHdRTU5N' + +const mainnetPoolsUrl = 'https://api.idle.finance/pools'; +// const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools'; + +>>>>>>> 36fc221f (FIX: Idle endpoint Authentication) const chains = { "eth": "ethereum", "matic": "polygon" }; +async function getDataWithAuth(url, token){ + const data = await superagent.get(url).set('Authorization', `Bearer ${token}`); + return data?.body +} + async function apy() { +<<<<<<< HEAD const mainnetPoolsResponse = await utils.getData(mainnetPoolsUrl); const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); @@ -38,6 +54,40 @@ async function apy() { return allVaults; }; +======= + const AUTH_TOKEN_DECODED = atob(AUTH_TOKEN_ENCODED) + const mainnetPoolsResponse = await getDataWithAuth(mainnetPoolsUrl, AUTH_TOKEN_DECODED) + + // console.log('mainnetPoolsResponse', mainnetPoolsResponse) + // const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); + + const poolsResponse = { + // matic: polygonPoolsResponse, + eth: mainnetPoolsResponse, + }; + + let allVaults = []; + + for (let chain of Object.keys(chains)) { + const chainPools = Object.values(poolsResponse[chain]); + + const pools = chainPools.map((v) => ({ + pool: v.address, + apyBase: Number(v.apr), + symbol: v.tokenName, + poolMeta: v.strategy, + tvlUsd: Number(v.tvl), + project: 'idle-finance', + chain: utils.formatChain(chains[chain]), + underlyingTokens: [v.underlyingAddress], + })) + + allVaults = [...allVaults, ...pools]; + } + + return allVaults; +} +>>>>>>> 36fc221f (FIX: Idle endpoint Authentication) const main = async () => { return await apy(); From fccbec42d42ba1d2cb4197d731942bb2dbe021e3 Mon Sep 17 00:00:00 2001 From: Samster91 Date: Fri, 3 Nov 2023 12:18:58 +0100 Subject: [PATCH 4/6] NEW: idle optimism, zkevm pools --- src/adaptors/idle/index.js | 82 ++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/src/adaptors/idle/index.js b/src/adaptors/idle/index.js index a3453f340f..30bd00b088 100644 --- a/src/adaptors/idle/index.js +++ b/src/adaptors/idle/index.js @@ -1,17 +1,15 @@ const utils = require('../utils'); const superagent = require('superagent'); -const AUTH_TOKEN_ENCODED = - 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmpiR2xsYm5SSlpDSTZJa0Z3Y0RZaUxDSnBZWFFpT2pFMk56QXlNemMxTWpkOS5rbnNtekVOSm40Yk5Ea0ZCM3h2eWZyaDBwVlFLTHY0NW9JanJQNHdRTU5N'; - -const mainnetPoolsUrl = 'https://api.idle.finance/pools'; -// const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools'; - const chains = { - eth: 'ethereum', - // matic: 'polygon', + ethereum: 'https://api.idle.finance/pools', + polygon: 'https://api-polygon.idle.finance/pools', + optimism: 'https://api-optimism.idle.finance/pools', + polygon_zkevm: 'https://api-zkevm.idle.finance/pools', }; +const AUTH_TOKEN_ENCODED = 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmpiR2xsYm5SSlpDSTZJa0Z3Y0RZaUxDSnBZWFFpT2pFMk56QXlNemMxTWpkOS5rbnNtekVOSm40Yk5Ea0ZCM3h2eWZyaDBwVlFLTHY0NW9JanJQNHdRTU5N'; + async function getDataWithAuth(url, token) { const data = await superagent .get(url) @@ -19,51 +17,39 @@ async function getDataWithAuth(url, token) { return data?.body; } -async function apy() { +const getApy = async () => { const AUTH_TOKEN_DECODED = atob(AUTH_TOKEN_ENCODED); - const mainnetPoolsResponse = await getDataWithAuth( - mainnetPoolsUrl, - AUTH_TOKEN_DECODED + const data = await Promise.all( + Object.entries(chains).map(async (chain) => { + const data = await getDataWithAuth(chain[1], AUTH_TOKEN_DECODED); + return data.map((v) => { + let protocolName = v.protocolName; + if (v.borrowerName){ + protocolName += ` ${v.borrowerName}` + } + return { + pool: v.address, + apyBase: Number(v.apr), + symbol: v.tokenName, + poolMeta: v.poolName.includes('Best') + ? v.poolName.split(' ').slice(1).join(' ') + : `${protocolName} ${v.strategy}`, + tvlUsd: Number(v.tvl), + project: 'idle', + chain: utils.formatChain(chain[0]), + underlyingTokens: [v.underlyingAddress], + } + }); + }) ); - // console.log('mainnetPoolsResponse', mainnetPoolsResponse) - // const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); - - const poolsResponse = { - // matic: polygonPoolsResponse, - eth: mainnetPoolsResponse, - }; - - let allVaults = []; - - for (let chain of Object.keys(chains)) { - const chainPools = Object.values(poolsResponse[chain]); - - const pools = chainPools.map((v) => ({ - pool: v.address, - apyBase: Number(v.apr), - symbol: v.tokenName, - poolMeta: v.poolName.includes('Best') - ? v.poolName.split(' ').slice(1).join(' ') - : v.strategy, - tvlUsd: Number(v.tvl), - project: 'idle', - chain: utils.formatChain(chains[chain]), - underlyingTokens: [v.underlyingAddress], - })); - - allVaults = [...allVaults, ...pools]; - } - - return allVaults; -} - -const main = async () => { - return await apy(); + return ( + data + .flat() + ); }; module.exports = { - apy: main, timetravel: false, - url: 'https://app.idle.finance/#/best', + apy: getApy, }; From f3f20c30105b50292f844d97a1ea9ba1bd4d2e55 Mon Sep 17 00:00:00 2001 From: Samster91 Date: Fri, 3 Nov 2023 12:20:56 +0100 Subject: [PATCH 5/6] FIX: idle removed folder --- src/adaptors/idle-finance/index.js | 99 ------------------------------ 1 file changed, 99 deletions(-) delete mode 100644 src/adaptors/idle-finance/index.js diff --git a/src/adaptors/idle-finance/index.js b/src/adaptors/idle-finance/index.js deleted file mode 100644 index daf18c4375..0000000000 --- a/src/adaptors/idle-finance/index.js +++ /dev/null @@ -1,99 +0,0 @@ -const utils = require('../utils'); -<<<<<<< HEAD -const mainnetPoolsUrl = 'https://api.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; -const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools?api-key=bPrtC2bfnAvapyXLgdvzVzW8u8igKv6E'; -======= -const superagent = require('superagent'); - -const AUTH_TOKEN_ENCODED = 'ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SmpiR2xsYm5SSlpDSTZJa0Z3Y0RZaUxDSnBZWFFpT2pFMk56QXlNemMxTWpkOS5rbnNtekVOSm40Yk5Ea0ZCM3h2eWZyaDBwVlFLTHY0NW9JanJQNHdRTU5N' - -const mainnetPoolsUrl = 'https://api.idle.finance/pools'; -// const polygonPoolsUrl = 'https://api-polygon.idle.finance/pools'; - ->>>>>>> 36fc221f (FIX: Idle endpoint Authentication) -const chains = { - "eth": "ethereum", - "matic": "polygon" -}; - -async function getDataWithAuth(url, token){ - const data = await superagent.get(url).set('Authorization', `Bearer ${token}`); - return data?.body -} - -async function apy() { -<<<<<<< HEAD - const mainnetPoolsResponse = await utils.getData(mainnetPoolsUrl); - const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); - - const poolsResponse = { - 'matic':polygonPoolsResponse, - "eth":mainnetPoolsResponse - }; - - let allVaults = []; - - for (let chain of Object.keys(chains)) { - const chainPools = Object.values(poolsResponse[chain]); - - const pools = chainPools.map(v => { - var poolNameParts = v.poolName.split(' '); - let poolName = (utils.formatSymbol(poolNameParts[0].toUpperCase())+' '+poolNameParts.slice(1,poolNameParts.length).join(' ')).trim(); - return { - pool: v.address, - apy: Number(v.apr), - symbol: poolName, - tvlUsd: Number(v.tvl), - project: 'idle-finance', - chain: utils.formatChain(chains[chain]) - }; - }); - - allVaults = [...allVaults, ...pools]; - }; - - return allVaults; -}; -======= - const AUTH_TOKEN_DECODED = atob(AUTH_TOKEN_ENCODED) - const mainnetPoolsResponse = await getDataWithAuth(mainnetPoolsUrl, AUTH_TOKEN_DECODED) - - // console.log('mainnetPoolsResponse', mainnetPoolsResponse) - // const polygonPoolsResponse = await utils.getData(polygonPoolsUrl); - - const poolsResponse = { - // matic: polygonPoolsResponse, - eth: mainnetPoolsResponse, - }; - - let allVaults = []; - - for (let chain of Object.keys(chains)) { - const chainPools = Object.values(poolsResponse[chain]); - - const pools = chainPools.map((v) => ({ - pool: v.address, - apyBase: Number(v.apr), - symbol: v.tokenName, - poolMeta: v.strategy, - tvlUsd: Number(v.tvl), - project: 'idle-finance', - chain: utils.formatChain(chains[chain]), - underlyingTokens: [v.underlyingAddress], - })) - - allVaults = [...allVaults, ...pools]; - } - - return allVaults; -} ->>>>>>> 36fc221f (FIX: Idle endpoint Authentication) - -const main = async () => { - return await apy(); -}; - -module.exports = { - apy: main, - timetravel: false, -}; From 46e9ea69ebe5ae4b18c193e94a3a6daee5598f06 Mon Sep 17 00:00:00 2001 From: Samster91 Date: Fri, 3 Nov 2023 12:30:20 +0100 Subject: [PATCH 6/6] NEW: idle dashboard url --- src/adaptors/idle/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adaptors/idle/index.js b/src/adaptors/idle/index.js index 30bd00b088..a46b02430d 100644 --- a/src/adaptors/idle/index.js +++ b/src/adaptors/idle/index.js @@ -52,4 +52,5 @@ const getApy = async () => { module.exports = { timetravel: false, apy: getApy, + url: 'https://app.idle.finance/' };