@defisaver/positions-sdk 2.1.22 → 2.1.23-dev-sena
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.
- package/cjs/claiming/ethena.d.ts +3 -0
- package/cjs/claiming/ethena.js +73 -0
- package/cjs/portfolio/index.js +26 -0
- package/cjs/types/claiming.d.ts +6 -2
- package/cjs/types/claiming.js +1 -0
- package/esm/claiming/ethena.d.ts +3 -0
- package/esm/claiming/ethena.js +65 -0
- package/esm/portfolio/index.js +26 -0
- package/esm/types/claiming.d.ts +6 -2
- package/esm/types/claiming.js +1 -0
- package/package.json +2 -2
- package/src/claiming/ethena.ts +67 -0
- package/src/portfolio/index.ts +26 -0
- package/src/types/claiming.ts +6 -1
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.fetchEthenaAirdropRewards = exports.fetchEthenaAirdropReward = void 0;
|
|
16
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
17
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
18
|
+
const viem_1 = require("viem");
|
|
19
|
+
const claiming_1 = require("../types/claiming");
|
|
20
|
+
const utils_1 = require("../services/utils");
|
|
21
|
+
const fetchEthenaAirdropReward = (address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
try {
|
|
23
|
+
const checksumAddress = (0, viem_1.getAddress)(address);
|
|
24
|
+
const response = yield fetch(`https://airdrop-data-ethena-s4.s3.us-west-2.amazonaws.com/${checksumAddress}/0x3d99219fbd49ace3f48d6ca1340e505ec1bdf27d1f8d0e15ec9f286cc9215fcd-${checksumAddress}.json`);
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
if (response.status === 403) {
|
|
27
|
+
// This is also okay, means that there are no rewards for the address
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
31
|
+
}
|
|
32
|
+
return yield response.json();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Error fetching Ethena airdrop rewards:', error);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
exports.fetchEthenaAirdropReward = fetchEthenaAirdropReward;
|
|
39
|
+
const fetchEthenaAirdropRewards = (walletAddresses) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const apiDataPromises = walletAddresses.map(address => (0, exports.fetchEthenaAirdropReward)(address));
|
|
41
|
+
const apiDataArray = yield Promise.all(apiDataPromises);
|
|
42
|
+
console.log(apiDataArray);
|
|
43
|
+
const results = {};
|
|
44
|
+
for (let i = 0; i < walletAddresses.length; i++) {
|
|
45
|
+
const walletAddress = walletAddresses[i];
|
|
46
|
+
const data = apiDataArray[i];
|
|
47
|
+
if (!data || data.claimed) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (data.length === 0) {
|
|
51
|
+
results[walletAddress.toLowerCase()] = [];
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const processedRewards = [];
|
|
55
|
+
const assetInfo = (0, tokens_1.getAssetInfo)('sENA');
|
|
56
|
+
console.log(assetInfo);
|
|
57
|
+
const amount = (0, utils_1.getEthAmountForDecimals)(data.events[0].awardAmount, assetInfo.decimals);
|
|
58
|
+
if (new decimal_js_1.default(amount).gt('0')) {
|
|
59
|
+
processedRewards.push({
|
|
60
|
+
symbol: assetInfo.symbol,
|
|
61
|
+
underlyingSymbol: assetInfo.symbol,
|
|
62
|
+
amount,
|
|
63
|
+
claimType: claiming_1.ClaimType.ETHENA_AIRDROP,
|
|
64
|
+
tokenAddress: assetInfo.address,
|
|
65
|
+
walletAddress,
|
|
66
|
+
label: 'Ethena Airdrop',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
results[walletAddress.toLowerCase()] = processedRewards;
|
|
70
|
+
}
|
|
71
|
+
return results;
|
|
72
|
+
});
|
|
73
|
+
exports.fetchEthenaAirdropRewards = fetchEthenaAirdropRewards;
|
package/cjs/portfolio/index.js
CHANGED
|
@@ -39,6 +39,7 @@ const compV3_1 = require("../claiming/compV3");
|
|
|
39
39
|
const spark_2 = require("../claiming/spark");
|
|
40
40
|
const morphoBlue_2 = require("../claiming/morphoBlue");
|
|
41
41
|
const king_1 = require("../claiming/king");
|
|
42
|
+
const ethena_1 = require("../claiming/ethena");
|
|
42
43
|
function getPortfolioData(provider, network, defaultProvider, addresses, summerFiAddresses) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
45
|
const isMainnet = network === common_1.NetworkNumber.Eth;
|
|
@@ -139,6 +140,7 @@ function getPortfolioData(provider, network, defaultProvider, addresses, summerF
|
|
|
139
140
|
spk: {},
|
|
140
141
|
king: {},
|
|
141
142
|
morpho: {},
|
|
143
|
+
ethena: {},
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
yield Promise.allSettled([
|
|
@@ -395,6 +397,30 @@ function getPortfolioData(provider, network, defaultProvider, addresses, summerF
|
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
399
|
}))(),
|
|
400
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
try {
|
|
402
|
+
if (!isMainnet) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const ethenaAirdropRewards = yield (0, ethena_1.fetchEthenaAirdropRewards)(addresses);
|
|
406
|
+
for (const address of addresses) {
|
|
407
|
+
const lowerAddress = address.toLowerCase();
|
|
408
|
+
rewardsData[lowerAddress].ethena = {
|
|
409
|
+
error: '',
|
|
410
|
+
data: ethenaAirdropRewards[lowerAddress] || [],
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
console.error('Error fetching Ethena Airdrop rewards data:', error);
|
|
416
|
+
for (const address of addresses) {
|
|
417
|
+
rewardsData[address.toLowerCase()].ethena = {
|
|
418
|
+
error: 'Error fetching Ethena Airdrop rewards data in batch',
|
|
419
|
+
data: null,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}))(),
|
|
398
424
|
]);
|
|
399
425
|
yield Promise.all([
|
|
400
426
|
...aaveV3Markets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
package/cjs/types/claiming.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export declare enum ClaimType {
|
|
|
15
15
|
/** Spark Airdrop */
|
|
16
16
|
SPARK_AIRDROP = "SPARK_AIRDROP",
|
|
17
17
|
/** Spark Airdrop */
|
|
18
|
-
SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS"
|
|
18
|
+
SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS",// TODO: This will be removed once we fully refactor spark rewards
|
|
19
|
+
ETHENA_AIRDROP = "ETHENA_AIRDROP"
|
|
19
20
|
}
|
|
20
21
|
type _ClaimableTokenPartial = {
|
|
21
22
|
symbol: string;
|
|
@@ -89,5 +90,8 @@ export type SparkAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
89
90
|
export type SparkWstEthRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
90
91
|
claimType: ClaimType.SPARK_WST_ETH_REWARDS;
|
|
91
92
|
};
|
|
92
|
-
export type
|
|
93
|
+
export type EthenaAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
94
|
+
claimType: ClaimType.ETHENA_AIRDROP;
|
|
95
|
+
};
|
|
96
|
+
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | CompoundV3CompClaimableToken | MorphoClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
|
|
93
97
|
export {};
|
package/cjs/types/claiming.js
CHANGED
|
@@ -19,6 +19,7 @@ var ClaimType;
|
|
|
19
19
|
ClaimType["SPARK_AIRDROP"] = "SPARK_AIRDROP";
|
|
20
20
|
/** Spark Airdrop */
|
|
21
21
|
ClaimType["SPARK_WST_ETH_REWARDS"] = "SPARK_WST_ETH_REWARDS";
|
|
22
|
+
ClaimType["ETHENA_AIRDROP"] = "ETHENA_AIRDROP";
|
|
22
23
|
})(ClaimType || (exports.ClaimType = ClaimType = {}));
|
|
23
24
|
var SparkAirdropType;
|
|
24
25
|
(function (SparkAirdropType) {
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { getAssetInfo } from '@defisaver/tokens';
|
|
11
|
+
import Dec from 'decimal.js';
|
|
12
|
+
import { getAddress } from 'viem';
|
|
13
|
+
import { ClaimType } from '../types/claiming';
|
|
14
|
+
import { getEthAmountForDecimals } from '../services/utils';
|
|
15
|
+
export const fetchEthenaAirdropReward = (address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const checksumAddress = getAddress(address);
|
|
18
|
+
const response = yield fetch(`https://airdrop-data-ethena-s4.s3.us-west-2.amazonaws.com/${checksumAddress}/0x3d99219fbd49ace3f48d6ca1340e505ec1bdf27d1f8d0e15ec9f286cc9215fcd-${checksumAddress}.json`);
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
if (response.status === 403) {
|
|
21
|
+
// This is also okay, means that there are no rewards for the address
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
return yield response.json();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Error fetching Ethena airdrop rewards:', error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export const fetchEthenaAirdropRewards = (walletAddresses) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const apiDataPromises = walletAddresses.map(address => fetchEthenaAirdropReward(address));
|
|
34
|
+
const apiDataArray = yield Promise.all(apiDataPromises);
|
|
35
|
+
console.log(apiDataArray);
|
|
36
|
+
const results = {};
|
|
37
|
+
for (let i = 0; i < walletAddresses.length; i++) {
|
|
38
|
+
const walletAddress = walletAddresses[i];
|
|
39
|
+
const data = apiDataArray[i];
|
|
40
|
+
if (!data || data.claimed) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (data.length === 0) {
|
|
44
|
+
results[walletAddress.toLowerCase()] = [];
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const processedRewards = [];
|
|
48
|
+
const assetInfo = getAssetInfo('sENA');
|
|
49
|
+
console.log(assetInfo);
|
|
50
|
+
const amount = getEthAmountForDecimals(data.events[0].awardAmount, assetInfo.decimals);
|
|
51
|
+
if (new Dec(amount).gt('0')) {
|
|
52
|
+
processedRewards.push({
|
|
53
|
+
symbol: assetInfo.symbol,
|
|
54
|
+
underlyingSymbol: assetInfo.symbol,
|
|
55
|
+
amount,
|
|
56
|
+
claimType: ClaimType.ETHENA_AIRDROP,
|
|
57
|
+
tokenAddress: assetInfo.address,
|
|
58
|
+
walletAddress,
|
|
59
|
+
label: 'Ethena Airdrop',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
results[walletAddress.toLowerCase()] = processedRewards;
|
|
63
|
+
}
|
|
64
|
+
return results;
|
|
65
|
+
});
|
package/esm/portfolio/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { getCompoundV3Rewards } from '../claiming/compV3';
|
|
|
33
33
|
import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
34
34
|
import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
|
|
35
35
|
import { getKingRewards } from '../claiming/king';
|
|
36
|
+
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
36
37
|
export function getPortfolioData(provider, network, defaultProvider, addresses, summerFiAddresses) {
|
|
37
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
39
|
const isMainnet = network === NetworkNumber.Eth;
|
|
@@ -133,6 +134,7 @@ export function getPortfolioData(provider, network, defaultProvider, addresses,
|
|
|
133
134
|
spk: {},
|
|
134
135
|
king: {},
|
|
135
136
|
morpho: {},
|
|
137
|
+
ethena: {},
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
140
|
yield Promise.allSettled([
|
|
@@ -389,6 +391,30 @@ export function getPortfolioData(provider, network, defaultProvider, addresses,
|
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
393
|
}))(),
|
|
394
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
try {
|
|
396
|
+
if (!isMainnet) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const ethenaAirdropRewards = yield fetchEthenaAirdropRewards(addresses);
|
|
400
|
+
for (const address of addresses) {
|
|
401
|
+
const lowerAddress = address.toLowerCase();
|
|
402
|
+
rewardsData[lowerAddress].ethena = {
|
|
403
|
+
error: '',
|
|
404
|
+
data: ethenaAirdropRewards[lowerAddress] || [],
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
console.error('Error fetching Ethena Airdrop rewards data:', error);
|
|
410
|
+
for (const address of addresses) {
|
|
411
|
+
rewardsData[address.toLowerCase()].ethena = {
|
|
412
|
+
error: 'Error fetching Ethena Airdrop rewards data in batch',
|
|
413
|
+
data: null,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}))(),
|
|
392
418
|
]);
|
|
393
419
|
yield Promise.all([
|
|
394
420
|
...aaveV3Markets.map((market) => allAddresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
package/esm/types/claiming.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export declare enum ClaimType {
|
|
|
15
15
|
/** Spark Airdrop */
|
|
16
16
|
SPARK_AIRDROP = "SPARK_AIRDROP",
|
|
17
17
|
/** Spark Airdrop */
|
|
18
|
-
SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS"
|
|
18
|
+
SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS",// TODO: This will be removed once we fully refactor spark rewards
|
|
19
|
+
ETHENA_AIRDROP = "ETHENA_AIRDROP"
|
|
19
20
|
}
|
|
20
21
|
type _ClaimableTokenPartial = {
|
|
21
22
|
symbol: string;
|
|
@@ -89,5 +90,8 @@ export type SparkAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
89
90
|
export type SparkWstEthRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
90
91
|
claimType: ClaimType.SPARK_WST_ETH_REWARDS;
|
|
91
92
|
};
|
|
92
|
-
export type
|
|
93
|
+
export type EthenaAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
94
|
+
claimType: ClaimType.ETHENA_AIRDROP;
|
|
95
|
+
};
|
|
96
|
+
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | CompoundV3CompClaimableToken | MorphoClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
|
|
93
97
|
export {};
|
package/esm/types/claiming.js
CHANGED
|
@@ -16,6 +16,7 @@ export var ClaimType;
|
|
|
16
16
|
ClaimType["SPARK_AIRDROP"] = "SPARK_AIRDROP";
|
|
17
17
|
/** Spark Airdrop */
|
|
18
18
|
ClaimType["SPARK_WST_ETH_REWARDS"] = "SPARK_WST_ETH_REWARDS";
|
|
19
|
+
ClaimType["ETHENA_AIRDROP"] = "ETHENA_AIRDROP";
|
|
19
20
|
})(ClaimType || (ClaimType = {}));
|
|
20
21
|
export var SparkAirdropType;
|
|
21
22
|
(function (SparkAirdropType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.23-dev-sena",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@defisaver/tokens": "
|
|
24
|
+
"@defisaver/tokens": "1.7.12-dev-sena",
|
|
25
25
|
"@types/lodash": "^4.17.15",
|
|
26
26
|
"@types/memoizee": "^0.4.12",
|
|
27
27
|
"decimal.js": "^10.6.0",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getAssetInfo } from '@defisaver/tokens';
|
|
2
|
+
import Dec from 'decimal.js';
|
|
3
|
+
import { getAddress } from 'viem';
|
|
4
|
+
import { EthAddress } from '../types/common';
|
|
5
|
+
import { ClaimType } from '../types/claiming';
|
|
6
|
+
import { getEthAmountForDecimals } from '../services/utils';
|
|
7
|
+
|
|
8
|
+
export const fetchEthenaAirdropReward = async (address: EthAddress) => {
|
|
9
|
+
try {
|
|
10
|
+
const checksumAddress = getAddress(address);
|
|
11
|
+
const response = await fetch(`https://airdrop-data-ethena-s4.s3.us-west-2.amazonaws.com/${checksumAddress}/0x3d99219fbd49ace3f48d6ca1340e505ec1bdf27d1f8d0e15ec9f286cc9215fcd-${checksumAddress}.json`);
|
|
12
|
+
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
if (response.status === 403) {
|
|
15
|
+
// This is also okay, means that there are no rewards for the address
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return await response.json();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error fetching Ethena airdrop rewards:', error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]): Promise<Record<string, any[]>> => {
|
|
28
|
+
const apiDataPromises = walletAddresses.map(address => fetchEthenaAirdropReward(address));
|
|
29
|
+
const apiDataArray = await Promise.all(apiDataPromises);
|
|
30
|
+
|
|
31
|
+
console.log(apiDataArray);
|
|
32
|
+
const results: Record<string, any[]> = {};
|
|
33
|
+
for (let i = 0; i < walletAddresses.length; i++) {
|
|
34
|
+
const walletAddress = walletAddresses[i];
|
|
35
|
+
const data = apiDataArray[i];
|
|
36
|
+
|
|
37
|
+
if (!data || data.claimed) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (data.length === 0) {
|
|
42
|
+
results[walletAddress.toLowerCase() as EthAddress] = [];
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const processedRewards = [];
|
|
47
|
+
const assetInfo = getAssetInfo('sENA');
|
|
48
|
+
console.log(assetInfo);
|
|
49
|
+
const amount = getEthAmountForDecimals(data.events[0].awardAmount, assetInfo.decimals);
|
|
50
|
+
|
|
51
|
+
if (new Dec(amount).gt('0')) {
|
|
52
|
+
processedRewards.push({
|
|
53
|
+
symbol: assetInfo.symbol,
|
|
54
|
+
underlyingSymbol: assetInfo.symbol,
|
|
55
|
+
amount,
|
|
56
|
+
claimType: ClaimType.ETHENA_AIRDROP,
|
|
57
|
+
tokenAddress: assetInfo.address,
|
|
58
|
+
walletAddress,
|
|
59
|
+
label: 'Ethena Airdrop',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
results[walletAddress.toLowerCase() as EthAddress] = processedRewards;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return results;
|
|
67
|
+
};
|
package/src/portfolio/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ import { getCompoundV3Rewards } from '../claiming/compV3';
|
|
|
48
48
|
import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
49
49
|
import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
|
|
50
50
|
import { getKingRewards } from '../claiming/king';
|
|
51
|
+
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
51
52
|
|
|
52
53
|
export async function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], summerFiAddresses: EthAddress[]): Promise<{
|
|
53
54
|
positions: PortfolioPositionsData;
|
|
@@ -161,6 +162,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
161
162
|
spk: {},
|
|
162
163
|
king: {},
|
|
163
164
|
morpho: {},
|
|
165
|
+
ethena: {},
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -402,6 +404,30 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
406
|
})(),
|
|
407
|
+
(async () => {
|
|
408
|
+
try {
|
|
409
|
+
if (!isMainnet) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const ethenaAirdropRewards = await fetchEthenaAirdropRewards(addresses);
|
|
414
|
+
for (const address of addresses) {
|
|
415
|
+
const lowerAddress = address.toLowerCase() as EthAddress;
|
|
416
|
+
rewardsData[lowerAddress].ethena = {
|
|
417
|
+
error: '',
|
|
418
|
+
data: ethenaAirdropRewards[lowerAddress] || [],
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
} catch (error) {
|
|
422
|
+
console.error('Error fetching Ethena Airdrop rewards data:', error);
|
|
423
|
+
for (const address of addresses) {
|
|
424
|
+
rewardsData[address.toLowerCase() as EthAddress].ethena = {
|
|
425
|
+
error: 'Error fetching Ethena Airdrop rewards data in batch',
|
|
426
|
+
data: null,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
})(),
|
|
405
431
|
]);
|
|
406
432
|
|
|
407
433
|
|
package/src/types/claiming.ts
CHANGED
|
@@ -17,6 +17,8 @@ export enum ClaimType {
|
|
|
17
17
|
SPARK_AIRDROP = 'SPARK_AIRDROP',
|
|
18
18
|
/** Spark Airdrop */
|
|
19
19
|
SPARK_WST_ETH_REWARDS = 'SPARK_WST_ETH_REWARDS', // TODO: This will be removed once we fully refactor spark rewards
|
|
20
|
+
|
|
21
|
+
ETHENA_AIRDROP = 'ETHENA_AIRDROP',
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
type _ClaimableTokenPartial = {
|
|
@@ -98,6 +100,8 @@ export type SparkAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
98
100
|
|
|
99
101
|
export type SparkWstEthRewardsClaimableToken = _ClaimableTokenPartial & { claimType: ClaimType.SPARK_WST_ETH_REWARDS };
|
|
100
102
|
|
|
103
|
+
export type EthenaAirdropClaimableToken = _ClaimableTokenPartial & { claimType: ClaimType.ETHENA_AIRDROP };
|
|
104
|
+
|
|
101
105
|
export type ClaimableToken =
|
|
102
106
|
AaveRewardsClaimableToken
|
|
103
107
|
| AaveMeritRewardsClaimableToken
|
|
@@ -106,4 +110,5 @@ export type ClaimableToken =
|
|
|
106
110
|
| SparkRewardsClaimableToken
|
|
107
111
|
| KingRewardsClaimableToken
|
|
108
112
|
| SparkAirdropClaimableToken
|
|
109
|
-
| SparkWstEthRewardsClaimableToken
|
|
113
|
+
| SparkWstEthRewardsClaimableToken
|
|
114
|
+
| EthenaAirdropClaimableToken;
|