@defisaver/positions-sdk 2.1.153-dev → 2.1.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import * as aaveV3Claim from './aaveV3';
2
- import * as compV3Claim from './compV3';
3
2
  import * as kingV3Claim from './king';
4
3
  import * as sparkClaim from './spark';
5
4
  import * as uniswapClaim from './uniswap';
6
- export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
5
+ export { aaveV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
@@ -33,11 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.uniswapClaim = exports.sparkClaim = exports.kingV3Claim = exports.compV3Claim = exports.aaveV3Claim = void 0;
36
+ exports.uniswapClaim = exports.sparkClaim = exports.kingV3Claim = exports.aaveV3Claim = void 0;
37
37
  const aaveV3Claim = __importStar(require("./aaveV3"));
38
38
  exports.aaveV3Claim = aaveV3Claim;
39
- const compV3Claim = __importStar(require("./compV3"));
40
- exports.compV3Claim = compV3Claim;
41
39
  const kingV3Claim = __importStar(require("./king"));
42
40
  exports.kingV3Claim = kingV3Claim;
43
41
  const sparkClaim = __importStar(require("./spark"));
@@ -48,7 +48,6 @@ const liquityV2_1 = require("../liquityV2");
48
48
  const fluid_1 = require("../fluid");
49
49
  const umbrella_1 = require("../umbrella");
50
50
  const aaveV3_2 = require("../claiming/aaveV3");
51
- const compV3_1 = require("../claiming/compV3");
52
51
  const spark_2 = require("../claiming/spark");
53
52
  const king_1 = require("../claiming/king");
54
53
  const ethena_1 = require("../claiming/ethena");
@@ -141,7 +140,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
141
140
  rewardsData[address.toLowerCase()] = {
142
141
  merkl: {},
143
142
  aaveV3: {},
144
- compV3: {},
145
143
  spark: {},
146
144
  spk: {},
147
145
  king: {},
@@ -351,17 +349,6 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
351
349
  rewardsData[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark rewards data for address ${address}`, data: null };
352
350
  }
353
351
  }))).flat(),
354
- // CompV3 rewards
355
- ...compoundV3Markets.map(market => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
356
- try {
357
- const compV3Rewards = yield (0, compV3_1.getCompoundV3Rewards)(client, network, address, market.baseMarketAddress);
358
- rewardsData[address.toLowerCase()].compV3[market.value] = { error: '', data: compV3Rewards };
359
- }
360
- catch (error) {
361
- console.error(`Error fetching Compound V3 rewards data for address ${address}:`, error);
362
- rewardsData[address.toLowerCase()].compV3[market.value] = { error: `Error fetching Compound V3 rewards data for address ${address}`, data: null };
363
- }
364
- }))).flat(),
365
352
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
366
353
  try {
367
354
  const merklData = yield (0, aaveV3_2.getMerklUnclaimedRewards)(address, network);
@@ -6,8 +6,6 @@ export declare enum ClaimType {
6
6
  AAVE_MERIT_REWARDS = "AAVE_MERIT_REWARDS",
7
7
  /** Rewards distributed through Merkl across supported protocols */
8
8
  MERKL_REWARDS = "MERKL_REWARDS",
9
- /** Rewards from Compound V3 (only in COMP) */
10
- COMPOUND_V3_COMP = "COMPOUND_V3_COMP",
11
9
  /** Rewards from Spark (wstETH only for now) */
12
10
  SPARK_REWARDS = "SPARK_REWARDS",
13
11
  /** Rewards from King (prev LTR^2 - received for weETH holding) */
@@ -68,12 +66,6 @@ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
68
66
  merkleProofs: string[];
69
67
  };
70
68
  };
71
- export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
72
- claimType: ClaimType.COMPOUND_V3_COMP;
73
- additionalClaimFields: {
74
- marketAddress: EthAddress;
75
- };
76
- };
77
69
  export declare enum SparkAirdropType {
78
70
  SPARK_IGNITION = "spark-ignition",
79
71
  PRE_FARMING_AND_SOCIAL = "pre-farming-and-social"
@@ -102,5 +94,5 @@ export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
102
94
  proof: string[];
103
95
  };
104
96
  };
105
- export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | CompoundV3CompClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
97
+ export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
106
98
  export {};
@@ -9,8 +9,6 @@ var ClaimType;
9
9
  ClaimType["AAVE_MERIT_REWARDS"] = "AAVE_MERIT_REWARDS";
10
10
  /** Rewards distributed through Merkl across supported protocols */
11
11
  ClaimType["MERKL_REWARDS"] = "MERKL_REWARDS";
12
- /** Rewards from Compound V3 (only in COMP) */
13
- ClaimType["COMPOUND_V3_COMP"] = "COMPOUND_V3_COMP";
14
12
  /** Rewards from Spark (wstETH only for now) */
15
13
  ClaimType["SPARK_REWARDS"] = "SPARK_REWARDS";
16
14
  /** Rewards from King (prev LTR^2 - received for weETH holding) */
@@ -1,6 +1,5 @@
1
1
  import * as aaveV3Claim from './aaveV3';
2
- import * as compV3Claim from './compV3';
3
2
  import * as kingV3Claim from './king';
4
3
  import * as sparkClaim from './spark';
5
4
  import * as uniswapClaim from './uniswap';
6
- export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
5
+ export { aaveV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
@@ -1,6 +1,5 @@
1
1
  import * as aaveV3Claim from './aaveV3';
2
- import * as compV3Claim from './compV3';
3
2
  import * as kingV3Claim from './king';
4
3
  import * as sparkClaim from './spark';
5
4
  import * as uniswapClaim from './uniswap';
6
- export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
5
+ export { aaveV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
@@ -28,7 +28,6 @@ import { _getLiquityV2MarketData, getLiquitySAndYBold, getLiquityV2Staking } fro
28
28
  import { _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
29
29
  import { getUmbrellaData } from '../umbrella';
30
30
  import { getMerklUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
31
- import { getCompoundV3Rewards } from '../claiming/compV3';
32
31
  import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
33
32
  import { getKingRewards } from '../claiming/king';
34
33
  import { fetchEthenaAirdropRewards } from '../claiming/ethena';
@@ -121,7 +120,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
121
120
  rewardsData[address.toLowerCase()] = {
122
121
  merkl: {},
123
122
  aaveV3: {},
124
- compV3: {},
125
123
  spark: {},
126
124
  spk: {},
127
125
  king: {},
@@ -331,17 +329,6 @@ export function getPortfolioData(provider_1, network_1, defaultProvider_1, addre
331
329
  rewardsData[address.toLowerCase()].spark[market.value] = { error: `Error fetching Spark rewards data for address ${address}`, data: null };
332
330
  }
333
331
  }))).flat(),
334
- // CompV3 rewards
335
- ...compoundV3Markets.map(market => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
336
- try {
337
- const compV3Rewards = yield getCompoundV3Rewards(client, network, address, market.baseMarketAddress);
338
- rewardsData[address.toLowerCase()].compV3[market.value] = { error: '', data: compV3Rewards };
339
- }
340
- catch (error) {
341
- console.error(`Error fetching Compound V3 rewards data for address ${address}:`, error);
342
- rewardsData[address.toLowerCase()].compV3[market.value] = { error: `Error fetching Compound V3 rewards data for address ${address}`, data: null };
343
- }
344
- }))).flat(),
345
332
  ...addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
346
333
  try {
347
334
  const merklData = yield getMerklUnclaimedRewards(address, network);
@@ -6,8 +6,6 @@ export declare enum ClaimType {
6
6
  AAVE_MERIT_REWARDS = "AAVE_MERIT_REWARDS",
7
7
  /** Rewards distributed through Merkl across supported protocols */
8
8
  MERKL_REWARDS = "MERKL_REWARDS",
9
- /** Rewards from Compound V3 (only in COMP) */
10
- COMPOUND_V3_COMP = "COMPOUND_V3_COMP",
11
9
  /** Rewards from Spark (wstETH only for now) */
12
10
  SPARK_REWARDS = "SPARK_REWARDS",
13
11
  /** Rewards from King (prev LTR^2 - received for weETH holding) */
@@ -68,12 +66,6 @@ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
68
66
  merkleProofs: string[];
69
67
  };
70
68
  };
71
- export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
72
- claimType: ClaimType.COMPOUND_V3_COMP;
73
- additionalClaimFields: {
74
- marketAddress: EthAddress;
75
- };
76
- };
77
69
  export declare enum SparkAirdropType {
78
70
  SPARK_IGNITION = "spark-ignition",
79
71
  PRE_FARMING_AND_SOCIAL = "pre-farming-and-social"
@@ -102,5 +94,5 @@ export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
102
94
  proof: string[];
103
95
  };
104
96
  };
105
- export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | CompoundV3CompClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
97
+ export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | MerklRewardsClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
106
98
  export {};
@@ -6,8 +6,6 @@ export var ClaimType;
6
6
  ClaimType["AAVE_MERIT_REWARDS"] = "AAVE_MERIT_REWARDS";
7
7
  /** Rewards distributed through Merkl across supported protocols */
8
8
  ClaimType["MERKL_REWARDS"] = "MERKL_REWARDS";
9
- /** Rewards from Compound V3 (only in COMP) */
10
- ClaimType["COMPOUND_V3_COMP"] = "COMPOUND_V3_COMP";
11
9
  /** Rewards from Spark (wstETH only for now) */
12
10
  ClaimType["SPARK_REWARDS"] = "SPARK_REWARDS";
13
11
  /** Rewards from King (prev LTR^2 - received for weETH holding) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.153-dev",
3
+ "version": "2.1.153",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -1,12 +1,10 @@
1
1
  import * as aaveV3Claim from './aaveV3';
2
- import * as compV3Claim from './compV3';
3
2
  import * as kingV3Claim from './king';
4
3
  import * as sparkClaim from './spark';
5
4
  import * as uniswapClaim from './uniswap';
6
5
 
7
6
  export {
8
7
  aaveV3Claim,
9
- compV3Claim,
10
8
  kingV3Claim,
11
9
  sparkClaim,
12
10
  uniswapClaim,
@@ -45,7 +45,6 @@ import { _getLiquityV2MarketData, getLiquitySAndYBold, getLiquityV2Staking } fro
45
45
  import { _getAllUserEarnPositionsWithFTokens, _getUserPositionsPortfolio } from '../fluid';
46
46
  import { getUmbrellaData } from '../umbrella';
47
47
  import { getMerklUnclaimedRewards, getUnclaimedRewardsForAllMarkets } from '../claiming/aaveV3';
48
- import { getCompoundV3Rewards } from '../claiming/compV3';
49
48
  import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
50
49
  import { getKingRewards } from '../claiming/king';
51
50
  import { fetchEthenaAirdropRewards } from '../claiming/ethena';
@@ -152,7 +151,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
152
151
  rewardsData[address.toLowerCase() as EthAddress] = {
153
152
  merkl: {},
154
153
  aaveV3: {},
155
- compV3: {},
156
154
  spark: {},
157
155
  spk: {},
158
156
  king: {},
@@ -351,16 +349,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
351
349
  rewardsData[address.toLowerCase() as EthAddress].spark[market.value] = { error: `Error fetching Spark rewards data for address ${address}`, data: null };
352
350
  }
353
351
  })).flat(),
354
- // CompV3 rewards
355
- ...compoundV3Markets.map(market => addresses.map(async (address) => {
356
- try {
357
- const compV3Rewards = await getCompoundV3Rewards(client, network, address, market.baseMarketAddress);
358
- rewardsData[address.toLowerCase() as EthAddress].compV3[market.value] = { error: '', data: compV3Rewards };
359
- } catch (error) {
360
- console.error(`Error fetching Compound V3 rewards data for address ${address}:`, error);
361
- rewardsData[address.toLowerCase() as EthAddress].compV3[market.value] = { error: `Error fetching Compound V3 rewards data for address ${address}`, data: null };
362
- }
363
- })).flat(),
364
352
  ...addresses.map(async (address) => {
365
353
  try {
366
354
  const merklData = await getMerklUnclaimedRewards(address, network);
@@ -7,8 +7,6 @@ export enum ClaimType {
7
7
  AAVE_MERIT_REWARDS = 'AAVE_MERIT_REWARDS',
8
8
  /** Rewards distributed through Merkl across supported protocols */
9
9
  MERKL_REWARDS = 'MERKL_REWARDS',
10
- /** Rewards from Compound V3 (only in COMP) */
11
- COMPOUND_V3_COMP = 'COMPOUND_V3_COMP',
12
10
  /** Rewards from Spark (wstETH only for now) */
13
11
  SPARK_REWARDS = 'SPARK_REWARDS',
14
12
  /** Rewards from King (prev LTR^2 - received for weETH holding) */
@@ -75,13 +73,6 @@ export type KingRewardsClaimableToken = _ClaimableTokenPartial & {
75
73
  };
76
74
  };
77
75
 
78
- export type CompoundV3CompClaimableToken = _ClaimableTokenPartial & {
79
- claimType: ClaimType.COMPOUND_V3_COMP,
80
- additionalClaimFields: {
81
- marketAddress: EthAddress;
82
- }
83
- };
84
-
85
76
  export enum SparkAirdropType {
86
77
  SPARK_IGNITION = 'spark-ignition',
87
78
  PRE_FARMING_AND_SOCIAL = 'pre-farming-and-social',
@@ -115,7 +106,6 @@ export type ClaimableToken =
115
106
  AaveRewardsClaimableToken
116
107
  | AaveMeritRewardsClaimableToken
117
108
  | MerklRewardsClaimableToken
118
- | CompoundV3CompClaimableToken
119
109
  | SparkRewardsClaimableToken
120
110
  | KingRewardsClaimableToken
121
111
  | SparkAirdropClaimableToken
@@ -1,15 +0,0 @@
1
- import { Client } from 'viem';
2
- import { EthAddress, NetworkNumber } from '../types/common';
3
- import { ClaimType } from '../types/claiming';
4
- export declare const getCompoundV3Rewards: (provider: Client, network: NetworkNumber, user: EthAddress, market: any) => Promise<{
5
- symbol: string;
6
- underlyingSymbol: string;
7
- tokenAddress: `0x${string}`;
8
- amount: string;
9
- walletAddress: `0x${string}`;
10
- label: string;
11
- claimType: ClaimType;
12
- additionalClaimFields: {
13
- marketAddress: any;
14
- };
15
- }[]>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getCompoundV3Rewards = void 0;
13
- const viem_1 = require("viem");
14
- const tokens_1 = require("@defisaver/tokens");
15
- const contracts_1 = require("../contracts");
16
- const claiming_1 = require("../types/claiming");
17
- // `CometRewards.NotSupported(address)`. CometRewards reverts with it for any Comet that has no
18
- // `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
19
- // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
20
- const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
21
- const isMarketWithoutRewardsConfig = (err) => {
22
- var _a;
23
- if (!(err instanceof viem_1.BaseError))
24
- return false;
25
- const revert = err.walk((e) => e instanceof viem_1.ContractFunctionRevertedError);
26
- return revert instanceof viem_1.ContractFunctionRevertedError && !!((_a = revert.raw) === null || _a === void 0 ? void 0 : _a.startsWith(NOT_SUPPORTED_ERROR_SIG));
27
- };
28
- const getCompoundV3Rewards = (provider, network, user, market) => __awaiter(void 0, void 0, void 0, function* () {
29
- const compV3View = (0, contracts_1.CompV3ViewContractViem)(provider, network);
30
- const rewards = yield compV3View.read.getRewardsOwed([market, user]).catch((err) => {
31
- if (isMarketWithoutRewardsConfig(err))
32
- return null;
33
- throw err;
34
- });
35
- if (!rewards || rewards.owed.toString() === '0' || (0, tokens_1.getAssetInfoByAddress)(rewards.token, network).symbol !== 'COMP')
36
- return [];
37
- return [{
38
- symbol: 'COMP',
39
- underlyingSymbol: 'COMP',
40
- tokenAddress: rewards.token,
41
- amount: (0, tokens_1.assetAmountInEth)(rewards.owed.toString() || 0, 'COMP'),
42
- walletAddress: user,
43
- label: 'Compound V3',
44
- claimType: claiming_1.ClaimType.COMPOUND_V3_COMP,
45
- additionalClaimFields: {
46
- marketAddress: market,
47
- },
48
- }];
49
- });
50
- exports.getCompoundV3Rewards = getCompoundV3Rewards;
@@ -1,15 +0,0 @@
1
- import { Client } from 'viem';
2
- import { EthAddress, NetworkNumber } from '../types/common';
3
- import { ClaimType } from '../types/claiming';
4
- export declare const getCompoundV3Rewards: (provider: Client, network: NetworkNumber, user: EthAddress, market: any) => Promise<{
5
- symbol: string;
6
- underlyingSymbol: string;
7
- tokenAddress: `0x${string}`;
8
- amount: string;
9
- walletAddress: `0x${string}`;
10
- label: string;
11
- claimType: ClaimType;
12
- additionalClaimFields: {
13
- marketAddress: any;
14
- };
15
- }[]>;
@@ -1,46 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { BaseError, ContractFunctionRevertedError } from 'viem';
11
- import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
12
- import { CompV3ViewContractViem } from '../contracts';
13
- import { ClaimType } from '../types/claiming';
14
- // `CometRewards.NotSupported(address)`. CometRewards reverts with it for any Comet that has no
15
- // `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
16
- // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
17
- const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
18
- const isMarketWithoutRewardsConfig = (err) => {
19
- var _a;
20
- if (!(err instanceof BaseError))
21
- return false;
22
- const revert = err.walk((e) => e instanceof ContractFunctionRevertedError);
23
- return revert instanceof ContractFunctionRevertedError && !!((_a = revert.raw) === null || _a === void 0 ? void 0 : _a.startsWith(NOT_SUPPORTED_ERROR_SIG));
24
- };
25
- export const getCompoundV3Rewards = (provider, network, user, market) => __awaiter(void 0, void 0, void 0, function* () {
26
- const compV3View = CompV3ViewContractViem(provider, network);
27
- const rewards = yield compV3View.read.getRewardsOwed([market, user]).catch((err) => {
28
- if (isMarketWithoutRewardsConfig(err))
29
- return null;
30
- throw err;
31
- });
32
- if (!rewards || rewards.owed.toString() === '0' || getAssetInfoByAddress(rewards.token, network).symbol !== 'COMP')
33
- return [];
34
- return [{
35
- symbol: 'COMP',
36
- underlyingSymbol: 'COMP',
37
- tokenAddress: rewards.token,
38
- amount: assetAmountInEth(rewards.owed.toString() || 0, 'COMP'),
39
- walletAddress: user,
40
- label: 'Compound V3',
41
- claimType: ClaimType.COMPOUND_V3_COMP,
42
- additionalClaimFields: {
43
- marketAddress: market,
44
- },
45
- }];
46
- });
@@ -1,37 +0,0 @@
1
- import { BaseError, Client, ContractFunctionRevertedError } from 'viem';
2
- import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
3
- import { EthAddress, NetworkNumber } from '../types/common';
4
- import { CompV3ViewContractViem } from '../contracts';
5
- import { ClaimType } from '../types/claiming';
6
-
7
- // `CometRewards.NotSupported(address)`. CometRewards reverts with it for any Comet that has no
8
- // `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
9
- // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
10
- const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
11
-
12
- const isMarketWithoutRewardsConfig = (err: unknown) => {
13
- if (!(err instanceof BaseError)) return false;
14
- const revert = err.walk((e) => e instanceof ContractFunctionRevertedError);
15
- return revert instanceof ContractFunctionRevertedError && !!revert.raw?.startsWith(NOT_SUPPORTED_ERROR_SIG);
16
- };
17
-
18
- export const getCompoundV3Rewards = async (provider: Client, network: NetworkNumber, user: EthAddress, market: any) => {
19
- const compV3View = CompV3ViewContractViem(provider, network);
20
- const rewards = await compV3View.read.getRewardsOwed([market, user]).catch((err) => {
21
- if (isMarketWithoutRewardsConfig(err)) return null;
22
- throw err;
23
- });
24
- if (!rewards || rewards.owed.toString() === '0' || getAssetInfoByAddress(rewards.token, network).symbol !== 'COMP') return [];
25
- return [{
26
- symbol: 'COMP',
27
- underlyingSymbol: 'COMP',
28
- tokenAddress: rewards.token,
29
- amount: assetAmountInEth(rewards.owed.toString() || 0, 'COMP'),
30
- walletAddress: user,
31
- label: 'Compound V3',
32
- claimType: ClaimType.COMPOUND_V3_COMP,
33
- additionalClaimFields: {
34
- marketAddress: market,
35
- },
36
- }];
37
- };