@sonarwatch/portfolio-plugins 0.12.185 → 0.12.187
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1546 -1538
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/plugins/abex/constants.d.ts +8 -1
- package/src/plugins/abex/constants.js +9 -2
- package/src/plugins/abex/constants.js.map +1 -1
- package/src/plugins/abex/getVaultInfo.d.ts +3 -0
- package/src/plugins/abex/getVaultInfo.js +65 -0
- package/src/plugins/abex/getVaultInfo.js.map +1 -0
- package/src/plugins/abex/helpers.d.ts +25 -0
- package/src/plugins/abex/helpers.js +353 -0
- package/src/plugins/abex/helpers.js.map +1 -0
- package/src/plugins/abex/index.js +7 -1
- package/src/plugins/abex/index.js.map +1 -1
- package/src/plugins/abex/marketsJob.js +13 -7
- package/src/plugins/abex/marketsJob.js.map +1 -1
- package/src/plugins/abex/ordersFetcher.d.ts +3 -0
- package/src/plugins/abex/ordersFetcher.js +49 -0
- package/src/plugins/abex/ordersFetcher.js.map +1 -0
- package/src/plugins/abex/parseValue.d.ts +1 -0
- package/src/plugins/abex/parseValue.js +30 -0
- package/src/plugins/abex/parseValue.js.map +1 -0
- package/src/plugins/abex/positionsFetcher.js +39 -57
- package/src/plugins/abex/positionsFetcher.js.map +1 -1
- package/src/plugins/abex/stakingFetcher.d.ts +3 -0
- package/src/plugins/abex/stakingFetcher.js +87 -0
- package/src/plugins/abex/stakingFetcher.js.map +1 -0
- package/src/plugins/abex/types.d.ts +172 -10
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bluemove/poolsJob.js +13 -11
- package/src/plugins/bluemove/poolsJob.js.map +1 -1
- package/src/plugins/raydium/index.js +7 -2
- package/src/plugins/raydium/index.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/zeta/airdropFetcher.js +14 -14
- package/src/utils/elementbuilder/ElementLeverageBuilder.d.ts +13 -0
- package/src/utils/elementbuilder/ElementLeverageBuilder.js +40 -0
- package/src/utils/elementbuilder/ElementLeverageBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementRegistry.d.ts +2 -0
- package/src/utils/elementbuilder/ElementRegistry.js +6 -0
- package/src/utils/elementbuilder/ElementRegistry.js.map +1 -1
- package/src/utils/elementbuilder/LevPositionBuilder.d.ts +9 -0
- package/src/utils/elementbuilder/LevPositionBuilder.js +49 -0
- package/src/utils/elementbuilder/LevPositionBuilder.js.map +1 -0
- package/src/utils/elementbuilder/LevPositionParams.d.ts +14 -0
- package/src/utils/elementbuilder/LevPositionParams.js +3 -0
- package/src/utils/elementbuilder/LevPositionParams.js.map +1 -0
- package/src/utils/misc/Memoized.d.ts +8 -0
- package/src/utils/misc/Memoized.js +31 -0
- package/src/utils/misc/Memoized.js.map +1 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluemove/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;
|
1
|
+
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/bluemove/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AAGpC,2CAAgE;AAChE,iDAAmD;AACnD,mFAAgF;AAEhF,8EAA2E;AAE3E,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,KAAK,GAAG,MAAM,IAAA,+CAAsB,EAAO,MAAM,EAAE,qBAAS,CAAC,CAAC;IAEpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;QACrB,IACE,CAAC,IAAI,CAAC,IAAI;YACV,CAAC,IAAI,CAAC,IAAI,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BACpD,MAAM,EAAE,GAAG;oBACX,UAAU,EAAE,WAAW;iBACxB;gBACD;oBACE,OAAO,EAAE,IAAA,mCAAkB,EAAC,SAAS,EAAE,0BAAS,CAAC,GAAG,CAAC;oBACrD,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS;oBACpD,MAAM,EAAE,GAAG;oBACX,UAAU,EAAE,WAAW;iBACxB;aACF;SACF,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -4,13 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
-
|
7
|
+
// import lpTokensJob from './lpTokensJob';
|
8
8
|
const clmmJob_1 = __importDefault(require("./clmmJob"));
|
9
9
|
const cpmmJob_1 = __importDefault(require("./cpmmJob"));
|
10
10
|
const farmsJob_1 = __importDefault(require("./farmsJob"));
|
11
11
|
const constants_1 = require("./constants");
|
12
12
|
const farmsFetcher_1 = __importDefault(require("./farmsFetcher"));
|
13
13
|
exports.platforms = [constants_1.platform];
|
14
|
-
exports.jobs = [
|
14
|
+
exports.jobs = [
|
15
|
+
// lpTokensJob,
|
16
|
+
farmsJob_1.default,
|
17
|
+
clmmJob_1.default,
|
18
|
+
cpmmJob_1.default,
|
19
|
+
];
|
15
20
|
exports.fetchers = [farmsFetcher_1.default];
|
16
21
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/index.ts"],"names":[],"mappings":";;;;;;AAGA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAA2C;AAC3C,wDAAgC;AAChC,wDAAgC;AAChC,0DAAkC;AAClC,2CAAuC;AACvC,kEAA0C;AAE7B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU;IACzB,eAAe;IACf,kBAAQ;IACR,iBAAO;IACP,iBAAO;CACR,CAAC;AACW,QAAA,QAAQ,GAAc,CAAC,sBAAY,CAAC,CAAC"}
|
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
|
|
54
54
|
}
|
55
55
|
function getV3PairsAddresses(url, length = 300) {
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const query = (0, graphql_request_1.gql) `
|
58
|
-
{
|
59
|
-
pools(
|
60
|
-
orderBy: totalValueLockedUSD
|
61
|
-
first: ${length}
|
62
|
-
orderDirection: desc
|
63
|
-
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
-
) {
|
65
|
-
id
|
66
|
-
token0Price
|
67
|
-
token1Price
|
68
|
-
liquidity
|
69
|
-
token0 {
|
70
|
-
id
|
71
|
-
totalSupply
|
72
|
-
decimals
|
73
|
-
}
|
74
|
-
token1 {
|
75
|
-
id
|
76
|
-
totalSupply
|
77
|
-
decimals
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
57
|
+
const query = (0, graphql_request_1.gql) `
|
58
|
+
{
|
59
|
+
pools(
|
60
|
+
orderBy: totalValueLockedUSD
|
61
|
+
first: ${length}
|
62
|
+
orderDirection: desc
|
63
|
+
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
+
) {
|
65
|
+
id
|
66
|
+
token0Price
|
67
|
+
token1Price
|
68
|
+
liquidity
|
69
|
+
token0 {
|
70
|
+
id
|
71
|
+
totalSupply
|
72
|
+
decimals
|
73
|
+
}
|
74
|
+
token1 {
|
75
|
+
id
|
76
|
+
totalSupply
|
77
|
+
decimals
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
81
|
`;
|
82
82
|
const res = yield (0, graphql_request_1.default)(url, query);
|
83
83
|
const pools = res.pools;
|
@@ -40,28 +40,28 @@ function getPairKey(version) {
|
|
40
40
|
exports.getPairKey = getPairKey;
|
41
41
|
function getPairsV2FromTheGraph(url, length = 300) {
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
43
|
-
const query = (0, graphql_request_1.gql) `
|
44
|
-
{
|
45
|
-
pairs(
|
46
|
-
orderBy: reserveUSD
|
47
|
-
first: ${length}
|
48
|
-
orderDirection: desc
|
49
|
-
where: { trackedReserveETH_not: "0" }
|
50
|
-
) {
|
51
|
-
id
|
52
|
-
reserve0
|
53
|
-
reserve1
|
54
|
-
totalSupply
|
55
|
-
token0 {
|
56
|
-
id
|
57
|
-
decimals
|
58
|
-
}
|
59
|
-
token1 {
|
60
|
-
id
|
61
|
-
decimals
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
43
|
+
const query = (0, graphql_request_1.gql) `
|
44
|
+
{
|
45
|
+
pairs(
|
46
|
+
orderBy: reserveUSD
|
47
|
+
first: ${length}
|
48
|
+
orderDirection: desc
|
49
|
+
where: { trackedReserveETH_not: "0" }
|
50
|
+
) {
|
51
|
+
id
|
52
|
+
reserve0
|
53
|
+
reserve1
|
54
|
+
totalSupply
|
55
|
+
token0 {
|
56
|
+
id
|
57
|
+
decimals
|
58
|
+
}
|
59
|
+
token1 {
|
60
|
+
id
|
61
|
+
decimals
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
65
|
`;
|
66
66
|
const res = yield (0, graphql_request_1.default)(url, query);
|
67
67
|
const pairs = res.pairs;
|
@@ -42,20 +42,20 @@ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/token
|
|
42
42
|
const clients_1 = require("../../utils/clients");
|
43
43
|
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
44
44
|
const helpers_1 = require("./helpers");
|
45
|
-
const query = (0, graphql_request_1.gql) `
|
46
|
-
query GetAirdropFinalFrontend($authority: String!) {
|
47
|
-
getAirdropFinalFrontend(authority: $authority) {
|
48
|
-
authority
|
49
|
-
community_allocation
|
50
|
-
eligibility
|
51
|
-
main_allocation
|
52
|
-
og_allocation
|
53
|
-
s1_allocation
|
54
|
-
s2_allocation
|
55
|
-
total_allocation
|
56
|
-
__typename
|
57
|
-
}
|
58
|
-
}
|
45
|
+
const query = (0, graphql_request_1.gql) `
|
46
|
+
query GetAirdropFinalFrontend($authority: String!) {
|
47
|
+
getAirdropFinalFrontend(authority: $authority) {
|
48
|
+
authority
|
49
|
+
community_allocation
|
50
|
+
eligibility
|
51
|
+
main_allocation
|
52
|
+
og_allocation
|
53
|
+
s1_allocation
|
54
|
+
s2_allocation
|
55
|
+
total_allocation
|
56
|
+
__typename
|
57
|
+
}
|
58
|
+
}
|
59
59
|
`;
|
60
60
|
const networkId = portfolio_core_1.NetworkId.solana;
|
61
61
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { NetworkIdType, PortfolioElementLeverage } from '@sonarwatch/portfolio-core';
|
2
|
+
import { ElementBuilder } from './ElementBuilder';
|
3
|
+
import { ElementParams } from './ElementParams';
|
4
|
+
import { TokenPriceMap } from '../../TokenPriceMap';
|
5
|
+
import { LevPositionBuilder } from './LevPositionBuilder';
|
6
|
+
import { LevPositionParams } from './LevPositionParams';
|
7
|
+
export declare class ElementLeverageBuilder extends ElementBuilder {
|
8
|
+
positions: LevPositionBuilder[];
|
9
|
+
constructor(params: ElementParams);
|
10
|
+
addPosition(params: LevPositionParams): LevPositionBuilder;
|
11
|
+
mints(): string[];
|
12
|
+
get(networkId: NetworkIdType, platformId: string, tokenPrices: TokenPriceMap): PortfolioElementLeverage | null;
|
13
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ElementLeverageBuilder = void 0;
|
4
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
5
|
+
const ElementBuilder_1 = require("./ElementBuilder");
|
6
|
+
const LevPositionBuilder_1 = require("./LevPositionBuilder");
|
7
|
+
class ElementLeverageBuilder extends ElementBuilder_1.ElementBuilder {
|
8
|
+
constructor(params) {
|
9
|
+
super(params);
|
10
|
+
this.positions = [];
|
11
|
+
}
|
12
|
+
addPosition(params) {
|
13
|
+
const levPositionBuilder = new LevPositionBuilder_1.LevPositionBuilder(params);
|
14
|
+
this.positions.push(levPositionBuilder);
|
15
|
+
return levPositionBuilder;
|
16
|
+
}
|
17
|
+
mints() {
|
18
|
+
return this.positions.map((position) => position.mints()).flat();
|
19
|
+
}
|
20
|
+
get(networkId, platformId, tokenPrices) {
|
21
|
+
const positions = this.positions
|
22
|
+
.map((p) => p.get(networkId, tokenPrices))
|
23
|
+
.filter((p) => p !== null);
|
24
|
+
const value = (0, portfolio_core_1.getUsdValueSum)(positions.map((a) => a.value));
|
25
|
+
const element = {
|
26
|
+
type: this.type,
|
27
|
+
label: this.label,
|
28
|
+
data: {
|
29
|
+
positions,
|
30
|
+
value,
|
31
|
+
},
|
32
|
+
networkId,
|
33
|
+
platformId,
|
34
|
+
value,
|
35
|
+
};
|
36
|
+
return element;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
exports.ElementLeverageBuilder = ElementLeverageBuilder;
|
40
|
+
//# sourceMappingURL=ElementLeverageBuilder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ElementLeverageBuilder.js","sourceRoot":"","sources":["../../../../../../packages/pl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;AAzCD,wDAyCC"}
|
@@ -5,6 +5,7 @@ import { Cache } from '../../Cache';
|
|
5
5
|
import { ElementMultipleBuilder } from './ElementMultipleBuilder';
|
6
6
|
import { ElementLiquidityBuilder } from './ElementLiquidityBuilder';
|
7
7
|
import { ElementBorrowlendBuilder } from './ElementBorrowlendBuilder';
|
8
|
+
import { ElementLeverageBuilder } from './ElementLeverageBuilder';
|
8
9
|
export declare class ElementRegistry {
|
9
10
|
readonly networkId: NetworkIdType;
|
10
11
|
readonly platformId: string;
|
@@ -13,5 +14,6 @@ export declare class ElementRegistry {
|
|
13
14
|
addElementMultiple(params: Omit<ElementParams, 'type'>): ElementMultipleBuilder;
|
14
15
|
addElementLiquidity(params: Omit<ElementParams, 'type'>): ElementLiquidityBuilder;
|
15
16
|
addElementBorrowlend(params: Omit<ElementParams, 'type'>): ElementBorrowlendBuilder;
|
17
|
+
addElementLeverage(params: Omit<ElementParams, 'type'>): ElementLeverageBuilder;
|
16
18
|
getElements(cache: Cache): Promise<PortfolioElement[]>;
|
17
19
|
}
|
@@ -14,6 +14,7 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
|
14
14
|
const ElementMultipleBuilder_1 = require("./ElementMultipleBuilder");
|
15
15
|
const ElementLiquidityBuilder_1 = require("./ElementLiquidityBuilder");
|
16
16
|
const ElementBorrowlendBuilder_1 = require("./ElementBorrowlendBuilder");
|
17
|
+
const ElementLeverageBuilder_1 = require("./ElementLeverageBuilder");
|
17
18
|
class ElementRegistry {
|
18
19
|
constructor(networkId, platformId) {
|
19
20
|
this.networkId = networkId;
|
@@ -35,6 +36,11 @@ class ElementRegistry {
|
|
35
36
|
this.elements.push(elementBuilder);
|
36
37
|
return elementBuilder;
|
37
38
|
}
|
39
|
+
addElementLeverage(params) {
|
40
|
+
const elementBuilder = new ElementLeverageBuilder_1.ElementLeverageBuilder(Object.assign({ type: portfolio_core_1.PortfolioElementType.leverage }, params));
|
41
|
+
this.elements.push(elementBuilder);
|
42
|
+
return elementBuilder;
|
43
|
+
}
|
38
44
|
getElements(cache) {
|
39
45
|
return __awaiter(this, void 0, void 0, function* () {
|
40
46
|
const mints = this.elements.map((e) => e.mints()).flat();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ElementRegistry.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AAIpC,qEAAkE;AAClE,uEAAoE;AACpE,yEAAsE;
|
1
|
+
{"version":3,"file":"ElementRegistry.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/ElementRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AAIpC,qEAAkE;AAClE,uEAAoE;AACpE,yEAAsE;AACtE,qEAAkE;AAElE,MAAa,eAAe;IAK1B,YAAY,SAAwB,EAAE,UAAkB;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IACD,kBAAkB,CAChB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,+CAAsB,iBAC/C,IAAI,EAAE,qCAAoB,CAAC,QAAQ,IAChC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,mBAAmB,CACjB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,iDAAuB,iBAChD,IAAI,EAAE,qCAAoB,CAAC,SAAS,IACjC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,oBAAoB,CAClB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,mDAAwB,iBACjD,IAAI,EAAE,qCAAoB,CAAC,UAAU,IAClC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,kBAAkB,CAChB,MAAmC;QAEnC,MAAM,cAAc,GAAG,IAAI,+CAAsB,iBAC/C,IAAI,EAAE,qCAAoB,CAAC,QAAQ,IAChC,MAAM,EACT,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnC,OAAO,cAAc,CAAC;IACxB,CAAC;IAEK,WAAW,CAAC,KAAY;;YAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACzD,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAE3E,OAAO,IAAI,CAAC,QAAQ;iBACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;iBAC/D,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CACtB,CAAC;QAC5B,CAAC;KAAA;CACF;AAhED,0CAgEC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { LevPosition, NetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import { TokenPriceMap } from '../../TokenPriceMap';
|
3
|
+
import { LevPositionParams } from './LevPositionParams';
|
4
|
+
export declare class LevPositionBuilder {
|
5
|
+
private params;
|
6
|
+
constructor(params: LevPositionParams);
|
7
|
+
mints(): string[];
|
8
|
+
get(networkId: NetworkIdType, tokenPrices: TokenPriceMap): LevPosition | null;
|
9
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.LevPositionBuilder = void 0;
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
|
+
class LevPositionBuilder {
|
9
|
+
constructor(params) {
|
10
|
+
this.params = params;
|
11
|
+
}
|
12
|
+
mints() {
|
13
|
+
if (this.params.collateralAmount)
|
14
|
+
return [this.params.address];
|
15
|
+
return [];
|
16
|
+
}
|
17
|
+
get(networkId, tokenPrices) {
|
18
|
+
var _a;
|
19
|
+
let collateralValue;
|
20
|
+
if (this.params.collateralAmount) {
|
21
|
+
const collateralTokenPrice = tokenPrices.get(this.params.address);
|
22
|
+
if (!collateralTokenPrice)
|
23
|
+
return null;
|
24
|
+
collateralValue = this.params.collateralAmount
|
25
|
+
.dividedBy(Math.pow(10, collateralTokenPrice.decimals))
|
26
|
+
.multipliedBy(collateralTokenPrice.price);
|
27
|
+
}
|
28
|
+
else if (!this.params.collateralValue) {
|
29
|
+
return null;
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
collateralValue = new bignumber_js_1.default(this.params.collateralValue);
|
33
|
+
}
|
34
|
+
return {
|
35
|
+
address: this.params.address,
|
36
|
+
side: this.params.side,
|
37
|
+
liquidationPrice: this.params.liquidationPrice || null,
|
38
|
+
collateralValue: collateralValue.toNumber(),
|
39
|
+
sizeValue: this.params.sizeValue.toNumber(),
|
40
|
+
pnlValue: (_a = this.params.pnlValue) === null || _a === void 0 ? void 0 : _a.toNumber(),
|
41
|
+
value: collateralValue.plus(this.params.pnlValue || 0).toNumber(),
|
42
|
+
name: this.params.name,
|
43
|
+
imageUri: this.params.imageUri,
|
44
|
+
leverage: this.params.leverage,
|
45
|
+
};
|
46
|
+
}
|
47
|
+
}
|
48
|
+
exports.LevPositionBuilder = LevPositionBuilder;
|
49
|
+
//# sourceMappingURL=LevPositionBuilder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LevPositionBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/LevPositionBuilder.ts"],"names":[],"mappings":";;;;;;AACA,gEAAqC;AAIrC,MAAa,kBAAkB;IAG7B,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,GAAG,CACD,SAAwB,EACxB,WAA0B;;QAE1B,IAAI,eAAe,CAAC;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YACjC,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,oBAAoB;gBAAE,OAAO,IAAI,CAAC;YACvC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB;iBAC3C,SAAS,CAAC,SAAA,EAAE,EAAI,oBAAoB,CAAC,QAAQ,CAAA,CAAC;iBAC9C,YAAY,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;aAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,eAAe,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,IAAI;YACtD,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE;YAC3C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,QAAQ,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,0CAAE,QAAQ,EAAE;YAC1C,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;YACjE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;SAChB,CAAC;IACnB,CAAC;CACF;AA1CD,gDA0CC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { LeverageSide, UsdValue } from '@sonarwatch/portfolio-core';
|
2
|
+
import BigNumber from 'bignumber.js';
|
3
|
+
export type LevPositionParams = {
|
4
|
+
address: string;
|
5
|
+
collateralAmount?: BigNumber;
|
6
|
+
collateralValue?: UsdValue;
|
7
|
+
side: LeverageSide;
|
8
|
+
sizeValue: BigNumber;
|
9
|
+
liquidationPrice?: BigNumber;
|
10
|
+
pnlValue?: BigNumber;
|
11
|
+
name?: string;
|
12
|
+
imageUri?: string;
|
13
|
+
leverage?: number;
|
14
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LevPositionParams.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/LevPositionParams.ts"],"names":[],"mappings":""}
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.Memoized = void 0;
|
13
|
+
const defaultMemoizedRefreshInterval = 600;
|
14
|
+
// T is the type of item memoized
|
15
|
+
class Memoized {
|
16
|
+
constructor(fetch, ttl = defaultMemoizedRefreshInterval) {
|
17
|
+
this.getItem = () => __awaiter(this, void 0, void 0, function* () {
|
18
|
+
const now = Date.now();
|
19
|
+
if (!this.item || this.lastUpdate + this.ttl < now) {
|
20
|
+
this.item = yield this.fetch();
|
21
|
+
this.lastUpdate = now;
|
22
|
+
}
|
23
|
+
return this.item;
|
24
|
+
});
|
25
|
+
this.fetch = fetch;
|
26
|
+
this.ttl = ttl;
|
27
|
+
this.lastUpdate = 0;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
exports.Memoized = Memoized;
|
31
|
+
//# sourceMappingURL=Memoized.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Memoized.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/Memoized.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAE3C,iCAAiC;AACjC,MAAa,QAAQ;IAOnB,YACE,KAAuB,EACvB,MAAc,8BAA8B;QAO9C,YAAO,GAAG,GAAS,EAAE;YACnB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAEvB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;gBACnD,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC/B,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;YACxB,CAAC;YAED,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC,CAAA,CAAC;QAdA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,CAAC;CAYF;AA1BD,4BA0BC"}
|
@@ -1,16 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
|
4
|
-
exports.infoQueryMsg = JSON.parse(`{
|
5
|
-
"info": {}
|
4
|
+
exports.infoQueryMsg = JSON.parse(`{
|
5
|
+
"info": {}
|
6
6
|
}`);
|
7
|
-
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
-
"token_info": {}
|
7
|
+
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
+
"token_info": {}
|
9
9
|
}`);
|
10
|
-
exports.minterQueryMsg = JSON.parse(`{
|
11
|
-
"minter": {}
|
10
|
+
exports.minterQueryMsg = JSON.parse(`{
|
11
|
+
"minter": {}
|
12
12
|
}`);
|
13
|
-
exports.poolQueryMsg = JSON.parse(`{
|
14
|
-
"pool": {}
|
13
|
+
exports.poolQueryMsg = JSON.parse(`{
|
14
|
+
"pool": {}
|
15
15
|
}`);
|
16
16
|
//# sourceMappingURL=constants.js.map
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
function getQueryBalanceByOwner(owner) {
|
4
|
-
return JSON.parse(`{
|
5
|
-
"balance": {
|
6
|
-
"address": "${owner}"
|
7
|
-
}
|
4
|
+
return JSON.parse(`{
|
5
|
+
"balance": {
|
6
|
+
"address": "${owner}"
|
7
|
+
}
|
8
8
|
}`);
|
9
9
|
}
|
10
10
|
exports.default = getQueryBalanceByOwner;
|