@triadxyz/triad-protocol 0.1.2-alpha.6 → 0.1.2-alpha.8
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/vault.d.ts +5 -2
- package/dist/vault.js +13 -13
- package/package.json +1 -1
package/dist/vault.d.ts
CHANGED
|
@@ -52,12 +52,13 @@ export default class Vault {
|
|
|
52
52
|
* @param position - Long or Short
|
|
53
53
|
* @param mint - Token mint for the vault (e.g. USDC)
|
|
54
54
|
*/
|
|
55
|
-
openPosition({ tickerPDA, amount, position, mint
|
|
55
|
+
openPosition({ tickerPDA, amount, position, mint }: {
|
|
56
56
|
tickerPDA: PublicKey;
|
|
57
57
|
amount: string;
|
|
58
58
|
position: 'Long' | 'Short';
|
|
59
59
|
mint: PublicKey;
|
|
60
|
-
|
|
60
|
+
}, options?: {
|
|
61
|
+
priorityFee: number;
|
|
61
62
|
}): Promise<string>;
|
|
62
63
|
/**
|
|
63
64
|
* Withdraw from a vault
|
|
@@ -72,5 +73,7 @@ export default class Vault {
|
|
|
72
73
|
tickerPDA: PublicKey;
|
|
73
74
|
mint: PublicKey;
|
|
74
75
|
positionIndex: number;
|
|
76
|
+
}, options?: {
|
|
77
|
+
priorityFee: number;
|
|
75
78
|
}): Promise<string>;
|
|
76
79
|
}
|
package/dist/vault.js
CHANGED
|
@@ -13,7 +13,6 @@ const anchor_1 = require("@coral-xyz/anchor");
|
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const helpers_1 = require("./utils/helpers");
|
|
15
15
|
const spl_token_1 = require("@solana/spl-token");
|
|
16
|
-
const priorityFee_1 = require("./utils/priorityFee");
|
|
17
16
|
class Vault {
|
|
18
17
|
constructor(program, provider) {
|
|
19
18
|
this.provider = provider;
|
|
@@ -50,7 +49,7 @@ class Vault {
|
|
|
50
49
|
* @param position - Long or Short
|
|
51
50
|
* @param mint - Token mint for the vault (e.g. USDC)
|
|
52
51
|
*/
|
|
53
|
-
openPosition({ tickerPDA, amount, position, mint,
|
|
52
|
+
openPosition({ tickerPDA, amount, position, mint }, options) {
|
|
54
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
54
|
try {
|
|
56
55
|
const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, this.provider.wallet.publicKey, tickerPDA);
|
|
@@ -64,6 +63,11 @@ class Vault {
|
|
|
64
63
|
}
|
|
65
64
|
catch (_a) { }
|
|
66
65
|
const instructions = [];
|
|
66
|
+
if (options === null || options === void 0 ? void 0 : options.priorityFee) {
|
|
67
|
+
instructions.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
68
|
+
microLamports: options.priorityFee
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
67
71
|
if (!hasUserPosition) {
|
|
68
72
|
instructions.push(yield this.program.methods
|
|
69
73
|
.createUserPosition()
|
|
@@ -93,11 +97,6 @@ class Vault {
|
|
|
93
97
|
recentBlockhash: blockhash,
|
|
94
98
|
instructions
|
|
95
99
|
}).compileToV0Message();
|
|
96
|
-
let feeEstimate = { priorityFeeEstimate: 65000 };
|
|
97
|
-
feeEstimate = yield (0, priorityFee_1.getPriorityFeeEstimate)('HIGH', message, RPCURL);
|
|
98
|
-
instructions.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
99
|
-
microLamports: feeEstimate.priorityFeeEstimate
|
|
100
|
-
}));
|
|
101
100
|
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(message));
|
|
102
101
|
}
|
|
103
102
|
catch (error) {
|
|
@@ -114,7 +113,7 @@ class Vault {
|
|
|
114
113
|
* @param positionPubkey - The position public key
|
|
115
114
|
*
|
|
116
115
|
*/
|
|
117
|
-
closePosition({ tickerPDA, mint, positionIndex }) {
|
|
116
|
+
closePosition({ tickerPDA, mint, positionIndex }, options) {
|
|
118
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
118
|
try {
|
|
120
119
|
const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, this.provider.wallet.publicKey, tickerPDA);
|
|
@@ -129,11 +128,12 @@ class Vault {
|
|
|
129
128
|
catch (e) {
|
|
130
129
|
console.log(e);
|
|
131
130
|
}
|
|
132
|
-
const instructions = [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
const instructions = [];
|
|
132
|
+
if (options === null || options === void 0 ? void 0 : options.priorityFee) {
|
|
133
|
+
instructions.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
134
|
+
microLamports: options.priorityFee
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
137
|
if (!hasUser) {
|
|
138
138
|
instructions.push(yield this.program.methods
|
|
139
139
|
.createUserPosition()
|