@sonarwatch/portfolio-plugins 0.12.179 → 0.12.180
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1510 -1506
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/loopscale/constants.d.ts +3 -1
- package/src/plugins/loopscale/constants.js +4 -4
- package/src/plugins/loopscale/constants.js.map +1 -1
- package/src/plugins/loopscale/filters.d.ts +7 -0
- package/src/plugins/loopscale/filters.js +62 -0
- package/src/plugins/loopscale/filters.js.map +1 -0
- package/src/plugins/loopscale/helpers.d.ts +33 -0
- package/src/plugins/loopscale/helpers.js +162 -0
- package/src/plugins/loopscale/helpers.js.map +1 -0
- package/src/plugins/loopscale/index.js +1 -2
- package/src/plugins/loopscale/index.js.map +1 -1
- package/src/plugins/loopscale/positionsFetcher.js +89 -40
- package/src/plugins/loopscale/positionsFetcher.js.map +1 -1
- package/src/plugins/loopscale/structs.d.ts +95 -14
- package/src/plugins/loopscale/structs.js +87 -13
- package/src/plugins/loopscale/structs.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/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/plugins/loopscale/marketsJob.d.ts +0 -3
- package/src/plugins/loopscale/marketsJob.js +0 -26
- package/src/plugins/loopscale/marketsJob.js.map +0 -1
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
package/src/index.js
CHANGED
@@ -146,6 +146,7 @@ const elemental_1 = require("./plugins/elemental");
|
|
146
146
|
const adrena_1 = require("./plugins/adrena");
|
147
147
|
const joule_1 = require("./plugins/joule");
|
148
148
|
const meso_1 = require("./plugins/meso");
|
149
|
+
const loopscale_1 = require("./plugins/loopscale");
|
149
150
|
var constants_1 = require("./plugins/tokens/constants");
|
150
151
|
Object.defineProperty(exports, "walletTokensPlatform", { enumerable: true, get: function () { return constants_1.walletTokensPlatform; } });
|
151
152
|
Object.defineProperty(exports, "walletNftsPlatform", { enumerable: true, get: function () { return constants_1.walletNftsPlatform; } });
|
@@ -285,6 +286,7 @@ exports.platforms = [
|
|
285
286
|
...adrena_1.platforms,
|
286
287
|
...joule_1.platforms,
|
287
288
|
...meso_1.platforms,
|
289
|
+
...loopscale_1.platforms,
|
288
290
|
];
|
289
291
|
// JOBS //
|
290
292
|
exports.jobs = [
|
@@ -407,6 +409,7 @@ exports.jobs = [
|
|
407
409
|
...adrena_1.jobs,
|
408
410
|
...joule_1.jobs,
|
409
411
|
...meso_1.jobs,
|
412
|
+
...loopscale_1.jobs,
|
410
413
|
];
|
411
414
|
// FETCHERS //
|
412
415
|
exports.fetchers = [
|
@@ -531,6 +534,7 @@ exports.fetchers = [
|
|
531
534
|
...adrena_1.fetchers,
|
532
535
|
...joule_1.fetchers,
|
533
536
|
...meso_1.fetchers,
|
537
|
+
...loopscale_1.fetchers,
|
534
538
|
];
|
535
539
|
exports.fetchersByAddressSystem = (0, getFetchersByAddressSystem_1.getFetchersByAddressSystem)(exports.fetchers);
|
536
540
|
exports.airdropFetchers = [
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/plugins/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,wFAAqF;AACrF,wEAAgD;AAChD,6CAI0B;AAC1B,yDAIgC;AAChC,uDAAgE;AAChE,iDAG4B;AAC5B,iDAI4B;AAC5B,2CAGyB;AACzB,yCAIwB;AACxB,+CAI2B;AAC3B,yCAIwB;AACxB,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IACnB,GAAG,oBAAiB;IACpB,GAAG,iBAAc;IACjB,GAAG,gBAAa;IAChB,GAAG,eAAY;IACf,GAAG,oBAAiB;CACrB,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,uDAA0B,EAAC,gBAAQ,CAAC,CAAC;AAE/D,QAAA,eAAe,GAAqB;IAC/C,GAAG,yBAAsB;IACzB,GAAG,wBAAqB;IACxB,GAAG,yBAAsB;IACzB,sBAAmB;IACnB,sBAAmB;IACnB,yBAAsB;IACtB,sBAAmB;IACnB,GAAG,0BAAuB;CAC3B,CAAC;AACW,QAAA,8BAA8B,GACzC,IAAA,uDAA0B,EAAC,uBAAe,CAAC,CAAC"}
|
@@ -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;
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Platform } from '@sonarwatch/portfolio-core';
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
2
3
|
export declare const platformId = "loopscale";
|
3
4
|
export declare const platform: Platform;
|
4
5
|
export declare const marketsCachePrefix = "loopscale-markets";
|
5
|
-
export declare const
|
6
|
+
export declare const creditbookProgramId: PublicKey;
|
7
|
+
export declare const lockboxProgramId: PublicKey;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.lockboxProgramId = exports.creditbookProgramId = exports.marketsCachePrefix = exports.platform = exports.platformId = void 0;
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
4
5
|
exports.platformId = 'loopscale';
|
5
6
|
exports.platform = {
|
6
7
|
id: exports.platformId,
|
@@ -11,7 +12,6 @@ exports.platform = {
|
|
11
12
|
// defiLlamaId: 'foo-finance', // from https://defillama.com/docs/api
|
12
13
|
};
|
13
14
|
exports.marketsCachePrefix = `${exports.platformId}-markets`;
|
14
|
-
exports.
|
15
|
-
|
16
|
-
// deposit lend tx : https://solana.fm/tx/2dRBwkQX3QArnMdEocYhRs3Drni2LR1cWDonsLKX3ks4dvjRXLSDzSx5T4ar5fTU1CjZDJT8kSJq5ADHyn7kRySM?cluster=mainnet-alpha
|
15
|
+
exports.creditbookProgramId = new web3_js_1.PublicKey('abfcSQac2vK2Pa6UAJb37DzarVxF15bDTdphJzAqYYp');
|
16
|
+
exports.lockboxProgramId = new web3_js_1.PublicKey('1oCkVqJ2uk4SuHyCuZKi8q3J6gjoe9Pux3XvHnHFVy4');
|
17
17
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/constants.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE/B,QAAA,UAAU,GAAG,WAAW,CAAC;AACzB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,kDAAkD;IACzD,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,6BAA6B;IACtC,qEAAqE;CACtE,CAAC;AACW,QAAA,kBAAkB,GAAG,GAAG,kBAAU,UAAU,CAAC;AAE7C,QAAA,mBAAmB,GAAG,IAAI,mBAAS,CAC9C,6CAA6C,CAC9C,CAAC;AACW,QAAA,gBAAgB,GAAG,IAAI,mBAAS,CAC3C,6CAA6C,CAC9C,CAAC"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { GetProgramAccountsFilter } from '@solana/web3.js';
|
2
|
+
export declare const roleFilters: (owner: string) => GetProgramAccountsFilter[];
|
3
|
+
export declare const escrowFilters: (organization_identifier: string) => GetProgramAccountsFilter[];
|
4
|
+
export declare const orderFilters: (organization_identifier: string) => GetProgramAccountsFilter[];
|
5
|
+
export declare const loanVaultLentFilters: (borrower: string) => GetProgramAccountsFilter[];
|
6
|
+
export declare const loanVaultBorrowedFilters: (borrower: string) => GetProgramAccountsFilter[];
|
7
|
+
export declare const lockboxFilters: (nft: string) => GetProgramAccountsFilter[];
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.lockboxFilters = exports.loanVaultBorrowedFilters = exports.loanVaultLentFilters = exports.orderFilters = exports.escrowFilters = exports.roleFilters = void 0;
|
4
|
+
const roleFilters = (owner) => [
|
5
|
+
{
|
6
|
+
memcmp: {
|
7
|
+
offset: 8,
|
8
|
+
bytes: owner,
|
9
|
+
},
|
10
|
+
},
|
11
|
+
];
|
12
|
+
exports.roleFilters = roleFilters;
|
13
|
+
const escrowFilters = (organization_identifier) => [
|
14
|
+
{
|
15
|
+
memcmp: {
|
16
|
+
offset: 8,
|
17
|
+
bytes: organization_identifier,
|
18
|
+
},
|
19
|
+
},
|
20
|
+
{ dataSize: 208 },
|
21
|
+
];
|
22
|
+
exports.escrowFilters = escrowFilters;
|
23
|
+
const orderFilters = (organization_identifier) => [
|
24
|
+
{
|
25
|
+
memcmp: {
|
26
|
+
offset: 73,
|
27
|
+
bytes: organization_identifier,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
{ dataSize: 355 },
|
31
|
+
];
|
32
|
+
exports.orderFilters = orderFilters;
|
33
|
+
const loanVaultLentFilters = (borrower) => [
|
34
|
+
{
|
35
|
+
memcmp: {
|
36
|
+
offset: 8 + 32,
|
37
|
+
bytes: borrower,
|
38
|
+
},
|
39
|
+
},
|
40
|
+
{ dataSize: 338 },
|
41
|
+
];
|
42
|
+
exports.loanVaultLentFilters = loanVaultLentFilters;
|
43
|
+
const loanVaultBorrowedFilters = (borrower) => [
|
44
|
+
{
|
45
|
+
memcmp: {
|
46
|
+
offset: 8 + 32 + 32,
|
47
|
+
bytes: borrower,
|
48
|
+
},
|
49
|
+
},
|
50
|
+
{ dataSize: 338 },
|
51
|
+
];
|
52
|
+
exports.loanVaultBorrowedFilters = loanVaultBorrowedFilters;
|
53
|
+
const lockboxFilters = (nft) => [
|
54
|
+
{
|
55
|
+
memcmp: {
|
56
|
+
offset: 52,
|
57
|
+
bytes: nft,
|
58
|
+
},
|
59
|
+
},
|
60
|
+
];
|
61
|
+
exports.lockboxFilters = lockboxFilters;
|
62
|
+
//# sourceMappingURL=filters.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/filters.ts"],"names":[],"mappings":";;;AAEO,MAAM,W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@ -0,0 +1,33 @@
|
|
1
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
2
|
+
import { ParsedAccount } from '../../utils/solana';
|
3
|
+
import { EscrowAccount, Ledger, LoanVault, Order } from './structs';
|
4
|
+
export declare const getAdminOrgs: (connection: Connection, owner: string) => Promise<PublicKey[]>;
|
5
|
+
export declare const getEscrows: (connection: Connection, adminOrgs: PublicKey[]) => Promise<ParsedAccount<EscrowAccount>[]>;
|
6
|
+
export declare const getLoanVaults: (connection: Connection, escrowAccounts: ParsedAccount<EscrowAccount>[]) => Promise<{
|
7
|
+
loansLent: ParsedAccount<LoanVault>[][];
|
8
|
+
loansBorrowed: ParsedAccount<LoanVault>[][];
|
9
|
+
}>;
|
10
|
+
export declare const getOrdersForLoans: (connection: Connection, loans: ParsedAccount<LoanVault>[]) => Promise<{
|
11
|
+
order: ParsedAccount<Order> | null;
|
12
|
+
ledgers: Ledger[];
|
13
|
+
orderAddress: PublicKey;
|
14
|
+
}[]>;
|
15
|
+
export declare const getLenderOrderValues: (orders: {
|
16
|
+
order: ParsedAccount<Order> | null;
|
17
|
+
ledgers: Ledger[];
|
18
|
+
orderAddress: PublicKey;
|
19
|
+
}[]) => Balances;
|
20
|
+
export declare const getBorrowerOrderValues: (orders: {
|
21
|
+
order: ParsedAccount<Order> | null;
|
22
|
+
ledgers: Ledger[];
|
23
|
+
orderAddress: PublicKey;
|
24
|
+
}[]) => Balances;
|
25
|
+
export declare const getBorrowerCollateralValues: (connection: Connection, orders: {
|
26
|
+
order: ParsedAccount<Order> | null;
|
27
|
+
ledgers: Ledger[];
|
28
|
+
orderAddress: PublicKey;
|
29
|
+
}[]) => Promise<Balances>;
|
30
|
+
export declare const getTokensBalance: (owner: string) => Promise<Balances>;
|
31
|
+
export type Balances = {
|
32
|
+
[key: string]: number;
|
33
|
+
};
|
@@ -0,0 +1,162 @@
|
|
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.getTokensBalance = exports.getBorrowerCollateralValues = exports.getBorrowerOrderValues = exports.getLenderOrderValues = exports.getOrdersForLoans = exports.getLoanVaults = exports.getEscrows = exports.getAdminOrgs = void 0;
|
16
|
+
const web3_js_1 = require("@solana/web3.js");
|
17
|
+
const solana_1 = require("../../utils/solana");
|
18
|
+
const constants_1 = require("./constants");
|
19
|
+
const structs_1 = require("./structs");
|
20
|
+
const filters_1 = require("./filters");
|
21
|
+
const getSolanaDasEndpoint_1 = __importDefault(require("../../utils/clients/getSolanaDasEndpoint"));
|
22
|
+
const getAssetsByOwnerDas_1 = require("../../utils/solana/das/getAssetsByOwnerDas");
|
23
|
+
const isHeliusFungibleAsset_1 = require("../../utils/solana/das/isHeliusFungibleAsset");
|
24
|
+
const getAdminOrgs = (connection, owner) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
+
const roles = yield (0, solana_1.getParsedProgramAccounts)(connection, structs_1.roleAccountStruct, constants_1.creditbookProgramId, (0, filters_1.roleFilters)(owner));
|
26
|
+
return roles
|
27
|
+
.filter((r) => r.type === 4 || r.type === 5)
|
28
|
+
.map((r) => r.organization);
|
29
|
+
});
|
30
|
+
exports.getAdminOrgs = getAdminOrgs;
|
31
|
+
const getEscrows = (connection, adminOrgs) => __awaiter(void 0, void 0, void 0, function* () {
|
32
|
+
return (yield Promise.all(adminOrgs.map((organizationIdentifier) => (0, solana_1.getParsedProgramAccounts)(connection, structs_1.escrowAccountStruct, constants_1.creditbookProgramId, (0, filters_1.escrowFilters)(organizationIdentifier.toString()))))).flat();
|
33
|
+
});
|
34
|
+
exports.getEscrows = getEscrows;
|
35
|
+
const getLoanVaults = (connection, escrowAccounts) => __awaiter(void 0, void 0, void 0, function* () {
|
36
|
+
const [loansBorrowed, loansLent] = yield Promise.all([
|
37
|
+
yield Promise.all(escrowAccounts.map((escrowAccount) => (0, solana_1.getParsedProgramAccounts)(connection, structs_1.loanVaultStruct, constants_1.creditbookProgramId, (0, filters_1.loanVaultBorrowedFilters)(escrowAccount.pubkey.toString())))),
|
38
|
+
yield Promise.all(escrowAccounts.map((escrowAccount) => (0, solana_1.getParsedProgramAccounts)(connection, structs_1.loanVaultStruct, constants_1.creditbookProgramId, (0, filters_1.loanVaultLentFilters)(escrowAccount.pubkey.toString())))),
|
39
|
+
]);
|
40
|
+
return {
|
41
|
+
loansLent,
|
42
|
+
loansBorrowed,
|
43
|
+
};
|
44
|
+
});
|
45
|
+
exports.getLoanVaults = getLoanVaults;
|
46
|
+
const getOrdersForLoans = (connection, loans) => __awaiter(void 0, void 0, void 0, function* () {
|
47
|
+
const orderAddresses = loans.map((l) => l.order);
|
48
|
+
const orders = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, structs_1.orderStruct, orderAddresses);
|
49
|
+
const orderLedgerAddresses = orderAddresses.map((o) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('order_ledgers'), o.toBytes()], constants_1.creditbookProgramId)[0]);
|
50
|
+
const orderLedgers = yield (0, solana_1.getParsedMultipleAccountsInfo)(connection, structs_1.orderLedgerStruct, orderLedgerAddresses);
|
51
|
+
const orderData = [];
|
52
|
+
for (let i = 0; i < orderAddresses.length; i++) {
|
53
|
+
const order = orders[i];
|
54
|
+
const orderLedger = orderLedgers[i];
|
55
|
+
if (!orderLedger)
|
56
|
+
continue;
|
57
|
+
const { ledgers } = orderLedger;
|
58
|
+
const orderAddress = orderAddresses[i];
|
59
|
+
orderData.push({ order, ledgers, orderAddress });
|
60
|
+
}
|
61
|
+
return orderData;
|
62
|
+
});
|
63
|
+
exports.getOrdersForLoans = getOrdersForLoans;
|
64
|
+
const getLenderOrderValues = (orders) => {
|
65
|
+
const loanValues = {};
|
66
|
+
for (let i = 0; i < orders.length; i++) {
|
67
|
+
const order = orders[i];
|
68
|
+
if (!order.order || !order.order.principal_mint)
|
69
|
+
continue;
|
70
|
+
const principal = order.order.principal_mint.toString();
|
71
|
+
const totalOwed = getOrderDueAmount(order.ledgers);
|
72
|
+
if (!Object.keys(loanValues).includes(principal)) {
|
73
|
+
loanValues[principal] = totalOwed;
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
loanValues[principal] += totalOwed;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return loanValues;
|
80
|
+
};
|
81
|
+
exports.getLenderOrderValues = getLenderOrderValues;
|
82
|
+
const getBorrowerOrderValues = (orders) => {
|
83
|
+
const loanValues = {};
|
84
|
+
for (let i = 0; i < orders.length; i++) {
|
85
|
+
const order = orders[i];
|
86
|
+
if (!order.order || !order.order.principal_mint)
|
87
|
+
continue;
|
88
|
+
const principal = order.order.principal_mint.toString();
|
89
|
+
const totalDue = getOrderDueAmount(order.ledgers);
|
90
|
+
if (!Object.keys(loanValues).includes(principal)) {
|
91
|
+
loanValues[principal] = totalDue;
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
loanValues[principal] += totalDue;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return loanValues;
|
98
|
+
};
|
99
|
+
exports.getBorrowerOrderValues = getBorrowerOrderValues;
|
100
|
+
function getOrderDueAmount(ledgers) {
|
101
|
+
return ledgers.reduce((prev, curr) => prev +
|
102
|
+
(curr.principal_due.toNumber() - curr.principal_repaid.toNumber()) +
|
103
|
+
(curr.interest_due.toNumber() - curr.interest_repaid.toNumber()), 0);
|
104
|
+
}
|
105
|
+
const getBorrowerCollateralValues = (connection, orders) => __awaiter(void 0, void 0, void 0, function* () {
|
106
|
+
const lbNfts = orders.map((o) => { var _a; return (_a = o.order) === null || _a === void 0 ? void 0 : _a.collateral_mint; });
|
107
|
+
const lockboxes = yield fetchLockboxesFromNFTs(connection, lbNfts.filter((p) => p !== null));
|
108
|
+
const balances = yield Promise.all(lockboxes.map((lockbox) => (0, exports.getTokensBalance)(lockbox.toString())));
|
109
|
+
return mergeBalances(balances);
|
110
|
+
});
|
111
|
+
exports.getBorrowerCollateralValues = getBorrowerCollateralValues;
|
112
|
+
const fetchLockboxesFromNFTs = (connection, nfts) => __awaiter(void 0, void 0, void 0, function* () {
|
113
|
+
const lbs = [];
|
114
|
+
for (let i = 0; i < nfts.length; i++) {
|
115
|
+
const lb = yield (0, solana_1.getParsedProgramAccounts)(connection, structs_1.lockboxStruct, constants_1.lockboxProgramId, (0, filters_1.lockboxFilters)(nfts[i].toString()));
|
116
|
+
if (lb.length > 0)
|
117
|
+
lbs.push(lb[0].pubkey);
|
118
|
+
}
|
119
|
+
return lbs;
|
120
|
+
});
|
121
|
+
const getTokensBalance = (owner) => __awaiter(void 0, void 0, void 0, function* () {
|
122
|
+
const dasEndpoint = (0, getSolanaDasEndpoint_1.default)();
|
123
|
+
const items = yield (0, getAssetsByOwnerDas_1.getAssetsByOwnerDas)(dasEndpoint, owner, {
|
124
|
+
showNativeBalance: false,
|
125
|
+
showGrandTotal: false,
|
126
|
+
showInscription: false,
|
127
|
+
});
|
128
|
+
const escrowValues = {};
|
129
|
+
items.filter(isHeliusFungibleAsset_1.isHeliusFungibleAsset).forEach((asset) => {
|
130
|
+
var _a;
|
131
|
+
if (!((_a = asset.token_info) === null || _a === void 0 ? void 0 : _a.balance))
|
132
|
+
return;
|
133
|
+
if (!Object.keys(escrowValues).includes(asset.id)) {
|
134
|
+
escrowValues[asset.id] = asset.token_info.balance;
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
escrowValues[asset.id] += asset.token_info.balance;
|
138
|
+
}
|
139
|
+
});
|
140
|
+
return escrowValues;
|
141
|
+
});
|
142
|
+
exports.getTokensBalance = getTokensBalance;
|
143
|
+
const mergeBalances = (balances) => {
|
144
|
+
if (!balances.length)
|
145
|
+
return {};
|
146
|
+
if (balances.length === 1)
|
147
|
+
return balances[0];
|
148
|
+
const mainBalance = balances[0];
|
149
|
+
for (let i = 1; i < balances.length; i++) {
|
150
|
+
Object.keys(balances[i]).forEach((mint) => {
|
151
|
+
const amount = balances[i][mint];
|
152
|
+
if (!Object.keys(mainBalance).includes(mint)) {
|
153
|
+
mainBalance[mint] = amount;
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
mainBalance[mint] += amount;
|
157
|
+
}
|
158
|
+
});
|
159
|
+
}
|
160
|
+
return mainBalance;
|
161
|
+
};
|
162
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAwD;AACxD,+CAI4B;AAC5B,2CAAoE;AACpE,uCAYmB;AACnB,uCAMmB;AACnB,oGAA4E;AAC5E,oFAAiF;AACjF,wFAAqF;AAE9E,MAAM,YAAY,GAAG,CAC1B,UAAsB,EACtB,KAAa,EACS,EAAE;IACxB,MAAM,KAAK,GAAG,MAAM,IAAA,iCAAwB,EAC1C,UAAU,EACV,2BAAiB,EACjB,+BAAmB,EACnB,IAAA,qBAAW,EAAC,KAAK,CAAC,CACnB,CAAC;IAEF,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;SAC3C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAA,CAAC;AAjBW,QAAA,gBAAgB,oBAiB3B;AAIF,MAAM,aAAa,GAAG,CAAC,QAAoB,EAAY,EAAE;IACvD,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7C,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC"}
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
7
|
const constants_1 = require("./constants");
|
8
|
-
const marketsJob_1 = __importDefault(require("./marketsJob"));
|
9
8
|
const positionsFetcher_1 = __importDefault(require("./positionsFetcher"));
|
10
9
|
exports.platforms = [constants_1.platform];
|
11
|
-
exports.jobs = [
|
10
|
+
exports.jobs = [];
|
12
11
|
exports.fetchers = [positionsFetcher_1.default];
|
13
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,0EAAkD;AAErC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,0BAAgB,CAAC,CAAC"}
|
@@ -13,54 +13,103 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
17
16
|
const constants_1 = require("./constants");
|
18
17
|
const clients_1 = require("../../utils/clients");
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
18
|
+
const helpers_1 = require("./helpers");
|
19
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
20
|
+
const depositsFetcher_1 = __importDefault(require("../marginfi/depositsFetcher"));
|
22
21
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
22
|
const connection = (0, clients_1.getClientSolana)();
|
24
|
-
const
|
25
|
-
|
26
|
-
dataSize: structs_1.liquidityStruct.byteSize,
|
27
|
-
},
|
28
|
-
{
|
29
|
-
memcmp: {
|
30
|
-
bytes: owner,
|
31
|
-
offset: 40,
|
32
|
-
},
|
33
|
-
},
|
34
|
-
]);
|
35
|
-
if (accounts.length === 0)
|
23
|
+
const adminOrgs = yield (0, helpers_1.getAdminOrgs)(connection, owner);
|
24
|
+
if (!adminOrgs.length)
|
36
25
|
return [];
|
37
|
-
const
|
38
|
-
|
39
|
-
accounts.forEach((acc) => {
|
40
|
-
if (acc.amountDeposited.isZero())
|
41
|
-
return;
|
42
|
-
const amount = acc.amountDeposited
|
43
|
-
.div(Math.pow(10, portfolio_core_1.solanaNativeDecimals))
|
44
|
-
.toNumber();
|
45
|
-
const asset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.solanaNativeAddress, amount, portfolio_core_1.NetworkId.solana, solTokenPrice);
|
46
|
-
assets.push(asset);
|
47
|
-
});
|
48
|
-
if (assets.length === 0)
|
26
|
+
const escrowAccounts = yield (0, helpers_1.getEscrows)(connection, adminOrgs);
|
27
|
+
if (!escrowAccounts.length)
|
49
28
|
return [];
|
50
|
-
const
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
data
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
29
|
+
const { loansLent, loansBorrowed } = yield (0, helpers_1.getLoanVaults)(connection, escrowAccounts);
|
30
|
+
const lenderLoanValues = [];
|
31
|
+
const borrowerLoanValues = [];
|
32
|
+
const borrowerCollateralValues = [];
|
33
|
+
for (const escrowAccount of escrowAccounts) {
|
34
|
+
const e = escrowAccounts.indexOf(escrowAccount);
|
35
|
+
const data = yield (0, helpers_1.getOrdersForLoans)(connection, [
|
36
|
+
...loansLent[e],
|
37
|
+
...loansBorrowed[e],
|
38
|
+
]);
|
39
|
+
const lenderOrders = [];
|
40
|
+
for (let i = 0; i < loansLent[e].length; i++) {
|
41
|
+
const loan = loansLent[e][i];
|
42
|
+
const order = data.find((o) => o.orderAddress.toString() === loan.order.toString());
|
43
|
+
if (order !== undefined &&
|
44
|
+
order.order &&
|
45
|
+
(order.order.status === 1 || order.order.status === 2))
|
46
|
+
lenderOrders.push(order);
|
47
|
+
}
|
48
|
+
const borrowerOrders = [];
|
49
|
+
for (let i = 0; i < loansBorrowed[e].length; i++) {
|
50
|
+
const loan = loansBorrowed[e][i];
|
51
|
+
const order = data.find((o) => o.orderAddress.toString() === loan.order.toString());
|
52
|
+
if (order !== undefined &&
|
53
|
+
order.order &&
|
54
|
+
(order.order.status === 1 || order.order.status === 2))
|
55
|
+
borrowerOrders.push(order);
|
56
|
+
}
|
57
|
+
lenderLoanValues.push((0, helpers_1.getLenderOrderValues)(lenderOrders));
|
58
|
+
borrowerLoanValues.push((0, helpers_1.getBorrowerOrderValues)(borrowerOrders));
|
59
|
+
borrowerCollateralValues.push(yield (0, helpers_1.getBorrowerCollateralValues)(connection, borrowerOrders));
|
60
|
+
}
|
61
|
+
const [escrowValues, escrowMarginfiElements] = yield Promise.all([
|
62
|
+
Promise.all(escrowAccounts.map((escrowAccount) => (0, helpers_1.getTokensBalance)(escrowAccount.pubkey.toString()))),
|
63
|
+
Promise.all(escrowAccounts.map((escrowAccount) => depositsFetcher_1.default.executor(escrowAccount.pubkey.toString(), cache))),
|
64
|
+
]);
|
65
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
66
|
+
escrowAccounts.forEach((escrowAccount, i) => {
|
67
|
+
const element = elementRegistry.addElementBorrowlend({
|
68
|
+
label: 'Lending',
|
69
|
+
name: Object.keys(borrowerLoanValues[i]).length > 0 ? 'Borrow' : 'Lend',
|
70
|
+
});
|
71
|
+
escrowMarginfiElements[i].forEach((marginfiElement) => {
|
72
|
+
if (marginfiElement.type === portfolio_core_1.PortfolioElementType.borrowlend) {
|
73
|
+
marginfiElement.data.suppliedAssets.forEach((asset) => {
|
74
|
+
if (asset.data.address && asset.data.amount) {
|
75
|
+
element.addSuppliedAsset({
|
76
|
+
address: asset.data.address,
|
77
|
+
amount: asset.data.amount,
|
78
|
+
alreadyShifted: true,
|
79
|
+
});
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
});
|
84
|
+
Object.keys(escrowValues[i]).forEach((address) => {
|
85
|
+
element.addSuppliedAsset({
|
86
|
+
address,
|
87
|
+
amount: escrowValues[i][address],
|
88
|
+
});
|
89
|
+
});
|
90
|
+
Object.keys(lenderLoanValues[i]).forEach((address) => {
|
91
|
+
element.addSuppliedAsset({
|
92
|
+
address,
|
93
|
+
amount: lenderLoanValues[i][address],
|
94
|
+
});
|
95
|
+
});
|
96
|
+
Object.keys(borrowerLoanValues[i]).forEach((address) => {
|
97
|
+
element.addBorrowedAsset({
|
98
|
+
address,
|
99
|
+
amount: borrowerLoanValues[i][address],
|
100
|
+
});
|
101
|
+
});
|
102
|
+
Object.keys(borrowerCollateralValues[i]).forEach((address) => {
|
103
|
+
element.addSuppliedAsset({
|
104
|
+
address,
|
105
|
+
amount: borrowerCollateralValues[i][address],
|
106
|
+
});
|
107
|
+
});
|
108
|
+
});
|
109
|
+
return elementRegistry.getElements(cache);
|
61
110
|
});
|
62
111
|
const fetcher = {
|
63
|
-
id: `${constants_1.platformId}-
|
112
|
+
id: `${constants_1.platformId}-positions`,
|
64
113
|
networkId: portfolio_core_1.NetworkId.solana,
|
65
114
|
executor,
|
66
115
|
};
|