@triadxyz/triad-protocol 0.1.1-alpha.4 → 0.1.1-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
2
  import { Connection, PublicKey } from '@solana/web3.js';
4
3
  import { TriadProtocol } from './types/triad_protocol';
@@ -10,34 +9,5 @@ export default class TriadProtocolClient {
10
9
  ticker: Ticker;
11
10
  vault: Vault;
12
11
  constructor(connection: Connection, wallet: Wallet);
13
- getUserPositions: (userWallet: PublicKey) => Promise<{
14
- ticker: import("@coral-xyz/anchor").ProgramAccount<{
15
- initTs: import("bn.js");
16
- updatedTs: import("bn.js");
17
- bump: number;
18
- authority: PublicKey;
19
- name: string;
20
- protocolProgramId: PublicKey;
21
- price: import("bn.js");
22
- vault: PublicKey;
23
- }>;
24
- position: {
25
- ts: import("bn.js");
26
- bump: number;
27
- totalDeposited: import("bn.js");
28
- totalWithdrawn: import("bn.js");
29
- lpShare: import("bn.js");
30
- totalPositions: number;
31
- ticker: PublicKey;
32
- authority: PublicKey;
33
- positions: {
34
- amount: import("bn.js");
35
- entryPrice: import("bn.js");
36
- ts: import("bn.js");
37
- isLong: boolean;
38
- isOpen: boolean;
39
- pnl: import("bn.js");
40
- }[];
41
- };
42
- }[]>;
12
+ getUserPositions: (userWallet: PublicKey) => Promise<{}[]>;
43
13
  }
package/dist/index.js CHANGED
@@ -22,14 +22,23 @@ class TriadProtocolClient {
22
22
  constructor(connection, wallet) {
23
23
  this.getUserPositions = (userWallet) => __awaiter(this, void 0, void 0, function* () {
24
24
  const tickers = yield this.ticker.getTickers();
25
- const positions = yield Promise.all(tickers.map((ticker) => __awaiter(this, void 0, void 0, function* () {
26
- const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, userWallet, ticker.publicKey);
27
- const position = yield this.program.account.userPosition.fetch(UserPositionPDA);
28
- return {
29
- ticker,
30
- position
31
- };
32
- })));
25
+ const positions = yield Promise.all(tickers
26
+ .map((ticker) => __awaiter(this, void 0, void 0, function* () {
27
+ let data = {};
28
+ try {
29
+ const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, userWallet, ticker.publicKey);
30
+ const position = yield this.program.account.userPosition.fetch(UserPositionPDA);
31
+ data = {
32
+ ticker,
33
+ position
34
+ };
35
+ }
36
+ catch (_a) {
37
+ return;
38
+ }
39
+ return data;
40
+ }))
41
+ .filter(Boolean));
33
42
  return positions;
34
43
  });
35
44
  this.provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.1.1-alpha.4",
3
+ "version": "0.1.1-alpha.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",