@sonarwatch/portfolio-plugins 0.12.109 → 0.12.111
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/plugins/raydium/farmsFetcher.d.ts +3 -0
- package/src/plugins/raydium/farmsFetcher.js +113 -0
- package/src/plugins/raydium/farmsFetcher.js.map +1 -0
- package/src/plugins/raydium/farmsJob.d.ts +11 -0
- package/src/plugins/raydium/farmsJob.js +165 -0
- package/src/plugins/raydium/farmsJob.js.map +1 -0
- package/src/plugins/raydium/filters.d.ts +18 -0
- package/src/plugins/raydium/filters.js +74 -1
- package/src/plugins/raydium/filters.js.map +1 -1
- package/src/plugins/raydium/helpers.d.ts +3 -1
- package/src/plugins/raydium/helpers.js +25 -1
- package/src/plugins/raydium/helpers.js.map +1 -1
- package/src/plugins/raydium/index.js +4 -2
- package/src/plugins/raydium/index.js.map +1 -1
- package/src/plugins/raydium/structs/farms.d.ts +123 -0
- package/src/plugins/raydium/structs/farms.js +111 -0
- package/src/plugins/raydium/structs/farms.js.map +1 -0
- package/src/plugins/raydium/types.d.ts +34 -0
- package/src/plugins/raydium/types.js.map +1 -1
- package/src/plugins/save/constants.d.ts +5 -3
- package/src/plugins/save/constants.js +6 -4
- package/src/plugins/save/constants.js.map +1 -1
- package/src/plugins/save/index.js +2 -1
- package/src/plugins/save/index.js.map +1 -1
- package/src/plugins/save/rewardStatsJob.d.ts +3 -0
- package/src/plugins/save/rewardStatsJob.js +31 -0
- package/src/plugins/save/rewardStatsJob.js.map +1 -0
- package/src/plugins/save/rewardsFetcher.js +96 -54
- package/src/plugins/save/rewardsFetcher.js.map +1 -1
- package/src/plugins/save/structs.d.ts +12 -0
- package/src/plugins/save/structs.js +12 -1
- package/src/plugins/save/structs.js.map +1 -1
- package/src/plugins/save/types.d.ts +46 -0
- package/src/plugins/zeta/airdropFetcher.js +2 -2
- package/src/plugins/zeta/airdropFetcher.js.map +1 -1
- package/src/plugins/zeta/helpers.d.ts +2 -0
- package/src/plugins/zeta/helpers.js +13 -1
- package/src/plugins/zeta/helpers.js.map +1 -1
@@ -0,0 +1,123 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
3
|
+
import BigNumber from 'bignumber.js';
|
4
|
+
import { BeetStruct } from '@metaplex-foundation/beet';
|
5
|
+
export type FarmAccount = {
|
6
|
+
state: BigNumber;
|
7
|
+
nonce: BigNumber;
|
8
|
+
owner: PublicKey;
|
9
|
+
poolLpTokenAccount: PublicKey;
|
10
|
+
lastBlock: BigNumber;
|
11
|
+
poolRewardTokenAccount: PublicKey;
|
12
|
+
totalReward: BigNumber;
|
13
|
+
perBlock: BigNumber;
|
14
|
+
perShare: BigNumber;
|
15
|
+
poolRewardTokenAccountB?: PublicKey;
|
16
|
+
totalRewardB?: BigNumber;
|
17
|
+
perBlockB?: BigNumber;
|
18
|
+
perShareB?: BigNumber;
|
19
|
+
};
|
20
|
+
export type FarmAccountV3 = FarmAccount & {
|
21
|
+
feeOwner: PublicKey;
|
22
|
+
feeY: BigNumber;
|
23
|
+
feeX: BigNumber;
|
24
|
+
};
|
25
|
+
export declare const farmAccountV3Struct: BeetStruct<FarmAccountV3, Partial<FarmAccountV3>>;
|
26
|
+
export type FarmAccountV4 = FarmAccount & {
|
27
|
+
option: number;
|
28
|
+
unknown: Buffer;
|
29
|
+
poolRewardTokenAccountB: PublicKey;
|
30
|
+
totalRewardB: BigNumber;
|
31
|
+
perShareB: BigNumber;
|
32
|
+
perBlockB: BigNumber;
|
33
|
+
};
|
34
|
+
export declare const farmAccountV4Struct: BeetStruct<FarmAccountV4, Partial<FarmAccountV4>>;
|
35
|
+
export type FarmAccountV5 = FarmAccountV4;
|
36
|
+
export declare const farmAccountV5Struct: BeetStruct<FarmAccountV4, Partial<FarmAccountV4>>;
|
37
|
+
export type FarmAccountV6RewardInfo = {
|
38
|
+
rewardState: BigNumber;
|
39
|
+
rewardOpenTime: BigNumber;
|
40
|
+
rewardEndTime: BigNumber;
|
41
|
+
rewardLastUpdateTime: BigNumber;
|
42
|
+
totalReward: BigNumber;
|
43
|
+
totalRewardEmissioned: BigNumber;
|
44
|
+
rewardClaimed: BigNumber;
|
45
|
+
rewardPerSecond: BigNumber;
|
46
|
+
accRewardPerShare: BigNumber;
|
47
|
+
rewardVault: PublicKey;
|
48
|
+
rewardMint: PublicKey;
|
49
|
+
rewardSender: PublicKey;
|
50
|
+
padding: BigNumber[];
|
51
|
+
};
|
52
|
+
export declare const farmAccountV6RewardInfoStruct: BeetStruct<FarmAccountV6RewardInfo, Partial<FarmAccountV6RewardInfo>>;
|
53
|
+
export type FarmAccountV6 = {
|
54
|
+
padding_1: BigNumber;
|
55
|
+
state: BigNumber;
|
56
|
+
nonce: BigNumber;
|
57
|
+
validRewardTokenNum: BigNumber;
|
58
|
+
rewardMultiplier: BigNumber;
|
59
|
+
rewardPeriodMax: BigNumber;
|
60
|
+
rewardPeriodMin: BigNumber;
|
61
|
+
rewardPeriodExtend: BigNumber;
|
62
|
+
lpMint: PublicKey;
|
63
|
+
lpVault: PublicKey;
|
64
|
+
rewardInfos: FarmAccountV6RewardInfo[];
|
65
|
+
creator: PublicKey;
|
66
|
+
padding_2: PublicKey;
|
67
|
+
padding_3: BigNumber[];
|
68
|
+
};
|
69
|
+
export declare const farmAccountV6Struct: BeetStruct<FarmAccountV6, Partial<FarmAccountV6>>;
|
70
|
+
export type UserFarmAccount = {
|
71
|
+
state: BigNumber;
|
72
|
+
poolId: PublicKey;
|
73
|
+
stakerOwner: PublicKey;
|
74
|
+
depositBalance: BigNumber;
|
75
|
+
rewardDebt: BigNumber;
|
76
|
+
rewardDebtB?: BigNumber;
|
77
|
+
};
|
78
|
+
export type UserFarmAccountV3 = {
|
79
|
+
state: BigNumber;
|
80
|
+
poolId: PublicKey;
|
81
|
+
stakerOwner: PublicKey;
|
82
|
+
depositBalance: BigNumber;
|
83
|
+
rewardDebt: BigNumber;
|
84
|
+
};
|
85
|
+
export declare const userFarmAccountV3Struct: BeetStruct<UserFarmAccountV3, Partial<UserFarmAccountV3>>;
|
86
|
+
export type UserFarmAccountV4 = {
|
87
|
+
state: BigNumber;
|
88
|
+
poolId: PublicKey;
|
89
|
+
stakerOwner: PublicKey;
|
90
|
+
depositBalance: BigNumber;
|
91
|
+
rewardDebt: BigNumber;
|
92
|
+
rewardDebtB: BigNumber;
|
93
|
+
};
|
94
|
+
export declare const userFarmAccountV4Struct: BeetStruct<UserFarmAccountV4, Partial<UserFarmAccountV4>>;
|
95
|
+
export type UserFarmAccountV5 = {
|
96
|
+
state: BigNumber;
|
97
|
+
poolId: PublicKey;
|
98
|
+
stakerOwner: PublicKey;
|
99
|
+
depositBalance: BigNumber;
|
100
|
+
rewardDebt: BigNumber;
|
101
|
+
rewardDebtB: BigNumber;
|
102
|
+
padding: BigNumber[];
|
103
|
+
};
|
104
|
+
export declare const userFarmAccountV5Struct: BeetStruct<UserFarmAccountV5, Partial<UserFarmAccountV5>>;
|
105
|
+
export type UserFarmAccountV31 = {
|
106
|
+
state: BigNumber;
|
107
|
+
poolId: PublicKey;
|
108
|
+
stakerOwner: PublicKey;
|
109
|
+
depositBalance: BigNumber;
|
110
|
+
rewardDebt: BigNumber;
|
111
|
+
padding: BigNumber[];
|
112
|
+
};
|
113
|
+
export declare const userFarmAccountV31Struct: BeetStruct<UserFarmAccountV31, Partial<UserFarmAccountV31>>;
|
114
|
+
export type UserFarmAccountV61 = {
|
115
|
+
padding_1: BigNumber;
|
116
|
+
state: BigNumber;
|
117
|
+
id: PublicKey;
|
118
|
+
owner: PublicKey;
|
119
|
+
deposited: BigNumber;
|
120
|
+
rewardDebts: BigNumber[];
|
121
|
+
padding_2: BigNumber[];
|
122
|
+
};
|
123
|
+
export declare const userFarmAccountV61Struct: BeetStruct<UserFarmAccountV61, Partial<UserFarmAccountV61>>;
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.userFarmAccountV61Struct = exports.userFarmAccountV31Struct = exports.userFarmAccountV5Struct = exports.userFarmAccountV4Struct = exports.userFarmAccountV3Struct = exports.farmAccountV6Struct = exports.farmAccountV6RewardInfoStruct = exports.farmAccountV5Struct = exports.farmAccountV4Struct = exports.farmAccountV3Struct = void 0;
|
4
|
+
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
5
|
+
const beet_1 = require("@metaplex-foundation/beet");
|
6
|
+
const solana_1 = require("../../../utils/solana");
|
7
|
+
exports.farmAccountV3Struct = new beet_1.BeetStruct([
|
8
|
+
['state', solana_1.u64],
|
9
|
+
['nonce', solana_1.u64],
|
10
|
+
['poolLpTokenAccount', beet_solana_1.publicKey],
|
11
|
+
['poolRewardTokenAccount', beet_solana_1.publicKey],
|
12
|
+
['owner', beet_solana_1.publicKey],
|
13
|
+
['feeOwner', beet_solana_1.publicKey],
|
14
|
+
['feeY', solana_1.u64],
|
15
|
+
['feeX', solana_1.u64],
|
16
|
+
['totalReward', solana_1.u64],
|
17
|
+
['perShare', solana_1.u128],
|
18
|
+
['lastBlock', solana_1.u64],
|
19
|
+
['perBlock', solana_1.u64],
|
20
|
+
], (args) => args);
|
21
|
+
exports.farmAccountV4Struct = new beet_1.BeetStruct([
|
22
|
+
['state', solana_1.u64],
|
23
|
+
['nonce', solana_1.u64],
|
24
|
+
['poolLpTokenAccount', beet_solana_1.publicKey],
|
25
|
+
['poolRewardTokenAccount', beet_solana_1.publicKey],
|
26
|
+
['totalReward', solana_1.u64],
|
27
|
+
['perShare', solana_1.u128],
|
28
|
+
['perBlock', solana_1.u64],
|
29
|
+
['option', beet_1.u8],
|
30
|
+
['poolRewardTokenAccountB', beet_solana_1.publicKey],
|
31
|
+
['unknown', (0, solana_1.blob)(7)],
|
32
|
+
['totalRewardB', solana_1.u64],
|
33
|
+
['perShareB', solana_1.u128],
|
34
|
+
['perBlockB', solana_1.u64],
|
35
|
+
['lastBlock', solana_1.u64],
|
36
|
+
['owner', beet_solana_1.publicKey],
|
37
|
+
], (args) => args);
|
38
|
+
exports.farmAccountV5Struct = exports.farmAccountV4Struct;
|
39
|
+
exports.farmAccountV6RewardInfoStruct = new beet_1.BeetStruct([
|
40
|
+
['rewardState', solana_1.u64],
|
41
|
+
['rewardOpenTime', solana_1.u64],
|
42
|
+
['rewardEndTime', solana_1.u64],
|
43
|
+
['rewardLastUpdateTime', solana_1.u64],
|
44
|
+
['totalReward', solana_1.u64],
|
45
|
+
['totalRewardEmissioned', solana_1.u64],
|
46
|
+
['rewardClaimed', solana_1.u64],
|
47
|
+
['rewardPerSecond', solana_1.u64],
|
48
|
+
['accRewardPerShare', solana_1.u128],
|
49
|
+
['rewardVault', beet_solana_1.publicKey],
|
50
|
+
['rewardMint', beet_solana_1.publicKey],
|
51
|
+
['rewardSender', beet_solana_1.publicKey],
|
52
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 16)],
|
53
|
+
], (args) => args);
|
54
|
+
exports.farmAccountV6Struct = new beet_1.BeetStruct([
|
55
|
+
['padding_1', solana_1.u64],
|
56
|
+
['state', solana_1.u64],
|
57
|
+
['nonce', solana_1.u64],
|
58
|
+
['validRewardTokenNum', solana_1.u64],
|
59
|
+
['rewardMultiplier', solana_1.u128],
|
60
|
+
['rewardPeriodMax', solana_1.u64],
|
61
|
+
['rewardPeriodMin', solana_1.u64],
|
62
|
+
['rewardPeriodExtend', solana_1.u64],
|
63
|
+
['lpMint', beet_solana_1.publicKey],
|
64
|
+
['lpVault', beet_solana_1.publicKey],
|
65
|
+
['rewardInfos', (0, beet_1.uniformFixedSizeArray)(exports.farmAccountV6RewardInfoStruct, 5)],
|
66
|
+
['creator', beet_solana_1.publicKey],
|
67
|
+
['padding_2', beet_solana_1.publicKey],
|
68
|
+
['padding_3', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 32)],
|
69
|
+
], (args) => args);
|
70
|
+
exports.userFarmAccountV3Struct = new beet_1.BeetStruct([
|
71
|
+
['state', solana_1.u64],
|
72
|
+
['poolId', beet_solana_1.publicKey],
|
73
|
+
['stakerOwner', beet_solana_1.publicKey],
|
74
|
+
['depositBalance', solana_1.u64],
|
75
|
+
['rewardDebt', solana_1.u64],
|
76
|
+
], (args) => args);
|
77
|
+
exports.userFarmAccountV4Struct = new beet_1.BeetStruct([
|
78
|
+
['state', solana_1.u64],
|
79
|
+
['poolId', beet_solana_1.publicKey],
|
80
|
+
['stakerOwner', beet_solana_1.publicKey],
|
81
|
+
['depositBalance', solana_1.u64],
|
82
|
+
['rewardDebt', solana_1.u64],
|
83
|
+
['rewardDebtB', solana_1.u64],
|
84
|
+
], (args) => args);
|
85
|
+
exports.userFarmAccountV5Struct = new beet_1.BeetStruct([
|
86
|
+
['state', solana_1.u64],
|
87
|
+
['poolId', beet_solana_1.publicKey],
|
88
|
+
['stakerOwner', beet_solana_1.publicKey],
|
89
|
+
['depositBalance', solana_1.u64],
|
90
|
+
['rewardDebt', solana_1.u128],
|
91
|
+
['rewardDebtB', solana_1.u128],
|
92
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 17)],
|
93
|
+
], (args) => args);
|
94
|
+
exports.userFarmAccountV31Struct = new beet_1.BeetStruct([
|
95
|
+
['state', solana_1.u64],
|
96
|
+
['poolId', beet_solana_1.publicKey],
|
97
|
+
['stakerOwner', beet_solana_1.publicKey],
|
98
|
+
['depositBalance', solana_1.u64],
|
99
|
+
['rewardDebt', solana_1.u128],
|
100
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 17)],
|
101
|
+
], (args) => args);
|
102
|
+
exports.userFarmAccountV61Struct = new beet_1.BeetStruct([
|
103
|
+
['padding_1', solana_1.u64],
|
104
|
+
['state', solana_1.u64],
|
105
|
+
['id', beet_solana_1.publicKey],
|
106
|
+
['owner', beet_solana_1.publicKey],
|
107
|
+
['deposited', solana_1.u64],
|
108
|
+
['rewardDebts', (0, beet_1.uniformFixedSizeArray)(solana_1.u128, 5)],
|
109
|
+
['padding_2', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 16)],
|
110
|
+
], (args) => args);
|
111
|
+
//# sourceMappingURL=farms.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"farms.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/raydium/structs/farms.ts"],"names":[],"mappings":";;;AAEA,kEAA6D;AAC7D,oDAImC;AACnC,kDAAwD;AAwB3C,QAAA,mBAAmB,GAAG,IAAI,iBAAU,CAC/C;IACE,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,oBAAoB,EAAE,uBAAS,CAAC;IACjC,CAAC,wBAAwB,EAAE,uBAAS,CAAC;IACrC,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,MAAM,EAAE,YAAG,CAAC;IACb,CAAC,MAAM,EAAE,YAAG,CAAC;IACb,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,UAAU,EAAE,aAAI,CAAC;IAClB,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,UAAU,EAAE,YAAG,CAAC;CAClB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAqB,CAChC,CAAC;AAWW,QAAA,mBAAmB,GAAG,IAAI,iBAAU,CAC/C;IACE,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,oBAAoB,EAAE,uBAAS,CAAC;IACjC,CAAC,wBAAwB,EAAE,uBAAS,CAAC;IACrC,CAAC,aAAa,EAAE,YAAG,CAAC;IACpB,CAAC,UAAU,EAAE,aAAI,CAAC;IAClB,CAAC,UAAU,EAAE,YAAG,CAAC;IACjB,CAAC,QAAQ,EAAE,SAAE,CAAC;IACd,CAAC,yBAAyB,EAAE,uBAAS,CAAC;IACtC,CAAC,SAAS,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACpB,C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,aAAI,CAAC;IACpB,CAAC,aAAa,EAAE,aAAI,CAAC;IACrB,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,YAAG,EAAE,EAAE,CAAC,CAAC;CAC5C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAyB,CACpC,CAAC;AAWW,QAAA,wBAAwB,GAAG,IAAI,iBAAU,CACpD;IACE,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,QAAQ,EAAE,uBAAS,CAAC;IACrB,CAAC,aAAa,EAAE,uBAAS,CAAC;IAC1B,CAAC,gBAAgB,EAAE,YAAG,CAAC;IACvB,CAAC,YAAY,EAAE,aAAI,CAAC;IACpB,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,YAAG,EAAE,EAAE,CAAC,CAAC;CAC5C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAA0B,CACrC,CAAC;AAYW,QAAA,wBAAwB,GAAG,IAAI,iBAAU,CACpD;IACE,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,IAAI,EAAE,uBAAS,CAAC;IACjB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,aAAa,EAAE,IAAA,4BAAqB,EAAC,aAAI,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC,WAAW,EAAE,IAAA,4BAAqB,EAAC,YAAG,EAAE,EAAE,CAAC,CAAC;CAC9C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAA0B,CACrC,CAAC"}
|
@@ -1,4 +1,10 @@
|
|
1
|
+
import { GetProgramAccountsFilter, PublicKey } from '@solana/web3.js';
|
2
|
+
import { BeetStruct } from '@metaplex-foundation/beet';
|
3
|
+
import { TokenPrice, Yield } from '@sonarwatch/portfolio-core';
|
4
|
+
import BigNumber from 'bignumber.js';
|
1
5
|
import { AmmInfoV4, AmmInfoV5 } from './structs/amms';
|
6
|
+
import { FarmAccount, FarmAccountV6, UserFarmAccountV3, UserFarmAccountV31, UserFarmAccountV4, UserFarmAccountV5 } from './structs/farms';
|
7
|
+
import { ParsedAccount } from '../../utils/solana';
|
2
8
|
export declare enum LiquidityPoolStatus {
|
3
9
|
Uninitialized = 0,
|
4
10
|
Initialized = 1,
|
@@ -19,3 +25,31 @@ export type EnhancedAmmInfoV5 = AmmInfoV5 & {
|
|
19
25
|
};
|
20
26
|
export type AmmInfo = AmmInfoV4 | AmmInfoV5;
|
21
27
|
export type EnhancedAmmInfo = EnhancedAmmInfoV4 | EnhancedAmmInfoV5;
|
28
|
+
export type UserFarmConfig = {
|
29
|
+
programId: PublicKey;
|
30
|
+
version: string;
|
31
|
+
filters: (address: string) => GetProgramAccountsFilter[];
|
32
|
+
struct: BeetStruct<UserFarmAccountV3, Partial<UserFarmAccountV3>> | BeetStruct<UserFarmAccountV4, Partial<UserFarmAccountV4>> | BeetStruct<UserFarmAccountV5, Partial<UserFarmAccountV5>> | BeetStruct<UserFarmAccountV31, Partial<UserFarmAccountV31>>;
|
33
|
+
};
|
34
|
+
export type FarmConfig = {
|
35
|
+
programId: PublicKey;
|
36
|
+
version: string;
|
37
|
+
d: number;
|
38
|
+
filters: GetProgramAccountsFilter[];
|
39
|
+
struct: BeetStruct<FarmAccount, Partial<FarmAccount>>;
|
40
|
+
};
|
41
|
+
export type FarmInfo = {
|
42
|
+
account: ParsedAccount<FarmAccount>;
|
43
|
+
lpToken: TokenPrice;
|
44
|
+
d: number;
|
45
|
+
rewardTokenA?: TokenPrice;
|
46
|
+
rewardTokenB?: TokenPrice;
|
47
|
+
yields?: Yield[];
|
48
|
+
};
|
49
|
+
export type FarmInfoV6 = {
|
50
|
+
account: FarmAccountV6;
|
51
|
+
lpToken: TokenPrice;
|
52
|
+
multiplier: BigNumber;
|
53
|
+
rewardTokens: (TokenPrice | undefined)[];
|
54
|
+
yields?: Yield[];
|
55
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/types.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/types.ts"],"names":[],"mappings":";;;AAeA,IAAY,mBASX;AATD,WAAY,mBAAmB;IAC7B,+EAAa,CAAA;IACb,2EAAW,CAAA;IACX,qEAAQ,CAAA;IACR,2FAAmB,CAAA;IACnB,+EAAa,CAAA;IACb,uEAAS,CAAA;IACT,6DAAI,CAAA;IACJ,mFAAe,CAAA;AACjB,CAAC,EATW,mBAAmB,mCAAnB,mBAAmB,QAS9B"}
|
@@ -3,14 +3,16 @@ import { Platform } from '@sonarwatch/portfolio-core';
|
|
3
3
|
export declare const platformId = "save";
|
4
4
|
export declare const platform: Platform;
|
5
5
|
export declare const marketsPrefix = "save-markets";
|
6
|
-
export declare const reservesPrefix = "save-reserves";
|
7
6
|
export declare const marketsKey = "markets";
|
7
|
+
export declare const reservesPrefix = "save-reserves";
|
8
|
+
export declare const rewardStatsPrefix = "save-reward-stats";
|
9
|
+
export declare const rewardStatsKey = "reward-stats";
|
8
10
|
export declare const pid: PublicKey;
|
9
11
|
export declare const merkleProgramId: PublicKey;
|
10
12
|
export declare const marketsEndpoint = "https://api.solend.fi/v1/markets/configs";
|
11
13
|
export declare const reserveEndpoint = "https://api.solend.fi/v1/reserves/?ids=";
|
12
14
|
export declare const wadsDecimal = 18;
|
13
15
|
export declare const mainMarket = "4UpD2fh7xH3VP9QQaXtsS1YY3bxzWhtfpks7FatyKvdY";
|
14
|
-
export declare const
|
15
|
-
export declare const
|
16
|
+
export declare const rewardProofsEndpoint = "https://api.save.finance/liquidity-mining/reward-proofs?obligation=";
|
17
|
+
export declare const externalRewardStatsEndpoint = "https://api.save.finance/liquidity-mining/external-reward-stats-v2?flat=true";
|
16
18
|
export declare const slndMint = "SLNDpmoWTVADgEdndyvWzroNL7zSi1dF9PC3xHGtPwp";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.slndMint = exports.
|
3
|
+
exports.slndMint = exports.externalRewardStatsEndpoint = exports.rewardProofsEndpoint = exports.mainMarket = exports.wadsDecimal = exports.reserveEndpoint = exports.marketsEndpoint = exports.merkleProgramId = exports.pid = exports.rewardStatsKey = exports.rewardStatsPrefix = exports.reservesPrefix = exports.marketsKey = exports.marketsPrefix = exports.platform = exports.platformId = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
exports.platformId = 'save';
|
6
6
|
exports.platform = {
|
@@ -11,15 +11,17 @@ exports.platform = {
|
|
11
11
|
website: 'https://save.finance/',
|
12
12
|
};
|
13
13
|
exports.marketsPrefix = `${exports.platformId}-markets`;
|
14
|
-
exports.reservesPrefix = `${exports.platformId}-reserves`;
|
15
14
|
exports.marketsKey = 'markets';
|
15
|
+
exports.reservesPrefix = `${exports.platformId}-reserves`;
|
16
|
+
exports.rewardStatsPrefix = `${exports.platformId}-reward-stats`;
|
17
|
+
exports.rewardStatsKey = 'reward-stats';
|
16
18
|
exports.pid = new web3_js_1.PublicKey('So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo');
|
17
19
|
exports.merkleProgramId = new web3_js_1.PublicKey('mrksLcZ6rMs9xkmJgw6oKiR3GECw44Gb5NeDqu64kiw');
|
18
20
|
exports.marketsEndpoint = 'https://api.solend.fi/v1/markets/configs';
|
19
21
|
exports.reserveEndpoint = 'https://api.solend.fi/v1/reserves/?ids=';
|
20
22
|
exports.wadsDecimal = 18;
|
21
23
|
exports.mainMarket = '4UpD2fh7xH3VP9QQaXtsS1YY3bxzWhtfpks7FatyKvdY';
|
22
|
-
exports.
|
23
|
-
exports.
|
24
|
+
exports.rewardProofsEndpoint = 'https://api.save.finance/liquidity-mining/reward-proofs?obligation=';
|
25
|
+
exports.externalRewardStatsEndpoint = 'https://api.save.finance/liquidity-mining/external-reward-stats-v2?flat=true';
|
24
26
|
exports.slndMint = 'SLNDpmoWTVADgEdndyvWzroNL7zSi1dF9PC3xHGtPwp';
|
25
27
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,uBAAuB;CACjC,CAAC;AACW,QAAA,aAAa,GAAG,GAAG,kBAAU,UAAU,CAAC;AACxC,QAAA,cAAc,GAAG,GAAG,kBAAU,WAAW,CAAC;AAC1C,QAAA,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,uBAAuB;CACjC,CAAC;AACW,QAAA,aAAa,GAAG,GAAG,kBAAU,UAAU,CAAC;AACxC,QAAA,UAAU,GAAG,SAAS,CAAC;AACvB,QAAA,cAAc,GAAG,GAAG,kBAAU,WAAW,CAAC;AAC1C,QAAA,iBAAiB,GAAG,GAAG,kBAAU,eAAe,CAAC;AACjD,QAAA,cAAc,GAAG,cAAc,CAAC;AAEhC,QAAA,GAAG,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AACnE,QAAA,eAAe,GAAG,IAAI,mBAAS,CAC1C,6CAA6C,CAC9C,CAAC;AACW,QAAA,eAAe,GAAG,0CAA0C,CAAC;AAC7D,QAAA,eAAe,GAAG,yCAAyC,CAAC;AAC5D,QAAA,WAAW,GAAG,EAAE,CAAC;AACjB,QAAA,UAAU,GAAG,8CAA8C,CAAC;AAC5D,QAAA,oBAAoB,GAC/B,qEAAqE,CAAC;AAC3D,QAAA,2BAA2B,GACtC,8EAA8E,CAAC;AAEpE,QAAA,QAAQ,GAAG,6CAA6C,CAAC"}
|
@@ -9,7 +9,8 @@ const marketsJob_1 = __importDefault(require("./marketsJob"));
|
|
9
9
|
const obligationsFetcher_1 = __importDefault(require("./obligationsFetcher"));
|
10
10
|
const constants_1 = require("./constants");
|
11
11
|
const rewardsFetcher_1 = __importDefault(require("./rewardsFetcher"));
|
12
|
+
const rewardStatsJob_1 = __importDefault(require("./rewardStatsJob"));
|
12
13
|
exports.platforms = [constants_1.platform];
|
13
|
-
exports.jobs = [marketsJob_1.default, reservesJob_1.default];
|
14
|
+
exports.jobs = [marketsJob_1.default, reservesJob_1.default, rewardStatsJob_1.default];
|
14
15
|
exports.fetchers = [obligationsFetcher_1.default, rewardsFetcher_1.default];
|
15
16
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/index.ts"],"names":[],"mappings":";;;;;;AAGA,gEAAwC;AACxC,8DAAsC;AACtC,8EAAqD;AACrD,2CAAuC;AACvC,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,EAAE,qBAAW,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/index.ts"],"names":[],"mappings":";;;;;;AAGA,gEAAwC;AACxC,8DAAsC;AACtC,8EAAqD;AACrD,2CAAuC;AACvC,sEAA8C;AAC9C,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,oBAAU,EAAE,qBAAW,EAAE,wBAAc,CAAC,CAAC;AACxD,QAAA,QAAQ,GAAc,CAAC,4BAAiB,EAAE,wBAAc,CAAC,CAAC"}
|
@@ -0,0 +1,31 @@
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const rewardStatsRes = yield axios_1.default.get(constants_1.externalRewardStatsEndpoint);
|
20
|
+
yield cache.setItem(constants_1.rewardStatsKey, rewardStatsRes.data, {
|
21
|
+
prefix: constants_1.rewardStatsPrefix,
|
22
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
23
|
+
});
|
24
|
+
});
|
25
|
+
const job = {
|
26
|
+
id: `${constants_1.platformId}-reward-stats`,
|
27
|
+
executor,
|
28
|
+
label: 'normal',
|
29
|
+
};
|
30
|
+
exports.default = job;
|
31
|
+
//# sourceMappingURL=rewardStatsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"rewardStatsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/rewardStatsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,+DAAuD;AACvD,2CAKqB;AAKrB,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,cAAc,GAAG,MAAM,eAAK,CAAC,GAAG,CACpC,uCAA2B,CAC5B,CAAC;IAEF,MAAM,KAAK,CAAC,OAAO,CAAC,0BAAc,EAAE,cAAc,CAAC,IAAI,EAAE;QACvD,MAAM,EAAE,6BAAiB;QACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,eAAe;IAChC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -14,77 +14,119 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
17
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
17
|
const web3_js_1 = require("@solana/web3.js");
|
19
18
|
const bn_js_1 = require("bn.js");
|
19
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
20
20
|
const constants_1 = require("./constants");
|
21
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
22
21
|
const solana_1 = require("../../utils/solana");
|
23
22
|
const clients_1 = require("../../utils/clients");
|
24
23
|
const structs_1 = require("./structs");
|
25
|
-
const
|
26
|
-
|
24
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
25
|
+
const getClaimData = (owner) => __awaiter(void 0, void 0, void 0, function* () {
|
27
26
|
const obligationAddress = yield web3_js_1.PublicKey.createWithSeed(new web3_js_1.PublicKey(owner), '4UpD2fh7xH3VP9QQaXtsS1YY3bxzWhtf', constants_1.pid);
|
28
|
-
const
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
const
|
33
|
-
const slndRewards = rewards.filter((reward) => reward.incentivizer === 'slnd_points' &&
|
34
|
-
reward.quantity &&
|
35
|
-
reward.quantity !== '0');
|
36
|
-
const claimAndBumps = slndRewards.map((d) => web3_js_1.PublicKey.findProgramAddressSync([
|
27
|
+
const rewardProofsRes = yield axios_1.default.get(constants_1.rewardProofsEndpoint + obligationAddress.toString());
|
28
|
+
return rewardProofsRes.data.map((d) => (Object.assign(Object.assign({}, d), { distributorPublicKey: new web3_js_1.PublicKey(d.distributorPublicKey) })));
|
29
|
+
});
|
30
|
+
const getRewardData = (client, claimData) => __awaiter(void 0, void 0, void 0, function* () {
|
31
|
+
const claimAndBumps = claimData.map((d) => web3_js_1.PublicKey.findProgramAddressSync([
|
37
32
|
Buffer.from('ClaimStatus', 'utf8'),
|
38
|
-
new bn_js_1.BN.BN(d.index).toArrayLike(Buffer, 'le', 8),
|
39
|
-
|
40
|
-
], new web3_js_1.PublicKey(constants_1.merkleProgramId))
|
41
|
-
const
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
33
|
+
new bn_js_1.BN.BN.BN(d.index).toArrayLike(Buffer, 'le', 8),
|
34
|
+
d.distributorPublicKey.toBytes(),
|
35
|
+
], new web3_js_1.PublicKey(constants_1.merkleProgramId)));
|
36
|
+
const [merkleDistributors, claimStatuses] = yield Promise.all([
|
37
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.merkleDistributorStruct, claimData.map((d) => d.distributorPublicKey)),
|
38
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.claimStatusStruct, claimAndBumps.map((candb) => candb[0])),
|
39
|
+
]);
|
40
|
+
const fullData = (yield Promise.all(claimData.map((d, index) => __awaiter(void 0, void 0, void 0, function* () {
|
41
|
+
const merkleDistributor = merkleDistributors[index];
|
42
|
+
const claimAndBump = claimAndBumps[index];
|
43
|
+
const claimStatus = claimStatuses[index];
|
44
|
+
if (!merkleDistributor || !claimAndBump)
|
45
|
+
return null;
|
46
|
+
const [distributorATAPublicKey] = web3_js_1.PublicKey.findProgramAddressSync([
|
47
|
+
d.distributorPublicKey.toBuffer(),
|
48
|
+
new web3_js_1.PublicKey(solana_1.solanaTokenPid).toBuffer(),
|
49
|
+
merkleDistributor.mint.toBuffer(),
|
50
|
+
], solana_1.associatedTokenProgramId);
|
51
|
+
const accountFunded = (yield client.getTokenAccountBalance(distributorATAPublicKey)).value
|
52
|
+
.amount !== '0';
|
53
|
+
return Object.assign(Object.assign({}, d), { accountFunded, claimId: claimAndBump[0], claimStatusBump: claimAndBump[1], claimed: Boolean(claimStatus === null || claimStatus === void 0 ? void 0 : claimStatus.isClaimed), claimedAt: claimStatus ? Number(claimStatus.claimedAt) : 0, distributor: merkleDistributor, distributorATAPublicKey });
|
54
|
+
})))).filter((d) => d !== null);
|
55
|
+
const slndRewards = fullData.filter((d) => ['slnd_options', 'slnd'].includes(d.incentivizer));
|
56
|
+
return {
|
57
|
+
pythPointsRewards: fullData.filter((c) => c.incentivizer === 'pyth_points'),
|
58
|
+
slndPointsRewards: fullData.filter((c) => c.incentivizer === 'slnd_points'),
|
59
|
+
slnd: slndRewards,
|
60
|
+
external: fullData
|
61
|
+
.filter((d) => !['slnd_options', 'slnd', 'pyth_points', 'slnd_points'].includes(d.incentivizer))
|
62
|
+
.reduce((acc, currentValue) => {
|
63
|
+
if (!acc[currentValue.distributor.mint.toString()]) {
|
64
|
+
acc[currentValue.distributor.mint.toString()] = [];
|
65
|
+
}
|
66
|
+
acc[currentValue.distributor.mint.toString()].push(currentValue);
|
67
|
+
return acc;
|
68
|
+
}, {}),
|
69
|
+
};
|
70
|
+
});
|
71
|
+
const getRewards = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
72
|
+
const claimData = yield getClaimData(owner);
|
73
|
+
if (claimData.length === 0)
|
50
74
|
return [];
|
51
|
-
const
|
52
|
-
|
53
|
-
(
|
75
|
+
const client = (0, clients_1.getClientSolana)();
|
76
|
+
const [rewardData, rewardStats] = yield Promise.all([
|
77
|
+
getRewardData(client, claimData),
|
78
|
+
cache.getItem(constants_1.rewardStatsKey, {
|
79
|
+
prefix: constants_1.rewardStatsPrefix,
|
80
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
81
|
+
}),
|
54
82
|
]);
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
83
|
+
if (!rewardStats || rewardStats.length === 0)
|
84
|
+
return [];
|
85
|
+
const rewardsSummary = [
|
86
|
+
...new Set(rewardStats.map((rew) => rew.rewardMint)),
|
87
|
+
].map((rewardMint) => {
|
88
|
+
var _a, _b;
|
89
|
+
const claims = (_b = (_a = rewardData === null || rewardData === void 0 ? void 0 : rewardData.external) === null || _a === void 0 ? void 0 : _a[rewardMint]) !== null && _b !== void 0 ? _b : [];
|
90
|
+
const unclaimed = claims.filter((cd) => !cd.claimed && cd.accountFunded);
|
91
|
+
const totalUnclaimed = unclaimed.reduce((sum, lot) => new bignumber_js_1.default(lot.quantity).plus(sum), new bignumber_js_1.default(0));
|
92
|
+
return {
|
93
|
+
rewardMint,
|
94
|
+
totalUnclaimed,
|
95
|
+
};
|
66
96
|
});
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
97
|
+
const unclaimedSlnd = rewardData === null || rewardData === void 0 ? void 0 : rewardData.slnd.filter((cd) => cd.incentivizer === 'slnd' && !cd.claimed).reduce((sum, lot) => new bignumber_js_1.default(lot.quantity).dividedBy(Math.pow(10, 6)).plus(sum), new bignumber_js_1.default(0));
|
98
|
+
rewardsSummary.push({
|
99
|
+
rewardMint: constants_1.slndMint,
|
100
|
+
totalUnclaimed: unclaimedSlnd,
|
101
|
+
});
|
102
|
+
return rewardsSummary.filter((r) => r.totalUnclaimed.isGreaterThan(0));
|
103
|
+
});
|
104
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
105
|
+
const rewards = yield getRewards(owner, cache);
|
106
|
+
if (rewards.length === 0)
|
107
|
+
return [];
|
108
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(rewards.map((r) => r.rewardMint), portfolio_core_1.NetworkId.solana);
|
109
|
+
const assets = [];
|
110
|
+
rewards.forEach((reward) => {
|
111
|
+
const tokenPrice = tokenPrices.get(reward.rewardMint);
|
71
112
|
if (!tokenPrice)
|
72
113
|
return;
|
73
|
-
assets.push(Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(tokenPrice.address,
|
114
|
+
assets.push(Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(tokenPrice.address, reward.totalUnclaimed.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPrice)), { attributes: { isClaimable: true } }));
|
74
115
|
});
|
75
116
|
if (assets.length === 0)
|
76
117
|
return [];
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
118
|
+
return [
|
119
|
+
{
|
120
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
121
|
+
label: 'Rewards',
|
122
|
+
platformId: constants_1.platformId,
|
123
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
124
|
+
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
|
125
|
+
data: {
|
126
|
+
assets,
|
127
|
+
},
|
85
128
|
},
|
86
|
-
|
87
|
-
return [element];
|
129
|
+
];
|
88
130
|
});
|
89
131
|
const fetcher = {
|
90
132
|
id: `${constants_1.platformId}-rewards`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rewardsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/rewardsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"rewardsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/save/rewardsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AACpC,kDAA0B;AAC1B,6CAAwD;AACxD,iCAA2B;AAC3B,gEAAqC;AAGrC,2CAQqB;AAErB,+CAI4B;AAC5B,iDAAsD;AACtD,uCAKmB;AACnB,qGAA6E;AAE7E,MAAM,YAAY,GAAG,CAAO,KAAa,EAAE,EAAE;IAC3C,MAAM,iBAAiB,GAAG,MAAM,mBAAS,CAAC,cAAc,CACtD,IAAI,mBAAS,CAAC,KAAK,CAAC,EACpB,kCAAkC,EAClC,eAAG,CACJ,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,eAAK,CAAC,GAAG,CACrC,gCAAoB,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CACpD,CAAC;IACF,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCAClC,CAAC,KACJ,oBAAoB,EAAE,IAAI,mBAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAC3D,CAAC,CAAC;AACN,CAAC,CAAA,CAAC;AAEF,MAAM,aAAa,GAAG,CAAO,MAAkB,EAAE,SAAsB,EAAE,EAAE;IACzE,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACxC,mBAAS,CAAC,sBAAsB,CAC9B;QACE,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;QAClC,IAAI,UAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,M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