@acta-markets/ts-sdk 0.0.1-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/README.md +308 -0
- package/dist/actaClient.d.ts +46 -0
- package/dist/actaClient.js +99 -0
- package/dist/chain/client.d.ts +65 -0
- package/dist/chain/client.js +82 -0
- package/dist/chain/fetch.d.ts +204 -0
- package/dist/chain/fetch.js +392 -0
- package/dist/chain/fetch.test.d.ts +1 -0
- package/dist/chain/fetch.test.js +158 -0
- package/dist/chain/flows/index.d.ts +1 -0
- package/dist/chain/flows/index.js +1 -0
- package/dist/chain/flows/openPosition.d.ts +48 -0
- package/dist/chain/flows/openPosition.js +78 -0
- package/dist/chain/flows/openPosition.test.d.ts +1 -0
- package/dist/chain/flows/openPosition.test.js +43 -0
- package/dist/chain/helpers.d.ts +16 -0
- package/dist/chain/helpers.js +60 -0
- package/dist/chain/index.d.ts +9 -0
- package/dist/chain/index.js +9 -0
- package/dist/chain/instructions.admin.d.ts +44 -0
- package/dist/chain/instructions.admin.js +113 -0
- package/dist/chain/instructions.d.ts +5 -0
- package/dist/chain/instructions.js +5 -0
- package/dist/chain/instructions.maker.d.ts +34 -0
- package/dist/chain/instructions.maker.js +86 -0
- package/dist/chain/instructions.market.d.ts +39 -0
- package/dist/chain/instructions.market.js +107 -0
- package/dist/chain/instructions.oracle.d.ts +38 -0
- package/dist/chain/instructions.oracle.js +63 -0
- package/dist/chain/instructions.position.d.ts +82 -0
- package/dist/chain/instructions.position.js +240 -0
- package/dist/chain/instructions.resolve.test.d.ts +1 -0
- package/dist/chain/instructions.resolve.test.js +32 -0
- package/dist/chain/instructions.shared.d.ts +23 -0
- package/dist/chain/instructions.shared.js +55 -0
- package/dist/chain/orders.d.ts +40 -0
- package/dist/chain/orders.js +117 -0
- package/dist/chain/orders.test.d.ts +1 -0
- package/dist/chain/orders.test.js +67 -0
- package/dist/chain/signers.d.ts +9 -0
- package/dist/chain/signers.js +19 -0
- package/dist/chain/signers.test.d.ts +1 -0
- package/dist/chain/signers.test.js +13 -0
- package/dist/chain/token.d.ts +59 -0
- package/dist/chain/token.js +136 -0
- package/dist/chain/token.test.d.ts +1 -0
- package/dist/chain/token.test.js +69 -0
- package/dist/chain/tx.d.ts +72 -0
- package/dist/chain/tx.js +97 -0
- package/dist/cjs/actaClient.js +103 -0
- package/dist/cjs/chain/client.js +119 -0
- package/dist/cjs/chain/fetch.js +431 -0
- package/dist/cjs/chain/fetch.test.js +160 -0
- package/dist/cjs/chain/flows/index.js +17 -0
- package/dist/cjs/chain/flows/openPosition.js +81 -0
- package/dist/cjs/chain/flows/openPosition.test.js +45 -0
- package/dist/cjs/chain/helpers.js +67 -0
- package/dist/cjs/chain/index.js +48 -0
- package/dist/cjs/chain/instructions.admin.js +119 -0
- package/dist/cjs/chain/instructions.js +21 -0
- package/dist/cjs/chain/instructions.maker.js +92 -0
- package/dist/cjs/chain/instructions.market.js +112 -0
- package/dist/cjs/chain/instructions.oracle.js +70 -0
- package/dist/cjs/chain/instructions.position.js +247 -0
- package/dist/cjs/chain/instructions.resolve.test.js +34 -0
- package/dist/cjs/chain/instructions.shared.js +64 -0
- package/dist/cjs/chain/orders.js +126 -0
- package/dist/cjs/chain/orders.test.js +69 -0
- package/dist/cjs/chain/signers.js +22 -0
- package/dist/cjs/chain/signers.test.js +15 -0
- package/dist/cjs/chain/token.js +147 -0
- package/dist/cjs/chain/token.test.js +71 -0
- package/dist/cjs/chain/tx.js +103 -0
- package/dist/cjs/constants.js +6 -0
- package/dist/cjs/constants.test.js +31 -0
- package/dist/cjs/events.js +75 -0
- package/dist/cjs/events.test.js +384 -0
- package/dist/cjs/generated/accounts/config.js +79 -0
- package/dist/cjs/generated/accounts/index.js +28 -0
- package/dist/cjs/generated/accounts/maker.js +71 -0
- package/dist/cjs/generated/accounts/market.js +93 -0
- package/dist/cjs/generated/accounts/oracle.js +85 -0
- package/dist/cjs/generated/accounts/position.js +89 -0
- package/dist/cjs/generated/errors/actaContract.js +154 -0
- package/dist/cjs/generated/errors/index.js +24 -0
- package/dist/cjs/generated/index.js +28 -0
- package/dist/cjs/generated/instructions/changeOracleSource.js +81 -0
- package/dist/cjs/generated/instructions/closeMarket.js +83 -0
- package/dist/cjs/generated/instructions/closeOracle.js +79 -0
- package/dist/cjs/generated/instructions/createMarket.js +116 -0
- package/dist/cjs/generated/instructions/createOracle.js +99 -0
- package/dist/cjs/generated/instructions/depositFundsToPosition.js +101 -0
- package/dist/cjs/generated/instructions/depositPremium.js +96 -0
- package/dist/cjs/generated/instructions/finalizeMarket.js +91 -0
- package/dist/cjs/generated/instructions/index.js +43 -0
- package/dist/cjs/generated/instructions/initializeConfig.js +108 -0
- package/dist/cjs/generated/instructions/liquidatePosition.js +107 -0
- package/dist/cjs/generated/instructions/openPosition.js +154 -0
- package/dist/cjs/generated/instructions/registerMaker.js +90 -0
- package/dist/cjs/generated/instructions/setOracleConfig.js +80 -0
- package/dist/cjs/generated/instructions/settlePosition.js +104 -0
- package/dist/cjs/generated/instructions/topupFeeFund.js +96 -0
- package/dist/cjs/generated/instructions/updateConfig.js +86 -0
- package/dist/cjs/generated/instructions/updateMakerQuoteSigning.js +79 -0
- package/dist/cjs/generated/instructions/updateMarketOracles.js +96 -0
- package/dist/cjs/generated/instructions/updateOraclePrice.js +89 -0
- package/dist/cjs/generated/instructions/withdrawFromFeeFund.js +96 -0
- package/dist/cjs/generated/instructions/withdrawPremium.js +96 -0
- package/dist/cjs/generated/programs/actaContract.js +108 -0
- package/dist/cjs/generated/programs/index.js +24 -0
- package/dist/cjs/generated/shared/index.js +94 -0
- package/dist/cjs/generated/types/actaEvent.js +342 -0
- package/dist/cjs/generated/types/eventKind.js +45 -0
- package/dist/cjs/generated/types/index.js +27 -0
- package/dist/cjs/generated/types/positionStatus.js +31 -0
- package/dist/cjs/generated/types/positionType.js +28 -0
- package/dist/cjs/idl/acta_contract.json +2329 -0
- package/dist/cjs/idl/hash.js +4 -0
- package/dist/cjs/index.js +84 -0
- package/dist/cjs/nonce.js +93 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/cjs/types/orderId.js +40 -0
- package/dist/cjs/types/orders.js +10 -0
- package/dist/cjs/ws/apy.js +106 -0
- package/dist/cjs/ws/apy.test.js +29 -0
- package/dist/cjs/ws/auth.js +104 -0
- package/dist/cjs/ws/client.handshake.integration.test.js +69 -0
- package/dist/cjs/ws/client.js +861 -0
- package/dist/cjs/ws/client.test.js +230 -0
- package/dist/cjs/ws/discovery.js +48 -0
- package/dist/cjs/ws/flows.js +101 -0
- package/dist/cjs/ws/flows.test.js +85 -0
- package/dist/cjs/ws/index.js +23 -0
- package/dist/cjs/ws/sponsoredTx.js +95 -0
- package/dist/cjs/ws/types.js +14 -0
- package/dist/cjs/ws/wirePolicy.js +34 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/constants.test.d.ts +1 -0
- package/dist/constants.test.js +29 -0
- package/dist/events.d.ts +15 -0
- package/dist/events.js +64 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +382 -0
- package/dist/generated/accounts/config.d.ts +47 -0
- package/dist/generated/accounts/config.js +68 -0
- package/dist/generated/accounts/index.d.ts +12 -0
- package/dist/generated/accounts/index.js +12 -0
- package/dist/generated/accounts/maker.d.ts +39 -0
- package/dist/generated/accounts/maker.js +60 -0
- package/dist/generated/accounts/market.d.ts +61 -0
- package/dist/generated/accounts/market.js +82 -0
- package/dist/generated/accounts/oracle.d.ts +53 -0
- package/dist/generated/accounts/oracle.js +74 -0
- package/dist/generated/accounts/position.d.ts +57 -0
- package/dist/generated/accounts/position.js +78 -0
- package/dist/generated/errors/actaContract.d.ts +103 -0
- package/dist/generated/errors/actaContract.js +149 -0
- package/dist/generated/errors/index.d.ts +8 -0
- package/dist/generated/errors/index.js +8 -0
- package/dist/generated/index.d.ts +12 -0
- package/dist/generated/index.js +12 -0
- package/dist/generated/instructions/changeOracleSource.d.ts +50 -0
- package/dist/generated/instructions/changeOracleSource.js +72 -0
- package/dist/generated/instructions/closeMarket.d.ts +58 -0
- package/dist/generated/instructions/closeMarket.js +74 -0
- package/dist/generated/instructions/closeOracle.d.ts +48 -0
- package/dist/generated/instructions/closeOracle.js +70 -0
- package/dist/generated/instructions/createMarket.d.ts +90 -0
- package/dist/generated/instructions/createMarket.js +107 -0
- package/dist/generated/instructions/createOracle.d.ts +71 -0
- package/dist/generated/instructions/createOracle.js +90 -0
- package/dist/generated/instructions/depositFundsToPosition.d.ts +73 -0
- package/dist/generated/instructions/depositFundsToPosition.js +92 -0
- package/dist/generated/instructions/depositPremium.d.ts +62 -0
- package/dist/generated/instructions/depositPremium.js +87 -0
- package/dist/generated/instructions/finalizeMarket.d.ts +63 -0
- package/dist/generated/instructions/finalizeMarket.js +82 -0
- package/dist/generated/instructions/index.d.ts +27 -0
- package/dist/generated/instructions/index.js +27 -0
- package/dist/generated/instructions/initializeConfig.d.ts +75 -0
- package/dist/generated/instructions/initializeConfig.js +99 -0
- package/dist/generated/instructions/liquidatePosition.d.ts +78 -0
- package/dist/generated/instructions/liquidatePosition.js +98 -0
- package/dist/generated/instructions/openPosition.d.ts +130 -0
- package/dist/generated/instructions/openPosition.js +145 -0
- package/dist/generated/instructions/registerMaker.d.ts +57 -0
- package/dist/generated/instructions/registerMaker.js +81 -0
- package/dist/generated/instructions/setOracleConfig.d.ts +53 -0
- package/dist/generated/instructions/setOracleConfig.js +71 -0
- package/dist/generated/instructions/settlePosition.d.ts +78 -0
- package/dist/generated/instructions/settlePosition.js +95 -0
- package/dist/generated/instructions/topupFeeFund.d.ts +67 -0
- package/dist/generated/instructions/topupFeeFund.js +87 -0
- package/dist/generated/instructions/updateConfig.d.ts +58 -0
- package/dist/generated/instructions/updateConfig.js +77 -0
- package/dist/generated/instructions/updateMakerQuoteSigning.d.ts +47 -0
- package/dist/generated/instructions/updateMakerQuoteSigning.js +70 -0
- package/dist/generated/instructions/updateMarketOracles.d.ts +65 -0
- package/dist/generated/instructions/updateMarketOracles.js +87 -0
- package/dist/generated/instructions/updateOraclePrice.d.ts +55 -0
- package/dist/generated/instructions/updateOraclePrice.js +80 -0
- package/dist/generated/instructions/withdrawFromFeeFund.d.ts +62 -0
- package/dist/generated/instructions/withdrawFromFeeFund.js +87 -0
- package/dist/generated/instructions/withdrawPremium.d.ts +62 -0
- package/dist/generated/instructions/withdrawPremium.js +87 -0
- package/dist/generated/programs/actaContract.d.ts +83 -0
- package/dist/generated/programs/actaContract.js +104 -0
- package/dist/generated/programs/index.d.ts +8 -0
- package/dist/generated/programs/index.js +8 -0
- package/dist/generated/shared/index.d.ts +49 -0
- package/dist/generated/shared/index.js +86 -0
- package/dist/generated/types/actaEvent.d.ts +249 -0
- package/dist/generated/types/actaEvent.js +335 -0
- package/dist/generated/types/eventKind.d.ts +33 -0
- package/dist/generated/types/eventKind.js +39 -0
- package/dist/generated/types/index.d.ts +11 -0
- package/dist/generated/types/index.js +11 -0
- package/dist/generated/types/positionStatus.d.ts +19 -0
- package/dist/generated/types/positionStatus.js +25 -0
- package/dist/generated/types/positionType.d.ts +16 -0
- package/dist/generated/types/positionType.js +22 -0
- package/dist/idl/acta_contract.json +2329 -0
- package/dist/idl/hash.d.ts +1 -0
- package/dist/idl/hash.js +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +34 -0
- package/dist/nonce.d.ts +29 -0
- package/dist/nonce.js +89 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/orderId.d.ts +13 -0
- package/dist/types/orderId.js +35 -0
- package/dist/types/orders.d.ts +9 -0
- package/dist/types/orders.js +9 -0
- package/dist/ws/apy.d.ts +79 -0
- package/dist/ws/apy.js +98 -0
- package/dist/ws/apy.test.d.ts +1 -0
- package/dist/ws/apy.test.js +27 -0
- package/dist/ws/auth.d.ts +67 -0
- package/dist/ws/auth.js +98 -0
- package/dist/ws/client.d.ts +263 -0
- package/dist/ws/client.handshake.integration.test.d.ts +1 -0
- package/dist/ws/client.handshake.integration.test.js +64 -0
- package/dist/ws/client.js +857 -0
- package/dist/ws/client.test.d.ts +1 -0
- package/dist/ws/client.test.js +228 -0
- package/dist/ws/discovery.d.ts +13 -0
- package/dist/ws/discovery.js +44 -0
- package/dist/ws/flows.d.ts +44 -0
- package/dist/ws/flows.js +96 -0
- package/dist/ws/flows.test.d.ts +1 -0
- package/dist/ws/flows.test.js +83 -0
- package/dist/ws/index.d.ts +7 -0
- package/dist/ws/index.js +7 -0
- package/dist/ws/sponsoredTx.d.ts +39 -0
- package/dist/ws/sponsoredTx.js +92 -0
- package/dist/ws/types.d.ts +900 -0
- package/dist/ws/types.js +13 -0
- package/dist/ws/wirePolicy.d.ts +12 -0
- package/dist/ws/wirePolicy.js +30 -0
- package/package.json +87 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { isProgramError, } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
/** NotSigned: Account must sign the transaction */
|
|
11
|
+
export const ACTA_CONTRACT_ERROR__NOT_SIGNED = 0x3e8; // 1000
|
|
12
|
+
/** InvalidOwner: Account owner mismatch */
|
|
13
|
+
export const ACTA_CONTRACT_ERROR__INVALID_OWNER = 0x3e9; // 1001
|
|
14
|
+
/** InvalidPda: PDA derivation failed (wrong seeds or bump) */
|
|
15
|
+
export const ACTA_CONTRACT_ERROR__INVALID_PDA = 0x3ea; // 1002
|
|
16
|
+
/** AccountNotInitialized: Account not initialized */
|
|
17
|
+
export const ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = 0x3eb; // 1003
|
|
18
|
+
/** InvalidAccountCount: Wrong number of accounts */
|
|
19
|
+
export const ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = 0x3ec; // 1004
|
|
20
|
+
/** InvalidAccountData: Account data corrupted or wrong format */
|
|
21
|
+
export const ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = 0x3ed; // 1005
|
|
22
|
+
/** AccountAlreadyInitialized: Account already initialized */
|
|
23
|
+
export const ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = 0x3ee; // 1006
|
|
24
|
+
/** MakerAlreadyRegistered: Maker PDA already exists */
|
|
25
|
+
export const ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = 0x3f2; // 1010
|
|
26
|
+
/** MakerNotRegistered: Maker PDA not found */
|
|
27
|
+
export const ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = 0x3f3; // 1011
|
|
28
|
+
/** MakerNotOwner: Caller is not the maker owner */
|
|
29
|
+
export const ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = 0x3f4; // 1012
|
|
30
|
+
/** MarketFinalized: Market already finalized */
|
|
31
|
+
export const ACTA_CONTRACT_ERROR__MARKET_FINALIZED = 0x3fc; // 1020
|
|
32
|
+
/** MarketNotFinalized: Market not yet finalized */
|
|
33
|
+
export const ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = 0x3fd; // 1021
|
|
34
|
+
/** MarketExpired: Market expired */
|
|
35
|
+
export const ACTA_CONTRACT_ERROR__MARKET_EXPIRED = 0x3fe; // 1022
|
|
36
|
+
/** MarketNotEmpty: Market has open positions (cannot close) */
|
|
37
|
+
export const ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = 0x3ff; // 1023
|
|
38
|
+
/** InvalidOracleType: Oracle type invalid or unsupported */
|
|
39
|
+
export const ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = 0x400; // 1024
|
|
40
|
+
/** InvalidOracleAccount: Oracle account invalid (owner/layout/mint mismatch) */
|
|
41
|
+
export const ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = 0x401; // 1025
|
|
42
|
+
/** OracleExpiryMismatch: Oracle expiry mismatch (wrong expiry) */
|
|
43
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = 0x402; // 1026
|
|
44
|
+
/** OracleStale: Oracle price is stale (updated_at before expiry) */
|
|
45
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_STALE = 0x403; // 1027
|
|
46
|
+
/** OracleInactive: Oracle inactive */
|
|
47
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = 0x404; // 1028
|
|
48
|
+
/** OracleInvalidPrice: Oracle price invalid (zero or negative) */
|
|
49
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = 0x405; // 1029
|
|
50
|
+
/** PositionAlreadyOpen: Position already exists */
|
|
51
|
+
export const ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = 0x406; // 1030
|
|
52
|
+
/** PositionNotOpen: Position not found */
|
|
53
|
+
export const ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = 0x407; // 1031
|
|
54
|
+
/** PositionAlreadyFunded: Position already funded by maker */
|
|
55
|
+
export const ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = 0x408; // 1032
|
|
56
|
+
/** PositionNotFunded: Position not funded (required for ITM settlement) */
|
|
57
|
+
export const ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = 0x409; // 1033
|
|
58
|
+
/** PositionAlreadySettled: Position already settled or liquidated */
|
|
59
|
+
export const ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = 0x40a; // 1034
|
|
60
|
+
/** PositionNotItm: Position not ITM (cannot liquidate OTM) */
|
|
61
|
+
export const ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = 0x40b; // 1035
|
|
62
|
+
/** PositionTypeMismatch: Position type doesn't match market (call vs put) */
|
|
63
|
+
export const ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = 0x40c; // 1036
|
|
64
|
+
/** InvalidOrderId: order_id != sha256(preimage) */
|
|
65
|
+
export const ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = 0x410; // 1040
|
|
66
|
+
/** InvalidSignatureCount: Ed25519 instruction has wrong signature count */
|
|
67
|
+
export const ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = 0x411; // 1041
|
|
68
|
+
/** SignerMismatch: Maker signing key mismatch */
|
|
69
|
+
export const ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = 0x412; // 1042
|
|
70
|
+
/** SignedMessageMismatch: Signed message != order_id */
|
|
71
|
+
export const ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = 0x413; // 1043
|
|
72
|
+
/** InvalidInstructionData: Instruction data malformed */
|
|
73
|
+
export const ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = 0x414; // 1044
|
|
74
|
+
/** MathOverflow: Arithmetic overflow */
|
|
75
|
+
export const ACTA_CONTRACT_ERROR__MATH_OVERFLOW = 0x41a; // 1050
|
|
76
|
+
/** MintMismatch: Mint mismatch between token accounts */
|
|
77
|
+
export const ACTA_CONTRACT_ERROR__MINT_MISMATCH = 0x41b; // 1051
|
|
78
|
+
/** InsufficientFunds: Balance is below the required amount */
|
|
79
|
+
export const ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = 0x41c; // 1052
|
|
80
|
+
/** InvalidProgramId: Wrong program ID */
|
|
81
|
+
export const ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = 0x424; // 1060
|
|
82
|
+
/** InvalidTimestamp: Clock timestamp invalid */
|
|
83
|
+
export const ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = 0x425; // 1061
|
|
84
|
+
/** Unauthorized: Unauthorized (not admin/keeper) */
|
|
85
|
+
export const ACTA_CONTRACT_ERROR__UNAUTHORIZED = 0x42e; // 1070
|
|
86
|
+
/** OracleCloseTooEarly: Oracle close delay not elapsed */
|
|
87
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = 0x42f; // 1071
|
|
88
|
+
/** OracleAlreadyUpdated: Oracle price has already been set for this expiry */
|
|
89
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = 0x430; // 1072
|
|
90
|
+
/** OracleSourceLocked: Oracle source fields are locked after first update */
|
|
91
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = 0x431; // 1073
|
|
92
|
+
/** OracleHasActiveMarkets: Oracle is still linked to active markets */
|
|
93
|
+
export const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
|
|
94
|
+
let actaContractErrorMessages;
|
|
95
|
+
if (process.env.NODE_ENV !== "production") {
|
|
96
|
+
actaContractErrorMessages = {
|
|
97
|
+
[ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED]: `Account already initialized`,
|
|
98
|
+
[ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED]: `Account not initialized`,
|
|
99
|
+
[ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS]: `Balance is below the required amount`,
|
|
100
|
+
[ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT]: `Wrong number of accounts`,
|
|
101
|
+
[ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA]: `Account data corrupted or wrong format`,
|
|
102
|
+
[ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA]: `Instruction data malformed`,
|
|
103
|
+
[ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT]: `Oracle account invalid (owner/layout/mint mismatch)`,
|
|
104
|
+
[ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE]: `Oracle type invalid or unsupported`,
|
|
105
|
+
[ACTA_CONTRACT_ERROR__INVALID_ORDER_ID]: `order_id != sha256(preimage)`,
|
|
106
|
+
[ACTA_CONTRACT_ERROR__INVALID_OWNER]: `Account owner mismatch`,
|
|
107
|
+
[ACTA_CONTRACT_ERROR__INVALID_PDA]: `PDA derivation failed (wrong seeds or bump)`,
|
|
108
|
+
[ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID]: `Wrong program ID`,
|
|
109
|
+
[ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT]: `Ed25519 instruction has wrong signature count`,
|
|
110
|
+
[ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP]: `Clock timestamp invalid`,
|
|
111
|
+
[ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED]: `Maker PDA already exists`,
|
|
112
|
+
[ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER]: `Caller is not the maker owner`,
|
|
113
|
+
[ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED]: `Maker PDA not found`,
|
|
114
|
+
[ACTA_CONTRACT_ERROR__MARKET_EXPIRED]: `Market expired`,
|
|
115
|
+
[ACTA_CONTRACT_ERROR__MARKET_FINALIZED]: `Market already finalized`,
|
|
116
|
+
[ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY]: `Market has open positions (cannot close)`,
|
|
117
|
+
[ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED]: `Market not yet finalized`,
|
|
118
|
+
[ACTA_CONTRACT_ERROR__MATH_OVERFLOW]: `Arithmetic overflow`,
|
|
119
|
+
[ACTA_CONTRACT_ERROR__MINT_MISMATCH]: `Mint mismatch between token accounts`,
|
|
120
|
+
[ACTA_CONTRACT_ERROR__NOT_SIGNED]: `Account must sign the transaction`,
|
|
121
|
+
[ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED]: `Oracle price has already been set for this expiry`,
|
|
122
|
+
[ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY]: `Oracle close delay not elapsed`,
|
|
123
|
+
[ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH]: `Oracle expiry mismatch (wrong expiry)`,
|
|
124
|
+
[ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS]: `Oracle is still linked to active markets`,
|
|
125
|
+
[ACTA_CONTRACT_ERROR__ORACLE_INACTIVE]: `Oracle inactive`,
|
|
126
|
+
[ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE]: `Oracle price invalid (zero or negative)`,
|
|
127
|
+
[ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED]: `Oracle source fields are locked after first update`,
|
|
128
|
+
[ACTA_CONTRACT_ERROR__ORACLE_STALE]: `Oracle price is stale (updated_at before expiry)`,
|
|
129
|
+
[ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED]: `Position already funded by maker`,
|
|
130
|
+
[ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN]: `Position already exists`,
|
|
131
|
+
[ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED]: `Position already settled or liquidated`,
|
|
132
|
+
[ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED]: `Position not funded (required for ITM settlement)`,
|
|
133
|
+
[ACTA_CONTRACT_ERROR__POSITION_NOT_ITM]: `Position not ITM (cannot liquidate OTM)`,
|
|
134
|
+
[ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN]: `Position not found`,
|
|
135
|
+
[ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH]: `Position type doesn't match market (call vs put)`,
|
|
136
|
+
[ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH]: `Signed message != order_id`,
|
|
137
|
+
[ACTA_CONTRACT_ERROR__SIGNER_MISMATCH]: `Maker signing key mismatch`,
|
|
138
|
+
[ACTA_CONTRACT_ERROR__UNAUTHORIZED]: `Unauthorized (not admin/keeper)`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export function getActaContractErrorMessage(code) {
|
|
142
|
+
if (process.env.NODE_ENV !== "production") {
|
|
143
|
+
return actaContractErrorMessages[code];
|
|
144
|
+
}
|
|
145
|
+
return "Error message not available in production bundles.";
|
|
146
|
+
}
|
|
147
|
+
export function isActaContractError(error, transactionMessage, code) {
|
|
148
|
+
return isProgramError(error, transactionMessage, ACTA_CONTRACT_PROGRAM_ADDRESS, code);
|
|
149
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
export * from "./accounts";
|
|
9
|
+
export * from "./errors";
|
|
10
|
+
export * from "./instructions";
|
|
11
|
+
export * from "./programs";
|
|
12
|
+
export * from "./types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
export * from "./accounts";
|
|
9
|
+
export * from "./errors";
|
|
10
|
+
export * from "./instructions";
|
|
11
|
+
export * from "./programs";
|
|
12
|
+
export * from "./types";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
export declare const CHANGE_ORACLE_SOURCE_DISCRIMINATOR = 18;
|
|
11
|
+
export declare function getChangeOracleSourceDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
+
export type ChangeOracleSourceInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountAdmin extends string | AccountMeta<string> = string, TAccountOraclePda extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
13
|
+
TAccountAdmin extends string ? ReadonlySignerAccount<TAccountAdmin> & AccountSignerMeta<TAccountAdmin> : TAccountAdmin,
|
|
14
|
+
TAccountOraclePda extends string ? WritableAccount<TAccountOraclePda> : TAccountOraclePda,
|
|
15
|
+
...TRemainingAccounts
|
|
16
|
+
]>;
|
|
17
|
+
export type ChangeOracleSourceInstructionData = {
|
|
18
|
+
discriminator: number;
|
|
19
|
+
oracleType: number;
|
|
20
|
+
feedId: ReadonlyUint8Array;
|
|
21
|
+
};
|
|
22
|
+
export type ChangeOracleSourceInstructionDataArgs = {
|
|
23
|
+
oracleType: number;
|
|
24
|
+
feedId: ReadonlyUint8Array;
|
|
25
|
+
};
|
|
26
|
+
export declare function getChangeOracleSourceInstructionDataEncoder(): FixedSizeEncoder<ChangeOracleSourceInstructionDataArgs>;
|
|
27
|
+
export declare function getChangeOracleSourceInstructionDataDecoder(): FixedSizeDecoder<ChangeOracleSourceInstructionData>;
|
|
28
|
+
export declare function getChangeOracleSourceInstructionDataCodec(): FixedSizeCodec<ChangeOracleSourceInstructionDataArgs, ChangeOracleSourceInstructionData>;
|
|
29
|
+
export type ChangeOracleSourceInput<TAccountAdmin extends string = string, TAccountOraclePda extends string = string> = {
|
|
30
|
+
/** Protocol admin authority */
|
|
31
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
32
|
+
/** Oracle PDA source to change */
|
|
33
|
+
oraclePda: Address<TAccountOraclePda>;
|
|
34
|
+
oracleType: ChangeOracleSourceInstructionDataArgs["oracleType"];
|
|
35
|
+
feedId: ChangeOracleSourceInstructionDataArgs["feedId"];
|
|
36
|
+
};
|
|
37
|
+
export declare function getChangeOracleSourceInstruction<TAccountAdmin extends string, TAccountOraclePda extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: ChangeOracleSourceInput<TAccountAdmin, TAccountOraclePda>, config?: {
|
|
38
|
+
programAddress?: TProgramAddress;
|
|
39
|
+
}): ChangeOracleSourceInstruction<TProgramAddress, TAccountAdmin, TAccountOraclePda>;
|
|
40
|
+
export type ParsedChangeOracleSourceInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
|
|
41
|
+
programAddress: Address<TProgram>;
|
|
42
|
+
accounts: {
|
|
43
|
+
/** Protocol admin authority */
|
|
44
|
+
admin: TAccountMetas[0];
|
|
45
|
+
/** Oracle PDA source to change */
|
|
46
|
+
oraclePda: TAccountMetas[1];
|
|
47
|
+
};
|
|
48
|
+
data: ChangeOracleSourceInstructionData;
|
|
49
|
+
};
|
|
50
|
+
export declare function parseChangeOracleSourceInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedChangeOracleSourceInstruction<TProgram, TAccountMetas>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
import { getAccountMetaFactory } from "../shared";
|
|
11
|
+
export const CHANGE_ORACLE_SOURCE_DISCRIMINATOR = 18;
|
|
12
|
+
export function getChangeOracleSourceDiscriminatorBytes() {
|
|
13
|
+
return getU8Encoder().encode(CHANGE_ORACLE_SOURCE_DISCRIMINATOR);
|
|
14
|
+
}
|
|
15
|
+
export function getChangeOracleSourceInstructionDataEncoder() {
|
|
16
|
+
return transformEncoder(getStructEncoder([
|
|
17
|
+
["discriminator", getU8Encoder()],
|
|
18
|
+
["oracleType", getU8Encoder()],
|
|
19
|
+
["feedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
20
|
+
]), (value) => ({
|
|
21
|
+
...value,
|
|
22
|
+
discriminator: CHANGE_ORACLE_SOURCE_DISCRIMINATOR,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
export function getChangeOracleSourceInstructionDataDecoder() {
|
|
26
|
+
return getStructDecoder([
|
|
27
|
+
["discriminator", getU8Decoder()],
|
|
28
|
+
["oracleType", getU8Decoder()],
|
|
29
|
+
["feedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
export function getChangeOracleSourceInstructionDataCodec() {
|
|
33
|
+
return combineCodec(getChangeOracleSourceInstructionDataEncoder(), getChangeOracleSourceInstructionDataDecoder());
|
|
34
|
+
}
|
|
35
|
+
export function getChangeOracleSourceInstruction(input, config) {
|
|
36
|
+
// Program address.
|
|
37
|
+
const programAddress = config?.programAddress ?? ACTA_CONTRACT_PROGRAM_ADDRESS;
|
|
38
|
+
// Original accounts.
|
|
39
|
+
const originalAccounts = {
|
|
40
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
41
|
+
oraclePda: { value: input.oraclePda ?? null, isWritable: true },
|
|
42
|
+
};
|
|
43
|
+
const accounts = originalAccounts;
|
|
44
|
+
// Original args.
|
|
45
|
+
const args = { ...input };
|
|
46
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
accounts: [
|
|
49
|
+
getAccountMeta(accounts.admin),
|
|
50
|
+
getAccountMeta(accounts.oraclePda),
|
|
51
|
+
],
|
|
52
|
+
data: getChangeOracleSourceInstructionDataEncoder().encode(args),
|
|
53
|
+
programAddress,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function parseChangeOracleSourceInstruction(instruction) {
|
|
57
|
+
if (instruction.accounts.length < 2) {
|
|
58
|
+
// TODO: Coded error.
|
|
59
|
+
throw new Error("Not enough accounts");
|
|
60
|
+
}
|
|
61
|
+
let accountIndex = 0;
|
|
62
|
+
const getNextAccount = () => {
|
|
63
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
64
|
+
accountIndex += 1;
|
|
65
|
+
return accountMeta;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
programAddress: instruction.programAddress,
|
|
69
|
+
accounts: { admin: getNextAccount(), oraclePda: getNextAccount() },
|
|
70
|
+
data: getChangeOracleSourceInstructionDataDecoder().decode(instruction.data),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
export declare const CLOSE_MARKET_DISCRIMINATOR = 14;
|
|
11
|
+
export declare function getCloseMarketDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
+
export type CloseMarketInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountAdmin extends string | AccountMeta<string> = string, TAccountConfigPda extends string | AccountMeta<string> = string, TAccountMarketPda extends string | AccountMeta<string> = string, TAccountOracleUnderlying extends string | AccountMeta<string> = string, TAccountOracleQuote extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
13
|
+
TAccountAdmin extends string ? ReadonlySignerAccount<TAccountAdmin> & AccountSignerMeta<TAccountAdmin> : TAccountAdmin,
|
|
14
|
+
TAccountConfigPda extends string ? ReadonlyAccount<TAccountConfigPda> : TAccountConfigPda,
|
|
15
|
+
TAccountMarketPda extends string ? WritableAccount<TAccountMarketPda> : TAccountMarketPda,
|
|
16
|
+
TAccountOracleUnderlying extends string ? WritableAccount<TAccountOracleUnderlying> : TAccountOracleUnderlying,
|
|
17
|
+
TAccountOracleQuote extends string ? WritableAccount<TAccountOracleQuote> : TAccountOracleQuote,
|
|
18
|
+
...TRemainingAccounts
|
|
19
|
+
]>;
|
|
20
|
+
export type CloseMarketInstructionData = {
|
|
21
|
+
discriminator: number;
|
|
22
|
+
};
|
|
23
|
+
export type CloseMarketInstructionDataArgs = {};
|
|
24
|
+
export declare function getCloseMarketInstructionDataEncoder(): FixedSizeEncoder<CloseMarketInstructionDataArgs>;
|
|
25
|
+
export declare function getCloseMarketInstructionDataDecoder(): FixedSizeDecoder<CloseMarketInstructionData>;
|
|
26
|
+
export declare function getCloseMarketInstructionDataCodec(): FixedSizeCodec<CloseMarketInstructionDataArgs, CloseMarketInstructionData>;
|
|
27
|
+
export type CloseMarketInput<TAccountAdmin extends string = string, TAccountConfigPda extends string = string, TAccountMarketPda extends string = string, TAccountOracleUnderlying extends string = string, TAccountOracleQuote extends string = string> = {
|
|
28
|
+
/** Protocol admin authority */
|
|
29
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
30
|
+
/** Config PDA for admin verification */
|
|
31
|
+
configPda: Address<TAccountConfigPda>;
|
|
32
|
+
/** Market PDA to close */
|
|
33
|
+
marketPda: Address<TAccountMarketPda>;
|
|
34
|
+
/** Underlying oracle PDA */
|
|
35
|
+
oracleUnderlying: Address<TAccountOracleUnderlying>;
|
|
36
|
+
/** Quote oracle PDA */
|
|
37
|
+
oracleQuote: Address<TAccountOracleQuote>;
|
|
38
|
+
};
|
|
39
|
+
export declare function getCloseMarketInstruction<TAccountAdmin extends string, TAccountConfigPda extends string, TAccountMarketPda extends string, TAccountOracleUnderlying extends string, TAccountOracleQuote extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CloseMarketInput<TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountOracleUnderlying, TAccountOracleQuote>, config?: {
|
|
40
|
+
programAddress?: TProgramAddress;
|
|
41
|
+
}): CloseMarketInstruction<TProgramAddress, TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountOracleUnderlying, TAccountOracleQuote>;
|
|
42
|
+
export type ParsedCloseMarketInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
|
|
43
|
+
programAddress: Address<TProgram>;
|
|
44
|
+
accounts: {
|
|
45
|
+
/** Protocol admin authority */
|
|
46
|
+
admin: TAccountMetas[0];
|
|
47
|
+
/** Config PDA for admin verification */
|
|
48
|
+
configPda: TAccountMetas[1];
|
|
49
|
+
/** Market PDA to close */
|
|
50
|
+
marketPda: TAccountMetas[2];
|
|
51
|
+
/** Underlying oracle PDA */
|
|
52
|
+
oracleUnderlying: TAccountMetas[3];
|
|
53
|
+
/** Quote oracle PDA */
|
|
54
|
+
oracleQuote: TAccountMetas[4];
|
|
55
|
+
};
|
|
56
|
+
data: CloseMarketInstructionData;
|
|
57
|
+
};
|
|
58
|
+
export declare function parseCloseMarketInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCloseMarketInstruction<TProgram, TAccountMetas>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { combineCodec, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
import { getAccountMetaFactory } from "../shared";
|
|
11
|
+
export const CLOSE_MARKET_DISCRIMINATOR = 14;
|
|
12
|
+
export function getCloseMarketDiscriminatorBytes() {
|
|
13
|
+
return getU8Encoder().encode(CLOSE_MARKET_DISCRIMINATOR);
|
|
14
|
+
}
|
|
15
|
+
export function getCloseMarketInstructionDataEncoder() {
|
|
16
|
+
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({ ...value, discriminator: CLOSE_MARKET_DISCRIMINATOR }));
|
|
17
|
+
}
|
|
18
|
+
export function getCloseMarketInstructionDataDecoder() {
|
|
19
|
+
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
20
|
+
}
|
|
21
|
+
export function getCloseMarketInstructionDataCodec() {
|
|
22
|
+
return combineCodec(getCloseMarketInstructionDataEncoder(), getCloseMarketInstructionDataDecoder());
|
|
23
|
+
}
|
|
24
|
+
export function getCloseMarketInstruction(input, config) {
|
|
25
|
+
// Program address.
|
|
26
|
+
const programAddress = config?.programAddress ?? ACTA_CONTRACT_PROGRAM_ADDRESS;
|
|
27
|
+
// Original accounts.
|
|
28
|
+
const originalAccounts = {
|
|
29
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
30
|
+
configPda: { value: input.configPda ?? null, isWritable: false },
|
|
31
|
+
marketPda: { value: input.marketPda ?? null, isWritable: true },
|
|
32
|
+
oracleUnderlying: {
|
|
33
|
+
value: input.oracleUnderlying ?? null,
|
|
34
|
+
isWritable: true,
|
|
35
|
+
},
|
|
36
|
+
oracleQuote: { value: input.oracleQuote ?? null, isWritable: true },
|
|
37
|
+
};
|
|
38
|
+
const accounts = originalAccounts;
|
|
39
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
accounts: [
|
|
42
|
+
getAccountMeta(accounts.admin),
|
|
43
|
+
getAccountMeta(accounts.configPda),
|
|
44
|
+
getAccountMeta(accounts.marketPda),
|
|
45
|
+
getAccountMeta(accounts.oracleUnderlying),
|
|
46
|
+
getAccountMeta(accounts.oracleQuote),
|
|
47
|
+
],
|
|
48
|
+
data: getCloseMarketInstructionDataEncoder().encode({}),
|
|
49
|
+
programAddress,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function parseCloseMarketInstruction(instruction) {
|
|
53
|
+
if (instruction.accounts.length < 5) {
|
|
54
|
+
// TODO: Coded error.
|
|
55
|
+
throw new Error("Not enough accounts");
|
|
56
|
+
}
|
|
57
|
+
let accountIndex = 0;
|
|
58
|
+
const getNextAccount = () => {
|
|
59
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
60
|
+
accountIndex += 1;
|
|
61
|
+
return accountMeta;
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
programAddress: instruction.programAddress,
|
|
65
|
+
accounts: {
|
|
66
|
+
admin: getNextAccount(),
|
|
67
|
+
configPda: getNextAccount(),
|
|
68
|
+
marketPda: getNextAccount(),
|
|
69
|
+
oracleUnderlying: getNextAccount(),
|
|
70
|
+
oracleQuote: getNextAccount(),
|
|
71
|
+
},
|
|
72
|
+
data: getCloseMarketInstructionDataDecoder().decode(instruction.data),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
export declare const CLOSE_ORACLE_DISCRIMINATOR = 19;
|
|
11
|
+
export declare function getCloseOracleDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
+
export type CloseOracleInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountSigner extends string | AccountMeta<string> = string, TAccountOraclePda extends string | AccountMeta<string> = string, TAccountClockSysvar extends string | AccountMeta<string> = "SysvarC1ock11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
13
|
+
TAccountSigner extends string ? WritableSignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner,
|
|
14
|
+
TAccountOraclePda extends string ? WritableAccount<TAccountOraclePda> : TAccountOraclePda,
|
|
15
|
+
TAccountClockSysvar extends string ? ReadonlyAccount<TAccountClockSysvar> : TAccountClockSysvar,
|
|
16
|
+
...TRemainingAccounts
|
|
17
|
+
]>;
|
|
18
|
+
export type CloseOracleInstructionData = {
|
|
19
|
+
discriminator: number;
|
|
20
|
+
};
|
|
21
|
+
export type CloseOracleInstructionDataArgs = {};
|
|
22
|
+
export declare function getCloseOracleInstructionDataEncoder(): FixedSizeEncoder<CloseOracleInstructionDataArgs>;
|
|
23
|
+
export declare function getCloseOracleInstructionDataDecoder(): FixedSizeDecoder<CloseOracleInstructionData>;
|
|
24
|
+
export declare function getCloseOracleInstructionDataCodec(): FixedSizeCodec<CloseOracleInstructionDataArgs, CloseOracleInstructionData>;
|
|
25
|
+
export type CloseOracleInput<TAccountSigner extends string = string, TAccountOraclePda extends string = string, TAccountClockSysvar extends string = string> = {
|
|
26
|
+
/** Protocol admin authority */
|
|
27
|
+
signer: TransactionSigner<TAccountSigner>;
|
|
28
|
+
/** Oracle PDA to close */
|
|
29
|
+
oraclePda: Address<TAccountOraclePda>;
|
|
30
|
+
/** Clock sysvar account */
|
|
31
|
+
clockSysvar?: Address<TAccountClockSysvar>;
|
|
32
|
+
};
|
|
33
|
+
export declare function getCloseOracleInstruction<TAccountSigner extends string, TAccountOraclePda extends string, TAccountClockSysvar extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CloseOracleInput<TAccountSigner, TAccountOraclePda, TAccountClockSysvar>, config?: {
|
|
34
|
+
programAddress?: TProgramAddress;
|
|
35
|
+
}): CloseOracleInstruction<TProgramAddress, TAccountSigner, TAccountOraclePda, TAccountClockSysvar>;
|
|
36
|
+
export type ParsedCloseOracleInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
|
|
37
|
+
programAddress: Address<TProgram>;
|
|
38
|
+
accounts: {
|
|
39
|
+
/** Protocol admin authority */
|
|
40
|
+
signer: TAccountMetas[0];
|
|
41
|
+
/** Oracle PDA to close */
|
|
42
|
+
oraclePda: TAccountMetas[1];
|
|
43
|
+
/** Clock sysvar account */
|
|
44
|
+
clockSysvar: TAccountMetas[2];
|
|
45
|
+
};
|
|
46
|
+
data: CloseOracleInstructionData;
|
|
47
|
+
};
|
|
48
|
+
export declare function parseCloseOracleInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCloseOracleInstruction<TProgram, TAccountMetas>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { combineCodec, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit";
|
|
9
|
+
import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
import { getAccountMetaFactory } from "../shared";
|
|
11
|
+
export const CLOSE_ORACLE_DISCRIMINATOR = 19;
|
|
12
|
+
export function getCloseOracleDiscriminatorBytes() {
|
|
13
|
+
return getU8Encoder().encode(CLOSE_ORACLE_DISCRIMINATOR);
|
|
14
|
+
}
|
|
15
|
+
export function getCloseOracleInstructionDataEncoder() {
|
|
16
|
+
return transformEncoder(getStructEncoder([["discriminator", getU8Encoder()]]), (value) => ({ ...value, discriminator: CLOSE_ORACLE_DISCRIMINATOR }));
|
|
17
|
+
}
|
|
18
|
+
export function getCloseOracleInstructionDataDecoder() {
|
|
19
|
+
return getStructDecoder([["discriminator", getU8Decoder()]]);
|
|
20
|
+
}
|
|
21
|
+
export function getCloseOracleInstructionDataCodec() {
|
|
22
|
+
return combineCodec(getCloseOracleInstructionDataEncoder(), getCloseOracleInstructionDataDecoder());
|
|
23
|
+
}
|
|
24
|
+
export function getCloseOracleInstruction(input, config) {
|
|
25
|
+
// Program address.
|
|
26
|
+
const programAddress = config?.programAddress ?? ACTA_CONTRACT_PROGRAM_ADDRESS;
|
|
27
|
+
// Original accounts.
|
|
28
|
+
const originalAccounts = {
|
|
29
|
+
signer: { value: input.signer ?? null, isWritable: true },
|
|
30
|
+
oraclePda: { value: input.oraclePda ?? null, isWritable: true },
|
|
31
|
+
clockSysvar: { value: input.clockSysvar ?? null, isWritable: false },
|
|
32
|
+
};
|
|
33
|
+
const accounts = originalAccounts;
|
|
34
|
+
// Resolve default values.
|
|
35
|
+
if (!accounts.clockSysvar.value) {
|
|
36
|
+
accounts.clockSysvar.value =
|
|
37
|
+
"SysvarC1ock11111111111111111111111111111111";
|
|
38
|
+
}
|
|
39
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
accounts: [
|
|
42
|
+
getAccountMeta(accounts.signer),
|
|
43
|
+
getAccountMeta(accounts.oraclePda),
|
|
44
|
+
getAccountMeta(accounts.clockSysvar),
|
|
45
|
+
],
|
|
46
|
+
data: getCloseOracleInstructionDataEncoder().encode({}),
|
|
47
|
+
programAddress,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function parseCloseOracleInstruction(instruction) {
|
|
51
|
+
if (instruction.accounts.length < 3) {
|
|
52
|
+
// TODO: Coded error.
|
|
53
|
+
throw new Error("Not enough accounts");
|
|
54
|
+
}
|
|
55
|
+
let accountIndex = 0;
|
|
56
|
+
const getNextAccount = () => {
|
|
57
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
58
|
+
accountIndex += 1;
|
|
59
|
+
return accountMeta;
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
programAddress: instruction.programAddress,
|
|
63
|
+
accounts: {
|
|
64
|
+
signer: getNextAccount(),
|
|
65
|
+
oraclePda: getNextAccount(),
|
|
66
|
+
clockSysvar: getNextAccount(),
|
|
67
|
+
},
|
|
68
|
+
data: getCloseOracleInstructionDataDecoder().decode(instruction.data),
|
|
69
|
+
};
|
|
70
|
+
}
|