hedge-web3 0.2.31 → 0.2.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -1883,16 +1883,6 @@ export declare type Vault = {
1883
1883
  "isMut": true;
1884
1884
  "isSigner": false;
1885
1885
  },
1886
- {
1887
- "name": "pool";
1888
- "isMut": true;
1889
- "isSigner": false;
1890
- },
1891
- {
1892
- "name": "stakedTokenMint";
1893
- "isMut": true;
1894
- "isSigner": false;
1895
- },
1896
1886
  {
1897
1887
  "name": "systemProgram";
1898
1888
  "isMut": false;
@@ -2086,16 +2076,6 @@ export declare type Vault = {
2086
2076
  "isMut": true;
2087
2077
  "isSigner": false;
2088
2078
  },
2089
- {
2090
- "name": "pool";
2091
- "isMut": true;
2092
- "isSigner": false;
2093
- },
2094
- {
2095
- "name": "stakedTokenMint";
2096
- "isMut": false;
2097
- "isSigner": false;
2098
- },
2099
2079
  {
2100
2080
  "name": "systemProgram";
2101
2081
  "isMut": false;
@@ -2938,6 +2918,173 @@ export declare type Vault = {
2938
2918
  "type": "bool";
2939
2919
  }
2940
2920
  ];
2921
+ },
2922
+ {
2923
+ "name": "compoundCreateReferralAccount";
2924
+ "accounts": [
2925
+ {
2926
+ "name": "signer";
2927
+ "isMut": true;
2928
+ "isSigner": true;
2929
+ },
2930
+ {
2931
+ "name": "vaultSystemState";
2932
+ "isMut": true;
2933
+ "isSigner": false;
2934
+ },
2935
+ {
2936
+ "name": "referralState";
2937
+ "isMut": true;
2938
+ "isSigner": false;
2939
+ },
2940
+ {
2941
+ "name": "referralAccount";
2942
+ "isMut": true;
2943
+ "isSigner": false;
2944
+ },
2945
+ {
2946
+ "name": "userReferralAccount";
2947
+ "isMut": true;
2948
+ "isSigner": false;
2949
+ },
2950
+ {
2951
+ "name": "poolPosition";
2952
+ "isMut": true;
2953
+ "isSigner": false;
2954
+ },
2955
+ {
2956
+ "name": "hedgeMint";
2957
+ "isMut": true;
2958
+ "isSigner": false;
2959
+ },
2960
+ {
2961
+ "name": "hdgAta";
2962
+ "isMut": true;
2963
+ "isSigner": false;
2964
+ },
2965
+ {
2966
+ "name": "pool";
2967
+ "isMut": true;
2968
+ "isSigner": false;
2969
+ },
2970
+ {
2971
+ "name": "stakedTokenMint";
2972
+ "isMut": true;
2973
+ "isSigner": false;
2974
+ },
2975
+ {
2976
+ "name": "systemProgram";
2977
+ "isMut": false;
2978
+ "isSigner": false;
2979
+ },
2980
+ {
2981
+ "name": "tokenProgram";
2982
+ "isMut": false;
2983
+ "isSigner": false;
2984
+ },
2985
+ {
2986
+ "name": "rent";
2987
+ "isMut": false;
2988
+ "isSigner": false;
2989
+ }
2990
+ ];
2991
+ "args": [
2992
+ {
2993
+ "name": "overrideCurrentTime";
2994
+ "type": "i64";
2995
+ }
2996
+ ];
2997
+ },
2998
+ {
2999
+ "name": "compoundReferralClaimFees";
3000
+ "accounts": [
3001
+ {
3002
+ "name": "signer";
3003
+ "isMut": true;
3004
+ "isSigner": true;
3005
+ },
3006
+ {
3007
+ "name": "vaultSystemState";
3008
+ "isMut": true;
3009
+ "isSigner": false;
3010
+ },
3011
+ {
3012
+ "name": "referralState";
3013
+ "isMut": true;
3014
+ "isSigner": false;
3015
+ },
3016
+ {
3017
+ "name": "referralAccount";
3018
+ "isMut": true;
3019
+ "isSigner": false;
3020
+ },
3021
+ {
3022
+ "name": "poolPosition";
3023
+ "isMut": true;
3024
+ "isSigner": false;
3025
+ },
3026
+ {
3027
+ "name": "hedgeMint";
3028
+ "isMut": true;
3029
+ "isSigner": false;
3030
+ },
3031
+ {
3032
+ "name": "signerHdgAta";
3033
+ "isMut": true;
3034
+ "isSigner": false;
3035
+ },
3036
+ {
3037
+ "name": "ushMint";
3038
+ "isMut": true;
3039
+ "isSigner": false;
3040
+ },
3041
+ {
3042
+ "name": "signerUshAta";
3043
+ "isMut": true;
3044
+ "isSigner": false;
3045
+ },
3046
+ {
3047
+ "name": "communityAssociatedHedgeTokenAccount";
3048
+ "isMut": true;
3049
+ "isSigner": false;
3050
+ },
3051
+ {
3052
+ "name": "feePool";
3053
+ "isMut": true;
3054
+ "isSigner": false;
3055
+ },
3056
+ {
3057
+ "name": "feePoolAssociatedUshTokenAccount";
3058
+ "isMut": true;
3059
+ "isSigner": false;
3060
+ },
3061
+ {
3062
+ "name": "pool";
3063
+ "isMut": true;
3064
+ "isSigner": false;
3065
+ },
3066
+ {
3067
+ "name": "stakedTokenMint";
3068
+ "isMut": false;
3069
+ "isSigner": false;
3070
+ },
3071
+ {
3072
+ "name": "systemProgram";
3073
+ "isMut": false;
3074
+ "isSigner": false;
3075
+ },
3076
+ {
3077
+ "name": "tokenProgram";
3078
+ "isMut": false;
3079
+ "isSigner": false;
3080
+ },
3081
+ {
3082
+ "name": "rent";
3083
+ "isMut": false;
3084
+ "isSigner": false;
3085
+ }
3086
+ ];
3087
+ "args": [];
2941
3088
  }
2942
3089
  ];
2943
3090
  "accounts": [
@@ -4693,6 +4840,16 @@ export declare type Vault = {
4693
4840
  "code": 6039;
4694
4841
  "name": "PoolPositionTimelockPeriodNotExpired";
4695
4842
  "msg": "Staking Pool Position timelock not expired";
4843
+ },
4844
+ {
4845
+ "code": 6040;
4846
+ "name": "PoolPositionOverClaim";
4847
+ "msg": "Cannot overclaim pool positon.";
4848
+ },
4849
+ {
4850
+ "code": 6041;
4851
+ "name": "PoolPositionNotOpen";
4852
+ "msg": "Pool Position not open";
4696
4853
  }
4697
4854
  ];
4698
4855
  };
@@ -8,6 +8,8 @@ export * from './instructions/closeLiquidationPoolPosition';
8
8
  export * from './instructions/createReferralAccount';
9
9
  export * from './instructions/createStakingPool';
10
10
  export * from './instructions/createUserReferralAccount';
11
+ export * from './instructions/compoundCreateReferralAccount';
12
+ export * from './instructions/compoundReferralClaimFees';
11
13
  export * from './instructions/createVault';
12
14
  export * from './instructions/depositLiquidationPool';
13
15
  export * from './instructions/depositStakingPool';
@@ -0,0 +1,17 @@
1
+ import { Program, Provider } from '@project-serum/anchor';
2
+ import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
+ import { Vault } from '../idl/vault';
4
+ /** @type {Function} - Creates a new referral account.
5
+ * This checks the user has enough HDG in their wallet or staked and
6
+ * then allows them to create a referral account. If they meet the PSM referral threshold,
7
+ * they will be eligible for PSM cut.
8
+ * Params:
9
+ * - program: Program<Vault> : The program instance of Hedge Vault program
10
+ * - provider: Provider : Current connection
11
+ * - payer: Signer : who we are creating the referral account for
12
+ * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
13
+ * - referrer: PublicKey
14
+ * - overrideTime?: number
15
+ */
16
+ export declare function compoundCreateReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
17
+ export declare function compoundCreateReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, userReferralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
@@ -0,0 +1,16 @@
1
+ import { Program, Provider } from '@project-serum/anchor';
2
+ import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
+ import { Vault } from '../idl/vault';
4
+ /** @type {Function} - Allows a referrer to claims their fees.
5
+ * This checks the user has enough HDG in their wallet or staked and
6
+ * then allows them to claim earned fees. If they meet the PSM referral threshold,
7
+ * they will be eligible for PSM cut.
8
+ * Params:
9
+ * - program: Program<Vault> : The program instance of Hedge Vault program
10
+ * - provider: Provider : Current connection
11
+ * - payer: Signer : who we are creating the referral account for
12
+ * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
13
+ * - referrer: PublicKey
14
+ */
15
+ export declare function compoundReferralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey): Promise<PublicKey>;
16
+ export declare function compoundReferralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, ushMintPublicKey: PublicKey, ushAssociatedTokenAccountPublicKey: PublicKey, communityAssociatedHedgeTokenAccountPublicKey: PublicKey, feePoolPublicKey: PublicKey, feePoolAssociatedUshTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
@@ -13,5 +13,5 @@ import { Vault } from '../idl/vault';
13
13
  * - referrer: PublicKey
14
14
  * - overrideTime?: number
15
15
  */
16
- export declare function createReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
17
- export declare function createReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, userReferralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
16
+ export declare function createReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, overrideTime?: number): Promise<PublicKey>;
17
+ export declare function createReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, userReferralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
@@ -12,5 +12,5 @@ import { Vault } from '../idl/vault';
12
12
  * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
13
13
  * - referrer: PublicKey
14
14
  */
15
- export declare function referralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey): Promise<PublicKey>;
16
- export declare function referralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, ushMintPublicKey: PublicKey, ushAssociatedTokenAccountPublicKey: PublicKey, communityAssociatedHedgeTokenAccountPublicKey: PublicKey, feePoolPublicKey: PublicKey, feePoolAssociatedUshTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
15
+ export declare function referralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey): Promise<PublicKey>;
16
+ export declare function referralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, ushMintPublicKey: PublicKey, ushAssociatedTokenAccountPublicKey: PublicKey, communityAssociatedHedgeTokenAccountPublicKey: PublicKey, feePoolPublicKey: PublicKey, feePoolAssociatedUshTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
package/lib/idl/vault.js CHANGED
@@ -1886,16 +1886,6 @@ exports.IDL = {
1886
1886
  "isMut": true,
1887
1887
  "isSigner": false
1888
1888
  },
1889
- {
1890
- "name": "pool",
1891
- "isMut": true,
1892
- "isSigner": false
1893
- },
1894
- {
1895
- "name": "stakedTokenMint",
1896
- "isMut": true,
1897
- "isSigner": false
1898
- },
1899
1889
  {
1900
1890
  "name": "systemProgram",
1901
1891
  "isMut": false,
@@ -2089,16 +2079,6 @@ exports.IDL = {
2089
2079
  "isMut": true,
2090
2080
  "isSigner": false
2091
2081
  },
2092
- {
2093
- "name": "pool",
2094
- "isMut": true,
2095
- "isSigner": false
2096
- },
2097
- {
2098
- "name": "stakedTokenMint",
2099
- "isMut": false,
2100
- "isSigner": false
2101
- },
2102
2082
  {
2103
2083
  "name": "systemProgram",
2104
2084
  "isMut": false,
@@ -2941,6 +2921,173 @@ exports.IDL = {
2941
2921
  "type": "bool"
2942
2922
  }
2943
2923
  ]
2924
+ },
2925
+ {
2926
+ "name": "compoundCreateReferralAccount",
2927
+ "accounts": [
2928
+ {
2929
+ "name": "signer",
2930
+ "isMut": true,
2931
+ "isSigner": true
2932
+ },
2933
+ {
2934
+ "name": "vaultSystemState",
2935
+ "isMut": true,
2936
+ "isSigner": false
2937
+ },
2938
+ {
2939
+ "name": "referralState",
2940
+ "isMut": true,
2941
+ "isSigner": false
2942
+ },
2943
+ {
2944
+ "name": "referralAccount",
2945
+ "isMut": true,
2946
+ "isSigner": false
2947
+ },
2948
+ {
2949
+ "name": "userReferralAccount",
2950
+ "isMut": true,
2951
+ "isSigner": false
2952
+ },
2953
+ {
2954
+ "name": "poolPosition",
2955
+ "isMut": true,
2956
+ "isSigner": false
2957
+ },
2958
+ {
2959
+ "name": "hedgeMint",
2960
+ "isMut": true,
2961
+ "isSigner": false
2962
+ },
2963
+ {
2964
+ "name": "hdgAta",
2965
+ "isMut": true,
2966
+ "isSigner": false
2967
+ },
2968
+ {
2969
+ "name": "pool",
2970
+ "isMut": true,
2971
+ "isSigner": false
2972
+ },
2973
+ {
2974
+ "name": "stakedTokenMint",
2975
+ "isMut": true,
2976
+ "isSigner": false
2977
+ },
2978
+ {
2979
+ "name": "systemProgram",
2980
+ "isMut": false,
2981
+ "isSigner": false
2982
+ },
2983
+ {
2984
+ "name": "tokenProgram",
2985
+ "isMut": false,
2986
+ "isSigner": false
2987
+ },
2988
+ {
2989
+ "name": "rent",
2990
+ "isMut": false,
2991
+ "isSigner": false
2992
+ }
2993
+ ],
2994
+ "args": [
2995
+ {
2996
+ "name": "overrideCurrentTime",
2997
+ "type": "i64"
2998
+ }
2999
+ ]
3000
+ },
3001
+ {
3002
+ "name": "compoundReferralClaimFees",
3003
+ "accounts": [
3004
+ {
3005
+ "name": "signer",
3006
+ "isMut": true,
3007
+ "isSigner": true
3008
+ },
3009
+ {
3010
+ "name": "vaultSystemState",
3011
+ "isMut": true,
3012
+ "isSigner": false
3013
+ },
3014
+ {
3015
+ "name": "referralState",
3016
+ "isMut": true,
3017
+ "isSigner": false
3018
+ },
3019
+ {
3020
+ "name": "referralAccount",
3021
+ "isMut": true,
3022
+ "isSigner": false
3023
+ },
3024
+ {
3025
+ "name": "poolPosition",
3026
+ "isMut": true,
3027
+ "isSigner": false
3028
+ },
3029
+ {
3030
+ "name": "hedgeMint",
3031
+ "isMut": true,
3032
+ "isSigner": false
3033
+ },
3034
+ {
3035
+ "name": "signerHdgAta",
3036
+ "isMut": true,
3037
+ "isSigner": false
3038
+ },
3039
+ {
3040
+ "name": "ushMint",
3041
+ "isMut": true,
3042
+ "isSigner": false
3043
+ },
3044
+ {
3045
+ "name": "signerUshAta",
3046
+ "isMut": true,
3047
+ "isSigner": false
3048
+ },
3049
+ {
3050
+ "name": "communityAssociatedHedgeTokenAccount",
3051
+ "isMut": true,
3052
+ "isSigner": false
3053
+ },
3054
+ {
3055
+ "name": "feePool",
3056
+ "isMut": true,
3057
+ "isSigner": false
3058
+ },
3059
+ {
3060
+ "name": "feePoolAssociatedUshTokenAccount",
3061
+ "isMut": true,
3062
+ "isSigner": false
3063
+ },
3064
+ {
3065
+ "name": "pool",
3066
+ "isMut": true,
3067
+ "isSigner": false
3068
+ },
3069
+ {
3070
+ "name": "stakedTokenMint",
3071
+ "isMut": false,
3072
+ "isSigner": false
3073
+ },
3074
+ {
3075
+ "name": "systemProgram",
3076
+ "isMut": false,
3077
+ "isSigner": false
3078
+ },
3079
+ {
3080
+ "name": "tokenProgram",
3081
+ "isMut": false,
3082
+ "isSigner": false
3083
+ },
3084
+ {
3085
+ "name": "rent",
3086
+ "isMut": false,
3087
+ "isSigner": false
3088
+ }
3089
+ ],
3090
+ "args": []
2944
3091
  }
2945
3092
  ],
2946
3093
  "accounts": [
@@ -4696,6 +4843,16 @@ exports.IDL = {
4696
4843
  "code": 6039,
4697
4844
  "name": "PoolPositionTimelockPeriodNotExpired",
4698
4845
  "msg": "Staking Pool Position timelock not expired"
4846
+ },
4847
+ {
4848
+ "code": 6040,
4849
+ "name": "PoolPositionOverClaim",
4850
+ "msg": "Cannot overclaim pool positon."
4851
+ },
4852
+ {
4853
+ "code": 6041,
4854
+ "name": "PoolPositionNotOpen",
4855
+ "msg": "Pool Position not open"
4699
4856
  }
4700
4857
  ]
4701
4858
  };
package/lib/index.js CHANGED
@@ -20,6 +20,8 @@ __exportStar(require("./instructions/closeLiquidationPoolPosition"), exports);
20
20
  __exportStar(require("./instructions/createReferralAccount"), exports);
21
21
  __exportStar(require("./instructions/createStakingPool"), exports);
22
22
  __exportStar(require("./instructions/createUserReferralAccount"), exports);
23
+ __exportStar(require("./instructions/compoundCreateReferralAccount"), exports);
24
+ __exportStar(require("./instructions/compoundReferralClaimFees"), exports);
23
25
  __exportStar(require("./instructions/createVault"), exports);
24
26
  __exportStar(require("./instructions/depositLiquidationPool"), exports);
25
27
  __exportStar(require("./instructions/depositStakingPool"), exports);
@@ -0,0 +1,83 @@
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.compoundCreateReferralAccountInstruction = exports.compoundCreateReferralAccount = void 0;
16
+ const anchor_1 = require("@project-serum/anchor");
17
+ const spl_token_1 = require("@solana/spl-token");
18
+ const web3_js_1 = require("@solana/web3.js");
19
+ const Constants_1 = require("../Constants");
20
+ const Errors_1 = require("../utils/Errors");
21
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
22
+ /** @type {Function} - Creates a new referral account.
23
+ * This checks the user has enough HDG in their wallet or staked and
24
+ * then allows them to create a referral account. If they meet the PSM referral threshold,
25
+ * they will be eligible for PSM cut.
26
+ * Params:
27
+ * - program: Program<Vault> : The program instance of Hedge Vault program
28
+ * - provider: Provider : Current connection
29
+ * - payer: Signer : who we are creating the referral account for
30
+ * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
31
+ * - referrer: PublicKey
32
+ * - overrideTime?: number
33
+ */
34
+ function compoundCreateReferralAccount(program, provider, payer, poolPosition, stakedTokenMintPublicKey, overrideTime) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ // setup transaction
37
+ const transaction = new web3_js_1.Transaction();
38
+ const signers = [payer];
39
+ const referrer = payer.publicKey;
40
+ // Setup public keys
41
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
42
+ // Find referral account
43
+ let referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
44
+ // Get the referral state PDA
45
+ const referallStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
46
+ // Get HDG mint public key
47
+ const hedgeMintPublicKey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
48
+ // Get HDG account of signer
49
+ const payerHdgAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, payer.publicKey);
50
+ // Derive the user referral account public key
51
+ const userReferralAccountPublicKey = yield (0, Constants_1.getUserReferralAccountPublicKey)(program.programId, payer.publicKey);
52
+ transaction.add(yield compoundCreateReferralAccountInstruction(program, payer.publicKey, poolPosition, stakedTokenMintPublicKey, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, userReferralAccountPublicKey, overrideTime));
53
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
54
+ return referralAccountPublicKey;
55
+ });
56
+ }
57
+ exports.compoundCreateReferralAccount = compoundCreateReferralAccount;
58
+ function compoundCreateReferralAccountInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, userReferralAccountPublicKey, overrideTime) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
61
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
62
+ return yield program.methods
63
+ .compoundCreateReferralAccount(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override times
64
+ )
65
+ .accounts({
66
+ signer: payerPublicKey,
67
+ vaultSystemState: vaultSystemStatePublicKey,
68
+ referralState: referralStatePublicKey,
69
+ referralAccount: referralAccountPublicKey,
70
+ userReferralAccount: userReferralAccountPublicKey,
71
+ poolPosition: poolPositionPublicKey,
72
+ pool: poolPublickey,
73
+ stakedTokenMint: stakedTokenMintPublicKey,
74
+ hedgeMint: hedgeMintPublicKey,
75
+ hdgAta: hdgAssociatedTokenAccountPublicKey,
76
+ systemProgram: web3_js_1.SystemProgram.programId,
77
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
78
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
79
+ })
80
+ .instruction();
81
+ });
82
+ }
83
+ exports.compoundCreateReferralAccountInstruction = compoundCreateReferralAccountInstruction;