hedge-web3 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/Constants.d.ts +1 -1
- package/declarations/idl/vault.d.ts +893 -756
- package/lib/Constants.js +3 -3
- package/lib/idl/vault.js +893 -756
- package/lib/utils/Errors.js +2 -2
- package/package.json +1 -1
- package/src/Constants.ts +73 -31
- package/src/idl/vault.ts +1780 -1506
- package/src/state/StakingPool.ts +0 -4
- package/src/utils/Errors.ts +2 -2
- package/declarations/idl/idl.d.ts +0 -2
- package/lib/idl/idl.js +0 -1475
- package/src/idl/idl.ts +0 -1474
package/lib/utils/Errors.js
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.parseAnchorErrors = void 0;
|
4
4
|
const anchor_1 = require("@project-serum/anchor");
|
5
|
-
const
|
5
|
+
const vault_1 = require("../idl/vault");
|
6
6
|
function parseAnchorErrors(error) {
|
7
|
-
const idlErrors = (0, anchor_1.parseIdlErrors)(
|
7
|
+
const idlErrors = (0, anchor_1.parseIdlErrors)(vault_1.IDL);
|
8
8
|
const parsedError = anchor_1.ProgramError.parse(error, idlErrors);
|
9
9
|
if (parsedError !== null) {
|
10
10
|
throw parsedError;
|
package/package.json
CHANGED
package/src/Constants.ts
CHANGED
@@ -1,64 +1,106 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
3
|
+
TOKEN_PROGRAM_ID,
|
4
|
+
} from '@solana/spl-token'
|
2
5
|
import { PublicKey } from '@solana/web3.js'
|
3
6
|
|
4
|
-
export const HEDGE_PROGRAM_ID = '
|
7
|
+
export const HEDGE_PROGRAM_ID = 'HDG2DRczYGkTuYTwTYy1UUhXXucT2Ujede2j4bWEoE6p'
|
5
8
|
export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
|
6
9
|
|
7
|
-
export const CHAINLINK_SOL_USD_ID =
|
10
|
+
export const CHAINLINK_SOL_USD_ID =
|
11
|
+
'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'
|
8
12
|
export const CHAINLINK_SOL_USD_PUBLICKEY = new PublicKey(CHAINLINK_SOL_USD_ID)
|
9
13
|
|
10
14
|
const enc = new TextEncoder()
|
11
15
|
|
12
|
-
export async function getLiquidationPoolStatePublicKey
|
13
|
-
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
16
|
+
export async function getLiquidationPoolStatePublicKey(): Promise<PublicKey> {
|
17
|
+
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
18
|
+
[enc.encode('LiquidationPoolStateV1')],
|
19
|
+
HEDGE_PROGRAM_PUBLICKEY
|
20
|
+
)
|
14
21
|
return poolPublicKey
|
15
22
|
}
|
16
23
|
|
17
|
-
export async function getLiquidationPoolUshAccountPublicKey
|
18
|
-
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
24
|
+
export async function getLiquidationPoolUshAccountPublicKey(): Promise<PublicKey> {
|
25
|
+
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
26
|
+
[enc.encode('LiquidationPoolUSHAccountV1')],
|
27
|
+
HEDGE_PROGRAM_PUBLICKEY
|
28
|
+
)
|
19
29
|
return poolPublicKey
|
20
30
|
}
|
21
31
|
|
22
|
-
export async function getUshMintPublicKey
|
23
|
-
const [findMintPublicKey] = await PublicKey.findProgramAddress(
|
32
|
+
export async function getUshMintPublicKey(): Promise<PublicKey> {
|
33
|
+
const [findMintPublicKey] = await PublicKey.findProgramAddress(
|
34
|
+
[enc.encode('UshMintV1')],
|
35
|
+
HEDGE_PROGRAM_PUBLICKEY
|
36
|
+
)
|
24
37
|
return findMintPublicKey
|
25
38
|
}
|
26
39
|
|
27
|
-
export async function getVaultSystemStatePublicKey
|
28
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
40
|
+
export async function getVaultSystemStatePublicKey(): Promise<PublicKey> {
|
41
|
+
const [publicKey] = await PublicKey.findProgramAddress(
|
42
|
+
[enc.encode('VaultSystemStateV1')],
|
43
|
+
HEDGE_PROGRAM_PUBLICKEY
|
44
|
+
)
|
29
45
|
return publicKey
|
30
46
|
}
|
31
47
|
|
32
|
-
export async function getHedgeMintPublicKey
|
33
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
48
|
+
export async function getHedgeMintPublicKey(): Promise<PublicKey> {
|
49
|
+
const [publicKey] = await PublicKey.findProgramAddress(
|
50
|
+
[enc.encode('HEDGEMintV1')],
|
51
|
+
HEDGE_PROGRAM_PUBLICKEY
|
52
|
+
)
|
34
53
|
return publicKey
|
35
54
|
}
|
36
55
|
|
37
|
-
export async function getPoolPublicKeyForMint
|
38
|
-
|
39
|
-
|
56
|
+
export async function getPoolPublicKeyForMint(
|
57
|
+
mintPublicKey: PublicKey
|
58
|
+
): Promise<[PublicKey, number, string]> {
|
59
|
+
const strToEncode = mintPublicKey.toString().substring(0, 12)
|
60
|
+
const [publicKey, bump] = await PublicKey.findProgramAddress(
|
61
|
+
[enc.encode(strToEncode)],
|
62
|
+
HEDGE_PROGRAM_PUBLICKEY
|
63
|
+
)
|
40
64
|
return [publicKey, bump, strToEncode]
|
41
65
|
}
|
42
|
-
export async function getVaultTypeAccountPublicKey
|
43
|
-
|
66
|
+
export async function getVaultTypeAccountPublicKey(
|
67
|
+
collateralType: string
|
68
|
+
): Promise<PublicKey> {
|
69
|
+
const [vaultTypeAccount] = await PublicKey.findProgramAddress(
|
70
|
+
[enc.encode(collateralType), enc.encode('State')],
|
71
|
+
HEDGE_PROGRAM_PUBLICKEY
|
72
|
+
)
|
44
73
|
return vaultTypeAccount
|
45
74
|
}
|
46
|
-
export async function getVaultTypeOracleAccountPublicKey
|
47
|
-
|
75
|
+
export async function getVaultTypeOracleAccountPublicKey(
|
76
|
+
collateralType: string
|
77
|
+
): Promise<PublicKey> {
|
78
|
+
const [vaultTypeOracleAccount] = await PublicKey.findProgramAddress(
|
79
|
+
[enc.encode(collateralType), enc.encode('Oracle')],
|
80
|
+
HEDGE_PROGRAM_PUBLICKEY
|
81
|
+
)
|
48
82
|
return vaultTypeOracleAccount
|
49
83
|
}
|
50
|
-
export async function findVaultAddress
|
51
|
-
const [vaultAddress] = await PublicKey.findProgramAddress(
|
84
|
+
export async function findVaultAddress(vaultSalt: string): Promise<PublicKey> {
|
85
|
+
const [vaultAddress] = await PublicKey.findProgramAddress(
|
86
|
+
[enc.encode('Vault'), enc.encode(vaultSalt)],
|
87
|
+
HEDGE_PROGRAM_PUBLICKEY
|
88
|
+
)
|
52
89
|
return vaultAddress
|
53
90
|
}
|
54
91
|
|
55
|
-
export async function findAssociatedTokenAddress
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
92
|
+
export async function findAssociatedTokenAddress(
|
93
|
+
walletAddress: PublicKey,
|
94
|
+
tokenMintAddress: PublicKey
|
95
|
+
): Promise<PublicKey> {
|
96
|
+
return (
|
97
|
+
await PublicKey.findProgramAddress(
|
98
|
+
[
|
99
|
+
walletAddress.toBuffer(),
|
100
|
+
TOKEN_PROGRAM_ID.toBuffer(),
|
101
|
+
tokenMintAddress.toBuffer(),
|
102
|
+
],
|
103
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
104
|
+
)
|
105
|
+
)[0]
|
64
106
|
}
|