@acta-markets/ts-sdk 0.0.19-beta → 0.0.21-beta
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/dist/chain/instructions.market.d.ts +0 -1
- package/dist/chain/instructions.market.js +1 -6
- package/dist/chain/instructions.oracle.d.ts +0 -3
- package/dist/chain/instructions.oracle.js +1 -5
- package/dist/chain/instructions.position.js +8 -16
- package/dist/chain/instructions.shared.d.ts +0 -1
- package/dist/chain/instructions.shared.js +0 -1
- package/dist/cjs/chain/instructions.market.js +0 -5
- package/dist/cjs/chain/instructions.oracle.js +0 -4
- package/dist/cjs/chain/instructions.position.js +8 -16
- package/dist/cjs/chain/instructions.shared.js +1 -2
- package/dist/cjs/generated/errors/actaContract.js +4 -1
- package/dist/cjs/generated/instructions/closeOracle.js +2 -13
- package/dist/cjs/generated/instructions/createMarket.js +1 -10
- package/dist/cjs/generated/instructions/createOracle.js +1 -4
- package/dist/cjs/generated/instructions/depositFundsToPosition.js +5 -11
- package/dist/cjs/generated/instructions/finalizeMarket.js +1 -9
- package/dist/cjs/generated/instructions/updateOraclePrice.js +2 -13
- package/dist/cjs/idl/acta_contract.json +10 -61
- package/dist/cjs/idl/hash.js +1 -1
- package/dist/cjs/ws/apy.js +4 -10
- package/dist/cjs/ws/apy.test.js +37 -1
- package/dist/cjs/ws/client.js +166 -15
- package/dist/generated/errors/actaContract.d.ts +3 -1
- package/dist/generated/errors/actaContract.js +3 -0
- package/dist/generated/instructions/closeOracle.d.ts +5 -10
- package/dist/generated/instructions/closeOracle.js +2 -13
- package/dist/generated/instructions/createMarket.d.ts +11 -21
- package/dist/generated/instructions/createMarket.js +1 -10
- package/dist/generated/instructions/createOracle.d.ts +7 -12
- package/dist/generated/instructions/createOracle.js +1 -4
- package/dist/generated/instructions/depositFundsToPosition.d.ts +9 -14
- package/dist/generated/instructions/depositFundsToPosition.js +5 -11
- package/dist/generated/instructions/finalizeMarket.d.ts +4 -9
- package/dist/generated/instructions/finalizeMarket.js +1 -9
- package/dist/generated/instructions/updateOraclePrice.d.ts +5 -10
- package/dist/generated/instructions/updateOraclePrice.js +2 -13
- package/dist/idl/acta_contract.json +10 -61
- package/dist/idl/hash.d.ts +1 -1
- package/dist/idl/hash.js +1 -1
- package/dist/ws/apy.d.ts +1 -1
- package/dist/ws/apy.js +4 -10
- package/dist/ws/apy.test.js +37 -1
- package/dist/ws/client.d.ts +60 -4
- package/dist/ws/client.js +166 -15
- package/dist/ws/types.d.ts +38 -2
- package/package.json +1 -1
|
@@ -23,7 +23,6 @@ export declare function buildFinalizeMarketIx(input: {
|
|
|
23
23
|
premiumMint?: Address<string>;
|
|
24
24
|
configPda?: Address<string>;
|
|
25
25
|
marketPda?: Address<string>;
|
|
26
|
-
clockSysvar?: Address<string>;
|
|
27
26
|
}): Promise<Instruction>;
|
|
28
27
|
export declare function buildCloseMarketIx(input: {
|
|
29
28
|
admin: Signerish;
|
|
@@ -3,7 +3,7 @@ import { getFinalizeMarketInstruction } from "../generated/instructions/finalize
|
|
|
3
3
|
import { getCloseMarketInstruction } from "../generated/instructions/closeMarket";
|
|
4
4
|
import { getActaProgramId } from "../index";
|
|
5
5
|
import { findConfigPda, findMarketPda, findOraclePda } from "./helpers";
|
|
6
|
-
import {
|
|
6
|
+
import { toAddress, toPublicKey, toTxnSigner, } from "./instructions.shared";
|
|
7
7
|
export async function buildCreateMarketIx(input) {
|
|
8
8
|
const configPda = input.configPda ??
|
|
9
9
|
(input.premiumMint
|
|
@@ -18,8 +18,6 @@ export async function buildCreateMarketIx(input) {
|
|
|
18
18
|
expiryTs: input.expiryTs,
|
|
19
19
|
isPut: input.isPut,
|
|
20
20
|
}));
|
|
21
|
-
const underlyingMintAcc = toAddress(input.underlyingMint);
|
|
22
|
-
const quoteMintAcc = toAddress(input.quoteMint);
|
|
23
21
|
const oracleUnderlying = input.oracleUnderlying ??
|
|
24
22
|
(await findOraclePda({
|
|
25
23
|
mint: toAddress(input.underlyingMint),
|
|
@@ -36,8 +34,6 @@ export async function buildCreateMarketIx(input) {
|
|
|
36
34
|
marketPda: toAddress(marketPda),
|
|
37
35
|
underlyingMint: toAddress(input.underlyingMint),
|
|
38
36
|
quoteMint: toAddress(input.quoteMint),
|
|
39
|
-
underlyingMintAcc,
|
|
40
|
-
quoteMintAcc,
|
|
41
37
|
oracleUnderlying: toAddress(oracleUnderlying),
|
|
42
38
|
oracleQuote: toAddress(oracleQuote),
|
|
43
39
|
expiryTs: input.expiryTs,
|
|
@@ -74,7 +70,6 @@ export async function buildFinalizeMarketIx(input) {
|
|
|
74
70
|
marketPda: toAddress(marketPda),
|
|
75
71
|
oracleUnderlying: toAddress(oracleUnderlying),
|
|
76
72
|
oracleQuote: toAddress(oracleQuote),
|
|
77
|
-
clockSysvar: toAddress(input.clockSysvar ?? CLOCK_SYSVAR_ID),
|
|
78
73
|
}, { programAddress: getActaProgramId() });
|
|
79
74
|
}
|
|
80
75
|
export async function buildCloseMarketIx(input) {
|
|
@@ -8,7 +8,6 @@ export declare function buildCreateOracleIx(input: {
|
|
|
8
8
|
authority: Address<string>;
|
|
9
9
|
feedId: Uint8Array;
|
|
10
10
|
oraclePda?: Address<string>;
|
|
11
|
-
mintAcc?: Address<string>;
|
|
12
11
|
systemProgram?: Address<string>;
|
|
13
12
|
}): Promise<Instruction>;
|
|
14
13
|
export declare function buildUpdateOraclePriceIx(input: {
|
|
@@ -16,7 +15,6 @@ export declare function buildUpdateOraclePriceIx(input: {
|
|
|
16
15
|
oraclePda: Address<string>;
|
|
17
16
|
price: bigint | number;
|
|
18
17
|
settledExpiryTs: bigint | number;
|
|
19
|
-
clockSysvar?: Address<string>;
|
|
20
18
|
}): Promise<Instruction>;
|
|
21
19
|
export declare function buildChangeOracleSourceIx(input: {
|
|
22
20
|
admin: Signerish;
|
|
@@ -27,7 +25,6 @@ export declare function buildChangeOracleSourceIx(input: {
|
|
|
27
25
|
export declare function buildCloseOracleIx(input: {
|
|
28
26
|
signer: Signerish;
|
|
29
27
|
oraclePda: Address<string>;
|
|
30
|
-
clockSysvar?: Address<string>;
|
|
31
28
|
}): Promise<Instruction>;
|
|
32
29
|
export declare function buildSetOracleConfigIx(input: {
|
|
33
30
|
admin: Signerish;
|
|
@@ -5,19 +5,17 @@ import { getCloseOracleInstruction } from "../generated/instructions/closeOracle
|
|
|
5
5
|
import { getSetOracleConfigInstruction } from "../generated/instructions/setOracleConfig";
|
|
6
6
|
import { getActaProgramId } from "../index";
|
|
7
7
|
import { findOraclePda } from "./helpers";
|
|
8
|
-
import {
|
|
8
|
+
import { toAddress, toTxnSigner, } from "./instructions.shared";
|
|
9
9
|
export async function buildCreateOracleIx(input) {
|
|
10
10
|
const oraclePda = input.oraclePda ??
|
|
11
11
|
(await findOraclePda({
|
|
12
12
|
mint: toAddress(input.mint),
|
|
13
13
|
expiryTs: input.expiryTs,
|
|
14
14
|
}));
|
|
15
|
-
const mintAcc = input.mintAcc ?? toAddress(input.mint);
|
|
16
15
|
return getCreateOracleInstruction({
|
|
17
16
|
admin: toTxnSigner(input.admin, "admin"),
|
|
18
17
|
oraclePda: toAddress(oraclePda),
|
|
19
18
|
mint: toAddress(input.mint),
|
|
20
|
-
mintAcc: toAddress(mintAcc),
|
|
21
19
|
systemProgram: input.systemProgram
|
|
22
20
|
? toAddress(input.systemProgram)
|
|
23
21
|
: undefined,
|
|
@@ -31,7 +29,6 @@ export async function buildUpdateOraclePriceIx(input) {
|
|
|
31
29
|
return getUpdateOraclePriceInstruction({
|
|
32
30
|
authority: toTxnSigner(input.authority, "authority"),
|
|
33
31
|
oraclePda: toAddress(input.oraclePda),
|
|
34
|
-
clockSysvar: toAddress(input.clockSysvar ?? CLOCK_SYSVAR_ID),
|
|
35
32
|
price: input.price,
|
|
36
33
|
settledExpiryTs: input.settledExpiryTs,
|
|
37
34
|
}, { programAddress: getActaProgramId() });
|
|
@@ -48,7 +45,6 @@ export async function buildCloseOracleIx(input) {
|
|
|
48
45
|
return getCloseOracleInstruction({
|
|
49
46
|
signer: toTxnSigner(input.signer, "signer"),
|
|
50
47
|
oraclePda: toAddress(input.oraclePda),
|
|
51
|
-
clockSysvar: toAddress(input.clockSysvar ?? CLOCK_SYSVAR_ID),
|
|
52
48
|
}, { programAddress: getActaProgramId() });
|
|
53
49
|
}
|
|
54
50
|
export async function buildSetOracleConfigIx(input) {
|
|
@@ -97,22 +97,15 @@ export async function buildDepositFundsToPositionIx(input) {
|
|
|
97
97
|
expiryTs: input.expiryTs,
|
|
98
98
|
isPut: input.isPut,
|
|
99
99
|
}));
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const quoteTokenProgram = await resolveTokenProgramForMint({
|
|
107
|
-
mint: input.quoteMint,
|
|
108
|
-
tokenProgram: input.quoteTokenProgram ?? input.tokenProgram,
|
|
100
|
+
const settlementMint = input.isPut ? input.underlyingMint : input.quoteMint;
|
|
101
|
+
const settlementTokenProgram = await resolveTokenProgramForMint({
|
|
102
|
+
mint: settlementMint,
|
|
103
|
+
tokenProgram: input.isPut
|
|
104
|
+
? (input.underlyingTokenProgram ?? input.tokenProgram)
|
|
105
|
+
: (input.quoteTokenProgram ?? input.tokenProgram),
|
|
109
106
|
rpc: input.rpc,
|
|
110
|
-
label: "
|
|
107
|
+
label: "settlementTokenProgram",
|
|
111
108
|
});
|
|
112
|
-
const settlementMint = input.isPut ? input.underlyingMint : input.quoteMint;
|
|
113
|
-
const settlementTokenProgram = input.isPut
|
|
114
|
-
? underlyingTokenProgram
|
|
115
|
-
: quoteTokenProgram;
|
|
116
109
|
const makerFundingAta = input.makerFundingAta ??
|
|
117
110
|
(await deriveAta({
|
|
118
111
|
mint: settlementMint,
|
|
@@ -132,8 +125,7 @@ export async function buildDepositFundsToPositionIx(input) {
|
|
|
132
125
|
marketPda: toAddress(marketPda),
|
|
133
126
|
makerFundingAta: toAddress(makerFundingAta),
|
|
134
127
|
posSettlementAta: toAddress(posSettlementAta),
|
|
135
|
-
|
|
136
|
-
quoteTokenProgram,
|
|
128
|
+
settlementTokenProgram,
|
|
137
129
|
}, { programAddress: getActaProgramId() });
|
|
138
130
|
}
|
|
139
131
|
export async function buildSettlePositionIx(input) {
|
|
@@ -3,7 +3,6 @@ import type { createSolanaRpc } from "@solana/rpc";
|
|
|
3
3
|
import { ASSOCIATED_TOKEN_PROGRAM_ID } from "./token";
|
|
4
4
|
export type Signerish = Address<string> | TransactionSigner<string>;
|
|
5
5
|
export type Rpc = ReturnType<typeof createSolanaRpc>;
|
|
6
|
-
export declare const CLOCK_SYSVAR_ID: Address<string>;
|
|
7
6
|
export declare const toAddress: (value: Address<string> | TransactionSigner<string>) => Address<string>;
|
|
8
7
|
export declare const toTxnSigner: (value: Signerish, label?: string) => TransactionSigner<string>;
|
|
9
8
|
export declare const toPublicKey: (value: Address<string>) => Address<string>;
|
|
@@ -2,7 +2,6 @@ import { isTransactionSigner as kitIsTransactionSigner, } from "@solana/kit";
|
|
|
2
2
|
import { getAddressEncoder, getProgramDerivedAddress } from "@solana/addresses";
|
|
3
3
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, fetchTokenProgramForMint, } from "./token";
|
|
4
4
|
const addressEncoder = getAddressEncoder();
|
|
5
|
-
export const CLOCK_SYSVAR_ID = "SysvarC1ock11111111111111111111111111111111";
|
|
6
5
|
export const toAddress = (value) => typeof value === "string"
|
|
7
6
|
? value
|
|
8
7
|
: value.address;
|
|
@@ -23,8 +23,6 @@ async function buildCreateMarketIx(input) {
|
|
|
23
23
|
expiryTs: input.expiryTs,
|
|
24
24
|
isPut: input.isPut,
|
|
25
25
|
}));
|
|
26
|
-
const underlyingMintAcc = (0, instructions_shared_1.toAddress)(input.underlyingMint);
|
|
27
|
-
const quoteMintAcc = (0, instructions_shared_1.toAddress)(input.quoteMint);
|
|
28
26
|
const oracleUnderlying = input.oracleUnderlying ??
|
|
29
27
|
(await (0, helpers_1.findOraclePda)({
|
|
30
28
|
mint: (0, instructions_shared_1.toAddress)(input.underlyingMint),
|
|
@@ -41,8 +39,6 @@ async function buildCreateMarketIx(input) {
|
|
|
41
39
|
marketPda: (0, instructions_shared_1.toAddress)(marketPda),
|
|
42
40
|
underlyingMint: (0, instructions_shared_1.toAddress)(input.underlyingMint),
|
|
43
41
|
quoteMint: (0, instructions_shared_1.toAddress)(input.quoteMint),
|
|
44
|
-
underlyingMintAcc,
|
|
45
|
-
quoteMintAcc,
|
|
46
42
|
oracleUnderlying: (0, instructions_shared_1.toAddress)(oracleUnderlying),
|
|
47
43
|
oracleQuote: (0, instructions_shared_1.toAddress)(oracleQuote),
|
|
48
44
|
expiryTs: input.expiryTs,
|
|
@@ -79,7 +75,6 @@ async function buildFinalizeMarketIx(input) {
|
|
|
79
75
|
marketPda: (0, instructions_shared_1.toAddress)(marketPda),
|
|
80
76
|
oracleUnderlying: (0, instructions_shared_1.toAddress)(oracleUnderlying),
|
|
81
77
|
oracleQuote: (0, instructions_shared_1.toAddress)(oracleQuote),
|
|
82
|
-
clockSysvar: (0, instructions_shared_1.toAddress)(input.clockSysvar ?? instructions_shared_1.CLOCK_SYSVAR_ID),
|
|
83
78
|
}, { programAddress: (0, index_1.getActaProgramId)() });
|
|
84
79
|
}
|
|
85
80
|
async function buildCloseMarketIx(input) {
|
|
@@ -19,12 +19,10 @@ async function buildCreateOracleIx(input) {
|
|
|
19
19
|
mint: (0, instructions_shared_1.toAddress)(input.mint),
|
|
20
20
|
expiryTs: input.expiryTs,
|
|
21
21
|
}));
|
|
22
|
-
const mintAcc = input.mintAcc ?? (0, instructions_shared_1.toAddress)(input.mint);
|
|
23
22
|
return (0, createOracle_1.getCreateOracleInstruction)({
|
|
24
23
|
admin: (0, instructions_shared_1.toTxnSigner)(input.admin, "admin"),
|
|
25
24
|
oraclePda: (0, instructions_shared_1.toAddress)(oraclePda),
|
|
26
25
|
mint: (0, instructions_shared_1.toAddress)(input.mint),
|
|
27
|
-
mintAcc: (0, instructions_shared_1.toAddress)(mintAcc),
|
|
28
26
|
systemProgram: input.systemProgram
|
|
29
27
|
? (0, instructions_shared_1.toAddress)(input.systemProgram)
|
|
30
28
|
: undefined,
|
|
@@ -38,7 +36,6 @@ async function buildUpdateOraclePriceIx(input) {
|
|
|
38
36
|
return (0, updateOraclePrice_1.getUpdateOraclePriceInstruction)({
|
|
39
37
|
authority: (0, instructions_shared_1.toTxnSigner)(input.authority, "authority"),
|
|
40
38
|
oraclePda: (0, instructions_shared_1.toAddress)(input.oraclePda),
|
|
41
|
-
clockSysvar: (0, instructions_shared_1.toAddress)(input.clockSysvar ?? instructions_shared_1.CLOCK_SYSVAR_ID),
|
|
42
39
|
price: input.price,
|
|
43
40
|
settledExpiryTs: input.settledExpiryTs,
|
|
44
41
|
}, { programAddress: (0, index_1.getActaProgramId)() });
|
|
@@ -55,7 +52,6 @@ async function buildCloseOracleIx(input) {
|
|
|
55
52
|
return (0, closeOracle_1.getCloseOracleInstruction)({
|
|
56
53
|
signer: (0, instructions_shared_1.toTxnSigner)(input.signer, "signer"),
|
|
57
54
|
oraclePda: (0, instructions_shared_1.toAddress)(input.oraclePda),
|
|
58
|
-
clockSysvar: (0, instructions_shared_1.toAddress)(input.clockSysvar ?? instructions_shared_1.CLOCK_SYSVAR_ID),
|
|
59
55
|
}, { programAddress: (0, index_1.getActaProgramId)() });
|
|
60
56
|
}
|
|
61
57
|
async function buildSetOracleConfigIx(input) {
|
|
@@ -104,22 +104,15 @@ async function buildDepositFundsToPositionIx(input) {
|
|
|
104
104
|
expiryTs: input.expiryTs,
|
|
105
105
|
isPut: input.isPut,
|
|
106
106
|
}));
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const quoteTokenProgram = await (0, instructions_shared_1.resolveTokenProgramForMint)({
|
|
114
|
-
mint: input.quoteMint,
|
|
115
|
-
tokenProgram: input.quoteTokenProgram ?? input.tokenProgram,
|
|
107
|
+
const settlementMint = input.isPut ? input.underlyingMint : input.quoteMint;
|
|
108
|
+
const settlementTokenProgram = await (0, instructions_shared_1.resolveTokenProgramForMint)({
|
|
109
|
+
mint: settlementMint,
|
|
110
|
+
tokenProgram: input.isPut
|
|
111
|
+
? (input.underlyingTokenProgram ?? input.tokenProgram)
|
|
112
|
+
: (input.quoteTokenProgram ?? input.tokenProgram),
|
|
116
113
|
rpc: input.rpc,
|
|
117
|
-
label: "
|
|
114
|
+
label: "settlementTokenProgram",
|
|
118
115
|
});
|
|
119
|
-
const settlementMint = input.isPut ? input.underlyingMint : input.quoteMint;
|
|
120
|
-
const settlementTokenProgram = input.isPut
|
|
121
|
-
? underlyingTokenProgram
|
|
122
|
-
: quoteTokenProgram;
|
|
123
116
|
const makerFundingAta = input.makerFundingAta ??
|
|
124
117
|
(await (0, instructions_shared_1.deriveAta)({
|
|
125
118
|
mint: settlementMint,
|
|
@@ -139,8 +132,7 @@ async function buildDepositFundsToPositionIx(input) {
|
|
|
139
132
|
marketPda: (0, instructions_shared_1.toAddress)(marketPda),
|
|
140
133
|
makerFundingAta: (0, instructions_shared_1.toAddress)(makerFundingAta),
|
|
141
134
|
posSettlementAta: (0, instructions_shared_1.toAddress)(posSettlementAta),
|
|
142
|
-
|
|
143
|
-
quoteTokenProgram,
|
|
135
|
+
settlementTokenProgram,
|
|
144
136
|
}, { programAddress: (0, index_1.getActaProgramId)() });
|
|
145
137
|
}
|
|
146
138
|
async function buildSettlePositionIx(input) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ASSOCIATED_TOKEN_PROGRAM_ID = exports.toPublicKeyFromSignerish = exports.toPublicKey = exports.toTxnSigner = exports.toAddress =
|
|
3
|
+
exports.ASSOCIATED_TOKEN_PROGRAM_ID = exports.toPublicKeyFromSignerish = exports.toPublicKey = exports.toTxnSigner = exports.toAddress = void 0;
|
|
4
4
|
exports.deriveAta = deriveAta;
|
|
5
5
|
exports.resolveTokenProgramForMint = resolveTokenProgramForMint;
|
|
6
6
|
const kit_1 = require("@solana/kit");
|
|
@@ -8,7 +8,6 @@ const addresses_1 = require("@solana/addresses");
|
|
|
8
8
|
const token_1 = require("./token");
|
|
9
9
|
Object.defineProperty(exports, "ASSOCIATED_TOKEN_PROGRAM_ID", { enumerable: true, get: function () { return token_1.ASSOCIATED_TOKEN_PROGRAM_ID; } });
|
|
10
10
|
const addressEncoder = (0, addresses_1.getAddressEncoder)();
|
|
11
|
-
exports.CLOCK_SYSVAR_ID = "SysvarC1ock11111111111111111111111111111111";
|
|
12
11
|
const toAddress = (value) => typeof value === "string"
|
|
13
12
|
? value
|
|
14
13
|
: value.address;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://github.com/codama-idl/codama
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
|
|
10
|
+
exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
|
|
11
11
|
exports.getActaContractErrorMessage = getActaContractErrorMessage;
|
|
12
12
|
exports.isActaContractError = isActaContractError;
|
|
13
13
|
const kit_1 = require("@solana/kit");
|
|
@@ -102,6 +102,8 @@ exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
|
|
|
102
102
|
exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
|
|
103
103
|
/** MarketNotExpired: Market has not expired yet */
|
|
104
104
|
exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
|
|
105
|
+
/** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
|
|
106
|
+
exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
|
|
105
107
|
let actaContractErrorMessages;
|
|
106
108
|
if (process.env.NODE_ENV !== "production") {
|
|
107
109
|
actaContractErrorMessages = {
|
|
@@ -138,6 +140,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
138
140
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS]: `Oracle is still linked to active markets`,
|
|
139
141
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE]: `Oracle inactive`,
|
|
140
142
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE]: `Oracle price invalid (zero or negative)`,
|
|
143
|
+
[exports.ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET]: `Oracle has not expired yet (cannot update price before expiry)`,
|
|
141
144
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED]: `Oracle source fields are locked after first update`,
|
|
142
145
|
[exports.ACTA_CONTRACT_ERROR__ORACLE_STALE]: `Oracle price is stale (updated_at before expiry)`,
|
|
143
146
|
[exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED]: `Position already funded by maker`,
|
|
@@ -37,27 +37,20 @@ function getCloseOracleInstruction(input, config) {
|
|
|
37
37
|
const originalAccounts = {
|
|
38
38
|
signer: { value: input.signer ?? null, isWritable: true },
|
|
39
39
|
oraclePda: { value: input.oraclePda ?? null, isWritable: true },
|
|
40
|
-
clockSysvar: { value: input.clockSysvar ?? null, isWritable: false },
|
|
41
40
|
};
|
|
42
41
|
const accounts = originalAccounts;
|
|
43
|
-
// Resolve default values.
|
|
44
|
-
if (!accounts.clockSysvar.value) {
|
|
45
|
-
accounts.clockSysvar.value =
|
|
46
|
-
"SysvarC1ock11111111111111111111111111111111";
|
|
47
|
-
}
|
|
48
42
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
|
|
49
43
|
return Object.freeze({
|
|
50
44
|
accounts: [
|
|
51
45
|
getAccountMeta(accounts.signer),
|
|
52
46
|
getAccountMeta(accounts.oraclePda),
|
|
53
|
-
getAccountMeta(accounts.clockSysvar),
|
|
54
47
|
],
|
|
55
48
|
data: getCloseOracleInstructionDataEncoder().encode({}),
|
|
56
49
|
programAddress,
|
|
57
50
|
});
|
|
58
51
|
}
|
|
59
52
|
function parseCloseOracleInstruction(instruction) {
|
|
60
|
-
if (instruction.accounts.length <
|
|
53
|
+
if (instruction.accounts.length < 2) {
|
|
61
54
|
// TODO: Coded error.
|
|
62
55
|
throw new Error("Not enough accounts");
|
|
63
56
|
}
|
|
@@ -69,11 +62,7 @@ function parseCloseOracleInstruction(instruction) {
|
|
|
69
62
|
};
|
|
70
63
|
return {
|
|
71
64
|
programAddress: instruction.programAddress,
|
|
72
|
-
accounts: {
|
|
73
|
-
signer: getNextAccount(),
|
|
74
|
-
oraclePda: getNextAccount(),
|
|
75
|
-
clockSysvar: getNextAccount(),
|
|
76
|
-
},
|
|
65
|
+
accounts: { signer: getNextAccount(), oraclePda: getNextAccount() },
|
|
77
66
|
data: getCloseOracleInstructionDataDecoder().decode(instruction.data),
|
|
78
67
|
};
|
|
79
68
|
}
|
|
@@ -48,11 +48,6 @@ function getCreateMarketInstruction(input, config) {
|
|
|
48
48
|
marketPda: { value: input.marketPda ?? null, isWritable: true },
|
|
49
49
|
underlyingMint: { value: input.underlyingMint ?? null, isWritable: false },
|
|
50
50
|
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
51
|
-
underlyingMintAcc: {
|
|
52
|
-
value: input.underlyingMintAcc ?? null,
|
|
53
|
-
isWritable: false,
|
|
54
|
-
},
|
|
55
|
-
quoteMintAcc: { value: input.quoteMintAcc ?? null, isWritable: false },
|
|
56
51
|
oracleUnderlying: {
|
|
57
52
|
value: input.oracleUnderlying ?? null,
|
|
58
53
|
isWritable: true,
|
|
@@ -76,8 +71,6 @@ function getCreateMarketInstruction(input, config) {
|
|
|
76
71
|
getAccountMeta(accounts.marketPda),
|
|
77
72
|
getAccountMeta(accounts.underlyingMint),
|
|
78
73
|
getAccountMeta(accounts.quoteMint),
|
|
79
|
-
getAccountMeta(accounts.underlyingMintAcc),
|
|
80
|
-
getAccountMeta(accounts.quoteMintAcc),
|
|
81
74
|
getAccountMeta(accounts.oracleUnderlying),
|
|
82
75
|
getAccountMeta(accounts.oracleQuote),
|
|
83
76
|
getAccountMeta(accounts.systemProgram),
|
|
@@ -87,7 +80,7 @@ function getCreateMarketInstruction(input, config) {
|
|
|
87
80
|
});
|
|
88
81
|
}
|
|
89
82
|
function parseCreateMarketInstruction(instruction) {
|
|
90
|
-
if (instruction.accounts.length <
|
|
83
|
+
if (instruction.accounts.length < 8) {
|
|
91
84
|
// TODO: Coded error.
|
|
92
85
|
throw new Error("Not enough accounts");
|
|
93
86
|
}
|
|
@@ -105,8 +98,6 @@ function parseCreateMarketInstruction(instruction) {
|
|
|
105
98
|
marketPda: getNextAccount(),
|
|
106
99
|
underlyingMint: getNextAccount(),
|
|
107
100
|
quoteMint: getNextAccount(),
|
|
108
|
-
underlyingMintAcc: getNextAccount(),
|
|
109
|
-
quoteMintAcc: getNextAccount(),
|
|
110
101
|
oracleUnderlying: getNextAccount(),
|
|
111
102
|
oracleQuote: getNextAccount(),
|
|
112
103
|
systemProgram: getNextAccount(),
|
|
@@ -50,7 +50,6 @@ function getCreateOracleInstruction(input, config) {
|
|
|
50
50
|
admin: { value: input.admin ?? null, isWritable: true },
|
|
51
51
|
oraclePda: { value: input.oraclePda ?? null, isWritable: true },
|
|
52
52
|
mint: { value: input.mint ?? null, isWritable: false },
|
|
53
|
-
mintAcc: { value: input.mintAcc ?? null, isWritable: false },
|
|
54
53
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
55
54
|
};
|
|
56
55
|
const accounts = originalAccounts;
|
|
@@ -67,7 +66,6 @@ function getCreateOracleInstruction(input, config) {
|
|
|
67
66
|
getAccountMeta(accounts.admin),
|
|
68
67
|
getAccountMeta(accounts.oraclePda),
|
|
69
68
|
getAccountMeta(accounts.mint),
|
|
70
|
-
getAccountMeta(accounts.mintAcc),
|
|
71
69
|
getAccountMeta(accounts.systemProgram),
|
|
72
70
|
],
|
|
73
71
|
data: getCreateOracleInstructionDataEncoder().encode(args),
|
|
@@ -75,7 +73,7 @@ function getCreateOracleInstruction(input, config) {
|
|
|
75
73
|
});
|
|
76
74
|
}
|
|
77
75
|
function parseCreateOracleInstruction(instruction) {
|
|
78
|
-
if (instruction.accounts.length <
|
|
76
|
+
if (instruction.accounts.length < 4) {
|
|
79
77
|
// TODO: Coded error.
|
|
80
78
|
throw new Error("Not enough accounts");
|
|
81
79
|
}
|
|
@@ -91,7 +89,6 @@ function parseCreateOracleInstruction(instruction) {
|
|
|
91
89
|
admin: getNextAccount(),
|
|
92
90
|
oraclePda: getNextAccount(),
|
|
93
91
|
mint: getNextAccount(),
|
|
94
|
-
mintAcc: getNextAccount(),
|
|
95
92
|
systemProgram: getNextAccount(),
|
|
96
93
|
},
|
|
97
94
|
data: getCreateOracleInstructionDataDecoder().decode(instruction.data),
|
|
@@ -47,12 +47,8 @@ function getDepositFundsToPositionInstruction(input, config) {
|
|
|
47
47
|
value: input.posSettlementAta ?? null,
|
|
48
48
|
isWritable: true,
|
|
49
49
|
},
|
|
50
|
-
|
|
51
|
-
value: input.
|
|
52
|
-
isWritable: false,
|
|
53
|
-
},
|
|
54
|
-
quoteTokenProgram: {
|
|
55
|
-
value: input.quoteTokenProgram ?? null,
|
|
50
|
+
settlementTokenProgram: {
|
|
51
|
+
value: input.settlementTokenProgram ?? null,
|
|
56
52
|
isWritable: false,
|
|
57
53
|
},
|
|
58
54
|
};
|
|
@@ -66,15 +62,14 @@ function getDepositFundsToPositionInstruction(input, config) {
|
|
|
66
62
|
getAccountMeta(accounts.marketPda),
|
|
67
63
|
getAccountMeta(accounts.makerFundingAta),
|
|
68
64
|
getAccountMeta(accounts.posSettlementAta),
|
|
69
|
-
getAccountMeta(accounts.
|
|
70
|
-
getAccountMeta(accounts.quoteTokenProgram),
|
|
65
|
+
getAccountMeta(accounts.settlementTokenProgram),
|
|
71
66
|
],
|
|
72
67
|
data: getDepositFundsToPositionInstructionDataEncoder().encode({}),
|
|
73
68
|
programAddress,
|
|
74
69
|
});
|
|
75
70
|
}
|
|
76
71
|
function parseDepositFundsToPositionInstruction(instruction) {
|
|
77
|
-
if (instruction.accounts.length <
|
|
72
|
+
if (instruction.accounts.length < 7) {
|
|
78
73
|
// TODO: Coded error.
|
|
79
74
|
throw new Error("Not enough accounts");
|
|
80
75
|
}
|
|
@@ -93,8 +88,7 @@ function parseDepositFundsToPositionInstruction(instruction) {
|
|
|
93
88
|
marketPda: getNextAccount(),
|
|
94
89
|
makerFundingAta: getNextAccount(),
|
|
95
90
|
posSettlementAta: getNextAccount(),
|
|
96
|
-
|
|
97
|
-
quoteTokenProgram: getNextAccount(),
|
|
91
|
+
settlementTokenProgram: getNextAccount(),
|
|
98
92
|
},
|
|
99
93
|
data: getDepositFundsToPositionInstructionDataDecoder().decode(instruction.data),
|
|
100
94
|
};
|
|
@@ -43,14 +43,8 @@ function getFinalizeMarketInstruction(input, config) {
|
|
|
43
43
|
isWritable: false,
|
|
44
44
|
},
|
|
45
45
|
oracleQuote: { value: input.oracleQuote ?? null, isWritable: false },
|
|
46
|
-
clockSysvar: { value: input.clockSysvar ?? null, isWritable: false },
|
|
47
46
|
};
|
|
48
47
|
const accounts = originalAccounts;
|
|
49
|
-
// Resolve default values.
|
|
50
|
-
if (!accounts.clockSysvar.value) {
|
|
51
|
-
accounts.clockSysvar.value =
|
|
52
|
-
"SysvarC1ock11111111111111111111111111111111";
|
|
53
|
-
}
|
|
54
48
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
|
|
55
49
|
return Object.freeze({
|
|
56
50
|
accounts: [
|
|
@@ -59,14 +53,13 @@ function getFinalizeMarketInstruction(input, config) {
|
|
|
59
53
|
getAccountMeta(accounts.configPda),
|
|
60
54
|
getAccountMeta(accounts.oracleUnderlying),
|
|
61
55
|
getAccountMeta(accounts.oracleQuote),
|
|
62
|
-
getAccountMeta(accounts.clockSysvar),
|
|
63
56
|
],
|
|
64
57
|
data: getFinalizeMarketInstructionDataEncoder().encode({}),
|
|
65
58
|
programAddress,
|
|
66
59
|
});
|
|
67
60
|
}
|
|
68
61
|
function parseFinalizeMarketInstruction(instruction) {
|
|
69
|
-
if (instruction.accounts.length <
|
|
62
|
+
if (instruction.accounts.length < 5) {
|
|
70
63
|
// TODO: Coded error.
|
|
71
64
|
throw new Error("Not enough accounts");
|
|
72
65
|
}
|
|
@@ -84,7 +77,6 @@ function parseFinalizeMarketInstruction(instruction) {
|
|
|
84
77
|
configPda: getNextAccount(),
|
|
85
78
|
oracleUnderlying: getNextAccount(),
|
|
86
79
|
oracleQuote: getNextAccount(),
|
|
87
|
-
clockSysvar: getNextAccount(),
|
|
88
80
|
},
|
|
89
81
|
data: getFinalizeMarketInstructionDataDecoder().decode(instruction.data),
|
|
90
82
|
};
|
|
@@ -45,29 +45,22 @@ function getUpdateOraclePriceInstruction(input, config) {
|
|
|
45
45
|
const originalAccounts = {
|
|
46
46
|
authority: { value: input.authority ?? null, isWritable: false },
|
|
47
47
|
oraclePda: { value: input.oraclePda ?? null, isWritable: true },
|
|
48
|
-
clockSysvar: { value: input.clockSysvar ?? null, isWritable: false },
|
|
49
48
|
};
|
|
50
49
|
const accounts = originalAccounts;
|
|
51
50
|
// Original args.
|
|
52
51
|
const args = { ...input };
|
|
53
|
-
// Resolve default values.
|
|
54
|
-
if (!accounts.clockSysvar.value) {
|
|
55
|
-
accounts.clockSysvar.value =
|
|
56
|
-
"SysvarC1ock11111111111111111111111111111111";
|
|
57
|
-
}
|
|
58
52
|
const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, "programId");
|
|
59
53
|
return Object.freeze({
|
|
60
54
|
accounts: [
|
|
61
55
|
getAccountMeta(accounts.authority),
|
|
62
56
|
getAccountMeta(accounts.oraclePda),
|
|
63
|
-
getAccountMeta(accounts.clockSysvar),
|
|
64
57
|
],
|
|
65
58
|
data: getUpdateOraclePriceInstructionDataEncoder().encode(args),
|
|
66
59
|
programAddress,
|
|
67
60
|
});
|
|
68
61
|
}
|
|
69
62
|
function parseUpdateOraclePriceInstruction(instruction) {
|
|
70
|
-
if (instruction.accounts.length <
|
|
63
|
+
if (instruction.accounts.length < 2) {
|
|
71
64
|
// TODO: Coded error.
|
|
72
65
|
throw new Error("Not enough accounts");
|
|
73
66
|
}
|
|
@@ -79,11 +72,7 @@ function parseUpdateOraclePriceInstruction(instruction) {
|
|
|
79
72
|
};
|
|
80
73
|
return {
|
|
81
74
|
programAddress: instruction.programAddress,
|
|
82
|
-
accounts: {
|
|
83
|
-
authority: getNextAccount(),
|
|
84
|
-
oraclePda: getNextAccount(),
|
|
85
|
-
clockSysvar: getNextAccount(),
|
|
86
|
-
},
|
|
75
|
+
accounts: { authority: getNextAccount(), oraclePda: getNextAccount() },
|
|
87
76
|
data: getUpdateOraclePriceInstructionDataDecoder().decode(instruction.data),
|
|
88
77
|
};
|
|
89
78
|
}
|