@defisaver/positions-sdk 2.0.15-dev-7 → 2.0.15-dev-8

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,17 +1,7 @@
1
1
  import { NetworkNumber } from '../types/common';
2
- import { AaveVersions } from '../types';
3
- type RewardInfo = {
4
- apy: string;
5
- rewardTokenSymbol: string;
6
- description: string;
7
- };
8
- type MeritTokenRewardMap = {
9
- supply: Record<string, RewardInfo>;
10
- borrow: Record<string, RewardInfo>;
11
- };
2
+ import { AaveVersions, MeritTokenRewardMap } from '../types';
12
3
  /**
13
4
  * Fetches merit rewards data from Aave API
14
5
  */
15
6
  export declare const fetchMeritRewardsData: () => Promise<Record<string, number | null>>;
16
7
  export declare const getMeritCampaigns: (chainId: NetworkNumber, market: AaveVersions) => Promise<MeritTokenRewardMap>;
17
- export {};
@@ -1,14 +1,5 @@
1
- import { EthAddress, NetworkNumber } from '../types/common';
2
- type RewardInfo = {
3
- apy: string;
4
- rewardTokenSymbol: string;
5
- description: string;
6
- identifier: string;
7
- };
8
- type MerkleRewardMap = Record<EthAddress, {
9
- supply?: RewardInfo;
10
- borrow?: RewardInfo;
11
- }>;
1
+ import { MerkleRewardMap } from '../types';
2
+ import { NetworkNumber } from '../types/common';
12
3
  export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
13
4
  /**
14
5
  * aEthLidoUSDC -> aUSDC
@@ -16,4 +7,3 @@ export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
16
7
  */
17
8
  export declare const formatAaveAsset: (_symbol: string) => string;
18
9
  export declare const getMerkleCampaigns: (chainId: NetworkNumber) => Promise<MerkleRewardMap>;
19
- export {};
@@ -12,17 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getMerkleCampaigns = exports.formatAaveAsset = exports.getAaveUnderlyingSymbol = void 0;
13
13
  const moneymarket_1 = require("../moneymarket");
14
14
  const utils_1 = require("../services/utils");
15
- var OpportunityAction;
16
- (function (OpportunityAction) {
17
- OpportunityAction["LEND"] = "LEND";
18
- OpportunityAction["BORROW"] = "BORROW";
19
- })(OpportunityAction || (OpportunityAction = {}));
20
- var OpportunityStatus;
21
- (function (OpportunityStatus) {
22
- OpportunityStatus["LIVE"] = "LIVE";
23
- OpportunityStatus["PAST"] = "PAST";
24
- OpportunityStatus["UPCOMING"] = "UPCOMING";
25
- })(OpportunityStatus || (OpportunityStatus = {}));
15
+ const types_1 = require("../types");
26
16
  const getAaveUnderlyingSymbol = (_symbol = '') => {
27
17
  let symbol = _symbol
28
18
  .replace(/^aEthLido/, '')
@@ -58,12 +48,12 @@ const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, functi
58
48
  const opportunities = yield res.json();
59
49
  const relevantOpportunities = opportunities
60
50
  .filter((o) => o.chainId === chainId)
61
- .filter((o) => o.status === OpportunityStatus.LIVE);
51
+ .filter((o) => o.status === types_1.OpportunityStatus.LIVE);
62
52
  return relevantOpportunities.reduce((acc, opportunity) => {
63
53
  var _a, _b;
64
54
  const rewardToken = opportunity.rewardsRecord.breakdowns[0].token;
65
55
  const description = `Eligible for ${(0, exports.formatAaveAsset)(rewardToken.symbol)} rewards through Merkl. ${opportunity.description ? `\n${opportunity.description}` : ''}`;
66
- if (opportunity.action === OpportunityAction.LEND && opportunity.explorerAddress) {
56
+ if (opportunity.action === types_1.OpportunityAction.LEND && opportunity.explorerAddress) {
67
57
  const supplyAToken = (_a = opportunity.explorerAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase();
68
58
  if (!acc[supplyAToken])
69
59
  acc[supplyAToken] = {};
@@ -75,7 +65,7 @@ const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, functi
75
65
  identifier: opportunity.identifier,
76
66
  };
77
67
  }
78
- if (opportunity.action === OpportunityAction.BORROW && opportunity.explorerAddress) {
68
+ if (opportunity.action === types_1.OpportunityAction.BORROW && opportunity.explorerAddress) {
79
69
  const borrowAToken = (_b = opportunity.explorerAddress) === null || _b === void 0 ? void 0 : _b.toLowerCase();
80
70
  if (!acc[borrowAToken])
81
71
  acc[borrowAToken] = {};
@@ -10,3 +10,5 @@ export * from './llamaLend';
10
10
  export * from './euler';
11
11
  export * from './fluid';
12
12
  export * from './portfolio';
13
+ export * from './merit';
14
+ export * from './merkl';
@@ -26,3 +26,5 @@ __exportStar(require("./llamaLend"), exports);
26
26
  __exportStar(require("./euler"), exports);
27
27
  __exportStar(require("./fluid"), exports);
28
28
  __exportStar(require("./portfolio"), exports);
29
+ __exportStar(require("./merit"), exports);
30
+ __exportStar(require("./merkl"), exports);
@@ -0,0 +1,9 @@
1
+ export type MeritRewardInfo = {
2
+ apy: string;
3
+ rewardTokenSymbol: string;
4
+ description: string;
5
+ };
6
+ export type MeritTokenRewardMap = {
7
+ supply: Record<string, MeritRewardInfo>;
8
+ borrow: Record<string, MeritRewardInfo>;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,75 @@
1
+ import { EthAddress } from './common';
2
+ export declare enum OpportunityAction {
3
+ LEND = "LEND",
4
+ BORROW = "BORROW"
5
+ }
6
+ export declare enum OpportunityStatus {
7
+ LIVE = "LIVE",
8
+ PAST = "PAST",
9
+ UPCOMING = "UPCOMING"
10
+ }
11
+ export type MerklOpportunity = {
12
+ chainId: number;
13
+ type: string;
14
+ identifier: EthAddress;
15
+ name: string;
16
+ status: OpportunityStatus;
17
+ action: OpportunityAction;
18
+ tvl: number;
19
+ apr: number;
20
+ dailyRewards: number;
21
+ tags: [];
22
+ id: string;
23
+ explorerAddress?: EthAddress;
24
+ description?: string;
25
+ tokens: {
26
+ id: string;
27
+ name: string;
28
+ chainId: number;
29
+ address: EthAddress;
30
+ decimals: number;
31
+ icon: string;
32
+ verified: boolean;
33
+ isTest: boolean;
34
+ price: number;
35
+ symbol: string;
36
+ }[];
37
+ rewardsRecord: {
38
+ id: string;
39
+ total: number;
40
+ timestamp: string;
41
+ breakdowns: {
42
+ token: {
43
+ id: string;
44
+ name: string;
45
+ chainId: number;
46
+ address: EthAddress;
47
+ decimals: number;
48
+ symbol: string;
49
+ displaySymbol: string;
50
+ icon: string;
51
+ verified: boolean;
52
+ isTest: boolean;
53
+ type: string;
54
+ isNative: boolean;
55
+ price: number;
56
+ };
57
+ amount: string;
58
+ value: number;
59
+ distributionType: string;
60
+ id: string;
61
+ campaignId: string;
62
+ dailyRewardsRecordId: string;
63
+ }[];
64
+ };
65
+ };
66
+ export type MerkleRewardInfo = {
67
+ apy: string;
68
+ rewardTokenSymbol: string;
69
+ description: string;
70
+ identifier: string;
71
+ };
72
+ export type MerkleRewardMap = Record<EthAddress, {
73
+ supply?: MerkleRewardInfo;
74
+ borrow?: MerkleRewardInfo;
75
+ }>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpportunityStatus = exports.OpportunityAction = void 0;
4
+ var OpportunityAction;
5
+ (function (OpportunityAction) {
6
+ OpportunityAction["LEND"] = "LEND";
7
+ OpportunityAction["BORROW"] = "BORROW";
8
+ })(OpportunityAction || (exports.OpportunityAction = OpportunityAction = {}));
9
+ var OpportunityStatus;
10
+ (function (OpportunityStatus) {
11
+ OpportunityStatus["LIVE"] = "LIVE";
12
+ OpportunityStatus["PAST"] = "PAST";
13
+ OpportunityStatus["UPCOMING"] = "UPCOMING";
14
+ })(OpportunityStatus || (exports.OpportunityStatus = OpportunityStatus = {}));
@@ -1,17 +1,7 @@
1
1
  import { NetworkNumber } from '../types/common';
2
- import { AaveVersions } from '../types';
3
- type RewardInfo = {
4
- apy: string;
5
- rewardTokenSymbol: string;
6
- description: string;
7
- };
8
- type MeritTokenRewardMap = {
9
- supply: Record<string, RewardInfo>;
10
- borrow: Record<string, RewardInfo>;
11
- };
2
+ import { AaveVersions, MeritTokenRewardMap } from '../types';
12
3
  /**
13
4
  * Fetches merit rewards data from Aave API
14
5
  */
15
6
  export declare const fetchMeritRewardsData: () => Promise<Record<string, number | null>>;
16
7
  export declare const getMeritCampaigns: (chainId: NetworkNumber, market: AaveVersions) => Promise<MeritTokenRewardMap>;
17
- export {};
@@ -1,14 +1,5 @@
1
- import { EthAddress, NetworkNumber } from '../types/common';
2
- type RewardInfo = {
3
- apy: string;
4
- rewardTokenSymbol: string;
5
- description: string;
6
- identifier: string;
7
- };
8
- type MerkleRewardMap = Record<EthAddress, {
9
- supply?: RewardInfo;
10
- borrow?: RewardInfo;
11
- }>;
1
+ import { MerkleRewardMap } from '../types';
2
+ import { NetworkNumber } from '../types/common';
12
3
  export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
13
4
  /**
14
5
  * aEthLidoUSDC -> aUSDC
@@ -16,4 +7,3 @@ export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
16
7
  */
17
8
  export declare const formatAaveAsset: (_symbol: string) => string;
18
9
  export declare const getMerkleCampaigns: (chainId: NetworkNumber) => Promise<MerkleRewardMap>;
19
- export {};
@@ -9,17 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { aprToApy } from '../moneymarket';
11
11
  import { DEFAULT_TIMEOUT, wethToEth } from '../services/utils';
12
- var OpportunityAction;
13
- (function (OpportunityAction) {
14
- OpportunityAction["LEND"] = "LEND";
15
- OpportunityAction["BORROW"] = "BORROW";
16
- })(OpportunityAction || (OpportunityAction = {}));
17
- var OpportunityStatus;
18
- (function (OpportunityStatus) {
19
- OpportunityStatus["LIVE"] = "LIVE";
20
- OpportunityStatus["PAST"] = "PAST";
21
- OpportunityStatus["UPCOMING"] = "UPCOMING";
22
- })(OpportunityStatus || (OpportunityStatus = {}));
12
+ import { OpportunityAction, OpportunityStatus, } from '../types';
23
13
  export const getAaveUnderlyingSymbol = (_symbol = '') => {
24
14
  let symbol = _symbol
25
15
  .replace(/^aEthLido/, '')
@@ -10,3 +10,5 @@ export * from './llamaLend';
10
10
  export * from './euler';
11
11
  export * from './fluid';
12
12
  export * from './portfolio';
13
+ export * from './merit';
14
+ export * from './merkl';
@@ -10,3 +10,5 @@ export * from './llamaLend';
10
10
  export * from './euler';
11
11
  export * from './fluid';
12
12
  export * from './portfolio';
13
+ export * from './merit';
14
+ export * from './merkl';
@@ -0,0 +1,9 @@
1
+ export type MeritRewardInfo = {
2
+ apy: string;
3
+ rewardTokenSymbol: string;
4
+ description: string;
5
+ };
6
+ export type MeritTokenRewardMap = {
7
+ supply: Record<string, MeritRewardInfo>;
8
+ borrow: Record<string, MeritRewardInfo>;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ import { EthAddress } from './common';
2
+ export declare enum OpportunityAction {
3
+ LEND = "LEND",
4
+ BORROW = "BORROW"
5
+ }
6
+ export declare enum OpportunityStatus {
7
+ LIVE = "LIVE",
8
+ PAST = "PAST",
9
+ UPCOMING = "UPCOMING"
10
+ }
11
+ export type MerklOpportunity = {
12
+ chainId: number;
13
+ type: string;
14
+ identifier: EthAddress;
15
+ name: string;
16
+ status: OpportunityStatus;
17
+ action: OpportunityAction;
18
+ tvl: number;
19
+ apr: number;
20
+ dailyRewards: number;
21
+ tags: [];
22
+ id: string;
23
+ explorerAddress?: EthAddress;
24
+ description?: string;
25
+ tokens: {
26
+ id: string;
27
+ name: string;
28
+ chainId: number;
29
+ address: EthAddress;
30
+ decimals: number;
31
+ icon: string;
32
+ verified: boolean;
33
+ isTest: boolean;
34
+ price: number;
35
+ symbol: string;
36
+ }[];
37
+ rewardsRecord: {
38
+ id: string;
39
+ total: number;
40
+ timestamp: string;
41
+ breakdowns: {
42
+ token: {
43
+ id: string;
44
+ name: string;
45
+ chainId: number;
46
+ address: EthAddress;
47
+ decimals: number;
48
+ symbol: string;
49
+ displaySymbol: string;
50
+ icon: string;
51
+ verified: boolean;
52
+ isTest: boolean;
53
+ type: string;
54
+ isNative: boolean;
55
+ price: number;
56
+ };
57
+ amount: string;
58
+ value: number;
59
+ distributionType: string;
60
+ id: string;
61
+ campaignId: string;
62
+ dailyRewardsRecordId: string;
63
+ }[];
64
+ };
65
+ };
66
+ export type MerkleRewardInfo = {
67
+ apy: string;
68
+ rewardTokenSymbol: string;
69
+ description: string;
70
+ identifier: string;
71
+ };
72
+ export type MerkleRewardMap = Record<EthAddress, {
73
+ supply?: MerkleRewardInfo;
74
+ borrow?: MerkleRewardInfo;
75
+ }>;
@@ -0,0 +1,11 @@
1
+ export var OpportunityAction;
2
+ (function (OpportunityAction) {
3
+ OpportunityAction["LEND"] = "LEND";
4
+ OpportunityAction["BORROW"] = "BORROW";
5
+ })(OpportunityAction || (OpportunityAction = {}));
6
+ export var OpportunityStatus;
7
+ (function (OpportunityStatus) {
8
+ OpportunityStatus["LIVE"] = "LIVE";
9
+ OpportunityStatus["PAST"] = "PAST";
10
+ OpportunityStatus["UPCOMING"] = "UPCOMING";
11
+ })(OpportunityStatus || (OpportunityStatus = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.0.15-dev-7",
3
+ "version": "2.0.15-dev-8",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -2,11 +2,7 @@
2
2
  import { DEFAULT_TIMEOUT } from '../services/utils';
3
3
  import { NetworkNumber } from '../types/common';
4
4
  import { aprToApy } from '../moneymarket';
5
- import { AaveVersions } from '../types';
6
-
7
-
8
- type RewardInfo = { apy: string; rewardTokenSymbol: string, description: string };
9
- type MeritTokenRewardMap = { supply: Record<string, RewardInfo>; borrow: Record<string, RewardInfo> };
5
+ import { AaveVersions, MeritTokenRewardMap } from '../types';
10
6
 
11
7
  /**
12
8
  * Maps API keys to reward data & actions - hardcoded and needs to be maintained actively.
@@ -1,77 +1,10 @@
1
1
  import { aprToApy } from '../moneymarket';
2
2
  import { DEFAULT_TIMEOUT, wethToEth } from '../services/utils';
3
+ import {
4
+ MerkleRewardMap, MerklOpportunity, OpportunityAction, OpportunityStatus,
5
+ } from '../types';
3
6
  import { EthAddress, NetworkNumber } from '../types/common';
4
7
 
5
- enum OpportunityAction {
6
- LEND = 'LEND',
7
- BORROW = 'BORROW',
8
- }
9
-
10
- enum OpportunityStatus {
11
- LIVE = 'LIVE',
12
- PAST = 'PAST',
13
- UPCOMING = 'UPCOMING',
14
- }
15
-
16
- type MerklOpportunity = {
17
- chainId: number;
18
- type: string;
19
- identifier: EthAddress;
20
- name: string;
21
- status: OpportunityStatus;
22
- action: OpportunityAction;
23
- tvl: number;
24
- apr: number;
25
- dailyRewards: number;
26
- tags: [];
27
- id: string;
28
- explorerAddress?: EthAddress;
29
- description?: string;
30
- tokens: {
31
- id: string;
32
- name: string;
33
- chainId: number;
34
- address: EthAddress;
35
- decimals: number;
36
- icon: string;
37
- verified: boolean;
38
- isTest: boolean;
39
- price: number;
40
- symbol: string;
41
- }[];
42
- rewardsRecord: {
43
- id: string;
44
- total: number;
45
- timestamp: string;
46
- breakdowns: {
47
- token: {
48
- id: string;
49
- name: string;
50
- chainId: number;
51
- address: EthAddress;
52
- decimals: number;
53
- symbol: string;
54
- displaySymbol: string;
55
- icon: string;
56
- verified: boolean;
57
- isTest: boolean;
58
- type: string;
59
- isNative: boolean;
60
- price: number;
61
- };
62
- amount: string;
63
- value: number;
64
- distributionType: string;
65
- id: string;
66
- campaignId: string;
67
- dailyRewardsRecordId: string;
68
- }[];
69
- };
70
- };
71
-
72
- type RewardInfo = { apy: string; rewardTokenSymbol: string, description: string, identifier: string };
73
- type MerkleRewardMap = Record<EthAddress, { supply?: RewardInfo; borrow?: RewardInfo }>;
74
-
75
8
  export const getAaveUnderlyingSymbol = (_symbol = '') => {
76
9
  let symbol = _symbol
77
10
  .replace(/^aEthLido/, '')
@@ -9,4 +9,6 @@ export * from './morphoBlue';
9
9
  export * from './llamaLend';
10
10
  export * from './euler';
11
11
  export * from './fluid';
12
- export * from './portfolio';
12
+ export * from './portfolio';
13
+ export * from './merit';
14
+ export * from './merkl';
@@ -0,0 +1,2 @@
1
+ export type MeritRewardInfo = { apy: string; rewardTokenSymbol: string, description: string };
2
+ export type MeritTokenRewardMap = { supply: Record<string, MeritRewardInfo>; borrow: Record<string, MeritRewardInfo> };
@@ -0,0 +1,71 @@
1
+ import { EthAddress } from './common';
2
+
3
+ export enum OpportunityAction {
4
+ LEND = 'LEND',
5
+ BORROW = 'BORROW',
6
+ }
7
+
8
+ export enum OpportunityStatus {
9
+ LIVE = 'LIVE',
10
+ PAST = 'PAST',
11
+ UPCOMING = 'UPCOMING',
12
+ }
13
+
14
+ export type MerklOpportunity = {
15
+ chainId: number;
16
+ type: string;
17
+ identifier: EthAddress;
18
+ name: string;
19
+ status: OpportunityStatus;
20
+ action: OpportunityAction;
21
+ tvl: number;
22
+ apr: number;
23
+ dailyRewards: number;
24
+ tags: [];
25
+ id: string;
26
+ explorerAddress?: EthAddress;
27
+ description?: string;
28
+ tokens: {
29
+ id: string;
30
+ name: string;
31
+ chainId: number;
32
+ address: EthAddress;
33
+ decimals: number;
34
+ icon: string;
35
+ verified: boolean;
36
+ isTest: boolean;
37
+ price: number;
38
+ symbol: string;
39
+ }[];
40
+ rewardsRecord: {
41
+ id: string;
42
+ total: number;
43
+ timestamp: string;
44
+ breakdowns: {
45
+ token: {
46
+ id: string;
47
+ name: string;
48
+ chainId: number;
49
+ address: EthAddress;
50
+ decimals: number;
51
+ symbol: string;
52
+ displaySymbol: string;
53
+ icon: string;
54
+ verified: boolean;
55
+ isTest: boolean;
56
+ type: string;
57
+ isNative: boolean;
58
+ price: number;
59
+ };
60
+ amount: string;
61
+ value: number;
62
+ distributionType: string;
63
+ id: string;
64
+ campaignId: string;
65
+ dailyRewardsRecordId: string;
66
+ }[];
67
+ };
68
+ };
69
+
70
+ export type MerkleRewardInfo = { apy: string; rewardTokenSymbol: string, description: string, identifier: string };
71
+ export type MerkleRewardMap = Record<EthAddress, { supply?: MerkleRewardInfo; borrow?: MerkleRewardInfo }>;