hedge-web3 0.1.33 → 0.1.34
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Program
|
1
|
+
import { Program } from '@project-serum/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from 'idl/vault';
|
4
|
-
export declare function claimStakingPoolPosition(program: Program<Vault>,
|
4
|
+
export declare function claimStakingPoolPosition(program: Program<Vault>, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
|
5
5
|
export declare function claimStakingPoolPositionInstruction(program: Program<Vault>, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, stakedTokenMint: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, poolPosition: PublicKey, payer: PublicKey, payerAssociatedTokenAccount: PublicKey): Promise<TransactionInstruction>;
|
@@ -14,17 +14,17 @@ const spl_token_1 = require("@solana/spl-token");
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
15
15
|
const Errors_1 = require("../utils/Errors");
|
16
16
|
const Constants_1 = require("../Constants");
|
17
|
-
function claimStakingPoolPosition(program,
|
17
|
+
function claimStakingPoolPosition(program, poolPosition, payer, collateralType) {
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
19
19
|
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
20
20
|
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccount);
|
21
21
|
const collateralMint = vaultTypeAccountInfo.collateralMint;
|
22
22
|
const stakedTokenMint = yield (0, Constants_1.getHedgeMintPublicKey)();
|
23
23
|
const [feePool] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMint);
|
24
|
-
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, feePool, true);
|
25
|
-
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
|
24
|
+
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(program.provider.connection, payer, collateralMint, feePool, true);
|
25
|
+
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(program.provider.connection, payer, collateralMint, payer.publicKey);
|
26
26
|
const transaction = new web3_js_1.Transaction().add(yield claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount.address, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address));
|
27
|
-
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
27
|
+
yield (0, web3_js_1.sendAndConfirmTransaction)(program.provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
28
28
|
return payerAssociatedTokenAccount.address;
|
29
29
|
});
|
30
30
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hedge-web3",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.34",
|
4
4
|
"description": "Hedge Javascript Web3 API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "declarations/index.d.ts",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"author": "Chris Coudron <coudron@hedge.so>",
|
15
15
|
"license": "ISC",
|
16
16
|
"dependencies": {
|
17
|
-
"@project-serum/anchor": "^0.24.
|
17
|
+
"@project-serum/anchor": "^0.24.2",
|
18
18
|
"@project-serum/serum": "^0.13.61",
|
19
19
|
"@rollup/plugin-typescript": "^8.3.0",
|
20
20
|
"@solana/buffer-layout": "^4.0.0",
|
@@ -21,7 +21,6 @@ import { Vault } from 'idl/vault'
|
|
21
21
|
|
22
22
|
export async function claimStakingPoolPosition(
|
23
23
|
program: Program<Vault>,
|
24
|
-
provider: Provider,
|
25
24
|
poolPosition: PublicKey,
|
26
25
|
payer: Signer,
|
27
26
|
collateralType: string
|
@@ -32,14 +31,14 @@ export async function claimStakingPoolPosition(
|
|
32
31
|
const stakedTokenMint = await getHedgeMintPublicKey()
|
33
32
|
const [feePool] = await getPoolPublicKeyForMint(stakedTokenMint)
|
34
33
|
const feePoolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
35
|
-
provider.connection,
|
34
|
+
program.provider.connection,
|
36
35
|
payer,
|
37
36
|
collateralMint,
|
38
37
|
feePool,
|
39
38
|
true
|
40
39
|
)
|
41
40
|
const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
42
|
-
provider.connection,
|
41
|
+
program.provider.connection,
|
43
42
|
payer,
|
44
43
|
collateralMint,
|
45
44
|
payer.publicKey
|
@@ -58,7 +57,7 @@ export async function claimStakingPoolPosition(
|
|
58
57
|
payerAssociatedTokenAccount.address
|
59
58
|
)
|
60
59
|
)
|
61
|
-
await sendAndConfirmTransaction(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
60
|
+
await sendAndConfirmTransaction(program.provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
62
61
|
return payerAssociatedTokenAccount.address
|
63
62
|
}
|
64
63
|
|