hedge-web3 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1706,6 +1706,22 @@ export declare type Vault = {
1706
1706
  }
1707
1707
  ];
1708
1708
  "args": [];
1709
+ },
1710
+ {
1711
+ "name": "closeClaimedLiquidationPool";
1712
+ "accounts": [
1713
+ {
1714
+ "name": "payer";
1715
+ "isMut": true;
1716
+ "isSigner": true;
1717
+ },
1718
+ {
1719
+ "name": "poolPosition";
1720
+ "isMut": true;
1721
+ "isSigner": false;
1722
+ }
1723
+ ];
1724
+ "args": [];
1709
1725
  }
1710
1726
  ];
1711
1727
  "accounts": [
@@ -5,6 +5,7 @@ export * from './instructions/claimStakingPoolPosition';
5
5
  export * from './instructions/depositLiquidationPool';
6
6
  export * from './instructions/closeLiquidationPoolPosition';
7
7
  export * from './instructions/claimLiquidationPoolPosition';
8
+ export * from './instructions/closeClaimedLiquidationPoolPosition';
8
9
  export * from './instructions/createVault';
9
10
  export * from './instructions/depositVault';
10
11
  export * from './instructions/withdrawVault';
@@ -0,0 +1,5 @@
1
+ import { Program, Provider } from '@project-serum/anchor';
2
+ import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
+ import { Vault } from '../idl/vault';
4
+ export declare function closeClaimedLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer): Promise<PublicKey>;
5
+ export declare function closeClaimedLiquidationPoolPositionInstruction(program: Program<Vault>, poolPosition: PublicKey, payer: PublicKey): Promise<TransactionInstruction>;
package/lib/idl/vault.js CHANGED
@@ -1709,6 +1709,22 @@ exports.IDL = {
1709
1709
  }
1710
1710
  ],
1711
1711
  "args": []
1712
+ },
1713
+ {
1714
+ "name": "closeClaimedLiquidationPool",
1715
+ "accounts": [
1716
+ {
1717
+ "name": "payer",
1718
+ "isMut": true,
1719
+ "isSigner": true
1720
+ },
1721
+ {
1722
+ "name": "poolPosition",
1723
+ "isMut": true,
1724
+ "isSigner": false
1725
+ }
1726
+ ],
1727
+ "args": []
1712
1728
  }
1713
1729
  ],
1714
1730
  "accounts": [
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ __exportStar(require("./instructions/claimStakingPoolPosition"), exports);
17
17
  __exportStar(require("./instructions/depositLiquidationPool"), exports);
18
18
  __exportStar(require("./instructions/closeLiquidationPoolPosition"), exports);
19
19
  __exportStar(require("./instructions/claimLiquidationPoolPosition"), exports);
20
+ __exportStar(require("./instructions/closeClaimedLiquidationPoolPosition"), exports);
20
21
  __exportStar(require("./instructions/createVault"), exports);
21
22
  __exportStar(require("./instructions/depositVault"), exports);
22
23
  __exportStar(require("./instructions/withdrawVault"), exports);
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.closeClaimedLiquidationPoolPositionInstruction = exports.closeClaimedLiquidationPoolPosition = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const Errors_1 = require("../utils/Errors");
18
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
19
+ function closeClaimedLiquidationPoolPosition(program, provider, poolPosition, payer) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const transaction = new web3_js_1.Transaction().add(yield closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer.publicKey));
22
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
23
+ return poolPosition;
24
+ });
25
+ }
26
+ exports.closeClaimedLiquidationPoolPosition = closeClaimedLiquidationPoolPosition;
27
+ function closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return program.methods
30
+ .closeClaimedLiquidationPool()
31
+ .accounts({
32
+ poolPosition: poolPosition,
33
+ payer: payer
34
+ })
35
+ .instruction();
36
+ });
37
+ }
38
+ exports.closeClaimedLiquidationPoolPositionInstruction = closeClaimedLiquidationPoolPositionInstruction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
package/src/idl/vault.ts CHANGED
@@ -1706,6 +1706,22 @@ export type Vault = {
1706
1706
  }
1707
1707
  ],
1708
1708
  "args": []
1709
+ },
1710
+ {
1711
+ "name": "closeClaimedLiquidationPool",
1712
+ "accounts": [
1713
+ {
1714
+ "name": "payer",
1715
+ "isMut": true,
1716
+ "isSigner": true
1717
+ },
1718
+ {
1719
+ "name": "poolPosition",
1720
+ "isMut": true,
1721
+ "isSigner": false
1722
+ }
1723
+ ],
1724
+ "args": []
1709
1725
  }
1710
1726
  ],
1711
1727
  "accounts": [
@@ -4537,6 +4553,22 @@ export const IDL: Vault = {
4537
4553
  }
4538
4554
  ],
4539
4555
  "args": []
4556
+ },
4557
+ {
4558
+ "name": "closeClaimedLiquidationPool",
4559
+ "accounts": [
4560
+ {
4561
+ "name": "payer",
4562
+ "isMut": true,
4563
+ "isSigner": true
4564
+ },
4565
+ {
4566
+ "name": "poolPosition",
4567
+ "isMut": true,
4568
+ "isSigner": false
4569
+ }
4570
+ ],
4571
+ "args": []
4540
4572
  }
4541
4573
  ],
4542
4574
  "accounts": [
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './instructions/claimStakingPoolPosition'
6
6
  export * from './instructions/depositLiquidationPool'
7
7
  export * from './instructions/closeLiquidationPoolPosition'
8
8
  export * from './instructions/claimLiquidationPoolPosition'
9
+ export * from './instructions/closeClaimedLiquidationPoolPosition'
9
10
  export * from './instructions/createVault'
10
11
  export * from './instructions/depositVault'
11
12
  export * from './instructions/withdrawVault'
@@ -0,0 +1,31 @@
1
+ import { Program, Provider } from '@project-serum/anchor'
2
+ import { PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js'
3
+ import { parseAnchorErrors } from '../utils/Errors'
4
+ import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
5
+ import { Vault } from '../idl/vault'
6
+
7
+ export async function closeClaimedLiquidationPoolPosition(
8
+ program: Program<Vault>,
9
+ provider: Provider,
10
+ poolPosition: PublicKey,
11
+ payer: Signer
12
+ ): Promise<PublicKey> {
13
+ const transaction = new Transaction().add(await closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer.publicKey))
14
+
15
+ await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
16
+ return poolPosition
17
+ }
18
+
19
+ export async function closeClaimedLiquidationPoolPositionInstruction(
20
+ program: Program<Vault>,
21
+ poolPosition: PublicKey,
22
+ payer: PublicKey
23
+ ): Promise<TransactionInstruction> {
24
+ return program.methods
25
+ .closeClaimedLiquidationPool()
26
+ .accounts({
27
+ poolPosition: poolPosition,
28
+ payer: payer
29
+ })
30
+ .instruction()
31
+ }
@@ -124,6 +124,7 @@ export async function liquidateVault(
124
124
  overrideTime
125
125
  )
126
126
  )
127
+
127
128
  await sendAndConfirmWithDebug(provider.connection, transaction, [payer, history, newEra])
128
129
  return vaultPublicKey
129
130
  }
@@ -27,7 +27,7 @@ export async function withdrawStakingPool(
27
27
  payer: Signer,
28
28
  poolPositionPublicKey: PublicKey,
29
29
  stakedTokenMintPublicKey: PublicKey,
30
- overrideStartTime?: number
30
+ overrideStartTime?: number,
31
31
  ): Promise<PublicKey> {
32
32
  const poolPosition = Keypair.generate()
33
33
  const transaction = new Transaction().add(
@@ -39,6 +39,7 @@ export async function withdrawStakingPool(
39
39
  overrideStartTime
40
40
  )
41
41
  )
42
+
42
43
  await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
43
44
  return poolPosition.publicKey
44
45
  }