hedge-web3 0.1.34 → 0.1.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const HEDGE_PROGRAM_ID = "HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY";
2
+ export declare const HEDGE_PROGRAM_ID = "HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ";
3
3
  export declare const HEDGE_PROGRAM_PUBLICKEY: PublicKey;
4
4
  export declare const CHAINLINK_SOL_USD_ID = "FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf";
5
5
  export declare const CHAINLINK_SOL_USD_PUBLICKEY: PublicKey;
@@ -1802,18 +1802,6 @@ export declare type Vault = {
1802
1802
  "type": {
1803
1803
  "kind": "struct";
1804
1804
  "fields": [
1805
- {
1806
- "name": "owner";
1807
- "type": "publicKey";
1808
- },
1809
- {
1810
- "name": "pool";
1811
- "type": "publicKey";
1812
- },
1813
- {
1814
- "name": "deposited";
1815
- "type": "u64";
1816
- },
1817
1805
  {
1818
1806
  "name": "startHedgeRewardAccumulator";
1819
1807
  "type": "u128";
@@ -1852,6 +1840,18 @@ export declare type Vault = {
1852
1840
  "name": "closedRewardedTokens";
1853
1841
  "type": "u64";
1854
1842
  },
1843
+ {
1844
+ "name": "deposited";
1845
+ "type": "u64";
1846
+ },
1847
+ {
1848
+ "name": "owner";
1849
+ "type": "publicKey";
1850
+ },
1851
+ {
1852
+ "name": "pool";
1853
+ "type": "publicKey";
1854
+ },
1855
1855
  {
1856
1856
  "name": "state";
1857
1857
  "type": {
@@ -1,5 +1,5 @@
1
- import { Program } from '@project-serum/anchor';
1
+ import { Program, Provider } 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>, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
4
+ export declare function claimStakingPoolPosition(program: Program<Vault>, provider: Provider, 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>;
package/lib/Constants.js CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getVaultSystemStatePublicKey = exports.getUshMintPublicKey = exports.getLiquidationPoolUshAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
13
13
  const spl_token_1 = require("@solana/spl-token");
14
14
  const web3_js_1 = require("@solana/web3.js");
15
- exports.HEDGE_PROGRAM_ID = 'HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY';
15
+ exports.HEDGE_PROGRAM_ID = 'HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ';
16
16
  exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
17
17
  exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
18
18
  exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
package/lib/idl/vault.js CHANGED
@@ -1805,18 +1805,6 @@ exports.IDL = {
1805
1805
  "type": {
1806
1806
  "kind": "struct",
1807
1807
  "fields": [
1808
- {
1809
- "name": "owner",
1810
- "type": "publicKey"
1811
- },
1812
- {
1813
- "name": "pool",
1814
- "type": "publicKey"
1815
- },
1816
- {
1817
- "name": "deposited",
1818
- "type": "u64"
1819
- },
1820
1808
  {
1821
1809
  "name": "startHedgeRewardAccumulator",
1822
1810
  "type": "u128"
@@ -1855,6 +1843,18 @@ exports.IDL = {
1855
1843
  "name": "closedRewardedTokens",
1856
1844
  "type": "u64"
1857
1845
  },
1846
+ {
1847
+ "name": "deposited",
1848
+ "type": "u64"
1849
+ },
1850
+ {
1851
+ "name": "owner",
1852
+ "type": "publicKey"
1853
+ },
1854
+ {
1855
+ "name": "pool",
1856
+ "type": "publicKey"
1857
+ },
1858
1858
  {
1859
1859
  "name": "state",
1860
1860
  "type": {
@@ -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, poolPosition, payer, collateralType) {
17
+ function claimStakingPoolPosition(program, provider, 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)(program.provider.connection, payer, collateralMint, feePool, true);
25
- const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(program.provider.connection, payer, collateralMint, payer.publicKey);
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);
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)(program.provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
27
+ yield (0, web3_js_1.sendAndConfirmTransaction)(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.34",
3
+ "version": "0.1.37",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
package/src/Constants.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from '@solana/spl-token'
5
5
  import { PublicKey } from '@solana/web3.js'
6
6
 
7
- export const HEDGE_PROGRAM_ID = 'HDG3uyafYaKxSYRW37ZBTdxaUCoyzaqbuirYucAeaPFY'
7
+ export const HEDGE_PROGRAM_ID = 'HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ'
8
8
  export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
9
9
 
10
10
  export const CHAINLINK_SOL_USD_ID =
package/src/idl/vault.ts CHANGED
@@ -1802,18 +1802,6 @@ export type Vault = {
1802
1802
  "type": {
1803
1803
  "kind": "struct",
1804
1804
  "fields": [
1805
- {
1806
- "name": "owner",
1807
- "type": "publicKey"
1808
- },
1809
- {
1810
- "name": "pool",
1811
- "type": "publicKey"
1812
- },
1813
- {
1814
- "name": "deposited",
1815
- "type": "u64"
1816
- },
1817
1805
  {
1818
1806
  "name": "startHedgeRewardAccumulator",
1819
1807
  "type": "u128"
@@ -1852,6 +1840,18 @@ export type Vault = {
1852
1840
  "name": "closedRewardedTokens",
1853
1841
  "type": "u64"
1854
1842
  },
1843
+ {
1844
+ "name": "deposited",
1845
+ "type": "u64"
1846
+ },
1847
+ {
1848
+ "name": "owner",
1849
+ "type": "publicKey"
1850
+ },
1851
+ {
1852
+ "name": "pool",
1853
+ "type": "publicKey"
1854
+ },
1855
1855
  {
1856
1856
  "name": "state",
1857
1857
  "type": {
@@ -4373,18 +4373,6 @@ export const IDL: Vault = {
4373
4373
  "type": {
4374
4374
  "kind": "struct",
4375
4375
  "fields": [
4376
- {
4377
- "name": "owner",
4378
- "type": "publicKey"
4379
- },
4380
- {
4381
- "name": "pool",
4382
- "type": "publicKey"
4383
- },
4384
- {
4385
- "name": "deposited",
4386
- "type": "u64"
4387
- },
4388
4376
  {
4389
4377
  "name": "startHedgeRewardAccumulator",
4390
4378
  "type": "u128"
@@ -4423,6 +4411,18 @@ export const IDL: Vault = {
4423
4411
  "name": "closedRewardedTokens",
4424
4412
  "type": "u64"
4425
4413
  },
4414
+ {
4415
+ "name": "deposited",
4416
+ "type": "u64"
4417
+ },
4418
+ {
4419
+ "name": "owner",
4420
+ "type": "publicKey"
4421
+ },
4422
+ {
4423
+ "name": "pool",
4424
+ "type": "publicKey"
4425
+ },
4426
4426
  {
4427
4427
  "name": "state",
4428
4428
  "type": {
@@ -21,6 +21,7 @@ import { Vault } from 'idl/vault'
21
21
 
22
22
  export async function claimStakingPoolPosition(
23
23
  program: Program<Vault>,
24
+ provider: Provider,
24
25
  poolPosition: PublicKey,
25
26
  payer: Signer,
26
27
  collateralType: string
@@ -31,14 +32,14 @@ export async function claimStakingPoolPosition(
31
32
  const stakedTokenMint = await getHedgeMintPublicKey()
32
33
  const [feePool] = await getPoolPublicKeyForMint(stakedTokenMint)
33
34
  const feePoolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
34
- program.provider.connection,
35
+ provider.connection,
35
36
  payer,
36
37
  collateralMint,
37
38
  feePool,
38
39
  true
39
40
  )
40
41
  const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
41
- program.provider.connection,
42
+ provider.connection,
42
43
  payer,
43
44
  collateralMint,
44
45
  payer.publicKey
@@ -57,7 +58,7 @@ export async function claimStakingPoolPosition(
57
58
  payerAssociatedTokenAccount.address
58
59
  )
59
60
  )
60
- await sendAndConfirmTransaction(program.provider.connection, transaction, [payer]).catch(parseAnchorErrors)
61
+ await sendAndConfirmTransaction(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
61
62
  return payerAssociatedTokenAccount.address
62
63
  }
63
64