hedge-web3 0.2.33 → 0.3.2
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/declarations/Constants.d.ts +0 -12
- package/declarations/HedgeConstants.d.ts +76 -0
- package/declarations/idl/pyth.d.ts +1 -1
- package/declarations/idl/switchboard.d.ts +1 -1
- package/declarations/idl/vault.d.ts +278 -1259
- package/declarations/index.d.ts +1 -12
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/createReferralAccount.d.ts +1 -1
- package/declarations/instructions/createStakingPool.d.ts +1 -1
- package/declarations/instructions/createUserReferralAccount.d.ts +1 -1
- package/declarations/instructions/createVault.d.ts +1 -2
- package/declarations/instructions/depositLiquidationPool.d.ts +1 -2
- package/declarations/instructions/depositStakingPool.d.ts +1 -2
- package/declarations/instructions/depositVault.d.ts +1 -2
- package/declarations/instructions/initHedgeFoundation.d.ts +1 -1
- package/declarations/instructions/initHedgeFoundationTokens.d.ts +1 -1
- package/declarations/instructions/liquidateVault.d.ts +1 -1
- package/declarations/instructions/loanVault.d.ts +1 -2
- package/declarations/instructions/psmEditAccount.d.ts +1 -2
- package/declarations/instructions/psmMintUsh.d.ts +1 -2
- package/declarations/instructions/psmRedeemUsh.d.ts +1 -2
- package/declarations/instructions/redeemVault.d.ts +1 -2
- package/declarations/instructions/referralClaimFees.d.ts +1 -1
- package/declarations/instructions/refreshOraclePrice.d.ts +1 -1
- package/declarations/instructions/repayVault.d.ts +1 -2
- package/declarations/instructions/setHalted.d.ts +1 -1
- package/declarations/instructions/transferVault.d.ts +1 -1
- package/declarations/instructions/updateReferralAccount.d.ts +1 -2
- package/declarations/instructions/updateReferralState.d.ts +1 -2
- package/declarations/instructions/updateVaultType.d.ts +1 -2
- package/declarations/instructions/withdrawStakingPool.d.ts +1 -1
- package/declarations/instructions/withdrawVault.d.ts +1 -2
- package/declarations/state/VaultAccount.d.ts +2 -3
- package/declarations/utils/getLinkedListAccounts.d.ts +1 -2
- package/declarations/utils/sendAndConfirmWithDebug.d.ts +2 -2
- package/lib/Constants.js +14 -41
- package/lib/HedgeConstants.js +170 -0
- package/lib/HedgeDecimal.js +1 -2
- package/lib/StakingPools.js +5 -1
- package/lib/Vaults.js +5 -1
- package/lib/idl/vault.js +277 -1258
- package/lib/index.js +6 -13
- package/lib/instructions/claimLiquidationPoolPosition.js +7 -8
- package/lib/instructions/claimStakingPoolPosition.js +7 -8
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +2 -3
- package/lib/instructions/closeLiquidationPoolPosition.js +16 -17
- package/lib/instructions/createReferralAccount.js +10 -11
- package/lib/instructions/createStakingPool.js +10 -11
- package/lib/instructions/createUserReferralAccount.js +9 -10
- package/lib/instructions/createVault.js +35 -50
- package/lib/instructions/depositLiquidationPool.js +12 -13
- package/lib/instructions/depositStakingPool.js +8 -9
- package/lib/instructions/depositVault.js +15 -26
- package/lib/instructions/initHedgeFoundation.js +24 -13
- package/lib/instructions/initHedgeFoundationTokens.js +7 -8
- package/lib/instructions/liquidateVault.js +12 -19
- package/lib/instructions/loanVault.js +17 -24
- package/lib/instructions/psmEditAccount.js +11 -11
- package/lib/instructions/psmMintUsh.js +18 -19
- package/lib/instructions/psmRedeemUsh.js +18 -19
- package/lib/instructions/redeemVault.js +10 -12
- package/lib/instructions/referralClaimFees.js +9 -10
- package/lib/instructions/refreshOraclePrice.js +10 -10
- package/lib/instructions/repayVault.js +12 -13
- package/lib/instructions/setHalted.js +4 -5
- package/lib/instructions/transferVault.js +2 -3
- package/lib/instructions/updateReferralAccount.js +6 -7
- package/lib/instructions/updateReferralState.js +6 -7
- package/lib/instructions/updateVaultType.js +5 -6
- package/lib/instructions/withdrawStakingPool.js +14 -15
- package/lib/instructions/withdrawVault.js +10 -11
- package/lib/state/VaultAccount.js +23 -9
- package/lib/state/VaultHistoryEvent.js +2 -2
- package/lib/utils/Errors.js +2 -3
- package/lib/utils/getLinkedListAccounts.js +2 -3
- package/lib/utils/sendAndConfirmWithDebug.js +50 -14
- package/package.json +9 -8
- package/src/{Constants.ts → HedgeConstants.ts} +13 -43
- package/src/idl/vault.ts +2004 -3966
- package/src/index.ts +3 -12
- package/src/instructions/claimLiquidationPoolPosition.ts +2 -2
- package/src/instructions/claimStakingPoolPosition.ts +2 -2
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +1 -1
- package/src/instructions/closeLiquidationPoolPosition.ts +2 -2
- package/src/instructions/createReferralAccount.ts +11 -8
- package/src/instructions/createStakingPool.ts +11 -4
- package/src/instructions/createUserReferralAccount.ts +2 -2
- package/src/instructions/createVault.ts +26 -37
- package/src/instructions/depositLiquidationPool.ts +2 -2
- package/src/instructions/depositStakingPool.ts +2 -2
- package/src/instructions/depositVault.ts +24 -18
- package/src/instructions/initHedgeFoundation.ts +19 -4
- package/src/instructions/initHedgeFoundationTokens.ts +2 -2
- package/src/instructions/liquidateVault.ts +29 -39
- package/src/instructions/loanVault.ts +24 -37
- package/src/instructions/psmEditAccount.ts +3 -3
- package/src/instructions/psmMintUsh.ts +3 -3
- package/src/instructions/psmRedeemUsh.ts +3 -3
- package/src/instructions/redeemVault.ts +2 -3
- package/src/instructions/referralClaimFees.ts +11 -9
- package/src/instructions/refreshOraclePrice.ts +5 -5
- package/src/instructions/repayVault.ts +2 -2
- package/src/instructions/setHalted.ts +2 -2
- package/src/instructions/transferVault.ts +1 -1
- package/src/instructions/updateReferralAccount.ts +2 -2
- package/src/instructions/updateReferralState.ts +2 -2
- package/src/instructions/updateVaultType.ts +2 -2
- package/src/instructions/withdrawStakingPool.ts +2 -2
- package/src/instructions/withdrawVault.ts +4 -4
- package/src/state/VaultAccount.ts +1 -1
- package/src/utils/Errors.ts +1 -1
- package/src/utils/getLinkedListAccounts.ts +1 -1
- package/src/utils/sendAndConfirmWithDebug.ts +72 -23
- package/declarations/instructions/adminWithdrawCol.d.ts +0 -5
- package/declarations/instructions/adminWithdrawUsh.d.ts +0 -5
- package/declarations/instructions/compoundCreateReferralAccount.d.ts +0 -17
- package/declarations/instructions/compoundReferralClaimFees.d.ts +0 -16
- package/declarations/instructions/createCompoundStakingPool.d.ts +0 -5
- package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositRewardsToCompoundPool.d.ts +0 -6
- package/declarations/instructions/setCompoundPoolActive.d.ts +0 -5
- package/declarations/instructions/setDelegateWallet.d.ts +0 -5
- package/declarations/instructions/setVaultTypeStatus.d.ts +0 -4
- package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/utils/Sender.d.ts +0 -2
- package/lib/instructions/adminWithdrawCol.js +0 -60
- package/lib/instructions/adminWithdrawUsh.js +0 -57
- package/lib/instructions/compoundCreateReferralAccount.js +0 -83
- package/lib/instructions/compoundReferralClaimFees.js +0 -87
- package/lib/instructions/createCompoundStakingPool.js +0 -58
- package/lib/instructions/createCompoundStakingPoolPosition.js +0 -56
- package/lib/instructions/depositCompoundStakingPoolPosition.js +0 -55
- package/lib/instructions/depositRewardsToCompoundPool.js +0 -64
- package/lib/instructions/setCompoundPoolActive.js +0 -43
- package/lib/instructions/setDelegateWallet.js +0 -43
- package/lib/instructions/setVaultTypeStatus.js +0 -38
- package/lib/instructions/withdrawCompoundStakingPoolPosition.js +0 -64
- package/lib/utils/Sender.js +0 -32
- package/src/instructions/adminWithdrawCol.ts +0 -87
- package/src/instructions/adminWithdrawUsh.ts +0 -78
- package/src/instructions/compoundCreateReferralAccount.ts +0 -119
- package/src/instructions/compoundReferralClaimFees.ts +0 -151
- package/src/instructions/createCompoundStakingPool.ts +0 -63
- package/src/instructions/createCompoundStakingPoolPosition.ts +0 -85
- package/src/instructions/depositCompoundStakingPoolPosition.ts +0 -78
- package/src/instructions/depositRewardsToCompoundPool.ts +0 -110
- package/src/instructions/setCompoundPoolActive.ts +0 -51
- package/src/instructions/setDelegateWallet.ts +0 -51
- package/src/instructions/withdrawCompoundStakingPoolPosition.ts +0 -100
@@ -9,27 +9,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
|
12
|
+
exports.default = sendAndConfirmWithDebug;
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
14
|
+
function sendAndConfirmWithDebug(connection, transaction, signers, computeUnits) {
|
13
15
|
return __awaiter(this, void 0, void 0, function* () {
|
14
|
-
|
15
|
-
|
16
|
-
.
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
try {
|
17
|
+
// Get the latest blockhash before sending
|
18
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash();
|
19
|
+
// Set blockhash AND feePayer BEFORE converting to VersionedTransaction
|
20
|
+
if (transaction instanceof web3_js_1.Transaction) {
|
21
|
+
// Add compute unit instruction FIRST if requested
|
22
|
+
if (computeUnits) {
|
23
|
+
const computeIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnits });
|
24
|
+
transaction.instructions.unshift(computeIx);
|
25
|
+
}
|
26
|
+
transaction.recentBlockhash = blockhash;
|
27
|
+
// Ensure feePayer is explicitly set on legacy transaction
|
28
|
+
if (!transaction.feePayer) {
|
29
|
+
transaction.feePayer = signers[0].publicKey;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else if (computeUnits) {
|
33
|
+
throw new Error('Compute units must be added before creating VersionedTransaction');
|
34
|
+
}
|
35
|
+
// Convert legacy Transaction to VersionedTransaction if needed
|
36
|
+
const versionedTx = transaction instanceof web3_js_1.Transaction
|
37
|
+
? new web3_js_1.VersionedTransaction(transaction.compileMessage())
|
38
|
+
: transaction;
|
39
|
+
// For VersionedTransaction, verify blockhash is set
|
40
|
+
if (!(transaction instanceof web3_js_1.Transaction) && !versionedTx.message.recentBlockhash) {
|
41
|
+
throw new Error('Versioned transaction requires recent blockhash');
|
42
|
+
}
|
43
|
+
// Sign the transaction if signers are provided
|
44
|
+
if (signers.length > 0) {
|
45
|
+
versionedTx.sign(signers);
|
46
|
+
}
|
47
|
+
// Send the transaction
|
48
|
+
const signature = yield connection.sendTransaction(versionedTx);
|
49
|
+
// Confirm using the newer confirmation strategy
|
50
|
+
const confirmationStrategy = {
|
51
|
+
signature,
|
52
|
+
blockhash,
|
53
|
+
lastValidBlockHeight
|
54
|
+
};
|
55
|
+
try {
|
56
|
+
yield connection.confirmTransaction(confirmationStrategy);
|
20
57
|
return signature;
|
21
|
-
}
|
22
|
-
|
58
|
+
}
|
59
|
+
catch (error) {
|
23
60
|
console.log('There was an error confirming the transaction', error);
|
24
61
|
console.trace();
|
25
62
|
throw error;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
63
|
+
}
|
64
|
+
}
|
65
|
+
catch (error) {
|
29
66
|
console.log('There was an error sending the transaction', error);
|
30
67
|
console.trace();
|
31
68
|
throw error;
|
32
|
-
}
|
69
|
+
}
|
33
70
|
});
|
34
71
|
}
|
35
|
-
exports.default = sendAndConfirmWithDebug;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hedge-web3",
|
3
|
-
"version": "0.2
|
3
|
+
"version": "0.3.2",
|
4
4
|
"description": "Hedge Javascript Web3 API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "declarations/index.d.ts",
|
@@ -14,26 +14,27 @@
|
|
14
14
|
"author": "Chris Coudron <coudron@hedge.so>",
|
15
15
|
"license": "ISC",
|
16
16
|
"dependencies": {
|
17
|
-
"@
|
18
|
-
"@project-serum/serum": "^0.13.61",
|
17
|
+
"@coral-xyz/anchor": "^0.29.0",
|
19
18
|
"@rollup/plugin-typescript": "^8.3.0",
|
20
19
|
"@solana/buffer-layout": "^4.0.0",
|
21
|
-
"@solana/spl-token": "^0.
|
22
|
-
"@solana/
|
20
|
+
"@solana/spl-token": "^0.3.9",
|
21
|
+
"@solana/spl-token-metadata": "^0.1.6",
|
22
|
+
"@solana/web3.js": "^1.90.0",
|
23
23
|
"@types/bn.js": "^5.1.0",
|
24
24
|
"@types/underscore": "^1.11.4",
|
25
25
|
"@types/uuid": "^8.3.4",
|
26
26
|
"bn.js": "^5.2.0",
|
27
27
|
"bs58": "^5.0.0",
|
28
28
|
"decimal.js": "^10.3.1",
|
29
|
+
"i": "^0.3.7",
|
30
|
+
"npm": "^10.9.2",
|
29
31
|
"rollup": "^2.62.0",
|
30
32
|
"ts-standard": "^11.0.0",
|
31
|
-
"typedoc": "^0.
|
32
|
-
"typescript": "^4.5.5",
|
33
|
+
"typedoc": "^0.27.6",
|
33
34
|
"underscore": "^1.13.2",
|
34
35
|
"uuid": "^8.3.2"
|
35
36
|
},
|
36
37
|
"devDependencies": {
|
37
|
-
"
|
38
|
+
"typescript": "^5.7.3"
|
38
39
|
}
|
39
40
|
}
|
@@ -11,7 +11,7 @@ const enc = new TextEncoder()
|
|
11
11
|
* @returns The Liquidation pool public key
|
12
12
|
*/
|
13
13
|
export async function getLiquidationPoolStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
14
|
-
const [poolPublicKey] = await PublicKey.
|
14
|
+
const [poolPublicKey] = await PublicKey.findProgramAddressSync([enc.encode('LiquidationPoolStateV1')], hedgeProgramId)
|
15
15
|
return poolPublicKey
|
16
16
|
}
|
17
17
|
/**
|
@@ -19,7 +19,7 @@ export async function getLiquidationPoolStatePublicKey(hedgeProgramId: PublicKey
|
|
19
19
|
* @returns The liquidation pool ush account public key
|
20
20
|
*/
|
21
21
|
export async function getLiquidationPoolUshAccountPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
22
|
-
const [poolPublicKey] = await PublicKey.
|
22
|
+
const [poolPublicKey] = await PublicKey.findProgramAddressSync([enc.encode('LiquidationPoolUSHAccountV1')], hedgeProgramId)
|
23
23
|
return poolPublicKey
|
24
24
|
}
|
25
25
|
/**
|
@@ -27,7 +27,7 @@ export async function getLiquidationPoolUshAccountPublicKey(hedgeProgramId: Publ
|
|
27
27
|
* @returns The USH mint public key
|
28
28
|
*/
|
29
29
|
export async function getUshMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
30
|
-
const [findMintPublicKey] = await PublicKey.
|
30
|
+
const [findMintPublicKey] = await PublicKey.findProgramAddressSync([enc.encode('UshMintV1')], hedgeProgramId)
|
31
31
|
return findMintPublicKey
|
32
32
|
}
|
33
33
|
/**
|
@@ -35,7 +35,7 @@ export async function getUshMintPublicKey(hedgeProgramId: PublicKey): Promise<Pu
|
|
35
35
|
* @returns The Vault System State public key
|
36
36
|
*/
|
37
37
|
export async function getVaultSystemStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
38
|
-
const [publicKey] = await PublicKey.
|
38
|
+
const [publicKey] = await PublicKey.findProgramAddressSync([enc.encode('VaultSystemStateV1')], hedgeProgramId)
|
39
39
|
return publicKey
|
40
40
|
}
|
41
41
|
|
@@ -44,7 +44,7 @@ export async function getVaultSystemStatePublicKey(hedgeProgramId: PublicKey): P
|
|
44
44
|
* @returns The Referral State public key
|
45
45
|
*/
|
46
46
|
export async function getReferralStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
47
|
-
const [publicKey] = await PublicKey.
|
47
|
+
const [publicKey] = await PublicKey.findProgramAddressSync([enc.encode('ReferralStateV1')], hedgeProgramId)
|
48
48
|
return publicKey
|
49
49
|
}
|
50
50
|
|
@@ -54,7 +54,7 @@ export async function getReferralStatePublicKey(hedgeProgramId: PublicKey): Prom
|
|
54
54
|
*/
|
55
55
|
export async function getReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey> {
|
56
56
|
const strToEncode = ownerPublicKey.toBuffer() //.substring(0, 28)
|
57
|
-
const [publicKey] = await PublicKey.
|
57
|
+
const [publicKey] = await PublicKey.findProgramAddressSync([enc.encode('refer_acct'), strToEncode], hedgeProgramId)
|
58
58
|
return publicKey
|
59
59
|
}
|
60
60
|
|
@@ -67,31 +67,16 @@ export async function getUserReferralAccountPublicKey(
|
|
67
67
|
ownerPublicKey: PublicKey
|
68
68
|
): Promise<PublicKey> {
|
69
69
|
const strToEncode = ownerPublicKey.toBuffer() //.substring(0, 28)
|
70
|
-
const [publicKey] = await PublicKey.
|
70
|
+
const [publicKey] = await PublicKey.findProgramAddressSync([enc.encode('user_ref'), strToEncode], hedgeProgramId)
|
71
71
|
return publicKey
|
72
72
|
}
|
73
73
|
|
74
|
-
/**
|
75
|
-
*
|
76
|
-
* @returns The compound pool position address for the given user
|
77
|
-
*/
|
78
|
-
export async function getCompoundPoolPositionAddress(
|
79
|
-
hedgeProgramId: PublicKey,
|
80
|
-
poolPublicKey: PublicKey,
|
81
|
-
ownerPublicKey: PublicKey
|
82
|
-
): Promise<PublicKey> {
|
83
|
-
const strToEncode = poolPublicKey.toBuffer()
|
84
|
-
const strToEncode2 = ownerPublicKey.toBuffer()
|
85
|
-
const [compoundPoolPosition] = await PublicKey.findProgramAddress([strToEncode, strToEncode2], hedgeProgramId)
|
86
|
-
return compoundPoolPosition
|
87
|
-
}
|
88
|
-
|
89
74
|
/**
|
90
75
|
*
|
91
76
|
* @returns The HDG mint public key
|
92
77
|
*/
|
93
78
|
export async function getHedgeMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
94
|
-
const [publicKey] = await PublicKey.
|
79
|
+
const [publicKey] = await PublicKey.findProgramAddressSync([enc.encode('HEDGEMintV1')], hedgeProgramId)
|
95
80
|
return publicKey
|
96
81
|
}
|
97
82
|
/**
|
@@ -105,32 +90,17 @@ export async function getPoolPublicKeyForMint(
|
|
105
90
|
mintPublicKey: PublicKey
|
106
91
|
): Promise<[PublicKey, number, string]> {
|
107
92
|
const strToEncode = mintPublicKey.toString().substring(0, 12)
|
108
|
-
const [publicKey, bump] = await PublicKey.
|
93
|
+
const [publicKey, bump] = await PublicKey.findProgramAddressSync([enc.encode(strToEncode)], hedgeProgramId)
|
109
94
|
return [publicKey, bump, strToEncode]
|
110
95
|
}
|
111
96
|
|
112
|
-
/**
|
113
|
-
* Get the public key for any compound staking pool
|
114
|
-
*
|
115
|
-
* @param mintPublicKey Staked collateral mint public key
|
116
|
-
* @returns the public key for that compound staking pool
|
117
|
-
*/
|
118
|
-
export async function getCompoundPoolPublicKeyForMint(
|
119
|
-
hedgeProgramId: PublicKey,
|
120
|
-
mintPublicKey: PublicKey
|
121
|
-
): Promise<[PublicKey, number]> {
|
122
|
-
const strToEncode = mintPublicKey.toBuffer()
|
123
|
-
const [publicKey, bump] = await PublicKey.findProgramAddress([enc.encode('CompoundPoolV1'), strToEncode], hedgeProgramId)
|
124
|
-
return [publicKey, bump]
|
125
|
-
}
|
126
|
-
|
127
97
|
/**
|
128
98
|
*
|
129
99
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
130
100
|
* @returns The public key for that Vault Type account
|
131
101
|
*/
|
132
102
|
export async function getVaultTypeAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey> {
|
133
|
-
const [vaultTypeAccount] = await PublicKey.
|
103
|
+
const [vaultTypeAccount] = await PublicKey.findProgramAddressSync(
|
134
104
|
[enc.encode(collateralType), enc.encode('State')],
|
135
105
|
hedgeProgramId
|
136
106
|
)
|
@@ -146,7 +116,7 @@ export async function getVaultTypeOracleAccountPublicKey(
|
|
146
116
|
hedgeProgramId: PublicKey,
|
147
117
|
collateralType: string
|
148
118
|
): Promise<PublicKey> {
|
149
|
-
const [vaultTypeOracleAccount] = await PublicKey.
|
119
|
+
const [vaultTypeOracleAccount] = await PublicKey.findProgramAddressSync(
|
150
120
|
[enc.encode(collateralType), enc.encode('Oracle')],
|
151
121
|
hedgeProgramId
|
152
122
|
)
|
@@ -160,7 +130,7 @@ export async function getVaultTypeOracleAccountPublicKey(
|
|
160
130
|
* @returns The public key for that Vault Type oracle info
|
161
131
|
*/
|
162
132
|
export async function findVaultAddress(hedgeProgramId: PublicKey, vaultSalt: string): Promise<PublicKey> {
|
163
|
-
const [vaultAddress] = await PublicKey.
|
133
|
+
const [vaultAddress] = await PublicKey.findProgramAddressSync([enc.encode('Vault'), enc.encode(vaultSalt)], hedgeProgramId)
|
164
134
|
return vaultAddress
|
165
135
|
}
|
166
136
|
|
@@ -176,7 +146,7 @@ export async function findAssociatedTokenAddress(
|
|
176
146
|
tokenMintAddress: PublicKey
|
177
147
|
): Promise<PublicKey> {
|
178
148
|
return (
|
179
|
-
|
149
|
+
PublicKey.findProgramAddressSync(
|
180
150
|
[walletAddress.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), tokenMintAddress.toBuffer()],
|
181
151
|
ASSOCIATED_TOKEN_PROGRAM_ID
|
182
152
|
)
|