Skip to content

Commit 6ae098a

Browse files
authored
Merge pull request #1776 from kinetic-market/kinetic
feat: Add Kinetic Isolated Markets
2 parents 1034d43 + ff4beaa commit 6ae098a

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

src/adaptors/kinetic/index.js

+35-18
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ const { comptrollerAbi, cToken, flrETH } = require('./abi');
88
const { symbol } = require('@defillama/sdk/build/erc20');
99

1010
const COMPTROLLER_ADDRESS = '0x8041680Fb73E1Fe5F851e76233DCDfA0f2D2D7c8';
11+
const ISO_COMPTROLLER_ADDRESS = '0xDcce91d46Ecb209645A26B5885500127819BeAdd';
1112
const FLR_ETH = '0x26a1fab310bd080542dc864647d05985360b16a5';
1213
const WETH = '0x1502fa4be69d526124d453619276faccab275d3d';
14+
const C_ETH_MARKET = '0xd7291D5001693d15b6e4d56d73B5d2cD7eCfE5c6';
1315
const FLARE_CHAIN = 'flare';
1416

1517
const JOULE = {
@@ -76,12 +78,12 @@ const calculateApy = (ratePerTimestamps) => {
7678
);
7779
};
7880

79-
const getRewards = async (rewardType, markets, isBorrow = false) => {
81+
const getRewards = async (rewardType, markets, comptroller, isBorrow = false) => {
8082
return (
8183
await sdk.api.abi.multiCall({
8284
chain: FLARE_CHAIN,
8385
calls: markets.map((market) => ({
84-
target: COMPTROLLER_ADDRESS,
86+
target: comptroller,
8587
params: [rewardType, market],
8688
})),
8789
abi: comptrollerAbi.find(
@@ -103,10 +105,10 @@ const multiCallMarkets = async (markets, method, abi) => {
103105
).output.map(({ output }) => output);
104106
};
105107

106-
const getApy = async () => {
108+
const getApy = async (comptroller) => {
107109
const allMarketsRes = (
108110
await sdk.api.abi.call({
109-
target: COMPTROLLER_ADDRESS,
111+
target: comptroller,
110112
chain: FLARE_CHAIN,
111113
abi: comptrollerAbi.find(({ name }) => name === 'getAllMarkets'),
112114
permitFailure: true,
@@ -119,23 +121,23 @@ const getApy = async () => {
119121
await sdk.api.abi.multiCall({
120122
chain: FLARE_CHAIN,
121123
calls: allMarkets.map((market) => ({
122-
target: COMPTROLLER_ADDRESS,
124+
target: comptroller,
123125
params: market,
124126
})),
125127
abi: comptrollerAbi.find(({ name }) => name === 'markets'),
126128
permitFailure: true,
127129
})
128130
).output.map(({ output }) => output);
129131

130-
const jouleRewards = await getRewards(REWARD_TYPES.JOULE, allMarkets);
131-
const flrRewards = await getRewards(REWARD_TYPES.FLR, allMarkets);
132-
const kiiRewards = await getRewards(REWARD_TYPES.KII, allMarkets);
133-
const rFLRRewards = await getRewards(REWARD_TYPES.RFLR, allMarkets);
132+
const jouleRewards = await getRewards(REWARD_TYPES.JOULE, allMarkets, comptroller);
133+
const flrRewards = await getRewards(REWARD_TYPES.FLR, allMarkets, comptroller);
134+
const kiiRewards = await getRewards(REWARD_TYPES.KII, allMarkets, comptroller);
135+
const rFLRRewards = await getRewards(REWARD_TYPES.RFLR, allMarkets, comptroller);
134136

135-
const jouleBorrowRewards = await getRewards(REWARD_TYPES.JOULE, allMarkets, true);
136-
const flrBorrowRewards = await getRewards(REWARD_TYPES.FLR, allMarkets, true);
137-
const kiiBorrowRewards = await getRewards(REWARD_TYPES.KII, allMarkets, true);
138-
const rflrBorrowRewards = await getRewards(REWARD_TYPES.RFLR, allMarkets, true);
137+
const jouleBorrowRewards = await getRewards(REWARD_TYPES.JOULE, allMarkets, comptroller, true);
138+
const flrBorrowRewards = await getRewards(REWARD_TYPES.FLR, allMarkets, comptroller, true);
139+
const kiiBorrowRewards = await getRewards(REWARD_TYPES.KII, allMarkets, comptroller, true);
140+
const rflrBorrowRewards = await getRewards(REWARD_TYPES.RFLR, allMarkets, comptroller, true);
139141

140142
const supplyRatePerTimestamp = await multiCallMarkets(
141143
allMarkets,
@@ -161,22 +163,32 @@ const getApy = async () => {
161163
cToken
162164
);
163165

164-
const underlyingTokens = await multiCallMarkets(
165-
allMarkets,
166+
const tempMarkets = allMarkets.filter(m => m.toLocaleLowerCase() != C_ETH_MARKET.toLocaleLowerCase())
167+
168+
let underlyingTokens = await multiCallMarkets(
169+
tempMarkets,
166170
'underlying',
167171
cToken
168172
);
169-
const underlyingSymbols = await multiCallMarkets(
173+
174+
let underlyingSymbols = await multiCallMarkets(
170175
underlyingTokens,
171176
'symbol',
172177
cToken
173178
);
174-
const underlyingDecimals = await multiCallMarkets(
179+
180+
let underlyingDecimals = await multiCallMarkets(
175181
underlyingTokens,
176182
'decimals',
177183
cToken
178184
);
179185

186+
if(underlyingTokens.length != allMarkets.length){
187+
underlyingTokens = underlyingTokens.concat([FLR.address]);
188+
underlyingSymbols = underlyingSymbols.concat('FLR');
189+
underlyingDecimals = underlyingDecimals.concat(18);
190+
}
191+
180192
const prices = await getPrices(
181193
underlyingTokens.concat([FLR.address, JOULE.address]).map((token) => 'flare:' + token)
182194
);
@@ -311,8 +323,13 @@ const getApy = async () => {
311323
return pools;
312324
};
313325

326+
const getAPys = async() => {
327+
const pools = await getApy(COMPTROLLER_ADDRESS);
328+
return pools.concat(await getApy(ISO_COMPTROLLER_ADDRESS))
329+
}
330+
314331
module.exports = {
315332
timetravel: false,
316-
apy: getApy,
333+
apy: getAPys,
317334
url: 'https://app.kinetic.market/dashboard',
318335
};

0 commit comments

Comments
 (0)