@sonarwatch/portfolio-plugins 0.11.78 → 0.11.80
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1043 -1035
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/parcl/depositsFetcher.js +72 -12
- package/src/plugins/parcl/depositsFetcher.js.map +1 -1
- package/src/plugins/parcl/filters.d.ts +2 -0
- package/src/plugins/parcl/filters.js +25 -1
- package/src/plugins/parcl/filters.js.map +1 -1
- package/src/plugins/parcl/helpers.d.ts +3 -1
- package/src/plugins/parcl/helpers.js +30 -3
- package/src/plugins/parcl/helpers.js.map +1 -1
- package/src/plugins/parcl/structs.d.ts +24 -0
- package/src/plugins/parcl/structs.js +23 -1
- package/src/plugins/parcl/structs.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
package/README.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
# @sonarwatch/portfolio-plugins
|
2
|
-
|
3
|
-
This library is @sonarwatch/portfolio-plugins
|
1
|
+
# @sonarwatch/portfolio-plugins
|
2
|
+
|
3
|
+
This library is @sonarwatch/portfolio-plugins
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.80",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"web3-v1": "npm:web3@^1.5.0"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@sonarwatch/portfolio-core": "0.11.
|
44
|
+
"@sonarwatch/portfolio-core": "0.11.80"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -36,27 +36,27 @@ exports.getBalancerPoolsV2 = void 0;
|
|
36
36
|
const graphql_request_1 = __importStar(require("graphql-request"));
|
37
37
|
function getBalancerPoolsV2(url) {
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
39
|
-
const query = (0, graphql_request_1.gql) `
|
40
|
-
query pools {
|
41
|
-
pools(
|
42
|
-
first: 1000
|
43
|
-
orderBy: totalLiquidity
|
44
|
-
orderDirection: desc
|
45
|
-
where: { totalLiquidity_gt: "500" }
|
46
|
-
) {
|
47
|
-
id
|
48
|
-
address
|
49
|
-
symbol
|
50
|
-
totalLiquidity
|
51
|
-
totalShares
|
52
|
-
tokens {
|
53
|
-
balance
|
54
|
-
decimals
|
55
|
-
symbol
|
56
|
-
address
|
57
|
-
}
|
58
|
-
}
|
59
|
-
}
|
39
|
+
const query = (0, graphql_request_1.gql) `
|
40
|
+
query pools {
|
41
|
+
pools(
|
42
|
+
first: 1000
|
43
|
+
orderBy: totalLiquidity
|
44
|
+
orderDirection: desc
|
45
|
+
where: { totalLiquidity_gt: "500" }
|
46
|
+
) {
|
47
|
+
id
|
48
|
+
address
|
49
|
+
symbol
|
50
|
+
totalLiquidity
|
51
|
+
totalShares
|
52
|
+
tokens {
|
53
|
+
balance
|
54
|
+
decimals
|
55
|
+
symbol
|
56
|
+
address
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
60
|
`;
|
61
61
|
const res = yield (0, graphql_request_1.default)(url, query);
|
62
62
|
const pools = res.pools;
|
@@ -20,28 +20,88 @@ const structs_1 = require("./structs");
|
|
20
20
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
21
21
|
const helpers_1 = require("./helpers");
|
22
22
|
const getParsedAccountInfo_1 = require("../../utils/solana/getParsedAccountInfo");
|
23
|
+
const filters_1 = require("./filters");
|
23
24
|
const thirtyDays = 30 * 1000 * 60 * 60 * 24;
|
24
25
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
26
|
const client = (0, clients_1.getClientSolana)();
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
const oldLpAccount = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, structs_1.lpAccountStruct, (0, helpers_1.getOldLpAccountPda)(owner));
|
28
|
+
let id = 0;
|
29
|
+
const lpPositions = [];
|
30
|
+
let parsedAccount;
|
31
|
+
do {
|
32
|
+
const accountPubKeys = (0, helpers_1.getLpPositionsPdas)(owner, id, id + 10);
|
33
|
+
parsedAccount = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.lpPositionStruct, accountPubKeys);
|
34
|
+
lpPositions.push(...parsedAccount);
|
35
|
+
id += 10;
|
36
|
+
} while (parsedAccount[parsedAccount.length]);
|
37
|
+
// id = 0;
|
38
|
+
// const settlementRequests = [];
|
39
|
+
// let requestsParsedAccounts;
|
40
|
+
// do {
|
41
|
+
// const accountPubKeys = getSettlementRequestsPdas(owner, id, id + 10);
|
42
|
+
// requestsParsedAccounts = await getParsedMultipleAccountsInfo(
|
43
|
+
// client,
|
44
|
+
// settlementRequestStruct,
|
45
|
+
// accountPubKeys
|
46
|
+
// );
|
47
|
+
// settlementRequests.push(...requestsParsedAccounts);
|
48
|
+
// id += 10;
|
49
|
+
// } while (requestsParsedAccounts[requestsParsedAccounts.length]);
|
50
|
+
// console.log(
|
51
|
+
// 'constexecutor:FetcherExecutor= ~ settlementRequests:',
|
52
|
+
// settlementRequests
|
53
|
+
// );
|
54
|
+
const settlementRequests = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.settlementRequestStruct, constants_1.programId, (0, filters_1.settlementRequestFilter)(owner));
|
31
55
|
const usdcTokenPrice = yield cache.getTokenPrice(solana_1.usdcSolanaMint, portfolio_core_1.NetworkId.solana);
|
32
|
-
const
|
33
|
-
const
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
56
|
+
const elements = [];
|
57
|
+
const assets = [];
|
58
|
+
if (oldLpAccount && !oldLpAccount.liquidity.isZero()) {
|
59
|
+
const unlockStartedAt = new Date(oldLpAccount.lastAddLiquidityTimestamp.times(1000).toNumber());
|
60
|
+
const unlockingAt = new Date(unlockStartedAt.getTime() + thirtyDays);
|
61
|
+
const asset = Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(solana_1.usdcSolanaMint, oldLpAccount.liquidity.dividedBy(Math.pow(10, 6)).toNumber(), portfolio_core_1.NetworkId.solana, usdcTokenPrice)), { attributes: {
|
62
|
+
lockedUntil: unlockingAt.getTime(),
|
63
|
+
tags: ['depreciated'],
|
64
|
+
} });
|
65
|
+
elements.push({
|
39
66
|
type: portfolio_core_1.PortfolioElementType.multiple,
|
40
67
|
label: 'Deposit',
|
41
68
|
networkId: portfolio_core_1.NetworkId.solana,
|
42
69
|
platformId: constants_1.platformId,
|
43
70
|
data: { assets: [asset] },
|
44
71
|
value: asset.value,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
for (const lpPosition of lpPositions) {
|
75
|
+
if (!lpPosition || lpPosition.liquidity.isZero())
|
76
|
+
continue;
|
77
|
+
const unlockingAt = new Date(lpPosition.maturity.times(1000).toNumber());
|
78
|
+
const asset = Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(solana_1.usdcSolanaMint, lpPosition.liquidity.dividedBy(Math.pow(10, 6)).toNumber(), portfolio_core_1.NetworkId.solana, usdcTokenPrice)), { attributes: {
|
79
|
+
lockedUntil: unlockingAt.getTime(),
|
80
|
+
} });
|
81
|
+
assets.push(asset);
|
82
|
+
}
|
83
|
+
for (const settlementRequest of settlementRequests) {
|
84
|
+
if (!settlementRequest || settlementRequest.amount.isZero())
|
85
|
+
continue;
|
86
|
+
const unlockingAt = new Date(settlementRequest.maturity.times(1000).toNumber());
|
87
|
+
if (unlockingAt.getTime() < Date.now())
|
88
|
+
continue;
|
89
|
+
const asset = Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(solana_1.usdcSolanaMint, settlementRequest.amount.dividedBy(Math.pow(10, 6)).toNumber(), portfolio_core_1.NetworkId.solana, usdcTokenPrice)), { attributes: {
|
90
|
+
lockedUntil: unlockingAt.getTime(),
|
91
|
+
tags: ['Pending Withdraw'],
|
92
|
+
} });
|
93
|
+
assets.push(asset);
|
94
|
+
}
|
95
|
+
if (assets.length === 0)
|
96
|
+
return [];
|
97
|
+
return [
|
98
|
+
{
|
99
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
100
|
+
label: 'Deposit',
|
101
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
102
|
+
platformId: constants_1.platformId,
|
103
|
+
data: { assets },
|
104
|
+
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
|
45
105
|
},
|
46
106
|
];
|
47
107
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,2CAAoD;AACpD,iDAAsD;AACtD,+CAI4B;AAC5B,uCAImB;AACnB,qGAA6E;AAC7E,uCAAmE;AACnE,kFAA+E;AAC/E,uCAAoD;AAEpD,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAE5C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,YAAY,GAAG,MAAM,IAAA,2CAAoB,EAC7C,MAAM,EACN,yBAAe,EACf,IAAA,4BAAkB,EAAC,KAAK,CAAC,CAC1B,CAAC;IAEF,I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@@ -1,2 +1,4 @@
|
|
1
1
|
import { GetProgramAccountsFilter } from '@solana/web3.js';
|
2
2
|
export declare const lpAccountFilter: (owner: string) => GetProgramAccountsFilter[];
|
3
|
+
export declare const lpPositionFilter: (owner: string) => GetProgramAccountsFilter[];
|
4
|
+
export declare const settlementRequestFilter: (owner: string) => GetProgramAccountsFilter[];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.lpAccountFilter = void 0;
|
3
|
+
exports.settlementRequestFilter = exports.lpPositionFilter = exports.lpAccountFilter = void 0;
|
4
4
|
const structs_1 = require("./structs");
|
5
5
|
const lpAccountFilter = (owner) => [
|
6
6
|
{
|
@@ -14,4 +14,28 @@ const lpAccountFilter = (owner) => [
|
|
14
14
|
},
|
15
15
|
];
|
16
16
|
exports.lpAccountFilter = lpAccountFilter;
|
17
|
+
const lpPositionFilter = (owner) => [
|
18
|
+
{
|
19
|
+
memcmp: {
|
20
|
+
offset: 72,
|
21
|
+
bytes: owner,
|
22
|
+
},
|
23
|
+
},
|
24
|
+
{
|
25
|
+
dataSize: structs_1.lpPositionStruct.byteSize,
|
26
|
+
},
|
27
|
+
];
|
28
|
+
exports.lpPositionFilter = lpPositionFilter;
|
29
|
+
const settlementRequestFilter = (owner) => [
|
30
|
+
{
|
31
|
+
memcmp: {
|
32
|
+
offset: 72,
|
33
|
+
bytes: owner,
|
34
|
+
},
|
35
|
+
},
|
36
|
+
{
|
37
|
+
dataSize: structs_1.settlementRequestStruct.byteSize,
|
38
|
+
},
|
39
|
+
];
|
40
|
+
exports.settlementRequestFilter = settlementRequestFilter;
|
17
41
|
//# sourceMappingURL=filters.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/filters.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/filters.ts"],"names":[],"mappings":";;;AACA,uCAImB;AAEZ,MAAM,eAAe,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IAC5E;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;IACD;QACE,QAAQ,EAAE,yBAAe,CAAC,QAAQ;KACnC;CACF,CAAC;AAVW,QAAA,eAAe,mBAU1B;AAEK,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IAC7E;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;IACD;QACE,QAAQ,EAAE,0BAAgB,CAAC,QAAQ;KACpC;CACF,CAAC;AAVW,QAAA,gBAAgB,oBAU3B;AAEK,MAAM,uBAAuB,GAAG,CACrC,KAAa,EACe,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;IACD;QACE,QAAQ,EAAE,iCAAuB,CAAC,QAAQ;KAC3C;CACF,CAAC;AAZW,QAAA,uBAAuB,2BAYlC"}
|
@@ -1,2 +1,4 @@
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
|
-
export declare function
|
2
|
+
export declare function getOldLpAccountPda(owner: string): PublicKey;
|
3
|
+
export declare function getLpPositionsPdas(owner: string, start: number, end: number): PublicKey[];
|
4
|
+
export declare function getSettlementRequestsPdas(owner: string, start: number, end: number): PublicKey[];
|
@@ -1,14 +1,41 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.getSettlementRequestsPdas = exports.getLpPositionsPdas = exports.getOldLpAccountPda = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
|
+
const bn_js_1 = require("bn.js");
|
5
6
|
const constants_1 = require("./constants");
|
6
|
-
function
|
7
|
+
function getOldLpAccountPda(owner) {
|
7
8
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
8
9
|
Buffer.from('lp_account', 'utf-8'),
|
9
10
|
new web3_js_1.PublicKey('82dGS7Jt4Km8ZgwZVRsJ2V6vPXEhVdgDaMP7cqPGG1TW').toBuffer(),
|
10
11
|
new web3_js_1.PublicKey(owner).toBuffer(),
|
11
12
|
], constants_1.programId)[0];
|
12
13
|
}
|
13
|
-
exports.
|
14
|
+
exports.getOldLpAccountPda = getOldLpAccountPda;
|
15
|
+
function getLpPositionsPdas(owner, start, end) {
|
16
|
+
const keys = [];
|
17
|
+
for (let i = start; i < end; i++) {
|
18
|
+
keys.push(web3_js_1.PublicKey.findProgramAddressSync([
|
19
|
+
Buffer.from('lp_position', 'utf-8'),
|
20
|
+
new web3_js_1.PublicKey('82dGS7Jt4Km8ZgwZVRsJ2V6vPXEhVdgDaMP7cqPGG1TW').toBuffer(),
|
21
|
+
new web3_js_1.PublicKey(owner).toBuffer(),
|
22
|
+
new bn_js_1.BN(i).toArrayLike(Buffer, 'le', 8),
|
23
|
+
], constants_1.programId)[0]);
|
24
|
+
}
|
25
|
+
return keys;
|
26
|
+
}
|
27
|
+
exports.getLpPositionsPdas = getLpPositionsPdas;
|
28
|
+
function getSettlementRequestsPdas(owner, start, end) {
|
29
|
+
const keys = [];
|
30
|
+
for (let i = start; i < end; i++) {
|
31
|
+
keys.push(web3_js_1.PublicKey.findProgramAddressSync([
|
32
|
+
Buffer.from('settlement_request', 'utf-8'),
|
33
|
+
new web3_js_1.PublicKey('82dGS7Jt4Km8ZgwZVRsJ2V6vPXEhVdgDaMP7cqPGG1TW').toBuffer(),
|
34
|
+
new web3_js_1.PublicKey(owner).toBuffer(),
|
35
|
+
new bn_js_1.BN(i).toArrayLike(Buffer, 'le', 8),
|
36
|
+
], constants_1.programId)[0]);
|
37
|
+
}
|
38
|
+
return keys;
|
39
|
+
}
|
40
|
+
exports.getSettlementRequestsPdas = getSettlementRequestsPdas;
|
14
41
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/helpers.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,2CAAwC;AAExC,SAAgB,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/helpers.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,iCAA2B;AAC3B,2CAAwC;AAExC,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,mBAAS,CAAC,sBAAsB,CACrC;QACE,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;QAClC,IAAI,mBAAS,CAAC,8CAA8C,CAAC,CAAC,QAAQ,EAAE;QACxE,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;KAChC,EACD,qBAAS,CACV,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AATD,gDASC;AAED,SAAgB,kBAAkB,CAChC,KAAa,EACb,KAAa,EACb,GAAW;IAEX,MAAM,IAAI,GAAgB,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CACP,mBAAS,CAAC,sBAAsB,CAC9B;YACE,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;YACnC,IAAI,mBAAS,CACX,8CAA8C,CAC/C,CAAC,QAAQ,EAAE;YACZ,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;YAC/B,IAAI,UAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SACvC,EACD,qBAAS,CACV,CAAC,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAtBD,gDAsBC;AAED,SAAgB,yBAAyB,CACvC,KAAa,EACb,KAAa,EACb,GAAW;IAEX,MAAM,IAAI,GAAgB,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CACP,mBAAS,CAAC,sBAAsB,CAC9B;YACE,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC;YAC1C,IAAI,mBAAS,CACX,8CAA8C,CAC/C,CAAC,QAAQ,EAAE;YACZ,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;YAC/B,IAAI,UAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SACvC,EACD,qBAAS,CACV,CAAC,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAtBD,8DAsBC"}
|
@@ -14,3 +14,27 @@ export type LpAccount = {
|
|
14
14
|
padding: number[];
|
15
15
|
};
|
16
16
|
export declare const lpAccountStruct: BeetStruct<LpAccount, Partial<LpAccount>>;
|
17
|
+
export type LpPosition = {
|
18
|
+
buffer: Buffer;
|
19
|
+
id: BigNumber;
|
20
|
+
liquidity: BigNumber;
|
21
|
+
shares: BigNumber;
|
22
|
+
maturity: BigNumber;
|
23
|
+
exchange: PublicKey;
|
24
|
+
owner: PublicKey;
|
25
|
+
bump: number;
|
26
|
+
padding: number[];
|
27
|
+
};
|
28
|
+
export declare const lpPositionStruct: BeetStruct<LpPosition, Partial<LpPosition>>;
|
29
|
+
export type SettlementRequest = {
|
30
|
+
buffer: Buffer;
|
31
|
+
id: BigNumber;
|
32
|
+
maturity: BigNumber;
|
33
|
+
amount: BigNumber;
|
34
|
+
keeperTip: BigNumber;
|
35
|
+
exchange: PublicKey;
|
36
|
+
owner: PublicKey;
|
37
|
+
ownerTokenAccount: PublicKey;
|
38
|
+
bump: Buffer;
|
39
|
+
};
|
40
|
+
export declare const settlementRequestStruct: BeetStruct<SettlementRequest, Partial<SettlementRequest>>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.lpAccountStruct = void 0;
|
3
|
+
exports.settlementRequestStruct = exports.lpPositionStruct = exports.lpAccountStruct = void 0;
|
4
4
|
const beet_1 = require("@metaplex-foundation/beet");
|
5
5
|
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
6
6
|
const solana_1 = require("../../utils/solana");
|
@@ -15,4 +15,26 @@ exports.lpAccountStruct = new beet_1.BeetStruct([
|
|
15
15
|
['bump', beet_1.u8],
|
16
16
|
['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 7)],
|
17
17
|
], (args) => args);
|
18
|
+
exports.lpPositionStruct = new beet_1.BeetStruct([
|
19
|
+
['buffer', (0, solana_1.blob)(8)],
|
20
|
+
['id', solana_1.u64],
|
21
|
+
['liquidity', solana_1.u64],
|
22
|
+
['shares', solana_1.u64],
|
23
|
+
['maturity', solana_1.u64],
|
24
|
+
['exchange', beet_solana_1.publicKey],
|
25
|
+
['owner', beet_solana_1.publicKey],
|
26
|
+
['bump', beet_1.u8],
|
27
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 7)],
|
28
|
+
], (args) => args);
|
29
|
+
exports.settlementRequestStruct = new beet_1.BeetStruct([
|
30
|
+
['buffer', (0, solana_1.blob)(8)],
|
31
|
+
['id', solana_1.u64],
|
32
|
+
['maturity', solana_1.u64],
|
33
|
+
['amount', solana_1.u64],
|
34
|
+
['keeperTip', solana_1.u64],
|
35
|
+
['exchange', beet_solana_1.publicKey],
|
36
|
+
['owner', beet_solana_1.publicKey],
|
37
|
+
['ownerTokenAccount', beet_solana_1.publicKey],
|
38
|
+
['bump', (0, solana_1.blob)(8)],
|
39
|
+
], (args) => args);
|
18
40
|
//# sourceMappingURL=structs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/structs.ts"],"names":[],"mappings":";;;AAAA,oDAImC;AACnC,kEAA6D;AAG7D,+CAA+C;AAclC,QAAA,eAAe,GAAG,IAAI,iBAAU,CAC3C;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,QAAQ,EAAE,YAAG,CAAC;IACf,CAAC,2BAA2B,EAAE,YAAG,CAAC;IAClC,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;CAC1C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAiB,CAC5B,CAAC"}
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/structs.ts"],"names":[],"mappings":";;;AAAA,oDAImC;AACnC,kEAA6D;AAG7D,+CAA+C;AAclC,QAAA,eAAe,GAAG,IAAI,iBAAU,CAC3C;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,QAAQ,EAAE,YAAG,CAAC;IACf,CAAC,2BAA2B,EAAE,YAAG,CAAC;IAClC,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;CAC1C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAiB,CAC5B,CAAC;AAcW,QAAA,gBAAgB,GAAG,IAAI,iBAAU,CAC5C;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,IAAI,EAAE,YAAG,CAAC;IACX,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,QAAQ,EAAE,YAAG,CAAC;IACf,CAAC,UAAU,EAAE,YAAG,CAAC;IACjB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;CAC1C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAkB,CAC7B,CAAC;AAcW,QAAA,uBAAuB,GAAG,IAAI,iBAAU,CACnD;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,IAAI,EAAE,YAAG,CAAC;IACX,CAAC,UAAU,EAAE,YAAG,CAAC;IACjB,CAAC,QAAQ,EAAE,YAAG,CAAC;IACf,CAAC,WAAW,EAAE,YAAG,CAAC;IAClB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,mBAAmB,EAAE,uBAAS,CAAC;IAChC,CAAC,MAAM,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;CAClB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAyB,CACpC,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;
|
@@ -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;
|