@triadxyz/triad-protocol 0.1.2-alpha.4 → 0.1.2-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/utils/priorityFee.d.ts +1 -1
- package/dist/vault.d.ts +2 -1
- package/dist/vault.js +7 -13
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getPriorityFeeEstimate(priorityLevel: any, transaction: any, RPC_URL:
|
|
1
|
+
export declare function getPriorityFeeEstimate(priorityLevel: any, transaction: any, RPC_URL: string): Promise<any>;
|
package/dist/vault.d.ts
CHANGED
|
@@ -52,11 +52,12 @@ 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, RPCURL }: {
|
|
56
56
|
tickerPDA: PublicKey;
|
|
57
57
|
amount: string;
|
|
58
58
|
position: 'Long' | 'Short';
|
|
59
59
|
mint: PublicKey;
|
|
60
|
+
RPCURL: string;
|
|
60
61
|
}): Promise<string>;
|
|
61
62
|
/**
|
|
62
63
|
* Withdraw from a vault
|
package/dist/vault.js
CHANGED
|
@@ -50,7 +50,7 @@ class Vault {
|
|
|
50
50
|
* @param position - Long or Short
|
|
51
51
|
* @param mint - Token mint for the vault (e.g. USDC)
|
|
52
52
|
*/
|
|
53
|
-
openPosition({ tickerPDA, amount, position, mint }) {
|
|
53
|
+
openPosition({ tickerPDA, amount, position, mint, RPCURL }) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
try {
|
|
56
56
|
const UserPositionPDA = (0, helpers_1.getUserPositionAddressSync)(this.program.programId, this.provider.wallet.publicKey, tickerPDA);
|
|
@@ -88,22 +88,16 @@ class Vault {
|
|
|
88
88
|
})
|
|
89
89
|
.instruction());
|
|
90
90
|
const { blockhash } = yield this.provider.connection.getLatestBlockhash();
|
|
91
|
-
const priorityLevel = 'HIGH';
|
|
92
|
-
let feeEstimate = { priorityFeeEstimate: 0 };
|
|
93
|
-
feeEstimate = yield (0, priorityFee_1.getPriorityFeeEstimate)(priorityLevel, new web3_js_1.TransactionMessage({
|
|
94
|
-
payerKey: this.provider.wallet.publicKey,
|
|
95
|
-
recentBlockhash: blockhash,
|
|
96
|
-
instructions
|
|
97
|
-
}).compileToV0Message(), this.provider.connection);
|
|
98
|
-
const computePriceIx = web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
99
|
-
microLamports: feeEstimate.priorityFeeEstimate
|
|
100
|
-
});
|
|
101
|
-
instructions.unshift(computePriceIx);
|
|
102
91
|
const message = new web3_js_1.TransactionMessage({
|
|
103
92
|
payerKey: this.provider.wallet.publicKey,
|
|
104
93
|
recentBlockhash: blockhash,
|
|
105
94
|
instructions
|
|
106
95
|
}).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
|
+
}));
|
|
107
101
|
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(message));
|
|
108
102
|
}
|
|
109
103
|
catch (error) {
|
|
@@ -137,7 +131,7 @@ class Vault {
|
|
|
137
131
|
}
|
|
138
132
|
const instructions = [
|
|
139
133
|
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
140
|
-
microLamports:
|
|
134
|
+
microLamports: 65000
|
|
141
135
|
})
|
|
142
136
|
];
|
|
143
137
|
if (!hasUser) {
|