@parqxchange/sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/accounts/marketOracle.d.ts +21 -0
- package/dist/accounts/marketOracle.js +114 -0
- package/dist/accounts/resolve.d.ts +75 -0
- package/dist/accounts/resolve.js +116 -0
- package/dist/actions/cranks.d.ts +8 -0
- package/dist/actions/cranks.js +10 -0
- package/dist/actions/liquidity.d.ts +23 -0
- package/dist/actions/liquidity.js +21 -0
- package/dist/actions/trading.d.ts +39 -0
- package/dist/actions/trading.js +95 -0
- package/dist/auth/tradingKey.d.ts +27 -0
- package/dist/auth/tradingKey.js +71 -0
- package/dist/decode/index.d.ts +39 -0
- package/dist/decode/index.js +445 -0
- package/dist/events/decoder.d.ts +60 -0
- package/dist/events/decoder.js +369 -0
- package/dist/events/emitter.d.ts +49 -0
- package/dist/events/emitter.js +153 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +93 -0
- package/dist/indexer/client.d.ts +13 -0
- package/dist/indexer/client.js +36 -0
- package/dist/indexer/types.d.ts +9 -0
- package/dist/indexer/types.js +2 -0
- package/dist/minimal.d.ts +3 -0
- package/dist/minimal.js +13 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +5 -0
- package/dist/programs/feeDistributor.d.ts +42 -0
- package/dist/programs/feeDistributor.js +42 -0
- package/dist/programs/oracle.d.ts +31 -0
- package/dist/programs/oracle.js +49 -0
- package/dist/programs/perp.d.ts +283 -0
- package/dist/programs/perp.js +346 -0
- package/dist/programs/pool.d.ts +113 -0
- package/dist/programs/pool.js +126 -0
- package/dist/programs/priceFeed.d.ts +13 -0
- package/dist/programs/priceFeed.js +21 -0
- package/dist/programs/staking.d.ts +76 -0
- package/dist/programs/staking.js +135 -0
- package/dist/types/index.d.ts +337 -0
- package/dist/types/index.js +9 -0
- package/dist/utils/computeBudget.d.ts +5 -0
- package/dist/utils/computeBudget.js +14 -0
- package/dist/utils/errors.d.ts +56 -0
- package/dist/utils/errors.js +138 -0
- package/dist/utils/pda.d.ts +28 -0
- package/dist/utils/pda.js +131 -0
- package/dist/utils/priceMath.d.ts +5 -0
- package/dist/utils/priceMath.js +46 -0
- package/dist/utils/tokenProgram.d.ts +2 -0
- package/dist/utils/tokenProgram.js +16 -0
- package/dist/utils/transaction.d.ts +2 -0
- package/dist/utils/transaction.js +12 -0
- package/dist/utils/version.d.ts +11 -0
- package/dist/utils/version.js +29 -0
- package/idl/fee_distributor.json +779 -0
- package/idl/oracle_adapter.json +767 -0
- package/idl/perp_engine.json +3908 -0
- package/idl/pool_program.json +2956 -0
- package/idl/price_feed.json +478 -0
- package/idl/staking.json +1336 -0
- package/package.json +98 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
export declare class StakingClient {
|
|
4
|
+
private readonly program;
|
|
5
|
+
constructor(program: Program);
|
|
6
|
+
stakeIx(accounts: {
|
|
7
|
+
owner: PublicKey;
|
|
8
|
+
stakingPool: PublicKey;
|
|
9
|
+
stakePosition: PublicKey;
|
|
10
|
+
stakedVault: PublicKey;
|
|
11
|
+
ownerTokenAccount: PublicKey;
|
|
12
|
+
tokenMint: PublicKey;
|
|
13
|
+
tokenProgram?: PublicKey;
|
|
14
|
+
rewardUsdc?: PublicKey;
|
|
15
|
+
rewardVault?: PublicKey;
|
|
16
|
+
}, amount: bigint, tier: number): Promise<TransactionInstruction>;
|
|
17
|
+
unstakeIx(accounts: {
|
|
18
|
+
owner: PublicKey;
|
|
19
|
+
stakingPool: PublicKey;
|
|
20
|
+
stakePosition: PublicKey;
|
|
21
|
+
stakedVault: PublicKey;
|
|
22
|
+
ownerTokenAccount: PublicKey;
|
|
23
|
+
stakedMint: PublicKey;
|
|
24
|
+
rewardMint: PublicKey;
|
|
25
|
+
stakedTokenProgram?: PublicKey;
|
|
26
|
+
rewardTokenProgram?: PublicKey;
|
|
27
|
+
rewardUsdc?: PublicKey;
|
|
28
|
+
ownerUsdcAccount?: PublicKey;
|
|
29
|
+
rewardVault?: PublicKey;
|
|
30
|
+
ownerRewardAccount?: PublicKey;
|
|
31
|
+
}): Promise<TransactionInstruction>;
|
|
32
|
+
claimRewardIx(accounts: {
|
|
33
|
+
owner: PublicKey;
|
|
34
|
+
stakingPool: PublicKey;
|
|
35
|
+
stakePosition: PublicKey;
|
|
36
|
+
rewardMint: PublicKey;
|
|
37
|
+
rewardTokenProgram?: PublicKey;
|
|
38
|
+
rewardUsdc?: PublicKey;
|
|
39
|
+
ownerUsdcAccount?: PublicKey;
|
|
40
|
+
rewardVault?: PublicKey;
|
|
41
|
+
ownerRewardAccount?: PublicKey;
|
|
42
|
+
}): Promise<TransactionInstruction>;
|
|
43
|
+
updateRewardIndexIx(accounts: {
|
|
44
|
+
stakingPool: PublicKey;
|
|
45
|
+
rewardUsdc?: PublicKey;
|
|
46
|
+
}): Promise<TransactionInstruction>;
|
|
47
|
+
initializeEmissionPoolIx(accounts: {
|
|
48
|
+
admin: PublicKey;
|
|
49
|
+
stakingPool: PublicKey;
|
|
50
|
+
stakedMint: PublicKey;
|
|
51
|
+
rewardMint: PublicKey;
|
|
52
|
+
adminRewardTokens: PublicKey;
|
|
53
|
+
rewardVault: PublicKey;
|
|
54
|
+
tokenProgram?: PublicKey;
|
|
55
|
+
}, totalAllocation: bigint, durationSeconds: bigint): Promise<TransactionInstruction>;
|
|
56
|
+
claimAndRestakeIx(accounts: {
|
|
57
|
+
owner: PublicKey;
|
|
58
|
+
lpStakingPool: PublicKey;
|
|
59
|
+
lpStakePosition: PublicKey;
|
|
60
|
+
lpRewardVault: PublicKey;
|
|
61
|
+
protoStakingPool: PublicKey;
|
|
62
|
+
protoStakePosition: PublicKey;
|
|
63
|
+
protoStakedVault: PublicKey;
|
|
64
|
+
protoMint: PublicKey;
|
|
65
|
+
protoRewardUsdc: PublicKey;
|
|
66
|
+
tokenProgram?: PublicKey;
|
|
67
|
+
}, tier: number): Promise<TransactionInstruction>;
|
|
68
|
+
reclaimUnallocatedIx(accounts: {
|
|
69
|
+
admin: PublicKey;
|
|
70
|
+
stakingPool: PublicKey;
|
|
71
|
+
rewardVault: PublicKey;
|
|
72
|
+
rewardMint: PublicKey;
|
|
73
|
+
adminTokenAccount: PublicKey;
|
|
74
|
+
tokenProgram?: PublicKey;
|
|
75
|
+
}): Promise<TransactionInstruction>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StakingClient = void 0;
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
7
|
+
class StakingClient {
|
|
8
|
+
program;
|
|
9
|
+
constructor(program) {
|
|
10
|
+
this.program = program;
|
|
11
|
+
}
|
|
12
|
+
async stakeIx(accounts, amount, tier) {
|
|
13
|
+
const accs = {
|
|
14
|
+
owner: accounts.owner,
|
|
15
|
+
stakingPool: accounts.stakingPool,
|
|
16
|
+
stakePosition: accounts.stakePosition,
|
|
17
|
+
stakedVault: accounts.stakedVault,
|
|
18
|
+
ownerTokenAccount: accounts.ownerTokenAccount,
|
|
19
|
+
tokenMint: accounts.tokenMint,
|
|
20
|
+
tokenProgram: accounts.tokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
21
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
22
|
+
};
|
|
23
|
+
if (accounts.rewardUsdc)
|
|
24
|
+
accs.rewardUsdc = accounts.rewardUsdc;
|
|
25
|
+
if (accounts.rewardVault)
|
|
26
|
+
accs.rewardVault = accounts.rewardVault;
|
|
27
|
+
return this.program.methods
|
|
28
|
+
.stake({ amount: new anchor_1.BN(amount.toString()), tier })
|
|
29
|
+
.accounts(accs)
|
|
30
|
+
.instruction();
|
|
31
|
+
}
|
|
32
|
+
async unstakeIx(accounts) {
|
|
33
|
+
const noneAcct = this.program.programId;
|
|
34
|
+
const accs = {
|
|
35
|
+
owner: accounts.owner,
|
|
36
|
+
stakingPool: accounts.stakingPool,
|
|
37
|
+
stakePosition: accounts.stakePosition,
|
|
38
|
+
stakedVault: accounts.stakedVault,
|
|
39
|
+
ownerTokenAccount: accounts.ownerTokenAccount,
|
|
40
|
+
stakedMint: accounts.stakedMint,
|
|
41
|
+
rewardMint: accounts.rewardMint,
|
|
42
|
+
stakedTokenProgram: accounts.stakedTokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
43
|
+
rewardTokenProgram: accounts.rewardTokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
44
|
+
rewardUsdc: accounts.rewardUsdc ?? noneAcct,
|
|
45
|
+
ownerUsdcAccount: accounts.ownerUsdcAccount ?? noneAcct,
|
|
46
|
+
rewardVault: accounts.rewardVault ?? noneAcct,
|
|
47
|
+
ownerRewardAccount: accounts.ownerRewardAccount ?? noneAcct,
|
|
48
|
+
};
|
|
49
|
+
return this.program.methods
|
|
50
|
+
.unstake()
|
|
51
|
+
.accounts(accs)
|
|
52
|
+
.instruction();
|
|
53
|
+
}
|
|
54
|
+
async claimRewardIx(accounts) {
|
|
55
|
+
const noneAcct = this.program.programId;
|
|
56
|
+
const accs = {
|
|
57
|
+
owner: accounts.owner,
|
|
58
|
+
stakingPool: accounts.stakingPool,
|
|
59
|
+
stakePosition: accounts.stakePosition,
|
|
60
|
+
rewardMint: accounts.rewardMint,
|
|
61
|
+
rewardTokenProgram: accounts.rewardTokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
62
|
+
rewardUsdc: accounts.rewardUsdc ?? noneAcct,
|
|
63
|
+
ownerUsdcAccount: accounts.ownerUsdcAccount ?? noneAcct,
|
|
64
|
+
rewardVault: accounts.rewardVault ?? noneAcct,
|
|
65
|
+
ownerRewardAccount: accounts.ownerRewardAccount ?? noneAcct,
|
|
66
|
+
};
|
|
67
|
+
return this.program.methods
|
|
68
|
+
.claimReward()
|
|
69
|
+
.accounts(accs)
|
|
70
|
+
.instruction();
|
|
71
|
+
}
|
|
72
|
+
async updateRewardIndexIx(accounts) {
|
|
73
|
+
const accs = {
|
|
74
|
+
stakingPool: accounts.stakingPool,
|
|
75
|
+
};
|
|
76
|
+
if (accounts.rewardUsdc)
|
|
77
|
+
accs.rewardUsdc = accounts.rewardUsdc;
|
|
78
|
+
return this.program.methods
|
|
79
|
+
.updateRewardIndex()
|
|
80
|
+
.accounts(accs)
|
|
81
|
+
.instruction();
|
|
82
|
+
}
|
|
83
|
+
async initializeEmissionPoolIx(accounts, totalAllocation, durationSeconds) {
|
|
84
|
+
return this.program.methods
|
|
85
|
+
.initializeEmissionPool({
|
|
86
|
+
tokenMint: accounts.stakedMint,
|
|
87
|
+
rewardMint: accounts.rewardMint,
|
|
88
|
+
totalAllocation: new anchor_1.BN(totalAllocation.toString()),
|
|
89
|
+
durationSeconds: new anchor_1.BN(durationSeconds.toString()),
|
|
90
|
+
})
|
|
91
|
+
.accounts({
|
|
92
|
+
admin: accounts.admin,
|
|
93
|
+
stakingPool: accounts.stakingPool,
|
|
94
|
+
stakedMint: accounts.stakedMint,
|
|
95
|
+
rewardMint: accounts.rewardMint,
|
|
96
|
+
adminRewardTokens: accounts.adminRewardTokens,
|
|
97
|
+
rewardVault: accounts.rewardVault,
|
|
98
|
+
tokenProgram: accounts.tokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
99
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
100
|
+
})
|
|
101
|
+
.instruction();
|
|
102
|
+
}
|
|
103
|
+
async claimAndRestakeIx(accounts, tier) {
|
|
104
|
+
return this.program.methods
|
|
105
|
+
.claimAndRestake({ tier })
|
|
106
|
+
.accounts({
|
|
107
|
+
owner: accounts.owner,
|
|
108
|
+
lpStakingPool: accounts.lpStakingPool,
|
|
109
|
+
lpStakePosition: accounts.lpStakePosition,
|
|
110
|
+
lpRewardVault: accounts.lpRewardVault,
|
|
111
|
+
protoStakingPool: accounts.protoStakingPool,
|
|
112
|
+
protoStakePosition: accounts.protoStakePosition,
|
|
113
|
+
protoStakedVault: accounts.protoStakedVault,
|
|
114
|
+
protoMint: accounts.protoMint,
|
|
115
|
+
protoRewardUsdc: accounts.protoRewardUsdc,
|
|
116
|
+
tokenProgram: accounts.tokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
117
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
118
|
+
})
|
|
119
|
+
.instruction();
|
|
120
|
+
}
|
|
121
|
+
async reclaimUnallocatedIx(accounts) {
|
|
122
|
+
return this.program.methods
|
|
123
|
+
.reclaimUnallocated()
|
|
124
|
+
.accounts({
|
|
125
|
+
admin: accounts.admin,
|
|
126
|
+
stakingPool: accounts.stakingPool,
|
|
127
|
+
rewardVault: accounts.rewardVault,
|
|
128
|
+
rewardMint: accounts.rewardMint,
|
|
129
|
+
adminTokenAccount: accounts.adminTokenAccount,
|
|
130
|
+
tokenProgram: accounts.tokenProgram ?? spl_token_1.TOKEN_PROGRAM_ID,
|
|
131
|
+
})
|
|
132
|
+
.instruction();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.StakingClient = StakingClient;
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
export type Side = "long" | "short";
|
|
3
|
+
export interface Position {
|
|
4
|
+
owner: PublicKey;
|
|
5
|
+
marketId: Uint8Array;
|
|
6
|
+
side: Side;
|
|
7
|
+
sizeUsdc: bigint;
|
|
8
|
+
collateralUsdc: bigint;
|
|
9
|
+
entryPrice: bigint;
|
|
10
|
+
fundingIndexSnapshot: bigint;
|
|
11
|
+
borrowingFactorSnapshot: bigint;
|
|
12
|
+
reservedMaxPayout: bigint;
|
|
13
|
+
collateralFromQueue: bigint;
|
|
14
|
+
openedAt: bigint;
|
|
15
|
+
bump: number;
|
|
16
|
+
}
|
|
17
|
+
export interface MarketState {
|
|
18
|
+
marketId: Uint8Array;
|
|
19
|
+
longOi: bigint;
|
|
20
|
+
shortOi: bigint;
|
|
21
|
+
fundingIndex: bigint;
|
|
22
|
+
lastFundingTs: bigint;
|
|
23
|
+
maxLeverage: number;
|
|
24
|
+
baseFeeBps: number;
|
|
25
|
+
mmrBps: number;
|
|
26
|
+
poolState: PublicKey;
|
|
27
|
+
poolProgram: PublicKey;
|
|
28
|
+
oracleProgram: PublicKey;
|
|
29
|
+
treasury: PublicKey;
|
|
30
|
+
stakingProgramId: PublicKey;
|
|
31
|
+
engineAuthBump: number;
|
|
32
|
+
isPaused: boolean;
|
|
33
|
+
savedFundingFactorPerSecond: bigint;
|
|
34
|
+
fundingIncreaseFactorPerSecond: bigint;
|
|
35
|
+
fundingDecreaseFactorPerSecond: bigint;
|
|
36
|
+
thresholdForStableFunding: bigint;
|
|
37
|
+
thresholdForDecreaseFunding: bigint;
|
|
38
|
+
minFundingFactorPerSecond: bigint;
|
|
39
|
+
maxFundingFactorPerSecond: bigint;
|
|
40
|
+
longCumulativeBorrowingFactor: bigint;
|
|
41
|
+
shortCumulativeBorrowingFactor: bigint;
|
|
42
|
+
lastBorrowingTs: bigint;
|
|
43
|
+
borrowingFactor: bigint;
|
|
44
|
+
optimalUsageFactor: bigint;
|
|
45
|
+
aboveOptimalBorrowingFactor: bigint;
|
|
46
|
+
longReservedUsdc: bigint;
|
|
47
|
+
shortReservedUsdc: bigint;
|
|
48
|
+
priceImpactFactor: bigint;
|
|
49
|
+
maxPriceImpactBps: number;
|
|
50
|
+
impactPoolUsdc: bigint;
|
|
51
|
+
keeper: PublicKey;
|
|
52
|
+
maxOiLong: bigint;
|
|
53
|
+
maxOiShort: bigint;
|
|
54
|
+
feeBpsFavorable: number;
|
|
55
|
+
bump: number;
|
|
56
|
+
offHoursMaxOiLong?: bigint;
|
|
57
|
+
offHoursMaxOiShort?: bigint;
|
|
58
|
+
adlFrozen?: number;
|
|
59
|
+
adlTailTriggerUsdcRth?: bigint;
|
|
60
|
+
adlTailTriggerUsdcOff?: bigint;
|
|
61
|
+
adlTailMinAgeSecsRth?: number;
|
|
62
|
+
adlTailMinAgeSecsOff?: number;
|
|
63
|
+
adlHaircutBpsRth?: number;
|
|
64
|
+
adlHaircutBpsOff?: number;
|
|
65
|
+
adlMaxHaircutBps?: number;
|
|
66
|
+
adlMaxFeedDivergenceBps?: number;
|
|
67
|
+
initialMarginBps?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface Market {
|
|
70
|
+
marketId: Uint8Array;
|
|
71
|
+
longOi: bigint;
|
|
72
|
+
shortOi: bigint;
|
|
73
|
+
fundingIndex: bigint;
|
|
74
|
+
lastFundingTs: bigint;
|
|
75
|
+
maxLeverage: number;
|
|
76
|
+
baseFeeBps: number;
|
|
77
|
+
mmrBps: number;
|
|
78
|
+
isPaused: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface PoolState {
|
|
81
|
+
marketId: Uint8Array;
|
|
82
|
+
usdcVault: PublicKey;
|
|
83
|
+
vaultAuthorityBump: number;
|
|
84
|
+
lpMint: PublicKey;
|
|
85
|
+
totalUsdc: bigint;
|
|
86
|
+
reservedUsdc: bigint;
|
|
87
|
+
cumulativeFees: bigint;
|
|
88
|
+
engineAuth: PublicKey;
|
|
89
|
+
engineAuthBump: number;
|
|
90
|
+
admin: PublicKey;
|
|
91
|
+
isPaused: boolean;
|
|
92
|
+
reserveFactor: bigint;
|
|
93
|
+
depositFeeBps: number;
|
|
94
|
+
withdrawalFeeBps: number;
|
|
95
|
+
sideBucket: bigint;
|
|
96
|
+
queueHeadIdx: bigint;
|
|
97
|
+
queueTailIdx: bigint;
|
|
98
|
+
queueTotalOwed: bigint;
|
|
99
|
+
bump: number;
|
|
100
|
+
currentAdlEpoch: number;
|
|
101
|
+
lastAdlCutIdx: bigint;
|
|
102
|
+
}
|
|
103
|
+
export type OrderType = "marketIncrease" | "limitIncrease" | "stopIncrease" | "marketDecrease" | "limitDecrease" | "stopLossDecrease";
|
|
104
|
+
export interface Order {
|
|
105
|
+
owner: PublicKey;
|
|
106
|
+
marketId: Uint8Array;
|
|
107
|
+
orderType: OrderType;
|
|
108
|
+
side: Side;
|
|
109
|
+
sizeUsdc: bigint;
|
|
110
|
+
collateralUsdc: bigint;
|
|
111
|
+
triggerPrice: bigint;
|
|
112
|
+
acceptablePrice: bigint;
|
|
113
|
+
minOutputUsdc: bigint;
|
|
114
|
+
referralCode: Uint8Array;
|
|
115
|
+
positionNonce: bigint;
|
|
116
|
+
createdAt: bigint;
|
|
117
|
+
nonce: bigint;
|
|
118
|
+
bump: number;
|
|
119
|
+
}
|
|
120
|
+
export interface OrderNonce {
|
|
121
|
+
owner: PublicKey;
|
|
122
|
+
nonce: bigint;
|
|
123
|
+
bump: number;
|
|
124
|
+
}
|
|
125
|
+
export interface TradingKey {
|
|
126
|
+
wallet: PublicKey;
|
|
127
|
+
delegate: PublicKey;
|
|
128
|
+
expiresAt: bigint;
|
|
129
|
+
bump: number;
|
|
130
|
+
}
|
|
131
|
+
export declare enum HaltMode {
|
|
132
|
+
None = 0,
|
|
133
|
+
ReduceOnly = 1,
|
|
134
|
+
Full = 2
|
|
135
|
+
}
|
|
136
|
+
export interface ProtocolConfig {
|
|
137
|
+
admin: PublicKey;
|
|
138
|
+
bump: number;
|
|
139
|
+
haltMode: number;
|
|
140
|
+
rthOpenMinutesUtc: number;
|
|
141
|
+
rthCloseMinutesUtc: number;
|
|
142
|
+
tierBreakpointsUsdc: bigint[];
|
|
143
|
+
rthMaxLeverage: number[];
|
|
144
|
+
offHoursMaxLeverage: number[];
|
|
145
|
+
}
|
|
146
|
+
export interface ReferralTier {
|
|
147
|
+
totalRebateBps: number;
|
|
148
|
+
discountSharePct: number;
|
|
149
|
+
}
|
|
150
|
+
export interface ReferralConfig {
|
|
151
|
+
admin: PublicKey;
|
|
152
|
+
tiers: [ReferralTier, ReferralTier, ReferralTier, ReferralTier];
|
|
153
|
+
bump: number;
|
|
154
|
+
}
|
|
155
|
+
export interface ReferralCode {
|
|
156
|
+
owner: PublicKey;
|
|
157
|
+
code: Uint8Array;
|
|
158
|
+
tier: number;
|
|
159
|
+
bump: number;
|
|
160
|
+
}
|
|
161
|
+
export interface TraderReferral {
|
|
162
|
+
trader: PublicKey;
|
|
163
|
+
code: Uint8Array;
|
|
164
|
+
bump: number;
|
|
165
|
+
}
|
|
166
|
+
export interface AffiliateReward {
|
|
167
|
+
affiliate: PublicKey;
|
|
168
|
+
marketId: Uint8Array;
|
|
169
|
+
accruedUsdc: bigint;
|
|
170
|
+
bump: number;
|
|
171
|
+
}
|
|
172
|
+
export interface FeePool {
|
|
173
|
+
admin: PublicKey;
|
|
174
|
+
perpEngine: PublicKey;
|
|
175
|
+
usdcAccount: PublicKey;
|
|
176
|
+
stakingReward: PublicKey;
|
|
177
|
+
treasury: PublicKey;
|
|
178
|
+
referralReserve: PublicKey;
|
|
179
|
+
stakerSplitBps: number;
|
|
180
|
+
treasurySplitBps: number;
|
|
181
|
+
referralSplitBps: number;
|
|
182
|
+
totalDistributed: bigint;
|
|
183
|
+
bump: number;
|
|
184
|
+
}
|
|
185
|
+
export interface StakingPool {
|
|
186
|
+
admin: PublicKey;
|
|
187
|
+
tokenMint: PublicKey;
|
|
188
|
+
stakedVault: PublicKey;
|
|
189
|
+
rewardSource: number;
|
|
190
|
+
rewardMint: PublicKey;
|
|
191
|
+
rewardVault: PublicKey;
|
|
192
|
+
rewardUsdc: PublicKey;
|
|
193
|
+
totalWeightedStake: bigint;
|
|
194
|
+
rewardIndex: bigint;
|
|
195
|
+
totalRewardsDistributed: bigint;
|
|
196
|
+
totalAllocation: bigint;
|
|
197
|
+
startTs: bigint;
|
|
198
|
+
endTs: bigint;
|
|
199
|
+
emittedSoFar: bigint;
|
|
200
|
+
lastUpdateTs: bigint;
|
|
201
|
+
bump: number;
|
|
202
|
+
}
|
|
203
|
+
export interface StakePosition {
|
|
204
|
+
pool: PublicKey;
|
|
205
|
+
owner: PublicKey;
|
|
206
|
+
amount: bigint;
|
|
207
|
+
lockupTier: number;
|
|
208
|
+
lockupExpiry: bigint;
|
|
209
|
+
weightedAmount: bigint;
|
|
210
|
+
rewardIndexSnap: bigint;
|
|
211
|
+
accruedReward: bigint;
|
|
212
|
+
bump: number;
|
|
213
|
+
}
|
|
214
|
+
export interface PayoutQueueEntry {
|
|
215
|
+
owner: PublicKey;
|
|
216
|
+
marketId: Uint8Array;
|
|
217
|
+
idx: bigint;
|
|
218
|
+
amount: bigint;
|
|
219
|
+
enqueuedAt: bigint;
|
|
220
|
+
status: number;
|
|
221
|
+
bump: number;
|
|
222
|
+
}
|
|
223
|
+
export interface UserQueueClaims {
|
|
224
|
+
owner: PublicKey;
|
|
225
|
+
marketId: Uint8Array;
|
|
226
|
+
unpaidOwed: bigint;
|
|
227
|
+
collateralDrawn: bigint;
|
|
228
|
+
phantomUnpaidOwed: bigint;
|
|
229
|
+
bump: number;
|
|
230
|
+
}
|
|
231
|
+
export interface PriceData {
|
|
232
|
+
price: bigint;
|
|
233
|
+
confidence: bigint;
|
|
234
|
+
timestamp: bigint;
|
|
235
|
+
}
|
|
236
|
+
export interface PositionOpenedEvent {
|
|
237
|
+
owner: PublicKey;
|
|
238
|
+
marketId: Uint8Array;
|
|
239
|
+
side: Side;
|
|
240
|
+
sizeUsdc: bigint;
|
|
241
|
+
collateral: bigint;
|
|
242
|
+
entryPrice: bigint;
|
|
243
|
+
}
|
|
244
|
+
export interface PositionClosedEvent {
|
|
245
|
+
owner: PublicKey;
|
|
246
|
+
marketId: Uint8Array;
|
|
247
|
+
pnl: bigint;
|
|
248
|
+
netReturn: bigint;
|
|
249
|
+
exitPrice: bigint;
|
|
250
|
+
}
|
|
251
|
+
export interface LiquidatedEvent {
|
|
252
|
+
owner: PublicKey;
|
|
253
|
+
marketId: Uint8Array;
|
|
254
|
+
badDebt: bigint;
|
|
255
|
+
}
|
|
256
|
+
export interface BadDebtEvent {
|
|
257
|
+
marketId: Uint8Array;
|
|
258
|
+
amount: bigint;
|
|
259
|
+
}
|
|
260
|
+
export interface FundingUpdatedEvent {
|
|
261
|
+
marketId: Uint8Array;
|
|
262
|
+
fundingIndex: bigint;
|
|
263
|
+
longOi: bigint;
|
|
264
|
+
shortOi: bigint;
|
|
265
|
+
}
|
|
266
|
+
export interface EnqueuedEvent {
|
|
267
|
+
idx: bigint;
|
|
268
|
+
owner: PublicKey;
|
|
269
|
+
marketId: Uint8Array;
|
|
270
|
+
amount: bigint;
|
|
271
|
+
queueTotalOwedAfter: bigint;
|
|
272
|
+
}
|
|
273
|
+
export interface HarvestedEvent {
|
|
274
|
+
idx: bigint;
|
|
275
|
+
owner: PublicKey;
|
|
276
|
+
marketId: Uint8Array;
|
|
277
|
+
amount: bigint;
|
|
278
|
+
}
|
|
279
|
+
export interface EntryVoidedEvent {
|
|
280
|
+
idx: bigint;
|
|
281
|
+
owner: PublicKey;
|
|
282
|
+
marketId: Uint8Array;
|
|
283
|
+
amount: bigint;
|
|
284
|
+
reason: number;
|
|
285
|
+
}
|
|
286
|
+
export interface SideBucketCreditedEvent {
|
|
287
|
+
marketId: Uint8Array;
|
|
288
|
+
amount: bigint;
|
|
289
|
+
source: number;
|
|
290
|
+
}
|
|
291
|
+
export interface QueueDrainedEvent {
|
|
292
|
+
marketId: Uint8Array;
|
|
293
|
+
residualToTreasury: bigint;
|
|
294
|
+
}
|
|
295
|
+
export interface PhantomCreditDrainedEvent {
|
|
296
|
+
owner: PublicKey;
|
|
297
|
+
marketId: Uint8Array;
|
|
298
|
+
amount: bigint;
|
|
299
|
+
}
|
|
300
|
+
export interface FeesSweptEvent {
|
|
301
|
+
marketId: Uint8Array;
|
|
302
|
+
amount: bigint;
|
|
303
|
+
}
|
|
304
|
+
export interface FeesDistributedEvent {
|
|
305
|
+
total: bigint;
|
|
306
|
+
stakerShare: bigint;
|
|
307
|
+
treasuryShare: bigint;
|
|
308
|
+
referralShare: bigint;
|
|
309
|
+
}
|
|
310
|
+
export interface TreasuryWithdrawalEvent {
|
|
311
|
+
amount: bigint;
|
|
312
|
+
destination: PublicKey;
|
|
313
|
+
}
|
|
314
|
+
export interface StakedEvent {
|
|
315
|
+
owner: PublicKey;
|
|
316
|
+
amount: bigint;
|
|
317
|
+
tier: number;
|
|
318
|
+
lockupExpiry: bigint;
|
|
319
|
+
weightedAmount: bigint;
|
|
320
|
+
}
|
|
321
|
+
export interface UnstakedEvent {
|
|
322
|
+
owner: PublicKey;
|
|
323
|
+
amount: bigint;
|
|
324
|
+
}
|
|
325
|
+
export interface RewardClaimedEvent {
|
|
326
|
+
owner: PublicKey;
|
|
327
|
+
amountUsdc: bigint;
|
|
328
|
+
}
|
|
329
|
+
export interface RewardIndexUpdatedEvent {
|
|
330
|
+
rewardIndex: bigint;
|
|
331
|
+
newRewards: bigint;
|
|
332
|
+
}
|
|
333
|
+
export interface CompoundedRewardEvent {
|
|
334
|
+
owner: PublicKey;
|
|
335
|
+
amount: bigint;
|
|
336
|
+
tier: number;
|
|
337
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HaltMode = void 0;
|
|
4
|
+
var HaltMode;
|
|
5
|
+
(function (HaltMode) {
|
|
6
|
+
HaltMode[HaltMode["None"] = 0] = "None";
|
|
7
|
+
HaltMode[HaltMode["ReduceOnly"] = 1] = "ReduceOnly";
|
|
8
|
+
HaltMode[HaltMode["Full"] = 2] = "Full";
|
|
9
|
+
})(HaltMode || (exports.HaltMode = HaltMode = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withComputeBudget = withComputeBudget;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
function withComputeBudget(ixs, opts) {
|
|
6
|
+
const units = opts?.units ?? 400_000;
|
|
7
|
+
const prefix = [
|
|
8
|
+
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units }),
|
|
9
|
+
];
|
|
10
|
+
if (opts?.microLamports && opts.microLamports > 0) {
|
|
11
|
+
prefix.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: opts.microLamports }));
|
|
12
|
+
}
|
|
13
|
+
return [...prefix, ...ixs];
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare enum ParquetError {
|
|
2
|
+
PriceStale = 7001,
|
|
3
|
+
PriceUncertain = 7002,
|
|
4
|
+
OracleNoReturnData = 7003,
|
|
5
|
+
OracleReturnMismatch = 7004,
|
|
6
|
+
InsufficientPool = 8001,
|
|
7
|
+
LeverageExceeded = 8002,
|
|
8
|
+
BelowMinSize = 8003,
|
|
9
|
+
WrongPool = 8004,
|
|
10
|
+
OiCapExceeded = 8005,
|
|
11
|
+
BelowMinCollateral = 8006,
|
|
12
|
+
InvalidConfig = 8007,
|
|
13
|
+
QueueCollateralExceedsClaim = 8008,
|
|
14
|
+
WalletAndQueueZero = 8009,
|
|
15
|
+
MissingQueueEntryAccount = 8010,
|
|
16
|
+
LeverageExceedsTierCap = 8011,
|
|
17
|
+
MalformedQueueEntry = 8012,
|
|
18
|
+
QueueOwnerMismatch = 8013,
|
|
19
|
+
QueueMarketMismatch = 8014,
|
|
20
|
+
InitialMarginUnmet = 8015,
|
|
21
|
+
HealthFactorTooLow = 9001,
|
|
22
|
+
PositionHealthy = 9002,
|
|
23
|
+
TradingKeyExpired = 10001,
|
|
24
|
+
Unauthorized = 10002,
|
|
25
|
+
PositionNotFound = 10003,
|
|
26
|
+
MarketPaused = 10004,
|
|
27
|
+
ProtocolHalted = 10005,
|
|
28
|
+
InvalidHaltMode = 10006,
|
|
29
|
+
MathOverflow = 11001,
|
|
30
|
+
SlippageExceeded = 12001,
|
|
31
|
+
OrderNotTriggered = 12002,
|
|
32
|
+
WrongOrderType = 12003,
|
|
33
|
+
ReferralCodeTaken = 13001,
|
|
34
|
+
ReferralCodeNotFound = 13002,
|
|
35
|
+
TraderAlreadyReferred = 13003,
|
|
36
|
+
InvalidTier = 13004,
|
|
37
|
+
FundingCadenceTooFast = 14001,
|
|
38
|
+
InvalidOptimalUsage = 15001,
|
|
39
|
+
MustBePaused = 15002,
|
|
40
|
+
MissingFeeSettings = 15003,
|
|
41
|
+
MissingAffiliateReward = 15004,
|
|
42
|
+
MissingAffiliateRewardBump = 15005,
|
|
43
|
+
MissingFeeDistributorAccounts = 15006,
|
|
44
|
+
QueueEntryNotPending = 6012,
|
|
45
|
+
QueueNonEmpty = 6013,
|
|
46
|
+
PhantomEmpty = 6014,
|
|
47
|
+
InsufficientClaim = 6015,
|
|
48
|
+
PhantomDrainInsufficientFunds = 6016,
|
|
49
|
+
MissingAccount = 6017,
|
|
50
|
+
WrongEntryIndex = 6018,
|
|
51
|
+
WrongMarketId = 6019,
|
|
52
|
+
OwnerMismatch = 6020
|
|
53
|
+
}
|
|
54
|
+
export declare function errorMessage(code: ParquetError): string;
|
|
55
|
+
export declare function decodeError(err: unknown): ParquetError | null;
|
|
56
|
+
export declare function isParquetError(err: unknown, code: ParquetError): boolean;
|