@triadxyz/triad-protocol 0.1.1-alpha.4 → 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 +1 -31
- package/dist/index.js +11 -6
- package/package.json +1 -1
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
});
|