@triadxyz/triad-protocol 0.1.1-alpha.2 → 0.1.1-alpha.5

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
@@ -23,12 +23,17 @@ class TriadProtocolClient {
23
23
  this.getUserPositions = (userWallet) => __awaiter(this, void 0, void 0, function* () {
24
24
  const tickers = yield this.ticker.getTickers();
25
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
- };
26
+ let data = {};
27
+ try {
28
+ const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, userWallet, ticker.publicKey);
29
+ const position = yield this.program.account.userPosition.fetch(UserPositionPDA);
30
+ data = {
31
+ ticker,
32
+ position
33
+ };
34
+ }
35
+ catch (_a) { }
36
+ return data;
32
37
  })));
33
38
  return positions;
34
39
  });
package/dist/ticker.d.ts CHANGED
@@ -31,4 +31,14 @@ export default class Ticker {
31
31
  protocolProgramId: PublicKey;
32
32
  tokenMint: PublicKey;
33
33
  }): Promise<string>;
34
+ /**
35
+ * Update a ticker's price
36
+ * @param name - The ticker's name
37
+ * @param price - The ticker's price
38
+ *
39
+ */
40
+ updateTickerPrice({ name, price }: {
41
+ name: string;
42
+ price: string;
43
+ }): Promise<string>;
34
44
  }
package/dist/ticker.js CHANGED
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const helpers_1 = require("./utils/helpers");
13
+ const bn_js_1 = require("bn.js");
13
14
  class Ticker {
14
15
  constructor(program, provider) {
15
16
  this.provider = provider;
@@ -47,5 +48,23 @@ class Ticker {
47
48
  .rpc();
48
49
  });
49
50
  }
51
+ /**
52
+ * Update a ticker's price
53
+ * @param name - The ticker's name
54
+ * @param price - The ticker's price
55
+ *
56
+ */
57
+ updateTickerPrice({ name, price }) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const TickerPDA = (0, helpers_1.getTickerAddressSync)(this.program.programId, name);
60
+ return this.program.methods
61
+ .updateTickerPrice({ price: new bn_js_1.BN(price) })
62
+ .accounts({
63
+ signer: this.provider.wallet.publicKey,
64
+ ticker: TickerPDA
65
+ })
66
+ .rpc();
67
+ });
68
+ }
50
69
  }
51
70
  exports.default = Ticker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.1.1-alpha.2",
3
+ "version": "0.1.1-alpha.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",