@omegax/protocol-sdk 0.4.4 → 0.6.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/NOTICE +5 -0
- package/README.md +88 -20
- package/dist/claims.d.ts +1 -2
- package/dist/claims.js +101 -166
- package/dist/internal/protocol/all.d.ts +283 -0
- package/dist/internal/protocol/all.js +7195 -0
- package/dist/internal/protocol/builders.d.ts +1 -0
- package/dist/internal/protocol/builders.js +1 -0
- package/dist/internal/protocol/client.d.ts +1 -0
- package/dist/internal/protocol/client.js +1 -0
- package/dist/internal/protocol/constants.d.ts +1 -0
- package/dist/internal/protocol/constants.js +1 -0
- package/dist/internal/protocol/decoders.d.ts +1 -0
- package/dist/internal/protocol/decoders.js +1 -0
- package/dist/internal/protocol/fetchers.d.ts +1 -0
- package/dist/internal/protocol/fetchers.js +1 -0
- package/dist/internal/protocol/shared.d.ts +1 -0
- package/dist/internal/protocol/shared.js +1 -0
- package/dist/internal/protocol-seeds/all.d.ts +265 -0
- package/dist/internal/protocol-seeds/all.js +455 -0
- package/dist/internal/protocol-seeds/claims.d.ts +1 -0
- package/dist/internal/protocol-seeds/claims.js +1 -0
- package/dist/internal/protocol-seeds/core.d.ts +1 -0
- package/dist/internal/protocol-seeds/core.js +1 -0
- package/dist/internal/protocol-seeds/liquidity.d.ts +1 -0
- package/dist/internal/protocol-seeds/liquidity.js +1 -0
- package/dist/internal/protocol-seeds/oracle.d.ts +1 -0
- package/dist/internal/protocol-seeds/oracle.js +1 -0
- package/dist/internal/protocol-seeds/policy.d.ts +1 -0
- package/dist/internal/protocol-seeds/policy.js +1 -0
- package/dist/internal/reward-claim.d.ts +17 -0
- package/dist/internal/reward-claim.js +27 -0
- package/dist/internal/rpc.d.ts +15 -0
- package/dist/internal/rpc.js +26 -0
- package/dist/internal/types/all.d.ts +1952 -0
- package/dist/internal/types/all.js +1 -0
- package/dist/internal/types/builders.d.ts +1 -0
- package/dist/internal/types/builders.js +1 -0
- package/dist/internal/types/claims.d.ts +1 -0
- package/dist/internal/types/claims.js +1 -0
- package/dist/internal/types/oracle.d.ts +1 -0
- package/dist/internal/types/oracle.js +1 -0
- package/dist/internal/types/protocol.d.ts +1 -0
- package/dist/internal/types/protocol.js +1 -0
- package/dist/internal/types/rpc.d.ts +1 -0
- package/dist/internal/types/rpc.js +1 -0
- package/dist/oracle.js +3 -2
- package/dist/protocol.d.ts +3 -13
- package/dist/protocol.js +3 -4534
- package/dist/protocol_seeds.d.ts +1 -220
- package/dist/protocol_seeds.js +1 -324
- package/dist/rpc.js +51 -6
- package/dist/transactions.d.ts +1 -0
- package/dist/transactions.js +28 -6
- package/dist/types.d.ts +1 -1424
- package/dist/types.js +1 -1
- package/package.json +22 -5
package/dist/protocol.js
CHANGED
|
@@ -1,4534 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { asPubkey, deriveClaimPda, deriveClaimDelegatePda, deriveClaimV2Pda, deriveConfigPda, deriveConfigV2Pda, deriveCoverageClaimPda, deriveCoverageProductPda, deriveCoverageProductPaymentOptionPda, deriveCoverageNftPda, deriveCoveragePolicyPda, deriveCycleOutcomePda, deriveCycleWindowPda, deriveEnrollmentReplayPda, deriveAttestationVotePda, deriveCycleQuoteReplayPda, deriveInviteIssuerPda, deriveMemberCyclePda, deriveMembershipPda, deriveOracleStakePda, deriveOracleProfilePda, deriveOutcomeAggregatePda, deriveOraclePda, derivePoolAssetVaultPda, derivePoolOraclePermissionSetPda, derivePoolOracleFeeVaultPda, derivePoolTermsPda, derivePoolOraclePolicyPda, derivePoolOraclePda, derivePoolPda, derivePoolRulePda, deriveProtocolFeeVaultPda, derivePremiumLedgerPda, derivePremiumReplayPda, derivePoolTreasuryReservePda, deriveReplayPda, deriveSchemaPda, ZERO_PUBKEY, } from './protocol_seeds.js';
|
|
5
|
-
const MAX_POOL_ID_SEED_BYTES = 32;
|
|
6
|
-
const MAX_ORACLE_SUPPORTED_SCHEMAS = 16;
|
|
7
|
-
export const PROTOCOL_PROGRAM_ID = 'Bn6eixac1QEEVErGBvBjxAd6pgB9e2q4XHvAkinQ5y1B';
|
|
8
|
-
const IX_INITIALIZE_PROTOCOL = anchorDiscriminator('global', 'initialize_protocol');
|
|
9
|
-
const IX_SET_PROTOCOL_PAUSE = anchorDiscriminator('global', 'set_protocol_pause');
|
|
10
|
-
const IX_CREATE_POOL = anchorDiscriminator('global', 'create_pool');
|
|
11
|
-
const IX_SET_POOL_STATUS = anchorDiscriminator('global', 'set_pool_status');
|
|
12
|
-
const IX_SET_CYCLE_WINDOW = anchorDiscriminator('global', 'set_cycle_window');
|
|
13
|
-
const IX_FUND_POOL = anchorDiscriminator('global', 'fund_pool');
|
|
14
|
-
const IX_REGISTER_ORACLE = anchorDiscriminator('global', 'register_oracle');
|
|
15
|
-
const IX_REGISTER_ORACLE_V2 = anchorDiscriminator('global', 'register_oracle_v2');
|
|
16
|
-
const IX_CLAIM_ORACLE_V2 = anchorDiscriminator('global', 'claim_oracle_v2');
|
|
17
|
-
const IX_UPDATE_ORACLE_PROFILE_V2 = anchorDiscriminator('global', 'update_oracle_profile_v2');
|
|
18
|
-
const IX_SET_POOL_ORACLE = anchorDiscriminator('global', 'set_pool_oracle');
|
|
19
|
-
const IX_ENROLL_MEMBER = anchorDiscriminator('global', 'enroll_member');
|
|
20
|
-
const IX_REVOKE_MEMBER = anchorDiscriminator('global', 'revoke_member');
|
|
21
|
-
const IX_SUBMIT_OUTCOME_ATTESTATION = anchorDiscriminator('global', 'submit_outcome_attestation');
|
|
22
|
-
const IX_SUBMIT_CLAIM = anchorDiscriminator('global', 'submit_claim');
|
|
23
|
-
const IX_SUBMIT_OUTCOME_ATTESTATION_VOTE = anchorDiscriminator('global', 'submit_outcome_attestation_vote');
|
|
24
|
-
const IX_FINALIZE_CYCLE_OUTCOME = anchorDiscriminator('global', 'finalize_cycle_outcome');
|
|
25
|
-
const IX_INITIALIZE_PROTOCOL_V2 = anchorDiscriminator('global', 'initialize_protocol_v2');
|
|
26
|
-
const IX_SET_PROTOCOL_PARAMS = anchorDiscriminator('global', 'set_protocol_params');
|
|
27
|
-
const IX_ROTATE_GOVERNANCE_AUTHORITY = anchorDiscriminator('global', 'rotate_governance_authority');
|
|
28
|
-
const IX_UPDATE_ORACLE_METADATA = anchorDiscriminator('global', 'update_oracle_metadata');
|
|
29
|
-
const IX_STAKE_ORACLE = anchorDiscriminator('global', 'stake_oracle');
|
|
30
|
-
const IX_REQUEST_UNSTAKE = anchorDiscriminator('global', 'request_unstake');
|
|
31
|
-
const IX_FINALIZE_UNSTAKE = anchorDiscriminator('global', 'finalize_unstake');
|
|
32
|
-
const IX_SLASH_ORACLE = anchorDiscriminator('global', 'slash_oracle');
|
|
33
|
-
const IX_CREATE_POOL_V2 = anchorDiscriminator('global', 'create_pool_v2');
|
|
34
|
-
const IX_SET_POOL_ORACLE_POLICY = anchorDiscriminator('global', 'set_pool_oracle_policy');
|
|
35
|
-
const IX_SET_POOL_ORACLE_PERMISSIONS = anchorDiscriminator('global', 'set_pool_oracle_permissions');
|
|
36
|
-
const IX_SET_POOL_COVERAGE_RESERVE_FLOOR = anchorDiscriminator('global', 'set_pool_coverage_reserve_floor');
|
|
37
|
-
const IX_SET_POOL_TERMS_HASH = anchorDiscriminator('global', 'set_pool_terms_hash');
|
|
38
|
-
const IX_REGISTER_OUTCOME_SCHEMA = anchorDiscriminator('global', 'register_outcome_schema');
|
|
39
|
-
const IX_VERIFY_OUTCOME_SCHEMA = anchorDiscriminator('global', 'verify_outcome_schema');
|
|
40
|
-
const IX_SET_POOL_OUTCOME_RULE = anchorDiscriminator('global', 'set_pool_outcome_rule');
|
|
41
|
-
const IX_REGISTER_INVITE_ISSUER = anchorDiscriminator('global', 'register_invite_issuer');
|
|
42
|
-
const IX_ENROLL_MEMBER_OPEN = anchorDiscriminator('global', 'enroll_member_open');
|
|
43
|
-
const IX_ENROLL_MEMBER_TOKEN_GATE = anchorDiscriminator('global', 'enroll_member_token_gate');
|
|
44
|
-
const IX_ENROLL_MEMBER_INVITE_PERMIT = anchorDiscriminator('global', 'enroll_member_invite_permit');
|
|
45
|
-
const IX_SET_CLAIM_DELEGATE = anchorDiscriminator('global', 'set_claim_delegate');
|
|
46
|
-
const IX_FUND_POOL_SOL = anchorDiscriminator('global', 'fund_pool_sol');
|
|
47
|
-
const IX_FUND_POOL_SPL = anchorDiscriminator('global', 'fund_pool_spl');
|
|
48
|
-
const IX_SUBMIT_REWARD_CLAIM = anchorDiscriminator('global', 'submit_reward_claim');
|
|
49
|
-
const IX_REGISTER_COVERAGE_PRODUCT_V2 = anchorDiscriminator('global', 'register_coverage_product_v2');
|
|
50
|
-
const IX_UPSERT_COVERAGE_PRODUCT_PAYMENT_OPTION = anchorDiscriminator('global', 'upsert_coverage_product_payment_option');
|
|
51
|
-
const IX_UPDATE_COVERAGE_PRODUCT_V2 = anchorDiscriminator('global', 'update_coverage_product_v2');
|
|
52
|
-
const IX_SUBSCRIBE_COVERAGE_PRODUCT_V2 = anchorDiscriminator('global', 'subscribe_coverage_product_v2');
|
|
53
|
-
const IX_ISSUE_COVERAGE_POLICY_FROM_PRODUCT_V2 = anchorDiscriminator('global', 'issue_coverage_policy_from_product_v2');
|
|
54
|
-
const IX_CREATE_COVERAGE_POLICY = anchorDiscriminator('global', 'create_coverage_policy');
|
|
55
|
-
const IX_MINT_POLICY_NFT = anchorDiscriminator('global', 'mint_policy_nft');
|
|
56
|
-
const IX_PAY_PREMIUM_ONCHAIN = anchorDiscriminator('global', 'pay_premium_onchain');
|
|
57
|
-
const IX_ATTEST_PREMIUM_PAID_OFFCHAIN = anchorDiscriminator('global', 'attest_premium_paid_offchain');
|
|
58
|
-
const IX_SUBMIT_COVERAGE_CLAIM = anchorDiscriminator('global', 'submit_coverage_claim');
|
|
59
|
-
const IX_SETTLE_COVERAGE_CLAIM = anchorDiscriminator('global', 'settle_coverage_claim');
|
|
60
|
-
const IX_MIGRATE_POOL_V1_TO_V2 = anchorDiscriminator('global', 'migrate_pool_v1_to_v2');
|
|
61
|
-
const IX_MIGRATE_MEMBERSHIP_V1_TO_V2 = anchorDiscriminator('global', 'migrate_membership_v1_to_v2');
|
|
62
|
-
const IX_ACTIVATE_CYCLE_WITH_QUOTE_SOL = anchorDiscriminator('global', 'activate_cycle_with_quote_sol');
|
|
63
|
-
const IX_ACTIVATE_CYCLE_WITH_QUOTE_SPL = anchorDiscriminator('global', 'activate_cycle_with_quote_spl');
|
|
64
|
-
const IX_SETTLE_CYCLE_COMMITMENT = anchorDiscriminator('global', 'settle_cycle_commitment');
|
|
65
|
-
const IX_SETTLE_CYCLE_COMMITMENT_SOL = anchorDiscriminator('global', 'settle_cycle_commitment_sol');
|
|
66
|
-
const IX_WITHDRAW_POOL_TREASURY_SPL = anchorDiscriminator('global', 'withdraw_pool_treasury_spl');
|
|
67
|
-
const IX_WITHDRAW_POOL_TREASURY_SOL = anchorDiscriminator('global', 'withdraw_pool_treasury_sol');
|
|
68
|
-
const IX_WITHDRAW_PROTOCOL_FEE_SPL = anchorDiscriminator('global', 'withdraw_protocol_fee_spl');
|
|
69
|
-
const IX_WITHDRAW_PROTOCOL_FEE_SOL = anchorDiscriminator('global', 'withdraw_protocol_fee_sol');
|
|
70
|
-
const IX_WITHDRAW_POOL_ORACLE_FEE_SPL = anchorDiscriminator('global', 'withdraw_pool_oracle_fee_spl');
|
|
71
|
-
const IX_WITHDRAW_POOL_ORACLE_FEE_SOL = anchorDiscriminator('global', 'withdraw_pool_oracle_fee_sol');
|
|
72
|
-
const ACCOUNT_PROTOCOL_CONFIG = anchorDiscriminator('account', 'ProtocolConfig');
|
|
73
|
-
const ACCOUNT_POOL = anchorDiscriminator('account', 'Pool');
|
|
74
|
-
const ACCOUNT_ORACLE_REGISTRY = anchorDiscriminator('account', 'OracleRegistryEntry');
|
|
75
|
-
const ACCOUNT_ORACLE_PROFILE = anchorDiscriminator('account', 'OracleProfile');
|
|
76
|
-
const ACCOUNT_POOL_ORACLE_APPROVAL = anchorDiscriminator('account', 'PoolOracleApproval');
|
|
77
|
-
const ACCOUNT_MEMBERSHIP_RECORD = anchorDiscriminator('account', 'MembershipRecord');
|
|
78
|
-
const ACCOUNT_CYCLE_OUTCOME = anchorDiscriminator('account', 'CycleOutcomeState');
|
|
79
|
-
const ACCOUNT_CYCLE_WINDOW = anchorDiscriminator('account', 'CycleWindow');
|
|
80
|
-
const ACCOUNT_CLAIM_RECORD = anchorDiscriminator('account', 'ClaimRecord');
|
|
81
|
-
const ACCOUNT_CYCLE_OUTCOME_AGGREGATE = anchorDiscriminator('account', 'CycleOutcomeAggregate');
|
|
82
|
-
const ACCOUNT_PROTOCOL_CONFIG_V2 = anchorDiscriminator('account', 'ProtocolConfigV2');
|
|
83
|
-
const ACCOUNT_ORACLE_STAKE_POSITION = anchorDiscriminator('account', 'OracleStakePosition');
|
|
84
|
-
const ACCOUNT_POOL_ORACLE_POLICY = anchorDiscriminator('account', 'PoolOraclePolicy');
|
|
85
|
-
const ACCOUNT_POOL_TERMS = anchorDiscriminator('account', 'PoolTerms');
|
|
86
|
-
const ACCOUNT_POOL_ASSET_VAULT = anchorDiscriminator('account', 'PoolAssetVault');
|
|
87
|
-
const ACCOUNT_PROTOCOL_FEE_VAULT = anchorDiscriminator('account', 'ProtocolFeeVault');
|
|
88
|
-
const ACCOUNT_POOL_ORACLE_FEE_VAULT = anchorDiscriminator('account', 'PoolOracleFeeVault');
|
|
89
|
-
const ACCOUNT_OUTCOME_SCHEMA = anchorDiscriminator('account', 'OutcomeSchemaRegistryEntry');
|
|
90
|
-
const ACCOUNT_POOL_OUTCOME_RULE = anchorDiscriminator('account', 'PoolOutcomeRule');
|
|
91
|
-
const ACCOUNT_INVITE_ISSUER = anchorDiscriminator('account', 'InviteIssuerRegistryEntry');
|
|
92
|
-
const ACCOUNT_CLAIM_DELEGATE_AUTH = anchorDiscriminator('account', 'ClaimDelegateAuthorization');
|
|
93
|
-
const ACCOUNT_CLAIM_RECORD_V2 = anchorDiscriminator('account', 'ClaimRecordV2');
|
|
94
|
-
const ACCOUNT_COVERAGE_CLAIM_RECORD = anchorDiscriminator('account', 'CoverageClaimRecord');
|
|
95
|
-
const ACCOUNT_COVERAGE_POLICY_POSITION_NFT = anchorDiscriminator('account', 'CoveragePolicyPositionNft');
|
|
96
|
-
const ACCOUNT_COVERAGE_PRODUCT = anchorDiscriminator('account', 'CoverageProduct');
|
|
97
|
-
const ACCOUNT_COVERAGE_PRODUCT_PAYMENT_OPTION = anchorDiscriminator('account', 'CoverageProductPaymentOption');
|
|
98
|
-
const ACCOUNT_ENROLLMENT_PERMIT_REPLAY = anchorDiscriminator('account', 'EnrollmentPermitReplay');
|
|
99
|
-
const ACCOUNT_ATTESTATION_VOTE = anchorDiscriminator('account', 'AttestationVote');
|
|
100
|
-
const ACCOUNT_COVERAGE_POLICY = anchorDiscriminator('account', 'CoveragePolicy');
|
|
101
|
-
const ACCOUNT_PREMIUM_LEDGER = anchorDiscriminator('account', 'PremiumLedger');
|
|
102
|
-
const ACCOUNT_PREMIUM_ATTESTATION_REPLAY = anchorDiscriminator('account', 'PremiumAttestationReplay');
|
|
103
|
-
const ACCOUNT_POOL_ORACLE_PERMISSION_SET = anchorDiscriminator('account', 'PoolOraclePermissionSet');
|
|
104
|
-
const ACCOUNT_MEMBER_CYCLE = anchorDiscriminator('account', 'MemberCycleState');
|
|
105
|
-
const ACCOUNT_CYCLE_QUOTE_REPLAY = anchorDiscriminator('account', 'CycleQuoteReplay');
|
|
106
|
-
const ACCOUNT_POOL_TREASURY_RESERVE = anchorDiscriminator('account', 'PoolTreasuryReserve');
|
|
107
|
-
const TOKEN_PROGRAM_ID = new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
|
|
108
|
-
const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
|
109
|
-
function pubkeyFromData(buffer, offset) {
|
|
110
|
-
return new PublicKey(buffer.subarray(offset, offset + 32)).toBase58();
|
|
111
|
-
}
|
|
112
|
-
function parsePoolStatus(code) {
|
|
113
|
-
switch (code) {
|
|
114
|
-
case 0:
|
|
115
|
-
return 'draft';
|
|
116
|
-
case 1:
|
|
117
|
-
return 'active';
|
|
118
|
-
case 2:
|
|
119
|
-
return 'paused';
|
|
120
|
-
case 3:
|
|
121
|
-
return 'closed';
|
|
122
|
-
default:
|
|
123
|
-
return 'unknown';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function parseMembershipStatus(code) {
|
|
127
|
-
switch (code) {
|
|
128
|
-
case 1:
|
|
129
|
-
return 'active';
|
|
130
|
-
case 2:
|
|
131
|
-
return 'revoked';
|
|
132
|
-
default:
|
|
133
|
-
return 'unknown';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function parsePoolType(code) {
|
|
137
|
-
switch (code) {
|
|
138
|
-
case 0:
|
|
139
|
-
return 'reward';
|
|
140
|
-
case 1:
|
|
141
|
-
return 'coverage';
|
|
142
|
-
default:
|
|
143
|
-
return 'unknown';
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function parseMemberCycleStatus(code) {
|
|
147
|
-
switch (code) {
|
|
148
|
-
case 1:
|
|
149
|
-
return 'active';
|
|
150
|
-
case 2:
|
|
151
|
-
return 'settled';
|
|
152
|
-
default:
|
|
153
|
-
return 'unknown';
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function deriveAssociatedTokenAddress(params) {
|
|
157
|
-
const owner = asPubkey(params.owner);
|
|
158
|
-
const mint = asPubkey(params.mint);
|
|
159
|
-
const [address] = PublicKey.findProgramAddressSync([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
160
|
-
return address;
|
|
161
|
-
}
|
|
162
|
-
export function buildCycleQuoteMessage(fields) {
|
|
163
|
-
return Buffer.concat([
|
|
164
|
-
Buffer.from('omegax:cycle_quote:v1', 'utf8'),
|
|
165
|
-
asPubkey(fields.poolAddress).toBuffer(),
|
|
166
|
-
asPubkey(fields.member).toBuffer(),
|
|
167
|
-
Buffer.from(fromHex(fields.productIdHashHex, 32)),
|
|
168
|
-
asPubkey(fields.paymentMint).toBuffer(),
|
|
169
|
-
encodeU64Le(fields.premiumAmountRaw),
|
|
170
|
-
encodeU64Le(fields.canonicalPremiumAmount),
|
|
171
|
-
encodeU64Le(fields.periodIndex),
|
|
172
|
-
Buffer.from([fields.commitmentEnabled ? 1 : 0]),
|
|
173
|
-
encodeU64Le(fields.bondAmountRaw),
|
|
174
|
-
encodeU64Le(fields.shieldFeeRaw),
|
|
175
|
-
encodeU64Le(fields.protocolFeeRaw),
|
|
176
|
-
encodeU64Le(fields.oracleFeeRaw),
|
|
177
|
-
encodeU64Le(fields.netPoolPremiumRaw),
|
|
178
|
-
encodeU64Le(fields.totalAmountRaw),
|
|
179
|
-
Buffer.from([fields.includedShieldCount]),
|
|
180
|
-
encodeU16Le(fields.thresholdBps),
|
|
181
|
-
encodeI64Le(fields.expiresAtTs),
|
|
182
|
-
Buffer.from(fromHex(fields.nonceHashHex, 32)),
|
|
183
|
-
Buffer.from(fromHex(fields.quoteMetaHashHex, 32)),
|
|
184
|
-
]);
|
|
185
|
-
}
|
|
186
|
-
function asCycleQuoteMessage(input) {
|
|
187
|
-
if (input instanceof Uint8Array) {
|
|
188
|
-
return Buffer.from(input);
|
|
189
|
-
}
|
|
190
|
-
return buildCycleQuoteMessage(input);
|
|
191
|
-
}
|
|
192
|
-
export function buildCycleQuoteHash(input) {
|
|
193
|
-
return Buffer.from(blake3(asCycleQuoteMessage(input)));
|
|
194
|
-
}
|
|
195
|
-
export function buildCycleQuoteSignatureMessage(input) {
|
|
196
|
-
return Buffer.concat([
|
|
197
|
-
Buffer.from('omegax:cycle_quote_sig:v1', 'utf8'),
|
|
198
|
-
buildCycleQuoteHash(input),
|
|
199
|
-
]);
|
|
200
|
-
}
|
|
201
|
-
export function compileTransactionToV0(transaction, lookupTableAccounts) {
|
|
202
|
-
if (!transaction.feePayer) {
|
|
203
|
-
throw new Error('transaction fee payer is required to compile a v0 transaction');
|
|
204
|
-
}
|
|
205
|
-
if (!transaction.recentBlockhash) {
|
|
206
|
-
throw new Error('transaction recentBlockhash is required to compile a v0 transaction');
|
|
207
|
-
}
|
|
208
|
-
const message = new TransactionMessage({
|
|
209
|
-
payerKey: transaction.feePayer,
|
|
210
|
-
recentBlockhash: transaction.recentBlockhash,
|
|
211
|
-
instructions: transaction.instructions,
|
|
212
|
-
}).compileToV0Message(lookupTableAccounts);
|
|
213
|
-
return new VersionedTransaction(message);
|
|
214
|
-
}
|
|
215
|
-
function hasDiscriminator(data, discriminator) {
|
|
216
|
-
if (data.length < 8)
|
|
217
|
-
return false;
|
|
218
|
-
return discriminator.equals(data.subarray(0, 8));
|
|
219
|
-
}
|
|
220
|
-
function decodeProtocolConfigAccount(address, data) {
|
|
221
|
-
if (!hasDiscriminator(data, ACCOUNT_PROTOCOL_CONFIG)) {
|
|
222
|
-
throw new Error('account discriminator mismatch for ProtocolConfig');
|
|
223
|
-
}
|
|
224
|
-
let offset = 8;
|
|
225
|
-
const admin = pubkeyFromData(data, offset);
|
|
226
|
-
offset += 32;
|
|
227
|
-
const protocolFeeBps = readU16Le(data, offset);
|
|
228
|
-
offset += 2;
|
|
229
|
-
const emergencyPaused = data.readUInt8(offset) === 1;
|
|
230
|
-
offset += 1;
|
|
231
|
-
const bump = data.readUInt8(offset);
|
|
232
|
-
return {
|
|
233
|
-
address,
|
|
234
|
-
admin,
|
|
235
|
-
protocolFeeBps,
|
|
236
|
-
emergencyPaused,
|
|
237
|
-
bump,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function decodePoolAccount(address, data) {
|
|
241
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL)) {
|
|
242
|
-
throw new Error('account discriminator mismatch for Pool');
|
|
243
|
-
}
|
|
244
|
-
let offset = 8;
|
|
245
|
-
const authority = pubkeyFromData(data, offset);
|
|
246
|
-
offset += 32;
|
|
247
|
-
const poolId = readString(data, offset);
|
|
248
|
-
offset = poolId.offset;
|
|
249
|
-
const organizationRef = readString(data, offset);
|
|
250
|
-
offset = organizationRef.offset;
|
|
251
|
-
const payoutLamportsPerPass = readU64Le(data, offset);
|
|
252
|
-
offset += 8;
|
|
253
|
-
const membershipMode = data.readUInt8(offset);
|
|
254
|
-
offset += 1;
|
|
255
|
-
const tokenGateMint = pubkeyFromData(data, offset);
|
|
256
|
-
offset += 32;
|
|
257
|
-
const tokenGateMinBalance = readU64Le(data, offset);
|
|
258
|
-
offset += 8;
|
|
259
|
-
const inviteIssuer = pubkeyFromData(data, offset);
|
|
260
|
-
offset += 32;
|
|
261
|
-
const statusCode = data.readUInt8(offset);
|
|
262
|
-
offset += 1;
|
|
263
|
-
const bump = data.readUInt8(offset);
|
|
264
|
-
return {
|
|
265
|
-
address,
|
|
266
|
-
authority,
|
|
267
|
-
poolId: poolId.value,
|
|
268
|
-
organizationRef: organizationRef.value,
|
|
269
|
-
payoutLamportsPerPass,
|
|
270
|
-
membershipMode,
|
|
271
|
-
tokenGateMint,
|
|
272
|
-
tokenGateMinBalance,
|
|
273
|
-
inviteIssuer,
|
|
274
|
-
statusCode,
|
|
275
|
-
status: parsePoolStatus(statusCode),
|
|
276
|
-
bump,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function decodeOracleRegistryEntryAccount(address, data) {
|
|
280
|
-
if (!hasDiscriminator(data, ACCOUNT_ORACLE_REGISTRY)) {
|
|
281
|
-
throw new Error('account discriminator mismatch for OracleRegistryEntry');
|
|
282
|
-
}
|
|
283
|
-
let offset = 8;
|
|
284
|
-
const oracle = pubkeyFromData(data, offset);
|
|
285
|
-
offset += 32;
|
|
286
|
-
const active = data.readUInt8(offset) === 1;
|
|
287
|
-
offset += 1;
|
|
288
|
-
const bump = data.readUInt8(offset);
|
|
289
|
-
offset += 1;
|
|
290
|
-
const metadataUri = readString(data, offset).value;
|
|
291
|
-
return {
|
|
292
|
-
address,
|
|
293
|
-
oracle,
|
|
294
|
-
active,
|
|
295
|
-
bump,
|
|
296
|
-
metadataUri,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function decodeOracleProfileAccount(address, data) {
|
|
300
|
-
if (!hasDiscriminator(data, ACCOUNT_ORACLE_PROFILE)) {
|
|
301
|
-
throw new Error('account discriminator mismatch for OracleProfile');
|
|
302
|
-
}
|
|
303
|
-
let offset = 8;
|
|
304
|
-
const oracle = pubkeyFromData(data, offset);
|
|
305
|
-
offset += 32;
|
|
306
|
-
const admin = pubkeyFromData(data, offset);
|
|
307
|
-
offset += 32;
|
|
308
|
-
const oracleType = data.readUInt8(offset);
|
|
309
|
-
offset += 1;
|
|
310
|
-
const displayName = readString(data, offset);
|
|
311
|
-
offset = displayName.offset;
|
|
312
|
-
const legalName = readString(data, offset);
|
|
313
|
-
offset = legalName.offset;
|
|
314
|
-
const websiteUrl = readString(data, offset);
|
|
315
|
-
offset = websiteUrl.offset;
|
|
316
|
-
const appUrl = readString(data, offset);
|
|
317
|
-
offset = appUrl.offset;
|
|
318
|
-
const logoUri = readString(data, offset);
|
|
319
|
-
offset = logoUri.offset;
|
|
320
|
-
const webhookUrl = readString(data, offset);
|
|
321
|
-
offset = webhookUrl.offset;
|
|
322
|
-
const supportedSchemaCount = data.readUInt8(offset);
|
|
323
|
-
offset += 1;
|
|
324
|
-
const supportedSchemaKeyHashesHex = [];
|
|
325
|
-
for (let index = 0; index < 16; index += 1) {
|
|
326
|
-
const schemaHash = data.subarray(offset, offset + 32);
|
|
327
|
-
offset += 32;
|
|
328
|
-
if (index < supportedSchemaCount) {
|
|
329
|
-
supportedSchemaKeyHashesHex.push(toHex(schemaHash));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const claimed = data.readUInt8(offset) === 1;
|
|
333
|
-
offset += 1;
|
|
334
|
-
const createdAtTs = Number(readI64Le(data, offset));
|
|
335
|
-
offset += 8;
|
|
336
|
-
const updatedAtTs = Number(readI64Le(data, offset));
|
|
337
|
-
offset += 8;
|
|
338
|
-
const bump = data.readUInt8(offset);
|
|
339
|
-
return {
|
|
340
|
-
address,
|
|
341
|
-
oracle,
|
|
342
|
-
admin,
|
|
343
|
-
oracleType,
|
|
344
|
-
displayName: displayName.value,
|
|
345
|
-
legalName: legalName.value,
|
|
346
|
-
websiteUrl: websiteUrl.value,
|
|
347
|
-
appUrl: appUrl.value,
|
|
348
|
-
logoUri: logoUri.value,
|
|
349
|
-
webhookUrl: webhookUrl.value,
|
|
350
|
-
supportedSchemaCount,
|
|
351
|
-
supportedSchemaKeyHashesHex,
|
|
352
|
-
claimed,
|
|
353
|
-
createdAtTs,
|
|
354
|
-
updatedAtTs,
|
|
355
|
-
bump,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function decodePoolOracleApprovalAccount(address, data) {
|
|
359
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_ORACLE_APPROVAL)) {
|
|
360
|
-
throw new Error('account discriminator mismatch for PoolOracleApproval');
|
|
361
|
-
}
|
|
362
|
-
let offset = 8;
|
|
363
|
-
const pool = pubkeyFromData(data, offset);
|
|
364
|
-
offset += 32;
|
|
365
|
-
const oracle = pubkeyFromData(data, offset);
|
|
366
|
-
offset += 32;
|
|
367
|
-
const active = data.readUInt8(offset) === 1;
|
|
368
|
-
offset += 1;
|
|
369
|
-
const bump = data.readUInt8(offset);
|
|
370
|
-
return {
|
|
371
|
-
address,
|
|
372
|
-
pool,
|
|
373
|
-
oracle,
|
|
374
|
-
active,
|
|
375
|
-
bump,
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
function decodeMembershipRecordAccount(address, data) {
|
|
379
|
-
if (!hasDiscriminator(data, ACCOUNT_MEMBERSHIP_RECORD)) {
|
|
380
|
-
throw new Error('account discriminator mismatch for MembershipRecord');
|
|
381
|
-
}
|
|
382
|
-
let offset = 8;
|
|
383
|
-
const pool = pubkeyFromData(data, offset);
|
|
384
|
-
offset += 32;
|
|
385
|
-
const member = pubkeyFromData(data, offset);
|
|
386
|
-
offset += 32;
|
|
387
|
-
const subjectCommitment = data.subarray(offset, offset + 32);
|
|
388
|
-
offset += 32;
|
|
389
|
-
const statusCode = data.readUInt8(offset);
|
|
390
|
-
offset += 1;
|
|
391
|
-
const enrolledAt = Number(readI64Le(data, offset));
|
|
392
|
-
offset += 8;
|
|
393
|
-
const updatedAt = Number(readI64Le(data, offset));
|
|
394
|
-
offset += 8;
|
|
395
|
-
const bump = data.readUInt8(offset);
|
|
396
|
-
return {
|
|
397
|
-
address,
|
|
398
|
-
pool,
|
|
399
|
-
member,
|
|
400
|
-
subjectCommitmentHex: toHex(subjectCommitment),
|
|
401
|
-
statusCode,
|
|
402
|
-
status: parseMembershipStatus(statusCode),
|
|
403
|
-
enrolledAt,
|
|
404
|
-
updatedAt,
|
|
405
|
-
bump,
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
function decodeCycleOutcomeAccount(address, data) {
|
|
409
|
-
if (!hasDiscriminator(data, ACCOUNT_CYCLE_OUTCOME)) {
|
|
410
|
-
throw new Error('account discriminator mismatch for CycleOutcomeState');
|
|
411
|
-
}
|
|
412
|
-
let offset = 8;
|
|
413
|
-
const pool = pubkeyFromData(data, offset);
|
|
414
|
-
offset += 32;
|
|
415
|
-
const member = pubkeyFromData(data, offset);
|
|
416
|
-
offset += 32;
|
|
417
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
418
|
-
offset += 32;
|
|
419
|
-
const passCount = data.readUInt32LE(offset);
|
|
420
|
-
offset += 4;
|
|
421
|
-
const attestationCount = data.readUInt32LE(offset);
|
|
422
|
-
offset += 4;
|
|
423
|
-
const latestAsOfTs = Number(readI64Le(data, offset));
|
|
424
|
-
offset += 8;
|
|
425
|
-
const claimed = data.readUInt8(offset) === 1;
|
|
426
|
-
offset += 1;
|
|
427
|
-
const bump = data.readUInt8(offset);
|
|
428
|
-
return {
|
|
429
|
-
address,
|
|
430
|
-
pool,
|
|
431
|
-
member,
|
|
432
|
-
cycleHashHex: toHex(cycleHash),
|
|
433
|
-
passCount,
|
|
434
|
-
attestationCount,
|
|
435
|
-
latestAsOfTs,
|
|
436
|
-
claimed,
|
|
437
|
-
bump,
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
function decodeCycleWindowAccount(address, data) {
|
|
441
|
-
if (!hasDiscriminator(data, ACCOUNT_CYCLE_WINDOW)) {
|
|
442
|
-
throw new Error('account discriminator mismatch for CycleWindow');
|
|
443
|
-
}
|
|
444
|
-
let offset = 8;
|
|
445
|
-
const pool = pubkeyFromData(data, offset);
|
|
446
|
-
offset += 32;
|
|
447
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
448
|
-
offset += 32;
|
|
449
|
-
const authority = pubkeyFromData(data, offset);
|
|
450
|
-
offset += 32;
|
|
451
|
-
const claimOpenTs = Number(readI64Le(data, offset));
|
|
452
|
-
offset += 8;
|
|
453
|
-
const claimCloseTs = Number(readI64Le(data, offset));
|
|
454
|
-
offset += 8;
|
|
455
|
-
const bump = data.readUInt8(offset);
|
|
456
|
-
return {
|
|
457
|
-
address,
|
|
458
|
-
pool,
|
|
459
|
-
cycleHashHex: toHex(cycleHash),
|
|
460
|
-
authority,
|
|
461
|
-
claimOpenTs,
|
|
462
|
-
claimCloseTs,
|
|
463
|
-
bump,
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
function decodeClaimRecordAccount(address, data) {
|
|
467
|
-
if (!hasDiscriminator(data, ACCOUNT_CLAIM_RECORD)) {
|
|
468
|
-
throw new Error('account discriminator mismatch for ClaimRecord');
|
|
469
|
-
}
|
|
470
|
-
let offset = 8;
|
|
471
|
-
const pool = pubkeyFromData(data, offset);
|
|
472
|
-
offset += 32;
|
|
473
|
-
const member = pubkeyFromData(data, offset);
|
|
474
|
-
offset += 32;
|
|
475
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
476
|
-
offset += 32;
|
|
477
|
-
const claimIntent = data.subarray(offset, offset + 32);
|
|
478
|
-
offset += 32;
|
|
479
|
-
const payoutLamports = readU64Le(data, offset);
|
|
480
|
-
offset += 8;
|
|
481
|
-
const passCount = data.readUInt32LE(offset);
|
|
482
|
-
offset += 4;
|
|
483
|
-
const submittedAt = Number(readI64Le(data, offset));
|
|
484
|
-
offset += 8;
|
|
485
|
-
const bump = data.readUInt8(offset);
|
|
486
|
-
return {
|
|
487
|
-
address,
|
|
488
|
-
pool,
|
|
489
|
-
member,
|
|
490
|
-
cycleHashHex: toHex(cycleHash),
|
|
491
|
-
claimIntentHex: toHex(claimIntent),
|
|
492
|
-
payoutLamports,
|
|
493
|
-
passCount,
|
|
494
|
-
submittedAt,
|
|
495
|
-
bump,
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
function decodeCycleOutcomeAggregateAccount(address, data) {
|
|
499
|
-
if (!hasDiscriminator(data, ACCOUNT_CYCLE_OUTCOME_AGGREGATE)) {
|
|
500
|
-
throw new Error('account discriminator mismatch for CycleOutcomeAggregate');
|
|
501
|
-
}
|
|
502
|
-
let offset = 8;
|
|
503
|
-
const pool = pubkeyFromData(data, offset);
|
|
504
|
-
offset += 32;
|
|
505
|
-
const member = pubkeyFromData(data, offset);
|
|
506
|
-
offset += 32;
|
|
507
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
508
|
-
offset += 32;
|
|
509
|
-
const ruleHash = data.subarray(offset, offset + 32);
|
|
510
|
-
offset += 32;
|
|
511
|
-
const passVotes = data.readUInt16LE(offset);
|
|
512
|
-
offset += 2;
|
|
513
|
-
const failVotes = data.readUInt16LE(offset);
|
|
514
|
-
offset += 2;
|
|
515
|
-
const quorumM = data.readUInt8(offset);
|
|
516
|
-
offset += 1;
|
|
517
|
-
const quorumN = data.readUInt8(offset);
|
|
518
|
-
offset += 1;
|
|
519
|
-
const finalized = data.readUInt8(offset) === 1;
|
|
520
|
-
offset += 1;
|
|
521
|
-
const passed = data.readUInt8(offset) === 1;
|
|
522
|
-
offset += 1;
|
|
523
|
-
const claimed = data.readUInt8(offset) === 1;
|
|
524
|
-
offset += 1;
|
|
525
|
-
const rewardLiabilityReserved = data.readUInt8(offset) === 1;
|
|
526
|
-
offset += 1;
|
|
527
|
-
const latestAsOfTs = Number(readI64Le(data, offset));
|
|
528
|
-
offset += 8;
|
|
529
|
-
const bump = data.readUInt8(offset);
|
|
530
|
-
return {
|
|
531
|
-
address,
|
|
532
|
-
pool,
|
|
533
|
-
member,
|
|
534
|
-
cycleHashHex: toHex(cycleHash),
|
|
535
|
-
ruleHashHex: toHex(ruleHash),
|
|
536
|
-
passVotes,
|
|
537
|
-
failVotes,
|
|
538
|
-
quorumM,
|
|
539
|
-
quorumN,
|
|
540
|
-
finalized,
|
|
541
|
-
passed,
|
|
542
|
-
claimed,
|
|
543
|
-
rewardLiabilityReserved,
|
|
544
|
-
latestAsOfTs,
|
|
545
|
-
bump,
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
function decodeProtocolConfigV2Account(address, data) {
|
|
549
|
-
if (!hasDiscriminator(data, ACCOUNT_PROTOCOL_CONFIG_V2)) {
|
|
550
|
-
throw new Error('account discriminator mismatch for ProtocolConfigV2');
|
|
551
|
-
}
|
|
552
|
-
let offset = 8;
|
|
553
|
-
const admin = pubkeyFromData(data, offset);
|
|
554
|
-
offset += 32;
|
|
555
|
-
const governanceAuthority = pubkeyFromData(data, offset);
|
|
556
|
-
offset += 32;
|
|
557
|
-
const governanceRealm = pubkeyFromData(data, offset);
|
|
558
|
-
offset += 32;
|
|
559
|
-
const governanceConfig = pubkeyFromData(data, offset);
|
|
560
|
-
offset += 32;
|
|
561
|
-
const defaultStakeMint = pubkeyFromData(data, offset);
|
|
562
|
-
offset += 32;
|
|
563
|
-
const protocolFeeBps = readU16Le(data, offset);
|
|
564
|
-
offset += 2;
|
|
565
|
-
const minOracleStake = readU64Le(data, offset);
|
|
566
|
-
offset += 8;
|
|
567
|
-
const emergencyPaused = data.readUInt8(offset) === 1;
|
|
568
|
-
offset += 1;
|
|
569
|
-
const allowedPayoutMintsHash = data.subarray(offset, offset + 32);
|
|
570
|
-
offset += 32;
|
|
571
|
-
const bump = data.readUInt8(offset);
|
|
572
|
-
return {
|
|
573
|
-
address,
|
|
574
|
-
admin,
|
|
575
|
-
governanceAuthority,
|
|
576
|
-
governanceRealm,
|
|
577
|
-
governanceConfig,
|
|
578
|
-
defaultStakeMint,
|
|
579
|
-
protocolFeeBps,
|
|
580
|
-
minOracleStake,
|
|
581
|
-
emergencyPaused,
|
|
582
|
-
allowedPayoutMintsHashHex: toHex(allowedPayoutMintsHash),
|
|
583
|
-
bump,
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
function decodeOracleStakePositionAccount(address, data) {
|
|
587
|
-
if (!hasDiscriminator(data, ACCOUNT_ORACLE_STAKE_POSITION)) {
|
|
588
|
-
throw new Error('account discriminator mismatch for OracleStakePosition');
|
|
589
|
-
}
|
|
590
|
-
let offset = 8;
|
|
591
|
-
const oracle = pubkeyFromData(data, offset);
|
|
592
|
-
offset += 32;
|
|
593
|
-
const staker = pubkeyFromData(data, offset);
|
|
594
|
-
offset += 32;
|
|
595
|
-
const stakeMint = pubkeyFromData(data, offset);
|
|
596
|
-
offset += 32;
|
|
597
|
-
const stakeVault = pubkeyFromData(data, offset);
|
|
598
|
-
offset += 32;
|
|
599
|
-
const stakedAmount = readU64Le(data, offset);
|
|
600
|
-
offset += 8;
|
|
601
|
-
const pendingUnstakeAmount = readU64Le(data, offset);
|
|
602
|
-
offset += 8;
|
|
603
|
-
const canFinalizeUnstakeAt = Number(readI64Le(data, offset));
|
|
604
|
-
offset += 8;
|
|
605
|
-
const slashPending = data.readUInt8(offset) === 1;
|
|
606
|
-
offset += 1;
|
|
607
|
-
const bump = data.readUInt8(offset);
|
|
608
|
-
return {
|
|
609
|
-
address,
|
|
610
|
-
oracle,
|
|
611
|
-
staker,
|
|
612
|
-
stakeMint,
|
|
613
|
-
stakeVault,
|
|
614
|
-
stakedAmount,
|
|
615
|
-
pendingUnstakeAmount,
|
|
616
|
-
canFinalizeUnstakeAt,
|
|
617
|
-
slashPending,
|
|
618
|
-
bump,
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
function decodePoolOraclePolicyAccount(address, data) {
|
|
622
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_ORACLE_POLICY)) {
|
|
623
|
-
throw new Error('account discriminator mismatch for PoolOraclePolicy');
|
|
624
|
-
}
|
|
625
|
-
let offset = 8;
|
|
626
|
-
const pool = pubkeyFromData(data, offset);
|
|
627
|
-
offset += 32;
|
|
628
|
-
const quorumM = data.readUInt8(offset);
|
|
629
|
-
offset += 1;
|
|
630
|
-
const quorumN = data.readUInt8(offset);
|
|
631
|
-
offset += 1;
|
|
632
|
-
const requireVerifiedSchema = data.readUInt8(offset) === 1;
|
|
633
|
-
offset += 1;
|
|
634
|
-
const oracleFeeBps = readU16Le(data, offset);
|
|
635
|
-
offset += 2;
|
|
636
|
-
const allowDelegateClaim = data.readUInt8(offset) === 1;
|
|
637
|
-
offset += 1;
|
|
638
|
-
const bump = data.readUInt8(offset);
|
|
639
|
-
return {
|
|
640
|
-
address,
|
|
641
|
-
pool,
|
|
642
|
-
quorumM,
|
|
643
|
-
quorumN,
|
|
644
|
-
requireVerifiedSchema,
|
|
645
|
-
oracleFeeBps,
|
|
646
|
-
allowDelegateClaim,
|
|
647
|
-
bump,
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
function decodePoolTermsAccount(address, data) {
|
|
651
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_TERMS)) {
|
|
652
|
-
throw new Error('account discriminator mismatch for PoolTerms');
|
|
653
|
-
}
|
|
654
|
-
let offset = 8;
|
|
655
|
-
const pool = pubkeyFromData(data, offset);
|
|
656
|
-
offset += 32;
|
|
657
|
-
const poolTypeCode = data.readUInt8(offset);
|
|
658
|
-
offset += 1;
|
|
659
|
-
const payoutAssetMint = pubkeyFromData(data, offset);
|
|
660
|
-
offset += 32;
|
|
661
|
-
const termsHash = data.subarray(offset, offset + 32);
|
|
662
|
-
offset += 32;
|
|
663
|
-
const payoutPolicyHash = data.subarray(offset, offset + 32);
|
|
664
|
-
offset += 32;
|
|
665
|
-
const cycleMode = data.readUInt8(offset);
|
|
666
|
-
offset += 1;
|
|
667
|
-
const metadataUri = readString(data, offset);
|
|
668
|
-
offset = metadataUri.offset;
|
|
669
|
-
const bump = data.readUInt8(offset);
|
|
670
|
-
return {
|
|
671
|
-
address,
|
|
672
|
-
pool,
|
|
673
|
-
poolTypeCode,
|
|
674
|
-
poolType: parsePoolType(poolTypeCode),
|
|
675
|
-
payoutAssetMint,
|
|
676
|
-
termsHashHex: toHex(termsHash),
|
|
677
|
-
payoutPolicyHashHex: toHex(payoutPolicyHash),
|
|
678
|
-
cycleMode,
|
|
679
|
-
metadataUri: metadataUri.value,
|
|
680
|
-
bump,
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
function decodePoolAssetVaultAccount(address, data) {
|
|
684
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_ASSET_VAULT)) {
|
|
685
|
-
throw new Error('account discriminator mismatch for PoolAssetVault');
|
|
686
|
-
}
|
|
687
|
-
let offset = 8;
|
|
688
|
-
const pool = pubkeyFromData(data, offset);
|
|
689
|
-
offset += 32;
|
|
690
|
-
const payoutMint = pubkeyFromData(data, offset);
|
|
691
|
-
offset += 32;
|
|
692
|
-
const vaultTokenAccount = pubkeyFromData(data, offset);
|
|
693
|
-
offset += 32;
|
|
694
|
-
const active = data.readUInt8(offset) === 1;
|
|
695
|
-
offset += 1;
|
|
696
|
-
const bump = data.readUInt8(offset);
|
|
697
|
-
return {
|
|
698
|
-
address,
|
|
699
|
-
pool,
|
|
700
|
-
payoutMint,
|
|
701
|
-
vaultTokenAccount,
|
|
702
|
-
active,
|
|
703
|
-
bump,
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
function decodeProtocolFeeVaultAccount(address, data) {
|
|
707
|
-
if (!hasDiscriminator(data, ACCOUNT_PROTOCOL_FEE_VAULT)) {
|
|
708
|
-
throw new Error('account discriminator mismatch for ProtocolFeeVault');
|
|
709
|
-
}
|
|
710
|
-
let offset = 8;
|
|
711
|
-
const paymentMint = pubkeyFromData(data, offset);
|
|
712
|
-
offset += 32;
|
|
713
|
-
const bump = data.readUInt8(offset);
|
|
714
|
-
return {
|
|
715
|
-
address,
|
|
716
|
-
paymentMint,
|
|
717
|
-
bump,
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
function decodePoolOracleFeeVaultAccount(address, data) {
|
|
721
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_ORACLE_FEE_VAULT)) {
|
|
722
|
-
throw new Error('account discriminator mismatch for PoolOracleFeeVault');
|
|
723
|
-
}
|
|
724
|
-
let offset = 8;
|
|
725
|
-
const pool = pubkeyFromData(data, offset);
|
|
726
|
-
offset += 32;
|
|
727
|
-
const oracle = pubkeyFromData(data, offset);
|
|
728
|
-
offset += 32;
|
|
729
|
-
const paymentMint = pubkeyFromData(data, offset);
|
|
730
|
-
offset += 32;
|
|
731
|
-
const bump = data.readUInt8(offset);
|
|
732
|
-
return {
|
|
733
|
-
address,
|
|
734
|
-
pool,
|
|
735
|
-
oracle,
|
|
736
|
-
paymentMint,
|
|
737
|
-
bump,
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
function decodePoolOraclePermissionSetAccount(address, data) {
|
|
741
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_ORACLE_PERMISSION_SET)) {
|
|
742
|
-
throw new Error('account discriminator mismatch for PoolOraclePermissionSet');
|
|
743
|
-
}
|
|
744
|
-
let offset = 8;
|
|
745
|
-
const pool = pubkeyFromData(data, offset);
|
|
746
|
-
offset += 32;
|
|
747
|
-
const oracle = pubkeyFromData(data, offset);
|
|
748
|
-
offset += 32;
|
|
749
|
-
const permissions = data.readUInt32LE(offset);
|
|
750
|
-
offset += 4;
|
|
751
|
-
const bump = data.readUInt8(offset);
|
|
752
|
-
return {
|
|
753
|
-
address,
|
|
754
|
-
pool,
|
|
755
|
-
oracle,
|
|
756
|
-
permissions,
|
|
757
|
-
bump,
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
function decodeMemberCycleAccount(address, data) {
|
|
761
|
-
if (!hasDiscriminator(data, ACCOUNT_MEMBER_CYCLE)) {
|
|
762
|
-
throw new Error('account discriminator mismatch for MemberCycleState');
|
|
763
|
-
}
|
|
764
|
-
let offset = 8;
|
|
765
|
-
const pool = pubkeyFromData(data, offset);
|
|
766
|
-
offset += 32;
|
|
767
|
-
const member = pubkeyFromData(data, offset);
|
|
768
|
-
offset += 32;
|
|
769
|
-
const productIdHashHex = toHex(data.subarray(offset, offset + 32));
|
|
770
|
-
offset += 32;
|
|
771
|
-
const periodIndex = readU64Le(data, offset);
|
|
772
|
-
offset += 8;
|
|
773
|
-
const paymentMint = pubkeyFromData(data, offset);
|
|
774
|
-
offset += 32;
|
|
775
|
-
const premiumAmountRaw = readU64Le(data, offset);
|
|
776
|
-
offset += 8;
|
|
777
|
-
const bondAmountRaw = readU64Le(data, offset);
|
|
778
|
-
offset += 8;
|
|
779
|
-
const shieldFeeRaw = readU64Le(data, offset);
|
|
780
|
-
offset += 8;
|
|
781
|
-
const protocolFeeRaw = readU64Le(data, offset);
|
|
782
|
-
offset += 8;
|
|
783
|
-
const oracleFeeRaw = readU64Le(data, offset);
|
|
784
|
-
offset += 8;
|
|
785
|
-
const netPoolPremiumRaw = readU64Le(data, offset);
|
|
786
|
-
offset += 8;
|
|
787
|
-
const totalAmountRaw = readU64Le(data, offset);
|
|
788
|
-
offset += 8;
|
|
789
|
-
const canonicalPremiumAmount = readU64Le(data, offset);
|
|
790
|
-
offset += 8;
|
|
791
|
-
const commitmentEnabled = data.readUInt8(offset) === 1;
|
|
792
|
-
offset += 1;
|
|
793
|
-
const thresholdBps = readU16Le(data, offset);
|
|
794
|
-
offset += 2;
|
|
795
|
-
const includedShieldCount = data.readUInt8(offset);
|
|
796
|
-
offset += 1;
|
|
797
|
-
const shieldConsumed = data.readUInt8(offset) === 1;
|
|
798
|
-
offset += 1;
|
|
799
|
-
const statusCode = data.readUInt8(offset);
|
|
800
|
-
offset += 1;
|
|
801
|
-
const passed = data.readUInt8(offset) === 1;
|
|
802
|
-
offset += 1;
|
|
803
|
-
const activatedAt = Number(readI64Le(data, offset));
|
|
804
|
-
offset += 8;
|
|
805
|
-
const settledAt = Number(readI64Le(data, offset));
|
|
806
|
-
offset += 8;
|
|
807
|
-
const quoteHashHex = toHex(data.subarray(offset, offset + 32));
|
|
808
|
-
offset += 32;
|
|
809
|
-
const bump = data.readUInt8(offset);
|
|
810
|
-
return {
|
|
811
|
-
address,
|
|
812
|
-
pool,
|
|
813
|
-
member,
|
|
814
|
-
productIdHashHex,
|
|
815
|
-
periodIndex,
|
|
816
|
-
paymentMint,
|
|
817
|
-
premiumAmountRaw,
|
|
818
|
-
bondAmountRaw,
|
|
819
|
-
shieldFeeRaw,
|
|
820
|
-
protocolFeeRaw,
|
|
821
|
-
oracleFeeRaw,
|
|
822
|
-
netPoolPremiumRaw,
|
|
823
|
-
totalAmountRaw,
|
|
824
|
-
canonicalPremiumAmount,
|
|
825
|
-
commitmentEnabled,
|
|
826
|
-
thresholdBps,
|
|
827
|
-
includedShieldCount,
|
|
828
|
-
shieldConsumed,
|
|
829
|
-
statusCode,
|
|
830
|
-
status: parseMemberCycleStatus(statusCode),
|
|
831
|
-
passed,
|
|
832
|
-
activatedAt,
|
|
833
|
-
settledAt,
|
|
834
|
-
quoteHashHex,
|
|
835
|
-
bump,
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
function decodeCycleQuoteReplayAccount(address, data) {
|
|
839
|
-
if (!hasDiscriminator(data, ACCOUNT_CYCLE_QUOTE_REPLAY)) {
|
|
840
|
-
throw new Error('account discriminator mismatch for CycleQuoteReplay');
|
|
841
|
-
}
|
|
842
|
-
let offset = 8;
|
|
843
|
-
const pool = pubkeyFromData(data, offset);
|
|
844
|
-
offset += 32;
|
|
845
|
-
const member = pubkeyFromData(data, offset);
|
|
846
|
-
offset += 32;
|
|
847
|
-
const nonceHashHex = toHex(data.subarray(offset, offset + 32));
|
|
848
|
-
offset += 32;
|
|
849
|
-
const quoteHashHex = toHex(data.subarray(offset, offset + 32));
|
|
850
|
-
offset += 32;
|
|
851
|
-
const createdAt = Number(readI64Le(data, offset));
|
|
852
|
-
offset += 8;
|
|
853
|
-
const bump = data.readUInt8(offset);
|
|
854
|
-
return {
|
|
855
|
-
address,
|
|
856
|
-
pool,
|
|
857
|
-
member,
|
|
858
|
-
nonceHashHex,
|
|
859
|
-
quoteHashHex,
|
|
860
|
-
createdAt,
|
|
861
|
-
bump,
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
function decodePoolTreasuryReserveAccount(address, data) {
|
|
865
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_TREASURY_RESERVE)) {
|
|
866
|
-
throw new Error('account discriminator mismatch for PoolTreasuryReserve');
|
|
867
|
-
}
|
|
868
|
-
let offset = 8;
|
|
869
|
-
const pool = pubkeyFromData(data, offset);
|
|
870
|
-
offset += 32;
|
|
871
|
-
const paymentMint = pubkeyFromData(data, offset);
|
|
872
|
-
offset += 32;
|
|
873
|
-
const reservedRefundAmount = readU64Le(data, offset);
|
|
874
|
-
offset += 8;
|
|
875
|
-
const reservedRewardAmount = readU64Le(data, offset);
|
|
876
|
-
offset += 8;
|
|
877
|
-
const manualCoverageReserveAmount = readU64Le(data, offset);
|
|
878
|
-
offset += 8;
|
|
879
|
-
const bump = data.readUInt8(offset);
|
|
880
|
-
return {
|
|
881
|
-
address,
|
|
882
|
-
pool,
|
|
883
|
-
paymentMint,
|
|
884
|
-
reservedRefundAmount,
|
|
885
|
-
reservedRewardAmount,
|
|
886
|
-
manualCoverageReserveAmount,
|
|
887
|
-
bump,
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
function decodeOutcomeSchemaAccount(address, data) {
|
|
891
|
-
if (!hasDiscriminator(data, ACCOUNT_OUTCOME_SCHEMA)) {
|
|
892
|
-
throw new Error('account discriminator mismatch for OutcomeSchemaRegistryEntry');
|
|
893
|
-
}
|
|
894
|
-
let offset = 8;
|
|
895
|
-
const schemaKeyHash = data.subarray(offset, offset + 32);
|
|
896
|
-
offset += 32;
|
|
897
|
-
const schemaKey = readString(data, offset);
|
|
898
|
-
offset = schemaKey.offset;
|
|
899
|
-
const version = readU16Le(data, offset);
|
|
900
|
-
offset += 2;
|
|
901
|
-
const schemaHash = data.subarray(offset, offset + 32);
|
|
902
|
-
offset += 32;
|
|
903
|
-
const publisher = pubkeyFromData(data, offset);
|
|
904
|
-
offset += 32;
|
|
905
|
-
const verified = data.readUInt8(offset) === 1;
|
|
906
|
-
offset += 1;
|
|
907
|
-
const metadataUri = readString(data, offset);
|
|
908
|
-
offset = metadataUri.offset;
|
|
909
|
-
const bump = data.readUInt8(offset);
|
|
910
|
-
return {
|
|
911
|
-
address,
|
|
912
|
-
schemaKeyHashHex: toHex(schemaKeyHash),
|
|
913
|
-
schemaKey: schemaKey.value,
|
|
914
|
-
version,
|
|
915
|
-
schemaHashHex: toHex(schemaHash),
|
|
916
|
-
publisher,
|
|
917
|
-
verified,
|
|
918
|
-
metadataUri: metadataUri.value,
|
|
919
|
-
bump,
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
function decodePoolOutcomeRuleAccount(address, data) {
|
|
923
|
-
if (!hasDiscriminator(data, ACCOUNT_POOL_OUTCOME_RULE)) {
|
|
924
|
-
throw new Error('account discriminator mismatch for PoolOutcomeRule');
|
|
925
|
-
}
|
|
926
|
-
let offset = 8;
|
|
927
|
-
const pool = pubkeyFromData(data, offset);
|
|
928
|
-
offset += 32;
|
|
929
|
-
const ruleHash = data.subarray(offset, offset + 32);
|
|
930
|
-
offset += 32;
|
|
931
|
-
const schemaKeyHash = data.subarray(offset, offset + 32);
|
|
932
|
-
offset += 32;
|
|
933
|
-
const ruleId = readString(data, offset);
|
|
934
|
-
offset = ruleId.offset;
|
|
935
|
-
const schemaKey = readString(data, offset);
|
|
936
|
-
offset = schemaKey.offset;
|
|
937
|
-
const schemaVersion = readU16Le(data, offset);
|
|
938
|
-
offset += 2;
|
|
939
|
-
const payoutHash = data.subarray(offset, offset + 32);
|
|
940
|
-
offset += 32;
|
|
941
|
-
const enabled = data.readUInt8(offset) === 1;
|
|
942
|
-
offset += 1;
|
|
943
|
-
const bump = data.readUInt8(offset);
|
|
944
|
-
return {
|
|
945
|
-
address,
|
|
946
|
-
pool,
|
|
947
|
-
ruleHashHex: toHex(ruleHash),
|
|
948
|
-
schemaKeyHashHex: toHex(schemaKeyHash),
|
|
949
|
-
ruleId: ruleId.value,
|
|
950
|
-
schemaKey: schemaKey.value,
|
|
951
|
-
schemaVersion,
|
|
952
|
-
payoutHashHex: toHex(payoutHash),
|
|
953
|
-
enabled,
|
|
954
|
-
bump,
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
function decodeInviteIssuerAccount(address, data) {
|
|
958
|
-
if (!hasDiscriminator(data, ACCOUNT_INVITE_ISSUER)) {
|
|
959
|
-
throw new Error('account discriminator mismatch for InviteIssuerRegistryEntry');
|
|
960
|
-
}
|
|
961
|
-
let offset = 8;
|
|
962
|
-
const issuer = pubkeyFromData(data, offset);
|
|
963
|
-
offset += 32;
|
|
964
|
-
const organizationRef = readString(data, offset);
|
|
965
|
-
offset = organizationRef.offset;
|
|
966
|
-
const metadataUri = readString(data, offset);
|
|
967
|
-
offset = metadataUri.offset;
|
|
968
|
-
const active = data.readUInt8(offset) === 1;
|
|
969
|
-
offset += 1;
|
|
970
|
-
const bump = data.readUInt8(offset);
|
|
971
|
-
return {
|
|
972
|
-
address,
|
|
973
|
-
issuer,
|
|
974
|
-
organizationRef: organizationRef.value,
|
|
975
|
-
metadataUri: metadataUri.value,
|
|
976
|
-
active,
|
|
977
|
-
bump,
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function decodeEnrollmentPermitReplayAccount(address, data) {
|
|
981
|
-
if (!hasDiscriminator(data, ACCOUNT_ENROLLMENT_PERMIT_REPLAY)) {
|
|
982
|
-
throw new Error('account discriminator mismatch for EnrollmentPermitReplay');
|
|
983
|
-
}
|
|
984
|
-
let offset = 8;
|
|
985
|
-
const pool = pubkeyFromData(data, offset);
|
|
986
|
-
offset += 32;
|
|
987
|
-
const issuer = pubkeyFromData(data, offset);
|
|
988
|
-
offset += 32;
|
|
989
|
-
const member = pubkeyFromData(data, offset);
|
|
990
|
-
offset += 32;
|
|
991
|
-
const nonceHash = data.subarray(offset, offset + 32);
|
|
992
|
-
offset += 32;
|
|
993
|
-
const inviteIdHash = data.subarray(offset, offset + 32);
|
|
994
|
-
offset += 32;
|
|
995
|
-
const createdAt = Number(readI64Le(data, offset));
|
|
996
|
-
offset += 8;
|
|
997
|
-
const bump = data.readUInt8(offset);
|
|
998
|
-
return {
|
|
999
|
-
address,
|
|
1000
|
-
pool,
|
|
1001
|
-
issuer,
|
|
1002
|
-
member,
|
|
1003
|
-
nonceHashHex: toHex(nonceHash),
|
|
1004
|
-
inviteIdHashHex: toHex(inviteIdHash),
|
|
1005
|
-
createdAt,
|
|
1006
|
-
bump,
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
function decodeAttestationVoteAccount(address, data) {
|
|
1010
|
-
if (!hasDiscriminator(data, ACCOUNT_ATTESTATION_VOTE)) {
|
|
1011
|
-
throw new Error('account discriminator mismatch for AttestationVote');
|
|
1012
|
-
}
|
|
1013
|
-
let offset = 8;
|
|
1014
|
-
const pool = pubkeyFromData(data, offset);
|
|
1015
|
-
offset += 32;
|
|
1016
|
-
const member = pubkeyFromData(data, offset);
|
|
1017
|
-
offset += 32;
|
|
1018
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
1019
|
-
offset += 32;
|
|
1020
|
-
const ruleHash = data.subarray(offset, offset + 32);
|
|
1021
|
-
offset += 32;
|
|
1022
|
-
const oracle = pubkeyFromData(data, offset);
|
|
1023
|
-
offset += 32;
|
|
1024
|
-
const passed = data.readUInt8(offset) === 1;
|
|
1025
|
-
offset += 1;
|
|
1026
|
-
const attestationDigest = data.subarray(offset, offset + 32);
|
|
1027
|
-
offset += 32;
|
|
1028
|
-
const observedValueHash = data.subarray(offset, offset + 32);
|
|
1029
|
-
offset += 32;
|
|
1030
|
-
const asOfTs = Number(readI64Le(data, offset));
|
|
1031
|
-
offset += 8;
|
|
1032
|
-
const bump = data.readUInt8(offset);
|
|
1033
|
-
return {
|
|
1034
|
-
address,
|
|
1035
|
-
pool,
|
|
1036
|
-
member,
|
|
1037
|
-
cycleHashHex: toHex(cycleHash),
|
|
1038
|
-
ruleHashHex: toHex(ruleHash),
|
|
1039
|
-
oracle,
|
|
1040
|
-
passed,
|
|
1041
|
-
attestationDigestHex: toHex(attestationDigest),
|
|
1042
|
-
observedValueHashHex: toHex(observedValueHash),
|
|
1043
|
-
asOfTs,
|
|
1044
|
-
bump,
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
function decodeClaimDelegateAccount(address, data) {
|
|
1048
|
-
if (!hasDiscriminator(data, ACCOUNT_CLAIM_DELEGATE_AUTH)) {
|
|
1049
|
-
throw new Error('account discriminator mismatch for ClaimDelegateAuthorization');
|
|
1050
|
-
}
|
|
1051
|
-
let offset = 8;
|
|
1052
|
-
const pool = pubkeyFromData(data, offset);
|
|
1053
|
-
offset += 32;
|
|
1054
|
-
const member = pubkeyFromData(data, offset);
|
|
1055
|
-
offset += 32;
|
|
1056
|
-
const delegate = pubkeyFromData(data, offset);
|
|
1057
|
-
offset += 32;
|
|
1058
|
-
const active = data.readUInt8(offset) === 1;
|
|
1059
|
-
offset += 1;
|
|
1060
|
-
const updatedAt = Number(readI64Le(data, offset));
|
|
1061
|
-
offset += 8;
|
|
1062
|
-
const bump = data.readUInt8(offset);
|
|
1063
|
-
return {
|
|
1064
|
-
address,
|
|
1065
|
-
pool,
|
|
1066
|
-
member,
|
|
1067
|
-
delegate,
|
|
1068
|
-
active,
|
|
1069
|
-
updatedAt,
|
|
1070
|
-
bump,
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
function decodeCoveragePolicyAccount(address, data) {
|
|
1074
|
-
if (!hasDiscriminator(data, ACCOUNT_COVERAGE_POLICY)) {
|
|
1075
|
-
throw new Error('account discriminator mismatch for CoveragePolicy');
|
|
1076
|
-
}
|
|
1077
|
-
let offset = 8;
|
|
1078
|
-
const pool = pubkeyFromData(data, offset);
|
|
1079
|
-
offset += 32;
|
|
1080
|
-
const member = pubkeyFromData(data, offset);
|
|
1081
|
-
offset += 32;
|
|
1082
|
-
const termsHash = data.subarray(offset, offset + 32);
|
|
1083
|
-
offset += 32;
|
|
1084
|
-
const status = data.readUInt8(offset);
|
|
1085
|
-
offset += 1;
|
|
1086
|
-
const startsAt = Number(readI64Le(data, offset));
|
|
1087
|
-
offset += 8;
|
|
1088
|
-
const endsAt = Number(readI64Le(data, offset));
|
|
1089
|
-
offset += 8;
|
|
1090
|
-
const premiumDueEverySecs = Number(readI64Le(data, offset));
|
|
1091
|
-
offset += 8;
|
|
1092
|
-
const premiumGraceSecs = Number(readI64Le(data, offset));
|
|
1093
|
-
offset += 8;
|
|
1094
|
-
const nextDueAt = Number(readI64Le(data, offset));
|
|
1095
|
-
offset += 8;
|
|
1096
|
-
const nftMint = pubkeyFromData(data, offset);
|
|
1097
|
-
offset += 32;
|
|
1098
|
-
const bump = data.readUInt8(offset);
|
|
1099
|
-
return {
|
|
1100
|
-
address,
|
|
1101
|
-
pool,
|
|
1102
|
-
member,
|
|
1103
|
-
termsHashHex: toHex(termsHash),
|
|
1104
|
-
status,
|
|
1105
|
-
startsAt,
|
|
1106
|
-
endsAt,
|
|
1107
|
-
premiumDueEverySecs,
|
|
1108
|
-
premiumGraceSecs,
|
|
1109
|
-
nextDueAt,
|
|
1110
|
-
nftMint,
|
|
1111
|
-
bump,
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
function decodePremiumLedgerAccount(address, data) {
|
|
1115
|
-
if (!hasDiscriminator(data, ACCOUNT_PREMIUM_LEDGER)) {
|
|
1116
|
-
throw new Error('account discriminator mismatch for PremiumLedger');
|
|
1117
|
-
}
|
|
1118
|
-
let offset = 8;
|
|
1119
|
-
const pool = pubkeyFromData(data, offset);
|
|
1120
|
-
offset += 32;
|
|
1121
|
-
const member = pubkeyFromData(data, offset);
|
|
1122
|
-
offset += 32;
|
|
1123
|
-
const periodIndex = readU64Le(data, offset);
|
|
1124
|
-
offset += 8;
|
|
1125
|
-
const amount = readU64Le(data, offset);
|
|
1126
|
-
offset += 8;
|
|
1127
|
-
const source = data.readUInt8(offset);
|
|
1128
|
-
offset += 1;
|
|
1129
|
-
const paidAt = Number(readI64Le(data, offset));
|
|
1130
|
-
offset += 8;
|
|
1131
|
-
const bump = data.readUInt8(offset);
|
|
1132
|
-
return {
|
|
1133
|
-
address,
|
|
1134
|
-
pool,
|
|
1135
|
-
member,
|
|
1136
|
-
periodIndex,
|
|
1137
|
-
amount,
|
|
1138
|
-
source,
|
|
1139
|
-
paidAt,
|
|
1140
|
-
bump,
|
|
1141
|
-
};
|
|
1142
|
-
}
|
|
1143
|
-
function decodeClaimRecordV2Account(address, data) {
|
|
1144
|
-
if (!hasDiscriminator(data, ACCOUNT_CLAIM_RECORD_V2)) {
|
|
1145
|
-
throw new Error('account discriminator mismatch for ClaimRecordV2');
|
|
1146
|
-
}
|
|
1147
|
-
let offset = 8;
|
|
1148
|
-
const pool = pubkeyFromData(data, offset);
|
|
1149
|
-
offset += 32;
|
|
1150
|
-
const member = pubkeyFromData(data, offset);
|
|
1151
|
-
offset += 32;
|
|
1152
|
-
const claimant = pubkeyFromData(data, offset);
|
|
1153
|
-
offset += 32;
|
|
1154
|
-
const cycleHash = data.subarray(offset, offset + 32);
|
|
1155
|
-
offset += 32;
|
|
1156
|
-
const ruleHash = data.subarray(offset, offset + 32);
|
|
1157
|
-
offset += 32;
|
|
1158
|
-
const intentHash = data.subarray(offset, offset + 32);
|
|
1159
|
-
offset += 32;
|
|
1160
|
-
const payoutMint = pubkeyFromData(data, offset);
|
|
1161
|
-
offset += 32;
|
|
1162
|
-
const payoutAmount = readU64Le(data, offset);
|
|
1163
|
-
offset += 8;
|
|
1164
|
-
const recipient = pubkeyFromData(data, offset);
|
|
1165
|
-
offset += 32;
|
|
1166
|
-
const submittedAt = Number(readI64Le(data, offset));
|
|
1167
|
-
offset += 8;
|
|
1168
|
-
const bump = data.readUInt8(offset);
|
|
1169
|
-
return {
|
|
1170
|
-
address,
|
|
1171
|
-
pool,
|
|
1172
|
-
member,
|
|
1173
|
-
claimant,
|
|
1174
|
-
cycleHashHex: toHex(cycleHash),
|
|
1175
|
-
ruleHashHex: toHex(ruleHash),
|
|
1176
|
-
intentHashHex: toHex(intentHash),
|
|
1177
|
-
payoutMint,
|
|
1178
|
-
payoutAmount,
|
|
1179
|
-
recipient,
|
|
1180
|
-
submittedAt,
|
|
1181
|
-
bump,
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
function decodeCoverageProductAccount(address, data) {
|
|
1185
|
-
if (!hasDiscriminator(data, ACCOUNT_COVERAGE_PRODUCT)) {
|
|
1186
|
-
throw new Error('account discriminator mismatch for CoverageProduct');
|
|
1187
|
-
}
|
|
1188
|
-
let offset = 8;
|
|
1189
|
-
const pool = pubkeyFromData(data, offset);
|
|
1190
|
-
offset += 32;
|
|
1191
|
-
const admin = pubkeyFromData(data, offset);
|
|
1192
|
-
offset += 32;
|
|
1193
|
-
const productIdHash = data.subarray(offset, offset + 32);
|
|
1194
|
-
offset += 32;
|
|
1195
|
-
const active = data.readUInt8(offset) === 1;
|
|
1196
|
-
offset += 1;
|
|
1197
|
-
const displayName = readString(data, offset);
|
|
1198
|
-
offset = displayName.offset;
|
|
1199
|
-
const metadataUri = readString(data, offset);
|
|
1200
|
-
offset = metadataUri.offset;
|
|
1201
|
-
const termsHash = data.subarray(offset, offset + 32);
|
|
1202
|
-
offset += 32;
|
|
1203
|
-
const durationSecs = Number(readI64Le(data, offset));
|
|
1204
|
-
offset += 8;
|
|
1205
|
-
const premiumDueEverySecs = Number(readI64Le(data, offset));
|
|
1206
|
-
offset += 8;
|
|
1207
|
-
const premiumGraceSecs = Number(readI64Le(data, offset));
|
|
1208
|
-
offset += 8;
|
|
1209
|
-
const premiumAmount = readU64Le(data, offset);
|
|
1210
|
-
offset += 8;
|
|
1211
|
-
const createdAtTs = Number(readI64Le(data, offset));
|
|
1212
|
-
offset += 8;
|
|
1213
|
-
const updatedAtTs = Number(readI64Le(data, offset));
|
|
1214
|
-
offset += 8;
|
|
1215
|
-
const bump = data.readUInt8(offset);
|
|
1216
|
-
return {
|
|
1217
|
-
address,
|
|
1218
|
-
pool,
|
|
1219
|
-
admin,
|
|
1220
|
-
productIdHashHex: toHex(productIdHash),
|
|
1221
|
-
active,
|
|
1222
|
-
displayName: displayName.value,
|
|
1223
|
-
metadataUri: metadataUri.value,
|
|
1224
|
-
termsHashHex: toHex(termsHash),
|
|
1225
|
-
durationSecs,
|
|
1226
|
-
premiumDueEverySecs,
|
|
1227
|
-
premiumGraceSecs,
|
|
1228
|
-
premiumAmount,
|
|
1229
|
-
createdAtTs,
|
|
1230
|
-
updatedAtTs,
|
|
1231
|
-
bump,
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
function decodeCoverageProductPaymentOptionAccount(address, data) {
|
|
1235
|
-
if (!hasDiscriminator(data, ACCOUNT_COVERAGE_PRODUCT_PAYMENT_OPTION)) {
|
|
1236
|
-
throw new Error('account discriminator mismatch for CoverageProductPaymentOption');
|
|
1237
|
-
}
|
|
1238
|
-
let offset = 8;
|
|
1239
|
-
const pool = pubkeyFromData(data, offset);
|
|
1240
|
-
offset += 32;
|
|
1241
|
-
const productIdHash = data.subarray(offset, offset + 32);
|
|
1242
|
-
offset += 32;
|
|
1243
|
-
const paymentMint = pubkeyFromData(data, offset);
|
|
1244
|
-
offset += 32;
|
|
1245
|
-
const paymentAmount = readU64Le(data, offset);
|
|
1246
|
-
offset += 8;
|
|
1247
|
-
const active = data.readUInt8(offset) === 1;
|
|
1248
|
-
offset += 1;
|
|
1249
|
-
const bump = data.readUInt8(offset);
|
|
1250
|
-
return {
|
|
1251
|
-
address,
|
|
1252
|
-
pool,
|
|
1253
|
-
productIdHashHex: toHex(productIdHash),
|
|
1254
|
-
paymentMint,
|
|
1255
|
-
paymentAmount,
|
|
1256
|
-
active,
|
|
1257
|
-
bump,
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
function decodeCoveragePolicyPositionNftAccount(address, data) {
|
|
1261
|
-
if (!hasDiscriminator(data, ACCOUNT_COVERAGE_POLICY_POSITION_NFT)) {
|
|
1262
|
-
throw new Error('account discriminator mismatch for CoveragePolicyPositionNft');
|
|
1263
|
-
}
|
|
1264
|
-
let offset = 8;
|
|
1265
|
-
const pool = pubkeyFromData(data, offset);
|
|
1266
|
-
offset += 32;
|
|
1267
|
-
const member = pubkeyFromData(data, offset);
|
|
1268
|
-
offset += 32;
|
|
1269
|
-
const nftMint = pubkeyFromData(data, offset);
|
|
1270
|
-
offset += 32;
|
|
1271
|
-
const metadataUri = readString(data, offset);
|
|
1272
|
-
offset = metadataUri.offset;
|
|
1273
|
-
const bump = data.readUInt8(offset);
|
|
1274
|
-
return {
|
|
1275
|
-
address,
|
|
1276
|
-
pool,
|
|
1277
|
-
member,
|
|
1278
|
-
nftMint,
|
|
1279
|
-
metadataUri: metadataUri.value,
|
|
1280
|
-
bump,
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
function decodePremiumAttestationReplayAccount(address, data) {
|
|
1284
|
-
if (!hasDiscriminator(data, ACCOUNT_PREMIUM_ATTESTATION_REPLAY)) {
|
|
1285
|
-
throw new Error('account discriminator mismatch for PremiumAttestationReplay');
|
|
1286
|
-
}
|
|
1287
|
-
let offset = 8;
|
|
1288
|
-
const pool = pubkeyFromData(data, offset);
|
|
1289
|
-
offset += 32;
|
|
1290
|
-
const member = pubkeyFromData(data, offset);
|
|
1291
|
-
offset += 32;
|
|
1292
|
-
const periodIndex = readU64Le(data, offset);
|
|
1293
|
-
offset += 8;
|
|
1294
|
-
const replayHash = data.subarray(offset, offset + 32);
|
|
1295
|
-
offset += 32;
|
|
1296
|
-
const oracle = pubkeyFromData(data, offset);
|
|
1297
|
-
offset += 32;
|
|
1298
|
-
const createdAt = Number(readI64Le(data, offset));
|
|
1299
|
-
offset += 8;
|
|
1300
|
-
const bump = data.readUInt8(offset);
|
|
1301
|
-
return {
|
|
1302
|
-
address,
|
|
1303
|
-
pool,
|
|
1304
|
-
member,
|
|
1305
|
-
periodIndex,
|
|
1306
|
-
replayHashHex: toHex(replayHash),
|
|
1307
|
-
oracle,
|
|
1308
|
-
createdAt,
|
|
1309
|
-
bump,
|
|
1310
|
-
};
|
|
1311
|
-
}
|
|
1312
|
-
function decodeCoverageClaimRecordAccount(address, data) {
|
|
1313
|
-
if (!hasDiscriminator(data, ACCOUNT_COVERAGE_CLAIM_RECORD)) {
|
|
1314
|
-
throw new Error('account discriminator mismatch for CoverageClaimRecord');
|
|
1315
|
-
}
|
|
1316
|
-
let offset = 8;
|
|
1317
|
-
const pool = pubkeyFromData(data, offset);
|
|
1318
|
-
offset += 32;
|
|
1319
|
-
const member = pubkeyFromData(data, offset);
|
|
1320
|
-
offset += 32;
|
|
1321
|
-
const claimant = pubkeyFromData(data, offset);
|
|
1322
|
-
offset += 32;
|
|
1323
|
-
const intentHash = data.subarray(offset, offset + 32);
|
|
1324
|
-
offset += 32;
|
|
1325
|
-
const eventHash = data.subarray(offset, offset + 32);
|
|
1326
|
-
offset += 32;
|
|
1327
|
-
const status = data.readUInt8(offset);
|
|
1328
|
-
offset += 1;
|
|
1329
|
-
const submittedAt = Number(readI64Le(data, offset));
|
|
1330
|
-
offset += 8;
|
|
1331
|
-
const settledAt = Number(readI64Le(data, offset));
|
|
1332
|
-
offset += 8;
|
|
1333
|
-
const bump = data.readUInt8(offset);
|
|
1334
|
-
return {
|
|
1335
|
-
address,
|
|
1336
|
-
pool,
|
|
1337
|
-
member,
|
|
1338
|
-
claimant,
|
|
1339
|
-
intentHashHex: toHex(intentHash),
|
|
1340
|
-
eventHashHex: toHex(eventHash),
|
|
1341
|
-
status,
|
|
1342
|
-
submittedAt,
|
|
1343
|
-
settledAt,
|
|
1344
|
-
bump,
|
|
1345
|
-
};
|
|
1346
|
-
}
|
|
1347
|
-
function toUnixTimestamp(value) {
|
|
1348
|
-
const millis = new Date(value).getTime();
|
|
1349
|
-
if (!Number.isFinite(millis) || Number.isNaN(millis)) {
|
|
1350
|
-
throw new Error('invalid ISO timestamp');
|
|
1351
|
-
}
|
|
1352
|
-
return BigInt(Math.floor(millis / 1000));
|
|
1353
|
-
}
|
|
1354
|
-
function assertPoolIdSeedLength(poolId) {
|
|
1355
|
-
const length = Buffer.byteLength(poolId, 'utf8');
|
|
1356
|
-
if (length > MAX_POOL_ID_SEED_BYTES) {
|
|
1357
|
-
throw new Error(`poolId exceeds ${MAX_POOL_ID_SEED_BYTES} UTF-8 bytes`);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
function normalize32ByteHexOrHash(value, fallbackInput) {
|
|
1361
|
-
if (typeof value === 'string' && value.trim().length > 0) {
|
|
1362
|
-
return fromHex(value, 32);
|
|
1363
|
-
}
|
|
1364
|
-
return hashStringTo32(fallbackInput);
|
|
1365
|
-
}
|
|
1366
|
-
function encodeInitializeProtocolData(params) {
|
|
1367
|
-
if (!Number.isInteger(params.protocolFeeBps) || params.protocolFeeBps < 0 || params.protocolFeeBps > 10_000) {
|
|
1368
|
-
throw new Error('protocolFeeBps must be an integer between 0 and 10000');
|
|
1369
|
-
}
|
|
1370
|
-
return Buffer.concat([IX_INITIALIZE_PROTOCOL, encodeU16Le(params.protocolFeeBps)]);
|
|
1371
|
-
}
|
|
1372
|
-
function encodeSetProtocolPauseData(params) {
|
|
1373
|
-
return Buffer.concat([IX_SET_PROTOCOL_PAUSE, Buffer.from([params.paused ? 1 : 0])]);
|
|
1374
|
-
}
|
|
1375
|
-
function encodeCreatePoolData(params) {
|
|
1376
|
-
assertPoolIdSeedLength(params.poolId);
|
|
1377
|
-
const tokenGateMint = params.tokenGateMint ? asPubkey(params.tokenGateMint) : new PublicKey(ZERO_PUBKEY);
|
|
1378
|
-
const inviteIssuer = params.inviteIssuer ? asPubkey(params.inviteIssuer) : new PublicKey(ZERO_PUBKEY);
|
|
1379
|
-
return Buffer.concat([
|
|
1380
|
-
IX_CREATE_POOL,
|
|
1381
|
-
encodeString(params.poolId),
|
|
1382
|
-
encodeString(params.organizationRef),
|
|
1383
|
-
encodeU64Le(params.payoutLamportsPerPass),
|
|
1384
|
-
Buffer.from([params.membershipMode & 0xff]),
|
|
1385
|
-
tokenGateMint.toBuffer(),
|
|
1386
|
-
encodeU64Le(params.tokenGateMinBalance ?? 0n),
|
|
1387
|
-
inviteIssuer.toBuffer(),
|
|
1388
|
-
]);
|
|
1389
|
-
}
|
|
1390
|
-
function encodeSetPoolStatusData(params) {
|
|
1391
|
-
return Buffer.concat([IX_SET_POOL_STATUS, Buffer.from([params.status & 0xff])]);
|
|
1392
|
-
}
|
|
1393
|
-
function encodeSetCycleWindowData(params) {
|
|
1394
|
-
if (!Number.isFinite(params.claimOpenTs) || !Number.isFinite(params.claimCloseTs)) {
|
|
1395
|
-
throw new Error('claim window timestamps must be finite numbers');
|
|
1396
|
-
}
|
|
1397
|
-
const claimOpenTs = BigInt(Math.trunc(params.claimOpenTs));
|
|
1398
|
-
const claimCloseTs = BigInt(Math.trunc(params.claimCloseTs));
|
|
1399
|
-
if (claimCloseTs <= claimOpenTs) {
|
|
1400
|
-
throw new Error('claimCloseTs must be greater than claimOpenTs');
|
|
1401
|
-
}
|
|
1402
|
-
return Buffer.concat([
|
|
1403
|
-
IX_SET_CYCLE_WINDOW,
|
|
1404
|
-
Buffer.from(hashStringTo32(params.cycleId)),
|
|
1405
|
-
encodeI64Le(claimOpenTs),
|
|
1406
|
-
encodeI64Le(claimCloseTs),
|
|
1407
|
-
]);
|
|
1408
|
-
}
|
|
1409
|
-
function encodeFundPoolData(params) {
|
|
1410
|
-
return Buffer.concat([IX_FUND_POOL, encodeU64Le(params.lamports)]);
|
|
1411
|
-
}
|
|
1412
|
-
function encodeRegisterOracleData(params) {
|
|
1413
|
-
return Buffer.concat([IX_REGISTER_ORACLE, encodeString(params.metadataUri)]);
|
|
1414
|
-
}
|
|
1415
|
-
function encodeFixed32Vec(valuesHex) {
|
|
1416
|
-
const count = valuesHex.length >>> 0;
|
|
1417
|
-
if (count > MAX_ORACLE_SUPPORTED_SCHEMAS) {
|
|
1418
|
-
throw new Error(`supported schema key hashes cannot exceed ${MAX_ORACLE_SUPPORTED_SCHEMAS}`);
|
|
1419
|
-
}
|
|
1420
|
-
const encoded = [Buffer.alloc(4)];
|
|
1421
|
-
encoded[0].writeUInt32LE(count, 0);
|
|
1422
|
-
for (const value of valuesHex) {
|
|
1423
|
-
encoded.push(Buffer.from(fromHex(value, 32)));
|
|
1424
|
-
}
|
|
1425
|
-
return Buffer.concat(encoded);
|
|
1426
|
-
}
|
|
1427
|
-
function validateRewardClaimOptionalAccounts(params) {
|
|
1428
|
-
const providedCount = [
|
|
1429
|
-
params.poolAssetVault,
|
|
1430
|
-
params.poolVaultTokenAccount,
|
|
1431
|
-
params.recipientTokenAccount,
|
|
1432
|
-
].filter((value) => typeof value === 'string' && value.length > 0).length;
|
|
1433
|
-
if (providedCount !== 0 && providedCount !== 3) {
|
|
1434
|
-
throw new Error('poolAssetVault, poolVaultTokenAccount, and recipientTokenAccount must be provided together');
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
function encodeRegisterOracleV2Data(params) {
|
|
1438
|
-
return Buffer.concat([
|
|
1439
|
-
IX_REGISTER_ORACLE_V2,
|
|
1440
|
-
asPubkey(params.oraclePubkey).toBuffer(),
|
|
1441
|
-
Buffer.from([params.oracleType & 0xff]),
|
|
1442
|
-
encodeString(params.displayName),
|
|
1443
|
-
encodeString(params.legalName),
|
|
1444
|
-
encodeString(params.websiteUrl),
|
|
1445
|
-
encodeString(params.appUrl),
|
|
1446
|
-
encodeString(params.logoUri),
|
|
1447
|
-
encodeString(params.webhookUrl),
|
|
1448
|
-
encodeFixed32Vec(params.supportedSchemaKeyHashesHex),
|
|
1449
|
-
]);
|
|
1450
|
-
}
|
|
1451
|
-
function encodeUpdateOracleProfileV2Data(params) {
|
|
1452
|
-
return Buffer.concat([
|
|
1453
|
-
IX_UPDATE_ORACLE_PROFILE_V2,
|
|
1454
|
-
Buffer.from([params.oracleType & 0xff]),
|
|
1455
|
-
encodeString(params.displayName),
|
|
1456
|
-
encodeString(params.legalName),
|
|
1457
|
-
encodeString(params.websiteUrl),
|
|
1458
|
-
encodeString(params.appUrl),
|
|
1459
|
-
encodeString(params.logoUri),
|
|
1460
|
-
encodeString(params.webhookUrl),
|
|
1461
|
-
encodeFixed32Vec(params.supportedSchemaKeyHashesHex),
|
|
1462
|
-
]);
|
|
1463
|
-
}
|
|
1464
|
-
function encodeSetPoolOracleData(params) {
|
|
1465
|
-
return Buffer.concat([IX_SET_POOL_ORACLE, Buffer.from([params.active ? 1 : 0])]);
|
|
1466
|
-
}
|
|
1467
|
-
function encodeEnrollMemberData(params) {
|
|
1468
|
-
const subjectCommitment = normalize32ByteHexOrHash(params.subjectCommitmentHex, `subject:${params.member}`);
|
|
1469
|
-
const inviteCodeHash = params.inviteCodeHashHex
|
|
1470
|
-
? fromHex(params.inviteCodeHashHex, 32)
|
|
1471
|
-
: new Uint8Array(32);
|
|
1472
|
-
return Buffer.concat([
|
|
1473
|
-
IX_ENROLL_MEMBER,
|
|
1474
|
-
Buffer.from(subjectCommitment),
|
|
1475
|
-
Buffer.from(inviteCodeHash),
|
|
1476
|
-
]);
|
|
1477
|
-
}
|
|
1478
|
-
function encodeSubmitOutcomeAttestationData(params) {
|
|
1479
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
1480
|
-
const outcomeHash = hashStringTo32(params.outcomeId);
|
|
1481
|
-
const replayHash = hashStringTo32(params.replayKey);
|
|
1482
|
-
const digest = params.attestationDigestHex
|
|
1483
|
-
? Buffer.from(fromHex(params.attestationDigestHex, 32))
|
|
1484
|
-
: Buffer.from(hashStringTo32(`${params.cycleId}:${params.outcomeId}:${params.replayKey}`));
|
|
1485
|
-
if (digest.length !== 32) {
|
|
1486
|
-
throw new Error('attestation digest must be 32 bytes');
|
|
1487
|
-
}
|
|
1488
|
-
return Buffer.concat([
|
|
1489
|
-
IX_SUBMIT_OUTCOME_ATTESTATION,
|
|
1490
|
-
asPubkey(params.member).toBuffer(),
|
|
1491
|
-
Buffer.from(cycleHash),
|
|
1492
|
-
Buffer.from(outcomeHash),
|
|
1493
|
-
Buffer.from(replayHash),
|
|
1494
|
-
encodeI64Le(toUnixTimestamp(params.asOfIso)),
|
|
1495
|
-
Buffer.from([params.passed ? 1 : 0]),
|
|
1496
|
-
digest,
|
|
1497
|
-
]);
|
|
1498
|
-
}
|
|
1499
|
-
function encodeSubmitClaimData(params) {
|
|
1500
|
-
return Buffer.concat([
|
|
1501
|
-
IX_SUBMIT_CLAIM,
|
|
1502
|
-
Buffer.from(hashStringTo32(params.cycleId)),
|
|
1503
|
-
Buffer.from(hashStringTo32(params.intentId)),
|
|
1504
|
-
]);
|
|
1505
|
-
}
|
|
1506
|
-
function encodeSubmitOutcomeAttestationVoteData(params) {
|
|
1507
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
1508
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
1509
|
-
const digest = fromHex(params.attestationDigestHex, 32);
|
|
1510
|
-
const observedValueHash = fromHex(params.observedValueHashHex, 32);
|
|
1511
|
-
const asOfTs = BigInt(Math.trunc(params.asOfTs));
|
|
1512
|
-
return Buffer.concat([
|
|
1513
|
-
IX_SUBMIT_OUTCOME_ATTESTATION_VOTE,
|
|
1514
|
-
asPubkey(params.member).toBuffer(),
|
|
1515
|
-
Buffer.from(cycleHash),
|
|
1516
|
-
Buffer.from(ruleHash),
|
|
1517
|
-
Buffer.from(digest),
|
|
1518
|
-
Buffer.from(observedValueHash),
|
|
1519
|
-
encodeI64Le(asOfTs),
|
|
1520
|
-
Buffer.from([params.passed ? 1 : 0]),
|
|
1521
|
-
]);
|
|
1522
|
-
}
|
|
1523
|
-
function encodeInitializeProtocolV2Data(params) {
|
|
1524
|
-
if (!Number.isInteger(params.protocolFeeBps) || params.protocolFeeBps < 0 || params.protocolFeeBps > 10_000) {
|
|
1525
|
-
throw new Error('protocolFeeBps must be an integer between 0 and 10000');
|
|
1526
|
-
}
|
|
1527
|
-
return Buffer.concat([
|
|
1528
|
-
IX_INITIALIZE_PROTOCOL_V2,
|
|
1529
|
-
encodeU16Le(params.protocolFeeBps),
|
|
1530
|
-
asPubkey(params.governanceRealm).toBuffer(),
|
|
1531
|
-
asPubkey(params.governanceConfig).toBuffer(),
|
|
1532
|
-
asPubkey(params.defaultStakeMint).toBuffer(),
|
|
1533
|
-
encodeU64Le(params.minOracleStake),
|
|
1534
|
-
]);
|
|
1535
|
-
}
|
|
1536
|
-
function encodeSetProtocolParamsData(params) {
|
|
1537
|
-
if (!Number.isInteger(params.protocolFeeBps) || params.protocolFeeBps < 0 || params.protocolFeeBps > 10_000) {
|
|
1538
|
-
throw new Error('protocolFeeBps must be an integer between 0 and 10000');
|
|
1539
|
-
}
|
|
1540
|
-
return Buffer.concat([
|
|
1541
|
-
IX_SET_PROTOCOL_PARAMS,
|
|
1542
|
-
encodeU16Le(params.protocolFeeBps),
|
|
1543
|
-
Buffer.from(fromHex(params.allowedPayoutMintsHashHex, 32)),
|
|
1544
|
-
encodeU64Le(params.minOracleStake),
|
|
1545
|
-
Buffer.from([params.emergencyPaused ? 1 : 0]),
|
|
1546
|
-
]);
|
|
1547
|
-
}
|
|
1548
|
-
function encodeRotateGovernanceAuthorityData(params) {
|
|
1549
|
-
return Buffer.concat([
|
|
1550
|
-
IX_ROTATE_GOVERNANCE_AUTHORITY,
|
|
1551
|
-
asPubkey(params.newAuthority).toBuffer(),
|
|
1552
|
-
]);
|
|
1553
|
-
}
|
|
1554
|
-
function encodeUpdateOracleMetadataData(params) {
|
|
1555
|
-
return Buffer.concat([
|
|
1556
|
-
IX_UPDATE_ORACLE_METADATA,
|
|
1557
|
-
encodeString(params.metadataUri),
|
|
1558
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1559
|
-
]);
|
|
1560
|
-
}
|
|
1561
|
-
function encodeStakeOracleData(params) {
|
|
1562
|
-
return Buffer.concat([IX_STAKE_ORACLE, encodeU64Le(params.amount)]);
|
|
1563
|
-
}
|
|
1564
|
-
function encodeRequestUnstakeData(params) {
|
|
1565
|
-
return Buffer.concat([
|
|
1566
|
-
IX_REQUEST_UNSTAKE,
|
|
1567
|
-
encodeU64Le(params.amount),
|
|
1568
|
-
encodeI64Le(BigInt(Math.trunc(params.cooldownSeconds))),
|
|
1569
|
-
]);
|
|
1570
|
-
}
|
|
1571
|
-
function encodeSlashOracleData(params) {
|
|
1572
|
-
return Buffer.concat([IX_SLASH_ORACLE, encodeU64Le(params.amount)]);
|
|
1573
|
-
}
|
|
1574
|
-
function encodeCreatePoolV2Data(params) {
|
|
1575
|
-
assertPoolIdSeedLength(params.poolId);
|
|
1576
|
-
return Buffer.concat([
|
|
1577
|
-
IX_CREATE_POOL_V2,
|
|
1578
|
-
encodeString(params.poolId),
|
|
1579
|
-
encodeString(params.organizationRef),
|
|
1580
|
-
encodeU64Le(params.payoutLamportsPerPass),
|
|
1581
|
-
Buffer.from([params.membershipMode & 0xff]),
|
|
1582
|
-
asPubkey(params.tokenGateMint).toBuffer(),
|
|
1583
|
-
encodeU64Le(params.tokenGateMinBalance),
|
|
1584
|
-
asPubkey(params.inviteIssuer).toBuffer(),
|
|
1585
|
-
Buffer.from([params.poolType & 0xff]),
|
|
1586
|
-
asPubkey(params.payoutAssetMint).toBuffer(),
|
|
1587
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1588
|
-
Buffer.from(fromHex(params.payoutPolicyHashHex, 32)),
|
|
1589
|
-
Buffer.from([params.cycleMode & 0xff]),
|
|
1590
|
-
encodeString(params.metadataUri),
|
|
1591
|
-
]);
|
|
1592
|
-
}
|
|
1593
|
-
function encodeSetPoolOraclePolicyData(params) {
|
|
1594
|
-
return Buffer.concat([
|
|
1595
|
-
IX_SET_POOL_ORACLE_POLICY,
|
|
1596
|
-
Buffer.from([params.quorumM & 0xff]),
|
|
1597
|
-
Buffer.from([params.quorumN & 0xff]),
|
|
1598
|
-
Buffer.from([params.requireVerifiedSchema ? 1 : 0]),
|
|
1599
|
-
encodeU16Le(params.oracleFeeBps),
|
|
1600
|
-
Buffer.from([params.allowDelegateClaim ? 1 : 0]),
|
|
1601
|
-
]);
|
|
1602
|
-
}
|
|
1603
|
-
function encodeSetPoolOraclePermissionsData(params) {
|
|
1604
|
-
const permissions = params.permissions >>> 0;
|
|
1605
|
-
const out = Buffer.alloc(4);
|
|
1606
|
-
out.writeUInt32LE(permissions, 0);
|
|
1607
|
-
return Buffer.concat([IX_SET_POOL_ORACLE_PERMISSIONS, out]);
|
|
1608
|
-
}
|
|
1609
|
-
function encodeSetPoolCoverageReserveFloorData(params) {
|
|
1610
|
-
return Buffer.concat([
|
|
1611
|
-
IX_SET_POOL_COVERAGE_RESERVE_FLOOR,
|
|
1612
|
-
asPubkey(params.paymentMint).toBuffer(),
|
|
1613
|
-
encodeU64Le(params.amount),
|
|
1614
|
-
]);
|
|
1615
|
-
}
|
|
1616
|
-
function encodeWithdrawProtocolFeeSplData(params) {
|
|
1617
|
-
return Buffer.concat([IX_WITHDRAW_PROTOCOL_FEE_SPL, encodeU64Le(params.amount)]);
|
|
1618
|
-
}
|
|
1619
|
-
function encodeWithdrawProtocolFeeSolData(params) {
|
|
1620
|
-
return Buffer.concat([IX_WITHDRAW_PROTOCOL_FEE_SOL, encodeU64Le(params.amount)]);
|
|
1621
|
-
}
|
|
1622
|
-
function encodeWithdrawPoolOracleFeeSplData(params) {
|
|
1623
|
-
return Buffer.concat([IX_WITHDRAW_POOL_ORACLE_FEE_SPL, encodeU64Le(params.amount)]);
|
|
1624
|
-
}
|
|
1625
|
-
function encodeWithdrawPoolOracleFeeSolData(params) {
|
|
1626
|
-
return Buffer.concat([IX_WITHDRAW_POOL_ORACLE_FEE_SOL, encodeU64Le(params.amount)]);
|
|
1627
|
-
}
|
|
1628
|
-
function encodeSetPoolTermsHashData(params) {
|
|
1629
|
-
return Buffer.concat([
|
|
1630
|
-
IX_SET_POOL_TERMS_HASH,
|
|
1631
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1632
|
-
Buffer.from(fromHex(params.payoutPolicyHashHex, 32)),
|
|
1633
|
-
Buffer.from([params.cycleMode & 0xff]),
|
|
1634
|
-
encodeString(params.metadataUri),
|
|
1635
|
-
]);
|
|
1636
|
-
}
|
|
1637
|
-
function encodeRegisterOutcomeSchemaData(params) {
|
|
1638
|
-
return Buffer.concat([
|
|
1639
|
-
IX_REGISTER_OUTCOME_SCHEMA,
|
|
1640
|
-
Buffer.from(fromHex(params.schemaKeyHashHex, 32)),
|
|
1641
|
-
encodeString(params.schemaKey),
|
|
1642
|
-
encodeU16Le(params.version),
|
|
1643
|
-
Buffer.from(fromHex(params.schemaHashHex, 32)),
|
|
1644
|
-
encodeString(params.metadataUri),
|
|
1645
|
-
]);
|
|
1646
|
-
}
|
|
1647
|
-
function encodeVerifyOutcomeSchemaData(params) {
|
|
1648
|
-
return Buffer.concat([
|
|
1649
|
-
IX_VERIFY_OUTCOME_SCHEMA,
|
|
1650
|
-
Buffer.from([params.verified ? 1 : 0]),
|
|
1651
|
-
]);
|
|
1652
|
-
}
|
|
1653
|
-
function encodeSetPoolOutcomeRuleData(params) {
|
|
1654
|
-
return Buffer.concat([
|
|
1655
|
-
IX_SET_POOL_OUTCOME_RULE,
|
|
1656
|
-
Buffer.from(fromHex(params.ruleHashHex, 32)),
|
|
1657
|
-
Buffer.from(fromHex(params.schemaKeyHashHex, 32)),
|
|
1658
|
-
encodeString(params.ruleId),
|
|
1659
|
-
encodeString(params.schemaKey),
|
|
1660
|
-
encodeU16Le(params.schemaVersion),
|
|
1661
|
-
Buffer.from(fromHex(params.payoutHashHex, 32)),
|
|
1662
|
-
Buffer.from([params.enabled ? 1 : 0]),
|
|
1663
|
-
]);
|
|
1664
|
-
}
|
|
1665
|
-
function encodeRegisterInviteIssuerData(params) {
|
|
1666
|
-
return Buffer.concat([
|
|
1667
|
-
IX_REGISTER_INVITE_ISSUER,
|
|
1668
|
-
encodeString(params.organizationRef),
|
|
1669
|
-
encodeString(params.metadataUri),
|
|
1670
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1671
|
-
]);
|
|
1672
|
-
}
|
|
1673
|
-
function encodeEnrollMemberOpenData(params) {
|
|
1674
|
-
const subjectCommitment = normalize32ByteHexOrHash(params.subjectCommitmentHex, `subject:${params.member}`);
|
|
1675
|
-
return Buffer.concat([IX_ENROLL_MEMBER_OPEN, Buffer.from(subjectCommitment)]);
|
|
1676
|
-
}
|
|
1677
|
-
function encodeEnrollMemberTokenGateData(params) {
|
|
1678
|
-
const subjectCommitment = normalize32ByteHexOrHash(params.subjectCommitmentHex, `subject:${params.member}`);
|
|
1679
|
-
return Buffer.concat([IX_ENROLL_MEMBER_TOKEN_GATE, Buffer.from(subjectCommitment)]);
|
|
1680
|
-
}
|
|
1681
|
-
function encodeEnrollMemberInvitePermitData(params) {
|
|
1682
|
-
const subjectCommitment = normalize32ByteHexOrHash(params.subjectCommitmentHex, `subject:${params.member}`);
|
|
1683
|
-
return Buffer.concat([
|
|
1684
|
-
IX_ENROLL_MEMBER_INVITE_PERMIT,
|
|
1685
|
-
Buffer.from(subjectCommitment),
|
|
1686
|
-
Buffer.from(fromHex(params.nonceHashHex, 32)),
|
|
1687
|
-
Buffer.from(fromHex(params.inviteIdHashHex, 32)),
|
|
1688
|
-
encodeI64Le(BigInt(Math.trunc(params.expiresAtTs))),
|
|
1689
|
-
]);
|
|
1690
|
-
}
|
|
1691
|
-
function encodeSetClaimDelegateData(params) {
|
|
1692
|
-
return Buffer.concat([
|
|
1693
|
-
IX_SET_CLAIM_DELEGATE,
|
|
1694
|
-
asPubkey(params.delegate).toBuffer(),
|
|
1695
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1696
|
-
]);
|
|
1697
|
-
}
|
|
1698
|
-
function encodeFundPoolSolData(params) {
|
|
1699
|
-
return Buffer.concat([IX_FUND_POOL_SOL, encodeU64Le(params.lamports)]);
|
|
1700
|
-
}
|
|
1701
|
-
function encodeFundPoolSplData(params) {
|
|
1702
|
-
return Buffer.concat([IX_FUND_POOL_SPL, encodeU64Le(params.amount)]);
|
|
1703
|
-
}
|
|
1704
|
-
function encodeSubmitRewardClaimData(params) {
|
|
1705
|
-
return Buffer.concat([
|
|
1706
|
-
IX_SUBMIT_REWARD_CLAIM,
|
|
1707
|
-
asPubkey(params.member).toBuffer(),
|
|
1708
|
-
Buffer.from(hashStringTo32(params.cycleId)),
|
|
1709
|
-
Buffer.from(fromHex(params.ruleHashHex, 32)),
|
|
1710
|
-
Buffer.from(fromHex(params.intentHashHex, 32)),
|
|
1711
|
-
encodeU64Le(params.payoutAmount),
|
|
1712
|
-
asPubkey(params.recipient).toBuffer(),
|
|
1713
|
-
]);
|
|
1714
|
-
}
|
|
1715
|
-
function encodeRegisterCoverageProductV2Data(params) {
|
|
1716
|
-
return Buffer.concat([
|
|
1717
|
-
IX_REGISTER_COVERAGE_PRODUCT_V2,
|
|
1718
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
1719
|
-
encodeString(params.displayName),
|
|
1720
|
-
encodeString(params.metadataUri),
|
|
1721
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1722
|
-
encodeI64Le(BigInt(Math.trunc(params.durationSecs))),
|
|
1723
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumDueEverySecs))),
|
|
1724
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumGraceSecs))),
|
|
1725
|
-
encodeU64Le(params.premiumAmount),
|
|
1726
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1727
|
-
]);
|
|
1728
|
-
}
|
|
1729
|
-
function encodeUpsertCoverageProductPaymentOptionData(params) {
|
|
1730
|
-
return Buffer.concat([
|
|
1731
|
-
IX_UPSERT_COVERAGE_PRODUCT_PAYMENT_OPTION,
|
|
1732
|
-
asPubkey(params.paymentMint).toBuffer(),
|
|
1733
|
-
encodeU64Le(params.paymentAmount),
|
|
1734
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1735
|
-
]);
|
|
1736
|
-
}
|
|
1737
|
-
function encodeUpdateCoverageProductV2Data(params) {
|
|
1738
|
-
return Buffer.concat([
|
|
1739
|
-
IX_UPDATE_COVERAGE_PRODUCT_V2,
|
|
1740
|
-
encodeString(params.displayName),
|
|
1741
|
-
encodeString(params.metadataUri),
|
|
1742
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1743
|
-
encodeI64Le(BigInt(Math.trunc(params.durationSecs))),
|
|
1744
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumDueEverySecs))),
|
|
1745
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumGraceSecs))),
|
|
1746
|
-
encodeU64Le(params.premiumAmount),
|
|
1747
|
-
Buffer.from([params.active ? 1 : 0]),
|
|
1748
|
-
]);
|
|
1749
|
-
}
|
|
1750
|
-
function encodeSubscribeCoverageProductV2Data(params) {
|
|
1751
|
-
return Buffer.concat([
|
|
1752
|
-
IX_SUBSCRIBE_COVERAGE_PRODUCT_V2,
|
|
1753
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
1754
|
-
encodeI64Le(BigInt(Math.trunc(params.startsAt))),
|
|
1755
|
-
]);
|
|
1756
|
-
}
|
|
1757
|
-
function encodeIssueCoveragePolicyFromProductV2Data(params) {
|
|
1758
|
-
return Buffer.concat([
|
|
1759
|
-
IX_ISSUE_COVERAGE_POLICY_FROM_PRODUCT_V2,
|
|
1760
|
-
asPubkey(params.member).toBuffer(),
|
|
1761
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
1762
|
-
encodeI64Le(BigInt(Math.trunc(params.startsAt))),
|
|
1763
|
-
]);
|
|
1764
|
-
}
|
|
1765
|
-
function encodeCreateCoveragePolicyData(params) {
|
|
1766
|
-
return Buffer.concat([
|
|
1767
|
-
IX_CREATE_COVERAGE_POLICY,
|
|
1768
|
-
asPubkey(params.member).toBuffer(),
|
|
1769
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1770
|
-
encodeI64Le(BigInt(Math.trunc(params.startsAt))),
|
|
1771
|
-
encodeI64Le(BigInt(Math.trunc(params.endsAt))),
|
|
1772
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumDueEverySecs))),
|
|
1773
|
-
encodeI64Le(BigInt(Math.trunc(params.premiumGraceSecs))),
|
|
1774
|
-
]);
|
|
1775
|
-
}
|
|
1776
|
-
function encodeMintPolicyNftData(params) {
|
|
1777
|
-
return Buffer.concat([
|
|
1778
|
-
IX_MINT_POLICY_NFT,
|
|
1779
|
-
asPubkey(params.nftMint).toBuffer(),
|
|
1780
|
-
encodeString(params.metadataUri),
|
|
1781
|
-
]);
|
|
1782
|
-
}
|
|
1783
|
-
function encodePayPremiumOnchainData(params) {
|
|
1784
|
-
return Buffer.concat([
|
|
1785
|
-
IX_PAY_PREMIUM_ONCHAIN,
|
|
1786
|
-
encodeU64Le(params.periodIndex),
|
|
1787
|
-
encodeU64Le(params.amount),
|
|
1788
|
-
]);
|
|
1789
|
-
}
|
|
1790
|
-
function encodeAttestPremiumPaidOffchainData(params) {
|
|
1791
|
-
return Buffer.concat([
|
|
1792
|
-
IX_ATTEST_PREMIUM_PAID_OFFCHAIN,
|
|
1793
|
-
asPubkey(params.member).toBuffer(),
|
|
1794
|
-
encodeU64Le(params.periodIndex),
|
|
1795
|
-
Buffer.from(fromHex(params.replayHashHex, 32)),
|
|
1796
|
-
encodeU64Le(params.amount),
|
|
1797
|
-
encodeI64Le(BigInt(Math.trunc(params.paidAtTs))),
|
|
1798
|
-
]);
|
|
1799
|
-
}
|
|
1800
|
-
function encodeSubmitCoverageClaimData(params) {
|
|
1801
|
-
return Buffer.concat([
|
|
1802
|
-
IX_SUBMIT_COVERAGE_CLAIM,
|
|
1803
|
-
asPubkey(params.member).toBuffer(),
|
|
1804
|
-
Buffer.from(fromHex(params.intentHashHex, 32)),
|
|
1805
|
-
Buffer.from(fromHex(params.eventHashHex, 32)),
|
|
1806
|
-
]);
|
|
1807
|
-
}
|
|
1808
|
-
function encodeSettleCoverageClaimData(params) {
|
|
1809
|
-
return Buffer.concat([
|
|
1810
|
-
IX_SETTLE_COVERAGE_CLAIM,
|
|
1811
|
-
encodeU64Le(params.payoutAmount),
|
|
1812
|
-
]);
|
|
1813
|
-
}
|
|
1814
|
-
function encodeMigratePoolV1ToV2Data(params) {
|
|
1815
|
-
return Buffer.concat([
|
|
1816
|
-
IX_MIGRATE_POOL_V1_TO_V2,
|
|
1817
|
-
Buffer.from([params.poolType & 0xff]),
|
|
1818
|
-
asPubkey(params.payoutAssetMint).toBuffer(),
|
|
1819
|
-
Buffer.from(fromHex(params.termsHashHex, 32)),
|
|
1820
|
-
Buffer.from(fromHex(params.payoutPolicyHashHex, 32)),
|
|
1821
|
-
Buffer.from([params.cycleMode & 0xff]),
|
|
1822
|
-
encodeString(params.metadataUri),
|
|
1823
|
-
]);
|
|
1824
|
-
}
|
|
1825
|
-
function buildActivateCycleWithQuoteSolTransaction(params) {
|
|
1826
|
-
const programId = asPubkey(params.programId);
|
|
1827
|
-
const payer = asPubkey(params.payer);
|
|
1828
|
-
const member = asPubkey(params.member);
|
|
1829
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
1830
|
-
const oracle = asPubkey(params.oracle);
|
|
1831
|
-
const zeroPubkey = asPubkey(ZERO_PUBKEY);
|
|
1832
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
1833
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
1834
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
1835
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
1836
|
-
programId,
|
|
1837
|
-
poolAddress,
|
|
1838
|
-
oracle,
|
|
1839
|
-
});
|
|
1840
|
-
const [oraclePolicy] = derivePoolOraclePolicyPda({
|
|
1841
|
-
programId,
|
|
1842
|
-
poolAddress,
|
|
1843
|
-
});
|
|
1844
|
-
const [membership] = deriveMembershipPda({ programId, poolAddress, member });
|
|
1845
|
-
const [coverageProduct] = deriveCoverageProductPda({
|
|
1846
|
-
programId,
|
|
1847
|
-
poolAddress,
|
|
1848
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
1849
|
-
});
|
|
1850
|
-
const [coverageProductPaymentOption] = deriveCoverageProductPaymentOptionPda({
|
|
1851
|
-
programId,
|
|
1852
|
-
poolAddress,
|
|
1853
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
1854
|
-
paymentMint: zeroPubkey,
|
|
1855
|
-
});
|
|
1856
|
-
const [coveragePolicy] = deriveCoveragePolicyPda({ programId, poolAddress, member });
|
|
1857
|
-
const [coveragePolicyNft] = deriveCoverageNftPda({ programId, poolAddress, member });
|
|
1858
|
-
const [premiumLedger] = derivePremiumLedgerPda({ programId, poolAddress, member });
|
|
1859
|
-
const [protocolFeeVault] = deriveProtocolFeeVaultPda({
|
|
1860
|
-
programId,
|
|
1861
|
-
paymentMint: zeroPubkey,
|
|
1862
|
-
});
|
|
1863
|
-
const [poolOracleFeeVault] = derivePoolOracleFeeVaultPda({
|
|
1864
|
-
programId,
|
|
1865
|
-
poolAddress,
|
|
1866
|
-
oracle,
|
|
1867
|
-
paymentMint: zeroPubkey,
|
|
1868
|
-
});
|
|
1869
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
1870
|
-
programId,
|
|
1871
|
-
poolAddress,
|
|
1872
|
-
paymentMint: zeroPubkey,
|
|
1873
|
-
});
|
|
1874
|
-
const [memberCycle] = deriveMemberCyclePda({
|
|
1875
|
-
programId,
|
|
1876
|
-
poolAddress,
|
|
1877
|
-
member,
|
|
1878
|
-
periodIndex: params.periodIndex,
|
|
1879
|
-
});
|
|
1880
|
-
const [cycleQuoteReplay] = deriveCycleQuoteReplayPda({
|
|
1881
|
-
programId,
|
|
1882
|
-
poolAddress,
|
|
1883
|
-
member,
|
|
1884
|
-
nonceHash: fromHex(params.nonceHashHex, 32),
|
|
1885
|
-
});
|
|
1886
|
-
const ed25519Instruction = Ed25519Program.createInstructionWithPrivateKey({
|
|
1887
|
-
privateKey: params.oracleSecretKey,
|
|
1888
|
-
message: buildCycleQuoteSignatureMessage(params.quoteMessage),
|
|
1889
|
-
});
|
|
1890
|
-
const instruction = new TransactionInstruction({
|
|
1891
|
-
programId,
|
|
1892
|
-
keys: [
|
|
1893
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
1894
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
1895
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
1896
|
-
{ pubkey: member, isSigner: false, isWritable: false },
|
|
1897
|
-
{ pubkey: oracle, isSigner: false, isWritable: false },
|
|
1898
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
1899
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
1900
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
1901
|
-
{ pubkey: oraclePolicy, isSigner: false, isWritable: false },
|
|
1902
|
-
{ pubkey: membership, isSigner: false, isWritable: true },
|
|
1903
|
-
{ pubkey: coverageProduct, isSigner: false, isWritable: false },
|
|
1904
|
-
{ pubkey: coverageProductPaymentOption, isSigner: false, isWritable: false },
|
|
1905
|
-
{ pubkey: coveragePolicy, isSigner: false, isWritable: true },
|
|
1906
|
-
{ pubkey: coveragePolicyNft, isSigner: false, isWritable: true },
|
|
1907
|
-
{ pubkey: premiumLedger, isSigner: false, isWritable: true },
|
|
1908
|
-
{ pubkey: protocolFeeVault, isSigner: false, isWritable: true },
|
|
1909
|
-
{ pubkey: poolOracleFeeVault, isSigner: false, isWritable: true },
|
|
1910
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
1911
|
-
{ pubkey: memberCycle, isSigner: false, isWritable: true },
|
|
1912
|
-
{ pubkey: cycleQuoteReplay, isSigner: false, isWritable: true },
|
|
1913
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
1914
|
-
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false },
|
|
1915
|
-
],
|
|
1916
|
-
data: Buffer.concat([
|
|
1917
|
-
IX_ACTIVATE_CYCLE_WITH_QUOTE_SOL,
|
|
1918
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
1919
|
-
encodeU64Le(params.periodIndex),
|
|
1920
|
-
Buffer.from(fromHex(params.nonceHashHex, 32)),
|
|
1921
|
-
encodeU64Le(params.premiumAmountRaw),
|
|
1922
|
-
encodeU64Le(params.canonicalPremiumAmount),
|
|
1923
|
-
Buffer.from([params.commitmentEnabled ? 1 : 0]),
|
|
1924
|
-
encodeU64Le(params.bondAmountRaw),
|
|
1925
|
-
encodeU64Le(params.shieldFeeRaw),
|
|
1926
|
-
encodeU64Le(params.protocolFeeRaw),
|
|
1927
|
-
encodeU64Le(params.oracleFeeRaw),
|
|
1928
|
-
encodeU64Le(params.netPoolPremiumRaw),
|
|
1929
|
-
encodeU64Le(params.totalAmountRaw),
|
|
1930
|
-
Buffer.from([params.includedShieldCount]),
|
|
1931
|
-
encodeU16Le(params.thresholdBps),
|
|
1932
|
-
encodeI64Le(params.expiresAtTs),
|
|
1933
|
-
Buffer.from(fromHex(params.quoteMetaHashHex, 32)),
|
|
1934
|
-
]),
|
|
1935
|
-
});
|
|
1936
|
-
const transaction = new Transaction({
|
|
1937
|
-
feePayer: payer,
|
|
1938
|
-
recentBlockhash: params.recentBlockhash,
|
|
1939
|
-
});
|
|
1940
|
-
if (typeof params.computeUnitLimit === 'number') {
|
|
1941
|
-
transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
|
|
1942
|
-
units: params.computeUnitLimit,
|
|
1943
|
-
}));
|
|
1944
|
-
}
|
|
1945
|
-
return transaction.add(ed25519Instruction, instruction);
|
|
1946
|
-
}
|
|
1947
|
-
function buildActivateCycleWithQuoteSplTransaction(params) {
|
|
1948
|
-
const programId = asPubkey(params.programId);
|
|
1949
|
-
const payer = asPubkey(params.payer);
|
|
1950
|
-
const member = asPubkey(params.member);
|
|
1951
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
1952
|
-
const oracle = asPubkey(params.oracle);
|
|
1953
|
-
const paymentMint = asPubkey(params.paymentMint);
|
|
1954
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
1955
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
1956
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
1957
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
1958
|
-
programId,
|
|
1959
|
-
poolAddress,
|
|
1960
|
-
oracle,
|
|
1961
|
-
});
|
|
1962
|
-
const [oraclePolicy] = derivePoolOraclePolicyPda({
|
|
1963
|
-
programId,
|
|
1964
|
-
poolAddress,
|
|
1965
|
-
});
|
|
1966
|
-
const [membership] = deriveMembershipPda({ programId, poolAddress, member });
|
|
1967
|
-
const [coverageProduct] = deriveCoverageProductPda({
|
|
1968
|
-
programId,
|
|
1969
|
-
poolAddress,
|
|
1970
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
1971
|
-
});
|
|
1972
|
-
const [coverageProductPaymentOption] = deriveCoverageProductPaymentOptionPda({
|
|
1973
|
-
programId,
|
|
1974
|
-
poolAddress,
|
|
1975
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
1976
|
-
paymentMint,
|
|
1977
|
-
});
|
|
1978
|
-
const [coveragePolicy] = deriveCoveragePolicyPda({ programId, poolAddress, member });
|
|
1979
|
-
const [coveragePolicyNft] = deriveCoverageNftPda({ programId, poolAddress, member });
|
|
1980
|
-
const [premiumLedger] = derivePremiumLedgerPda({ programId, poolAddress, member });
|
|
1981
|
-
const [poolAssetVault] = derivePoolAssetVaultPda({
|
|
1982
|
-
programId,
|
|
1983
|
-
poolAddress,
|
|
1984
|
-
payoutMint: paymentMint,
|
|
1985
|
-
});
|
|
1986
|
-
const poolVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
1987
|
-
owner: poolAssetVault,
|
|
1988
|
-
mint: paymentMint,
|
|
1989
|
-
});
|
|
1990
|
-
const payerTokenAccount = deriveAssociatedTokenAddress({
|
|
1991
|
-
owner: payer,
|
|
1992
|
-
mint: paymentMint,
|
|
1993
|
-
});
|
|
1994
|
-
const [protocolFeeVault] = deriveProtocolFeeVaultPda({
|
|
1995
|
-
programId,
|
|
1996
|
-
paymentMint,
|
|
1997
|
-
});
|
|
1998
|
-
const protocolFeeVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
1999
|
-
owner: protocolFeeVault,
|
|
2000
|
-
mint: paymentMint,
|
|
2001
|
-
allowOwnerOffCurve: true,
|
|
2002
|
-
});
|
|
2003
|
-
const [poolOracleFeeVault] = derivePoolOracleFeeVaultPda({
|
|
2004
|
-
programId,
|
|
2005
|
-
poolAddress,
|
|
2006
|
-
oracle,
|
|
2007
|
-
paymentMint,
|
|
2008
|
-
});
|
|
2009
|
-
const poolOracleFeeVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
2010
|
-
owner: poolOracleFeeVault,
|
|
2011
|
-
mint: paymentMint,
|
|
2012
|
-
allowOwnerOffCurve: true,
|
|
2013
|
-
});
|
|
2014
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
2015
|
-
programId,
|
|
2016
|
-
poolAddress,
|
|
2017
|
-
paymentMint,
|
|
2018
|
-
});
|
|
2019
|
-
const [memberCycle] = deriveMemberCyclePda({
|
|
2020
|
-
programId,
|
|
2021
|
-
poolAddress,
|
|
2022
|
-
member,
|
|
2023
|
-
periodIndex: params.periodIndex,
|
|
2024
|
-
});
|
|
2025
|
-
const [cycleQuoteReplay] = deriveCycleQuoteReplayPda({
|
|
2026
|
-
programId,
|
|
2027
|
-
poolAddress,
|
|
2028
|
-
member,
|
|
2029
|
-
nonceHash: fromHex(params.nonceHashHex, 32),
|
|
2030
|
-
});
|
|
2031
|
-
const ed25519Instruction = Ed25519Program.createInstructionWithPrivateKey({
|
|
2032
|
-
privateKey: params.oracleSecretKey,
|
|
2033
|
-
message: buildCycleQuoteSignatureMessage(params.quoteMessage),
|
|
2034
|
-
});
|
|
2035
|
-
const instruction = new TransactionInstruction({
|
|
2036
|
-
programId,
|
|
2037
|
-
keys: [
|
|
2038
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
2039
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2040
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2041
|
-
{ pubkey: member, isSigner: false, isWritable: false },
|
|
2042
|
-
{ pubkey: oracle, isSigner: false, isWritable: false },
|
|
2043
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2044
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
2045
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2046
|
-
{ pubkey: oraclePolicy, isSigner: false, isWritable: false },
|
|
2047
|
-
{ pubkey: membership, isSigner: false, isWritable: true },
|
|
2048
|
-
{ pubkey: coverageProduct, isSigner: false, isWritable: false },
|
|
2049
|
-
{ pubkey: coverageProductPaymentOption, isSigner: false, isWritable: false },
|
|
2050
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: true },
|
|
2051
|
-
{ pubkey: coveragePolicy, isSigner: false, isWritable: true },
|
|
2052
|
-
{ pubkey: coveragePolicyNft, isSigner: false, isWritable: true },
|
|
2053
|
-
{ pubkey: premiumLedger, isSigner: false, isWritable: true },
|
|
2054
|
-
{ pubkey: poolAssetVault, isSigner: false, isWritable: true },
|
|
2055
|
-
{ pubkey: poolVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2056
|
-
{ pubkey: payerTokenAccount, isSigner: false, isWritable: true },
|
|
2057
|
-
{ pubkey: protocolFeeVault, isSigner: false, isWritable: true },
|
|
2058
|
-
{ pubkey: protocolFeeVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2059
|
-
{ pubkey: poolOracleFeeVault, isSigner: false, isWritable: true },
|
|
2060
|
-
{ pubkey: poolOracleFeeVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2061
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
2062
|
-
{ pubkey: memberCycle, isSigner: false, isWritable: true },
|
|
2063
|
-
{ pubkey: cycleQuoteReplay, isSigner: false, isWritable: true },
|
|
2064
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2065
|
-
{ pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2066
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2067
|
-
{ pubkey: SYSVAR_INSTRUCTIONS_PUBKEY, isSigner: false, isWritable: false },
|
|
2068
|
-
],
|
|
2069
|
-
data: Buffer.concat([
|
|
2070
|
-
IX_ACTIVATE_CYCLE_WITH_QUOTE_SPL,
|
|
2071
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
2072
|
-
encodeU64Le(params.periodIndex),
|
|
2073
|
-
Buffer.from(fromHex(params.nonceHashHex, 32)),
|
|
2074
|
-
encodeU64Le(params.premiumAmountRaw),
|
|
2075
|
-
encodeU64Le(params.canonicalPremiumAmount),
|
|
2076
|
-
Buffer.from([params.commitmentEnabled ? 1 : 0]),
|
|
2077
|
-
encodeU64Le(params.bondAmountRaw),
|
|
2078
|
-
encodeU64Le(params.shieldFeeRaw),
|
|
2079
|
-
encodeU64Le(params.protocolFeeRaw),
|
|
2080
|
-
encodeU64Le(params.oracleFeeRaw),
|
|
2081
|
-
encodeU64Le(params.netPoolPremiumRaw),
|
|
2082
|
-
encodeU64Le(params.totalAmountRaw),
|
|
2083
|
-
Buffer.from([params.includedShieldCount]),
|
|
2084
|
-
encodeU16Le(params.thresholdBps),
|
|
2085
|
-
encodeI64Le(params.expiresAtTs),
|
|
2086
|
-
Buffer.from(fromHex(params.quoteMetaHashHex, 32)),
|
|
2087
|
-
]),
|
|
2088
|
-
});
|
|
2089
|
-
return new Transaction({
|
|
2090
|
-
feePayer: payer,
|
|
2091
|
-
recentBlockhash: params.recentBlockhash,
|
|
2092
|
-
}).add(ComputeBudgetProgram.setComputeUnitLimit({
|
|
2093
|
-
units: params.computeUnitLimit ?? 400_000,
|
|
2094
|
-
}), ed25519Instruction, instruction);
|
|
2095
|
-
}
|
|
2096
|
-
function buildSettleCycleCommitmentTransaction(params) {
|
|
2097
|
-
const programId = asPubkey(params.programId);
|
|
2098
|
-
const payer = asPubkey(params.payer);
|
|
2099
|
-
const oracle = asPubkey(params.oracle);
|
|
2100
|
-
const member = asPubkey(params.member);
|
|
2101
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2102
|
-
const paymentMint = asPubkey(params.paymentMint);
|
|
2103
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2104
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2105
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
2106
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2107
|
-
programId,
|
|
2108
|
-
poolAddress,
|
|
2109
|
-
oracle,
|
|
2110
|
-
});
|
|
2111
|
-
const [poolAssetVault] = derivePoolAssetVaultPda({
|
|
2112
|
-
programId,
|
|
2113
|
-
poolAddress,
|
|
2114
|
-
payoutMint: paymentMint,
|
|
2115
|
-
});
|
|
2116
|
-
const poolVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
2117
|
-
owner: poolAssetVault,
|
|
2118
|
-
mint: paymentMint,
|
|
2119
|
-
});
|
|
2120
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
2121
|
-
programId,
|
|
2122
|
-
poolAddress,
|
|
2123
|
-
paymentMint,
|
|
2124
|
-
});
|
|
2125
|
-
const [memberCycle] = deriveMemberCyclePda({
|
|
2126
|
-
programId,
|
|
2127
|
-
poolAddress,
|
|
2128
|
-
member,
|
|
2129
|
-
periodIndex: params.periodIndex,
|
|
2130
|
-
});
|
|
2131
|
-
const recipientTokenAccount = deriveAssociatedTokenAddress({
|
|
2132
|
-
owner: member,
|
|
2133
|
-
mint: paymentMint,
|
|
2134
|
-
});
|
|
2135
|
-
const instruction = new TransactionInstruction({
|
|
2136
|
-
programId,
|
|
2137
|
-
keys: [
|
|
2138
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2139
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2140
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2141
|
-
{ pubkey: member, isSigner: false, isWritable: false },
|
|
2142
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2143
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
2144
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2145
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: true },
|
|
2146
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
2147
|
-
{ pubkey: poolAssetVault, isSigner: false, isWritable: false },
|
|
2148
|
-
{ pubkey: poolVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2149
|
-
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
|
|
2150
|
-
{ pubkey: memberCycle, isSigner: false, isWritable: true },
|
|
2151
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2152
|
-
],
|
|
2153
|
-
data: Buffer.concat([
|
|
2154
|
-
IX_SETTLE_CYCLE_COMMITMENT,
|
|
2155
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
2156
|
-
encodeU64Le(params.periodIndex),
|
|
2157
|
-
Buffer.from([params.passed ? 1 : 0]),
|
|
2158
|
-
Buffer.from([params.shieldConsumed ? 1 : 0]),
|
|
2159
|
-
]),
|
|
2160
|
-
});
|
|
2161
|
-
return new Transaction({
|
|
2162
|
-
feePayer: payer,
|
|
2163
|
-
recentBlockhash: params.recentBlockhash,
|
|
2164
|
-
}).add(instruction);
|
|
2165
|
-
}
|
|
2166
|
-
function buildSettleCycleCommitmentSolTransaction(params) {
|
|
2167
|
-
const programId = asPubkey(params.programId);
|
|
2168
|
-
const payer = asPubkey(params.payer);
|
|
2169
|
-
const oracle = asPubkey(params.oracle);
|
|
2170
|
-
const member = asPubkey(params.member);
|
|
2171
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2172
|
-
const zeroPubkey = asPubkey(ZERO_PUBKEY);
|
|
2173
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2174
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2175
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
2176
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2177
|
-
programId,
|
|
2178
|
-
poolAddress,
|
|
2179
|
-
oracle,
|
|
2180
|
-
});
|
|
2181
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
2182
|
-
programId,
|
|
2183
|
-
poolAddress,
|
|
2184
|
-
paymentMint: zeroPubkey,
|
|
2185
|
-
});
|
|
2186
|
-
const [memberCycle] = deriveMemberCyclePda({
|
|
2187
|
-
programId,
|
|
2188
|
-
poolAddress,
|
|
2189
|
-
member,
|
|
2190
|
-
periodIndex: params.periodIndex,
|
|
2191
|
-
});
|
|
2192
|
-
const instruction = new TransactionInstruction({
|
|
2193
|
-
programId,
|
|
2194
|
-
keys: [
|
|
2195
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2196
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2197
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2198
|
-
{ pubkey: member, isSigner: false, isWritable: false },
|
|
2199
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2200
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
2201
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2202
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
2203
|
-
{ pubkey: member, isSigner: false, isWritable: true },
|
|
2204
|
-
{ pubkey: memberCycle, isSigner: false, isWritable: true },
|
|
2205
|
-
],
|
|
2206
|
-
data: Buffer.concat([
|
|
2207
|
-
IX_SETTLE_CYCLE_COMMITMENT_SOL,
|
|
2208
|
-
Buffer.from(fromHex(params.productIdHashHex, 32)),
|
|
2209
|
-
encodeU64Le(params.periodIndex),
|
|
2210
|
-
Buffer.from([params.passed ? 1 : 0]),
|
|
2211
|
-
Buffer.from([params.shieldConsumed ? 1 : 0]),
|
|
2212
|
-
]),
|
|
2213
|
-
});
|
|
2214
|
-
return new Transaction({
|
|
2215
|
-
feePayer: payer,
|
|
2216
|
-
recentBlockhash: params.recentBlockhash,
|
|
2217
|
-
}).add(instruction);
|
|
2218
|
-
}
|
|
2219
|
-
function buildWithdrawPoolTreasurySplTransaction(params) {
|
|
2220
|
-
const programId = asPubkey(params.programId);
|
|
2221
|
-
const payer = asPubkey(params.payer);
|
|
2222
|
-
const oracle = asPubkey(params.oracle);
|
|
2223
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2224
|
-
const paymentMint = asPubkey(params.paymentMint);
|
|
2225
|
-
const recipientTokenAccount = asPubkey(params.recipientTokenAccount);
|
|
2226
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2227
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2228
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
2229
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2230
|
-
programId,
|
|
2231
|
-
poolAddress,
|
|
2232
|
-
oracle,
|
|
2233
|
-
});
|
|
2234
|
-
const [poolAssetVault] = derivePoolAssetVaultPda({
|
|
2235
|
-
programId,
|
|
2236
|
-
poolAddress,
|
|
2237
|
-
payoutMint: paymentMint,
|
|
2238
|
-
});
|
|
2239
|
-
const poolVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
2240
|
-
owner: poolAssetVault,
|
|
2241
|
-
mint: paymentMint,
|
|
2242
|
-
});
|
|
2243
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
2244
|
-
programId,
|
|
2245
|
-
poolAddress,
|
|
2246
|
-
paymentMint,
|
|
2247
|
-
});
|
|
2248
|
-
const instruction = new TransactionInstruction({
|
|
2249
|
-
programId,
|
|
2250
|
-
keys: [
|
|
2251
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2252
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2253
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2254
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2255
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
2256
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2257
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: true },
|
|
2258
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
2259
|
-
{ pubkey: poolAssetVault, isSigner: false, isWritable: false },
|
|
2260
|
-
{ pubkey: poolVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2261
|
-
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
|
|
2262
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2263
|
-
],
|
|
2264
|
-
data: Buffer.concat([IX_WITHDRAW_POOL_TREASURY_SPL, encodeU64Le(params.amount)]),
|
|
2265
|
-
});
|
|
2266
|
-
return new Transaction({
|
|
2267
|
-
feePayer: payer,
|
|
2268
|
-
recentBlockhash: params.recentBlockhash,
|
|
2269
|
-
}).add(instruction);
|
|
2270
|
-
}
|
|
2271
|
-
function buildWithdrawPoolTreasurySolTransaction(params) {
|
|
2272
|
-
const programId = asPubkey(params.programId);
|
|
2273
|
-
const payer = asPubkey(params.payer);
|
|
2274
|
-
const oracle = asPubkey(params.oracle);
|
|
2275
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2276
|
-
const recipientSystemAccount = asPubkey(params.recipientSystemAccount);
|
|
2277
|
-
const zeroPubkey = asPubkey(ZERO_PUBKEY);
|
|
2278
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2279
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2280
|
-
const [poolOracle] = derivePoolOraclePda({ programId, poolAddress, oracle });
|
|
2281
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2282
|
-
programId,
|
|
2283
|
-
poolAddress,
|
|
2284
|
-
oracle,
|
|
2285
|
-
});
|
|
2286
|
-
const [poolTreasuryReserve] = derivePoolTreasuryReservePda({
|
|
2287
|
-
programId,
|
|
2288
|
-
poolAddress,
|
|
2289
|
-
paymentMint: zeroPubkey,
|
|
2290
|
-
});
|
|
2291
|
-
const instruction = new TransactionInstruction({
|
|
2292
|
-
programId,
|
|
2293
|
-
keys: [
|
|
2294
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2295
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2296
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2297
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2298
|
-
{ pubkey: poolOracle, isSigner: false, isWritable: false },
|
|
2299
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2300
|
-
{ pubkey: poolTreasuryReserve, isSigner: false, isWritable: true },
|
|
2301
|
-
{ pubkey: recipientSystemAccount, isSigner: false, isWritable: true },
|
|
2302
|
-
],
|
|
2303
|
-
data: Buffer.concat([IX_WITHDRAW_POOL_TREASURY_SOL, encodeU64Le(params.amount)]),
|
|
2304
|
-
});
|
|
2305
|
-
return new Transaction({
|
|
2306
|
-
feePayer: payer,
|
|
2307
|
-
recentBlockhash: params.recentBlockhash,
|
|
2308
|
-
}).add(instruction);
|
|
2309
|
-
}
|
|
2310
|
-
function buildWithdrawProtocolFeeSplTransaction(params) {
|
|
2311
|
-
const programId = asPubkey(params.programId);
|
|
2312
|
-
const governanceAuthority = asPubkey(params.governanceAuthority);
|
|
2313
|
-
const paymentMint = asPubkey(params.paymentMint);
|
|
2314
|
-
const recipientTokenAccount = asPubkey(params.recipientTokenAccount);
|
|
2315
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2316
|
-
const [protocolFeeVault] = deriveProtocolFeeVaultPda({
|
|
2317
|
-
programId,
|
|
2318
|
-
paymentMint,
|
|
2319
|
-
});
|
|
2320
|
-
const protocolFeeVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
2321
|
-
owner: protocolFeeVault,
|
|
2322
|
-
mint: paymentMint,
|
|
2323
|
-
allowOwnerOffCurve: true,
|
|
2324
|
-
});
|
|
2325
|
-
const instruction = new TransactionInstruction({
|
|
2326
|
-
programId,
|
|
2327
|
-
keys: [
|
|
2328
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: true },
|
|
2329
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2330
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: true },
|
|
2331
|
-
{ pubkey: protocolFeeVault, isSigner: false, isWritable: true },
|
|
2332
|
-
{ pubkey: protocolFeeVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2333
|
-
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
|
|
2334
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2335
|
-
],
|
|
2336
|
-
data: encodeWithdrawProtocolFeeSplData(params),
|
|
2337
|
-
});
|
|
2338
|
-
return new Transaction({
|
|
2339
|
-
feePayer: governanceAuthority,
|
|
2340
|
-
recentBlockhash: params.recentBlockhash,
|
|
2341
|
-
}).add(instruction);
|
|
2342
|
-
}
|
|
2343
|
-
function buildWithdrawProtocolFeeSolTransaction(params) {
|
|
2344
|
-
const programId = asPubkey(params.programId);
|
|
2345
|
-
const governanceAuthority = asPubkey(params.governanceAuthority);
|
|
2346
|
-
const recipientSystemAccount = asPubkey(params.recipientSystemAccount);
|
|
2347
|
-
const zeroPubkey = asPubkey(ZERO_PUBKEY);
|
|
2348
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2349
|
-
const [protocolFeeVault] = deriveProtocolFeeVaultPda({
|
|
2350
|
-
programId,
|
|
2351
|
-
paymentMint: zeroPubkey,
|
|
2352
|
-
});
|
|
2353
|
-
const instruction = new TransactionInstruction({
|
|
2354
|
-
programId,
|
|
2355
|
-
keys: [
|
|
2356
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: true },
|
|
2357
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2358
|
-
{ pubkey: protocolFeeVault, isSigner: false, isWritable: true },
|
|
2359
|
-
{ pubkey: recipientSystemAccount, isSigner: false, isWritable: true },
|
|
2360
|
-
],
|
|
2361
|
-
data: encodeWithdrawProtocolFeeSolData(params),
|
|
2362
|
-
});
|
|
2363
|
-
return new Transaction({
|
|
2364
|
-
feePayer: governanceAuthority,
|
|
2365
|
-
recentBlockhash: params.recentBlockhash,
|
|
2366
|
-
}).add(instruction);
|
|
2367
|
-
}
|
|
2368
|
-
function buildWithdrawPoolOracleFeeSplTransaction(params) {
|
|
2369
|
-
const programId = asPubkey(params.programId);
|
|
2370
|
-
const oracle = asPubkey(params.oracle);
|
|
2371
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2372
|
-
const paymentMint = asPubkey(params.paymentMint);
|
|
2373
|
-
const recipientTokenAccount = asPubkey(params.recipientTokenAccount);
|
|
2374
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2375
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2376
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2377
|
-
programId,
|
|
2378
|
-
poolAddress,
|
|
2379
|
-
oracle,
|
|
2380
|
-
});
|
|
2381
|
-
const [poolOracleFeeVault] = derivePoolOracleFeeVaultPda({
|
|
2382
|
-
programId,
|
|
2383
|
-
poolAddress,
|
|
2384
|
-
oracle,
|
|
2385
|
-
paymentMint,
|
|
2386
|
-
});
|
|
2387
|
-
const poolOracleFeeVaultTokenAccount = deriveAssociatedTokenAddress({
|
|
2388
|
-
owner: poolOracleFeeVault,
|
|
2389
|
-
mint: paymentMint,
|
|
2390
|
-
allowOwnerOffCurve: true,
|
|
2391
|
-
});
|
|
2392
|
-
const instruction = new TransactionInstruction({
|
|
2393
|
-
programId,
|
|
2394
|
-
keys: [
|
|
2395
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2396
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2397
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2398
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2399
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2400
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: true },
|
|
2401
|
-
{ pubkey: poolOracleFeeVault, isSigner: false, isWritable: true },
|
|
2402
|
-
{ pubkey: poolOracleFeeVaultTokenAccount, isSigner: false, isWritable: true },
|
|
2403
|
-
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
|
|
2404
|
-
{ pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
2405
|
-
],
|
|
2406
|
-
data: encodeWithdrawPoolOracleFeeSplData(params),
|
|
2407
|
-
});
|
|
2408
|
-
return new Transaction({
|
|
2409
|
-
feePayer: oracle,
|
|
2410
|
-
recentBlockhash: params.recentBlockhash,
|
|
2411
|
-
}).add(instruction);
|
|
2412
|
-
}
|
|
2413
|
-
function buildWithdrawPoolOracleFeeSolTransaction(params) {
|
|
2414
|
-
const programId = asPubkey(params.programId);
|
|
2415
|
-
const oracle = asPubkey(params.oracle);
|
|
2416
|
-
const poolAddress = asPubkey(params.poolAddress);
|
|
2417
|
-
const recipientSystemAccount = asPubkey(params.recipientSystemAccount);
|
|
2418
|
-
const zeroPubkey = asPubkey(ZERO_PUBKEY);
|
|
2419
|
-
const [configV2] = deriveConfigV2Pda(programId);
|
|
2420
|
-
const [oracleEntry] = deriveOraclePda({ programId, oracle });
|
|
2421
|
-
const [poolOraclePermissions] = derivePoolOraclePermissionSetPda({
|
|
2422
|
-
programId,
|
|
2423
|
-
poolAddress,
|
|
2424
|
-
oracle,
|
|
2425
|
-
});
|
|
2426
|
-
const [poolOracleFeeVault] = derivePoolOracleFeeVaultPda({
|
|
2427
|
-
programId,
|
|
2428
|
-
poolAddress,
|
|
2429
|
-
oracle,
|
|
2430
|
-
paymentMint: zeroPubkey,
|
|
2431
|
-
});
|
|
2432
|
-
const instruction = new TransactionInstruction({
|
|
2433
|
-
programId,
|
|
2434
|
-
keys: [
|
|
2435
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2436
|
-
{ pubkey: configV2, isSigner: false, isWritable: false },
|
|
2437
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2438
|
-
{ pubkey: oracleEntry, isSigner: false, isWritable: false },
|
|
2439
|
-
{ pubkey: poolOraclePermissions, isSigner: false, isWritable: false },
|
|
2440
|
-
{ pubkey: poolOracleFeeVault, isSigner: false, isWritable: true },
|
|
2441
|
-
{ pubkey: recipientSystemAccount, isSigner: false, isWritable: true },
|
|
2442
|
-
],
|
|
2443
|
-
data: encodeWithdrawPoolOracleFeeSolData(params),
|
|
2444
|
-
});
|
|
2445
|
-
return new Transaction({
|
|
2446
|
-
feePayer: oracle,
|
|
2447
|
-
recentBlockhash: params.recentBlockhash,
|
|
2448
|
-
}).add(instruction);
|
|
2449
|
-
}
|
|
2450
|
-
export function createProtocolClient(connection, programIdInput) {
|
|
2451
|
-
const programId = new PublicKey(programIdInput);
|
|
2452
|
-
return {
|
|
2453
|
-
connection,
|
|
2454
|
-
programId,
|
|
2455
|
-
buildInitializeProtocolTx(params) {
|
|
2456
|
-
const admin = new PublicKey(params.admin);
|
|
2457
|
-
const [configPda] = deriveConfigPda(programId);
|
|
2458
|
-
const instruction = new TransactionInstruction({
|
|
2459
|
-
programId,
|
|
2460
|
-
keys: [
|
|
2461
|
-
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
2462
|
-
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
2463
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2464
|
-
],
|
|
2465
|
-
data: encodeInitializeProtocolData(params),
|
|
2466
|
-
});
|
|
2467
|
-
return new Transaction({
|
|
2468
|
-
feePayer: admin,
|
|
2469
|
-
recentBlockhash: params.recentBlockhash,
|
|
2470
|
-
}).add(instruction);
|
|
2471
|
-
},
|
|
2472
|
-
buildSetProtocolPauseTx(params) {
|
|
2473
|
-
const admin = new PublicKey(params.admin);
|
|
2474
|
-
const [configPda] = deriveConfigPda(programId);
|
|
2475
|
-
const instruction = new TransactionInstruction({
|
|
2476
|
-
programId,
|
|
2477
|
-
keys: [
|
|
2478
|
-
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
2479
|
-
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
2480
|
-
],
|
|
2481
|
-
data: encodeSetProtocolPauseData(params),
|
|
2482
|
-
});
|
|
2483
|
-
return new Transaction({
|
|
2484
|
-
feePayer: admin,
|
|
2485
|
-
recentBlockhash: params.recentBlockhash,
|
|
2486
|
-
}).add(instruction);
|
|
2487
|
-
},
|
|
2488
|
-
buildCreatePoolTx(params) {
|
|
2489
|
-
assertPoolIdSeedLength(params.poolId);
|
|
2490
|
-
const authority = new PublicKey(params.authority);
|
|
2491
|
-
const [configPda] = deriveConfigPda(programId);
|
|
2492
|
-
const [poolPda] = derivePoolPda({
|
|
2493
|
-
programId,
|
|
2494
|
-
authority,
|
|
2495
|
-
poolId: params.poolId,
|
|
2496
|
-
});
|
|
2497
|
-
const instruction = new TransactionInstruction({
|
|
2498
|
-
programId,
|
|
2499
|
-
keys: [
|
|
2500
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
2501
|
-
{ pubkey: configPda, isSigner: false, isWritable: false },
|
|
2502
|
-
{ pubkey: poolPda, isSigner: false, isWritable: true },
|
|
2503
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2504
|
-
],
|
|
2505
|
-
data: encodeCreatePoolData(params),
|
|
2506
|
-
});
|
|
2507
|
-
return new Transaction({
|
|
2508
|
-
feePayer: authority,
|
|
2509
|
-
recentBlockhash: params.recentBlockhash,
|
|
2510
|
-
}).add(instruction);
|
|
2511
|
-
},
|
|
2512
|
-
buildSetPoolStatusTx(params) {
|
|
2513
|
-
const authority = new PublicKey(params.authority);
|
|
2514
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2515
|
-
const instruction = new TransactionInstruction({
|
|
2516
|
-
programId,
|
|
2517
|
-
keys: [
|
|
2518
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
2519
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2520
|
-
],
|
|
2521
|
-
data: encodeSetPoolStatusData(params),
|
|
2522
|
-
});
|
|
2523
|
-
return new Transaction({
|
|
2524
|
-
feePayer: authority,
|
|
2525
|
-
recentBlockhash: params.recentBlockhash,
|
|
2526
|
-
}).add(instruction);
|
|
2527
|
-
},
|
|
2528
|
-
buildSetCycleWindowTx(params) {
|
|
2529
|
-
const authority = new PublicKey(params.authority);
|
|
2530
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2531
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
2532
|
-
const [cycleWindowPda] = deriveCycleWindowPda({
|
|
2533
|
-
programId,
|
|
2534
|
-
poolAddress,
|
|
2535
|
-
cycleHash,
|
|
2536
|
-
});
|
|
2537
|
-
const instruction = new TransactionInstruction({
|
|
2538
|
-
programId,
|
|
2539
|
-
keys: [
|
|
2540
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
2541
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2542
|
-
{ pubkey: cycleWindowPda, isSigner: false, isWritable: true },
|
|
2543
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2544
|
-
],
|
|
2545
|
-
data: encodeSetCycleWindowData(params),
|
|
2546
|
-
});
|
|
2547
|
-
return new Transaction({
|
|
2548
|
-
feePayer: authority,
|
|
2549
|
-
recentBlockhash: params.recentBlockhash,
|
|
2550
|
-
}).add(instruction);
|
|
2551
|
-
},
|
|
2552
|
-
buildFundPoolTx(params) {
|
|
2553
|
-
const funder = new PublicKey(params.funder);
|
|
2554
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2555
|
-
const instruction = new TransactionInstruction({
|
|
2556
|
-
programId,
|
|
2557
|
-
keys: [
|
|
2558
|
-
{ pubkey: funder, isSigner: true, isWritable: true },
|
|
2559
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2560
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2561
|
-
],
|
|
2562
|
-
data: encodeFundPoolData(params),
|
|
2563
|
-
});
|
|
2564
|
-
return new Transaction({
|
|
2565
|
-
feePayer: funder,
|
|
2566
|
-
recentBlockhash: params.recentBlockhash,
|
|
2567
|
-
}).add(instruction);
|
|
2568
|
-
},
|
|
2569
|
-
buildRegisterOracleTx(params) {
|
|
2570
|
-
const oracle = new PublicKey(params.oracle);
|
|
2571
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
2572
|
-
programId,
|
|
2573
|
-
oracle,
|
|
2574
|
-
});
|
|
2575
|
-
const instruction = new TransactionInstruction({
|
|
2576
|
-
programId,
|
|
2577
|
-
keys: [
|
|
2578
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2579
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: true },
|
|
2580
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2581
|
-
],
|
|
2582
|
-
data: encodeRegisterOracleData(params),
|
|
2583
|
-
});
|
|
2584
|
-
return new Transaction({
|
|
2585
|
-
feePayer: oracle,
|
|
2586
|
-
recentBlockhash: params.recentBlockhash,
|
|
2587
|
-
}).add(instruction);
|
|
2588
|
-
},
|
|
2589
|
-
buildSetPoolOracleTx(params) {
|
|
2590
|
-
const authority = new PublicKey(params.authority);
|
|
2591
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2592
|
-
const oracle = new PublicKey(params.oracle);
|
|
2593
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
2594
|
-
programId,
|
|
2595
|
-
oracle,
|
|
2596
|
-
});
|
|
2597
|
-
const [poolOraclePda] = derivePoolOraclePda({
|
|
2598
|
-
programId,
|
|
2599
|
-
poolAddress,
|
|
2600
|
-
oracle,
|
|
2601
|
-
});
|
|
2602
|
-
const instruction = new TransactionInstruction({
|
|
2603
|
-
programId,
|
|
2604
|
-
keys: [
|
|
2605
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
2606
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2607
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: false },
|
|
2608
|
-
{ pubkey: poolOraclePda, isSigner: false, isWritable: true },
|
|
2609
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2610
|
-
],
|
|
2611
|
-
data: encodeSetPoolOracleData(params),
|
|
2612
|
-
});
|
|
2613
|
-
return new Transaction({
|
|
2614
|
-
feePayer: authority,
|
|
2615
|
-
recentBlockhash: params.recentBlockhash,
|
|
2616
|
-
}).add(instruction);
|
|
2617
|
-
},
|
|
2618
|
-
buildEnrollMemberTx(params) {
|
|
2619
|
-
const member = new PublicKey(params.member);
|
|
2620
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2621
|
-
const [membershipPda] = deriveMembershipPda({
|
|
2622
|
-
programId,
|
|
2623
|
-
poolAddress,
|
|
2624
|
-
member,
|
|
2625
|
-
});
|
|
2626
|
-
const keys = [
|
|
2627
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
2628
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2629
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: true },
|
|
2630
|
-
];
|
|
2631
|
-
if (params.tokenGateAccount) {
|
|
2632
|
-
keys.push({
|
|
2633
|
-
pubkey: new PublicKey(params.tokenGateAccount),
|
|
2634
|
-
isSigner: false,
|
|
2635
|
-
isWritable: false,
|
|
2636
|
-
});
|
|
2637
|
-
}
|
|
2638
|
-
if (params.inviteIssuer) {
|
|
2639
|
-
keys.push({
|
|
2640
|
-
pubkey: new PublicKey(params.inviteIssuer),
|
|
2641
|
-
isSigner: true,
|
|
2642
|
-
isWritable: false,
|
|
2643
|
-
});
|
|
2644
|
-
}
|
|
2645
|
-
keys.push({
|
|
2646
|
-
pubkey: SystemProgram.programId,
|
|
2647
|
-
isSigner: false,
|
|
2648
|
-
isWritable: false,
|
|
2649
|
-
});
|
|
2650
|
-
const instruction = new TransactionInstruction({
|
|
2651
|
-
programId,
|
|
2652
|
-
keys,
|
|
2653
|
-
data: encodeEnrollMemberData(params),
|
|
2654
|
-
});
|
|
2655
|
-
return new Transaction({
|
|
2656
|
-
feePayer: member,
|
|
2657
|
-
recentBlockhash: params.recentBlockhash,
|
|
2658
|
-
}).add(instruction);
|
|
2659
|
-
},
|
|
2660
|
-
buildRevokeMemberTx(params) {
|
|
2661
|
-
const authority = new PublicKey(params.authority);
|
|
2662
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2663
|
-
const member = new PublicKey(params.member);
|
|
2664
|
-
const [membershipPda] = deriveMembershipPda({
|
|
2665
|
-
programId,
|
|
2666
|
-
poolAddress,
|
|
2667
|
-
member,
|
|
2668
|
-
});
|
|
2669
|
-
const instruction = new TransactionInstruction({
|
|
2670
|
-
programId,
|
|
2671
|
-
keys: [
|
|
2672
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
2673
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2674
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: true },
|
|
2675
|
-
],
|
|
2676
|
-
data: IX_REVOKE_MEMBER,
|
|
2677
|
-
});
|
|
2678
|
-
return new Transaction({
|
|
2679
|
-
feePayer: authority,
|
|
2680
|
-
recentBlockhash: params.recentBlockhash,
|
|
2681
|
-
}).add(instruction);
|
|
2682
|
-
},
|
|
2683
|
-
buildSubmitOutcomeAttestationTx(params) {
|
|
2684
|
-
const oracle = new PublicKey(params.oracle);
|
|
2685
|
-
const member = new PublicKey(params.member);
|
|
2686
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2687
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
2688
|
-
const replayHash = hashStringTo32(params.replayKey);
|
|
2689
|
-
const [poolOraclePda] = derivePoolOraclePda({
|
|
2690
|
-
programId,
|
|
2691
|
-
poolAddress,
|
|
2692
|
-
oracle,
|
|
2693
|
-
});
|
|
2694
|
-
const [membershipPda] = deriveMembershipPda({
|
|
2695
|
-
programId,
|
|
2696
|
-
poolAddress,
|
|
2697
|
-
member,
|
|
2698
|
-
});
|
|
2699
|
-
const [cycleOutcomePda] = deriveCycleOutcomePda({
|
|
2700
|
-
programId,
|
|
2701
|
-
poolAddress,
|
|
2702
|
-
member,
|
|
2703
|
-
cycleHash,
|
|
2704
|
-
});
|
|
2705
|
-
const [replayPda] = deriveReplayPda({
|
|
2706
|
-
programId,
|
|
2707
|
-
poolAddress,
|
|
2708
|
-
replayHash,
|
|
2709
|
-
});
|
|
2710
|
-
const instruction = new TransactionInstruction({
|
|
2711
|
-
programId,
|
|
2712
|
-
keys: [
|
|
2713
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2714
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2715
|
-
{ pubkey: poolOraclePda, isSigner: false, isWritable: false },
|
|
2716
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
2717
|
-
{ pubkey: cycleOutcomePda, isSigner: false, isWritable: true },
|
|
2718
|
-
{ pubkey: replayPda, isSigner: false, isWritable: true },
|
|
2719
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2720
|
-
],
|
|
2721
|
-
data: encodeSubmitOutcomeAttestationData(params),
|
|
2722
|
-
});
|
|
2723
|
-
return new Transaction({
|
|
2724
|
-
feePayer: oracle,
|
|
2725
|
-
recentBlockhash: params.recentBlockhash,
|
|
2726
|
-
}).add(instruction);
|
|
2727
|
-
},
|
|
2728
|
-
buildSubmitClaimTx(params) {
|
|
2729
|
-
const claimant = new PublicKey(params.claimant);
|
|
2730
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2731
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
2732
|
-
const [membershipPda] = deriveMembershipPda({
|
|
2733
|
-
programId,
|
|
2734
|
-
poolAddress,
|
|
2735
|
-
member: claimant,
|
|
2736
|
-
});
|
|
2737
|
-
const [cycleOutcomePda] = deriveCycleOutcomePda({
|
|
2738
|
-
programId,
|
|
2739
|
-
poolAddress,
|
|
2740
|
-
member: claimant,
|
|
2741
|
-
cycleHash,
|
|
2742
|
-
});
|
|
2743
|
-
const [claimPda] = deriveClaimPda({
|
|
2744
|
-
programId,
|
|
2745
|
-
poolAddress,
|
|
2746
|
-
member: claimant,
|
|
2747
|
-
cycleHash,
|
|
2748
|
-
});
|
|
2749
|
-
const [cycleWindowPda] = deriveCycleWindowPda({
|
|
2750
|
-
programId,
|
|
2751
|
-
poolAddress,
|
|
2752
|
-
cycleHash,
|
|
2753
|
-
});
|
|
2754
|
-
const instruction = new TransactionInstruction({
|
|
2755
|
-
programId,
|
|
2756
|
-
keys: [
|
|
2757
|
-
{ pubkey: claimant, isSigner: true, isWritable: true },
|
|
2758
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
2759
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
2760
|
-
{ pubkey: cycleOutcomePda, isSigner: false, isWritable: true },
|
|
2761
|
-
{ pubkey: cycleWindowPda, isSigner: false, isWritable: false },
|
|
2762
|
-
{ pubkey: claimPda, isSigner: false, isWritable: true },
|
|
2763
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2764
|
-
],
|
|
2765
|
-
data: encodeSubmitClaimData(params),
|
|
2766
|
-
});
|
|
2767
|
-
return new Transaction({
|
|
2768
|
-
feePayer: claimant,
|
|
2769
|
-
recentBlockhash: params.recentBlockhash,
|
|
2770
|
-
}).add(instruction);
|
|
2771
|
-
},
|
|
2772
|
-
buildSubmitOutcomeAttestationVoteTx(params) {
|
|
2773
|
-
const oracle = new PublicKey(params.oracle);
|
|
2774
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2775
|
-
const member = new PublicKey(params.member);
|
|
2776
|
-
const payoutMint = new PublicKey(params.payoutMint);
|
|
2777
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
2778
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
2779
|
-
const schemaKeyHash = fromHex(params.schemaKeyHashHex, 32);
|
|
2780
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
2781
|
-
programId,
|
|
2782
|
-
oracle,
|
|
2783
|
-
});
|
|
2784
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
2785
|
-
const [stakePositionPda] = deriveOracleStakePda({
|
|
2786
|
-
programId,
|
|
2787
|
-
oracle,
|
|
2788
|
-
staker: oracle,
|
|
2789
|
-
});
|
|
2790
|
-
const [poolOraclePolicyPda] = derivePoolOraclePolicyPda({
|
|
2791
|
-
programId,
|
|
2792
|
-
poolAddress,
|
|
2793
|
-
});
|
|
2794
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
2795
|
-
programId,
|
|
2796
|
-
poolAddress,
|
|
2797
|
-
});
|
|
2798
|
-
const [poolTreasuryReservePda] = derivePoolTreasuryReservePda({
|
|
2799
|
-
programId,
|
|
2800
|
-
poolAddress,
|
|
2801
|
-
paymentMint: payoutMint,
|
|
2802
|
-
});
|
|
2803
|
-
const [poolOraclePda] = derivePoolOraclePda({
|
|
2804
|
-
programId,
|
|
2805
|
-
poolAddress,
|
|
2806
|
-
oracle,
|
|
2807
|
-
});
|
|
2808
|
-
const [membershipPda] = deriveMembershipPda({
|
|
2809
|
-
programId,
|
|
2810
|
-
poolAddress,
|
|
2811
|
-
member,
|
|
2812
|
-
});
|
|
2813
|
-
const [poolRulePda] = derivePoolRulePda({
|
|
2814
|
-
programId,
|
|
2815
|
-
poolAddress,
|
|
2816
|
-
ruleHash,
|
|
2817
|
-
});
|
|
2818
|
-
const [schemaPda] = deriveSchemaPda({
|
|
2819
|
-
programId,
|
|
2820
|
-
schemaKeyHash,
|
|
2821
|
-
});
|
|
2822
|
-
const [votePda] = deriveAttestationVotePda({
|
|
2823
|
-
programId,
|
|
2824
|
-
poolAddress,
|
|
2825
|
-
member,
|
|
2826
|
-
cycleHash,
|
|
2827
|
-
ruleHash,
|
|
2828
|
-
oracle,
|
|
2829
|
-
});
|
|
2830
|
-
const [aggregatePda] = deriveOutcomeAggregatePda({
|
|
2831
|
-
programId,
|
|
2832
|
-
poolAddress,
|
|
2833
|
-
member,
|
|
2834
|
-
cycleHash,
|
|
2835
|
-
ruleHash,
|
|
2836
|
-
});
|
|
2837
|
-
const instruction = new TransactionInstruction({
|
|
2838
|
-
programId,
|
|
2839
|
-
keys: [
|
|
2840
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
2841
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: false },
|
|
2842
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
2843
|
-
{ pubkey: stakePositionPda, isSigner: false, isWritable: false },
|
|
2844
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2845
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
2846
|
-
{ pubkey: poolOraclePolicyPda, isSigner: false, isWritable: false },
|
|
2847
|
-
{ pubkey: poolTreasuryReservePda, isSigner: false, isWritable: true },
|
|
2848
|
-
{ pubkey: poolOraclePda, isSigner: false, isWritable: false },
|
|
2849
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
2850
|
-
{ pubkey: poolRulePda, isSigner: false, isWritable: false },
|
|
2851
|
-
{ pubkey: schemaPda, isSigner: false, isWritable: false },
|
|
2852
|
-
{ pubkey: votePda, isSigner: false, isWritable: true },
|
|
2853
|
-
{ pubkey: aggregatePda, isSigner: false, isWritable: true },
|
|
2854
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2855
|
-
],
|
|
2856
|
-
data: encodeSubmitOutcomeAttestationVoteData(params),
|
|
2857
|
-
});
|
|
2858
|
-
return new Transaction({
|
|
2859
|
-
feePayer: oracle,
|
|
2860
|
-
recentBlockhash: params.recentBlockhash,
|
|
2861
|
-
}).add(instruction);
|
|
2862
|
-
},
|
|
2863
|
-
buildFinalizeCycleOutcomeTx(params) {
|
|
2864
|
-
const payer = new PublicKey(params.payer);
|
|
2865
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
2866
|
-
const member = new PublicKey(params.member);
|
|
2867
|
-
const payoutMint = new PublicKey(params.payoutMint);
|
|
2868
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
2869
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
2870
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
2871
|
-
programId,
|
|
2872
|
-
poolAddress,
|
|
2873
|
-
});
|
|
2874
|
-
const [poolTreasuryReservePda] = derivePoolTreasuryReservePda({
|
|
2875
|
-
programId,
|
|
2876
|
-
poolAddress,
|
|
2877
|
-
paymentMint: payoutMint,
|
|
2878
|
-
});
|
|
2879
|
-
const [aggregatePda] = deriveOutcomeAggregatePda({
|
|
2880
|
-
programId,
|
|
2881
|
-
poolAddress,
|
|
2882
|
-
member,
|
|
2883
|
-
cycleHash,
|
|
2884
|
-
ruleHash,
|
|
2885
|
-
});
|
|
2886
|
-
const instruction = new TransactionInstruction({
|
|
2887
|
-
programId,
|
|
2888
|
-
keys: [
|
|
2889
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
2890
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
2891
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
2892
|
-
{ pubkey: poolTreasuryReservePda, isSigner: false, isWritable: true },
|
|
2893
|
-
{ pubkey: aggregatePda, isSigner: false, isWritable: true },
|
|
2894
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2895
|
-
],
|
|
2896
|
-
data: IX_FINALIZE_CYCLE_OUTCOME,
|
|
2897
|
-
});
|
|
2898
|
-
return new Transaction({
|
|
2899
|
-
feePayer: payer,
|
|
2900
|
-
recentBlockhash: params.recentBlockhash,
|
|
2901
|
-
}).add(instruction);
|
|
2902
|
-
},
|
|
2903
|
-
buildInitializeProtocolV2Tx(params) {
|
|
2904
|
-
const admin = new PublicKey(params.admin);
|
|
2905
|
-
const [configPda] = deriveConfigV2Pda(programId);
|
|
2906
|
-
const instruction = new TransactionInstruction({
|
|
2907
|
-
programId,
|
|
2908
|
-
keys: [
|
|
2909
|
-
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
2910
|
-
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
2911
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2912
|
-
],
|
|
2913
|
-
data: encodeInitializeProtocolV2Data(params),
|
|
2914
|
-
});
|
|
2915
|
-
return new Transaction({
|
|
2916
|
-
feePayer: admin,
|
|
2917
|
-
recentBlockhash: params.recentBlockhash,
|
|
2918
|
-
}).add(instruction);
|
|
2919
|
-
},
|
|
2920
|
-
buildSetProtocolParamsTx(params) {
|
|
2921
|
-
const governanceAuthority = new PublicKey(params.governanceAuthority);
|
|
2922
|
-
const [configPda] = deriveConfigV2Pda(programId);
|
|
2923
|
-
const instruction = new TransactionInstruction({
|
|
2924
|
-
programId,
|
|
2925
|
-
keys: [
|
|
2926
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: false },
|
|
2927
|
-
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
2928
|
-
],
|
|
2929
|
-
data: encodeSetProtocolParamsData(params),
|
|
2930
|
-
});
|
|
2931
|
-
return new Transaction({
|
|
2932
|
-
feePayer: governanceAuthority,
|
|
2933
|
-
recentBlockhash: params.recentBlockhash,
|
|
2934
|
-
}).add(instruction);
|
|
2935
|
-
},
|
|
2936
|
-
buildRotateGovernanceAuthorityTx(params) {
|
|
2937
|
-
const governanceAuthority = new PublicKey(params.governanceAuthority);
|
|
2938
|
-
const [configPda] = deriveConfigV2Pda(programId);
|
|
2939
|
-
const instruction = new TransactionInstruction({
|
|
2940
|
-
programId,
|
|
2941
|
-
keys: [
|
|
2942
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: false },
|
|
2943
|
-
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
2944
|
-
],
|
|
2945
|
-
data: encodeRotateGovernanceAuthorityData(params),
|
|
2946
|
-
});
|
|
2947
|
-
return new Transaction({
|
|
2948
|
-
feePayer: governanceAuthority,
|
|
2949
|
-
recentBlockhash: params.recentBlockhash,
|
|
2950
|
-
}).add(instruction);
|
|
2951
|
-
},
|
|
2952
|
-
buildRegisterOracleV2Tx(params) {
|
|
2953
|
-
const admin = new PublicKey(params.admin);
|
|
2954
|
-
const oraclePubkey = new PublicKey(params.oraclePubkey);
|
|
2955
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
2956
|
-
programId,
|
|
2957
|
-
oracle: oraclePubkey,
|
|
2958
|
-
});
|
|
2959
|
-
const [oracleProfilePda] = deriveOracleProfilePda({
|
|
2960
|
-
programId,
|
|
2961
|
-
oracle: oraclePubkey,
|
|
2962
|
-
});
|
|
2963
|
-
const instruction = new TransactionInstruction({
|
|
2964
|
-
programId,
|
|
2965
|
-
keys: [
|
|
2966
|
-
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
2967
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: true },
|
|
2968
|
-
{ pubkey: oracleProfilePda, isSigner: false, isWritable: true },
|
|
2969
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
2970
|
-
],
|
|
2971
|
-
data: encodeRegisterOracleV2Data(params),
|
|
2972
|
-
});
|
|
2973
|
-
return new Transaction({
|
|
2974
|
-
feePayer: admin,
|
|
2975
|
-
recentBlockhash: params.recentBlockhash,
|
|
2976
|
-
}).add(instruction);
|
|
2977
|
-
},
|
|
2978
|
-
buildClaimOracleV2Tx(params) {
|
|
2979
|
-
const oracle = new PublicKey(params.oracle);
|
|
2980
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
2981
|
-
programId,
|
|
2982
|
-
oracle,
|
|
2983
|
-
});
|
|
2984
|
-
const [oracleProfilePda] = deriveOracleProfilePda({
|
|
2985
|
-
programId,
|
|
2986
|
-
oracle,
|
|
2987
|
-
});
|
|
2988
|
-
const instruction = new TransactionInstruction({
|
|
2989
|
-
programId,
|
|
2990
|
-
keys: [
|
|
2991
|
-
{ pubkey: oracle, isSigner: true, isWritable: false },
|
|
2992
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: true },
|
|
2993
|
-
{ pubkey: oracleProfilePda, isSigner: false, isWritable: true },
|
|
2994
|
-
],
|
|
2995
|
-
data: IX_CLAIM_ORACLE_V2,
|
|
2996
|
-
});
|
|
2997
|
-
return new Transaction({
|
|
2998
|
-
feePayer: oracle,
|
|
2999
|
-
recentBlockhash: params.recentBlockhash,
|
|
3000
|
-
}).add(instruction);
|
|
3001
|
-
},
|
|
3002
|
-
buildUpdateOracleProfileV2Tx(params) {
|
|
3003
|
-
const authority = new PublicKey(params.authority);
|
|
3004
|
-
const [oracleProfilePda] = deriveOracleProfilePda({
|
|
3005
|
-
programId,
|
|
3006
|
-
oracle: params.oracle,
|
|
3007
|
-
});
|
|
3008
|
-
const instruction = new TransactionInstruction({
|
|
3009
|
-
programId,
|
|
3010
|
-
keys: [
|
|
3011
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
3012
|
-
{ pubkey: oracleProfilePda, isSigner: false, isWritable: true },
|
|
3013
|
-
],
|
|
3014
|
-
data: encodeUpdateOracleProfileV2Data(params),
|
|
3015
|
-
});
|
|
3016
|
-
return new Transaction({
|
|
3017
|
-
feePayer: authority,
|
|
3018
|
-
recentBlockhash: params.recentBlockhash,
|
|
3019
|
-
}).add(instruction);
|
|
3020
|
-
},
|
|
3021
|
-
buildUpdateOracleMetadataTx(params) {
|
|
3022
|
-
const oracle = new PublicKey(params.oracle);
|
|
3023
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
3024
|
-
programId,
|
|
3025
|
-
oracle,
|
|
3026
|
-
});
|
|
3027
|
-
const instruction = new TransactionInstruction({
|
|
3028
|
-
programId,
|
|
3029
|
-
keys: [
|
|
3030
|
-
{ pubkey: oracle, isSigner: true, isWritable: false },
|
|
3031
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: true },
|
|
3032
|
-
],
|
|
3033
|
-
data: encodeUpdateOracleMetadataData(params),
|
|
3034
|
-
});
|
|
3035
|
-
return new Transaction({
|
|
3036
|
-
feePayer: oracle,
|
|
3037
|
-
recentBlockhash: params.recentBlockhash,
|
|
3038
|
-
}).add(instruction);
|
|
3039
|
-
},
|
|
3040
|
-
buildStakeOracleTx(params) {
|
|
3041
|
-
const staker = new PublicKey(params.staker);
|
|
3042
|
-
const oracle = new PublicKey(params.oracle);
|
|
3043
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3044
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
3045
|
-
programId,
|
|
3046
|
-
oracle,
|
|
3047
|
-
});
|
|
3048
|
-
const [stakePositionPda] = deriveOracleStakePda({
|
|
3049
|
-
programId,
|
|
3050
|
-
oracle,
|
|
3051
|
-
staker,
|
|
3052
|
-
});
|
|
3053
|
-
const instruction = new TransactionInstruction({
|
|
3054
|
-
programId,
|
|
3055
|
-
keys: [
|
|
3056
|
-
{ pubkey: staker, isSigner: true, isWritable: true },
|
|
3057
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3058
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: false },
|
|
3059
|
-
{ pubkey: stakePositionPda, isSigner: false, isWritable: true },
|
|
3060
|
-
{ pubkey: new PublicKey(params.stakeMint), isSigner: false, isWritable: true },
|
|
3061
|
-
{ pubkey: new PublicKey(params.stakeVault), isSigner: true, isWritable: true },
|
|
3062
|
-
{ pubkey: new PublicKey(params.stakerTokenAccount), isSigner: false, isWritable: true },
|
|
3063
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3064
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3065
|
-
],
|
|
3066
|
-
data: encodeStakeOracleData(params),
|
|
3067
|
-
});
|
|
3068
|
-
return new Transaction({
|
|
3069
|
-
feePayer: staker,
|
|
3070
|
-
recentBlockhash: params.recentBlockhash,
|
|
3071
|
-
}).add(instruction);
|
|
3072
|
-
},
|
|
3073
|
-
buildRequestUnstakeTx(params) {
|
|
3074
|
-
const staker = new PublicKey(params.staker);
|
|
3075
|
-
const oracle = new PublicKey(params.oracle);
|
|
3076
|
-
const [stakePositionPda] = deriveOracleStakePda({
|
|
3077
|
-
programId,
|
|
3078
|
-
oracle,
|
|
3079
|
-
staker,
|
|
3080
|
-
});
|
|
3081
|
-
const instruction = new TransactionInstruction({
|
|
3082
|
-
programId,
|
|
3083
|
-
keys: [
|
|
3084
|
-
{ pubkey: staker, isSigner: true, isWritable: false },
|
|
3085
|
-
{ pubkey: stakePositionPda, isSigner: false, isWritable: true },
|
|
3086
|
-
],
|
|
3087
|
-
data: encodeRequestUnstakeData(params),
|
|
3088
|
-
});
|
|
3089
|
-
return new Transaction({
|
|
3090
|
-
feePayer: staker,
|
|
3091
|
-
recentBlockhash: params.recentBlockhash,
|
|
3092
|
-
}).add(instruction);
|
|
3093
|
-
},
|
|
3094
|
-
buildFinalizeUnstakeTx(params) {
|
|
3095
|
-
const staker = new PublicKey(params.staker);
|
|
3096
|
-
const oracle = new PublicKey(params.oracle);
|
|
3097
|
-
const [stakePositionPda] = deriveOracleStakePda({
|
|
3098
|
-
programId,
|
|
3099
|
-
oracle,
|
|
3100
|
-
staker,
|
|
3101
|
-
});
|
|
3102
|
-
const instruction = new TransactionInstruction({
|
|
3103
|
-
programId,
|
|
3104
|
-
keys: [
|
|
3105
|
-
{ pubkey: staker, isSigner: true, isWritable: false },
|
|
3106
|
-
{ pubkey: stakePositionPda, isSigner: false, isWritable: true },
|
|
3107
|
-
{ pubkey: new PublicKey(params.stakeVault), isSigner: false, isWritable: true },
|
|
3108
|
-
{ pubkey: new PublicKey(params.destinationTokenAccount), isSigner: false, isWritable: true },
|
|
3109
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3110
|
-
],
|
|
3111
|
-
data: IX_FINALIZE_UNSTAKE,
|
|
3112
|
-
});
|
|
3113
|
-
return new Transaction({
|
|
3114
|
-
feePayer: staker,
|
|
3115
|
-
recentBlockhash: params.recentBlockhash,
|
|
3116
|
-
}).add(instruction);
|
|
3117
|
-
},
|
|
3118
|
-
buildSlashOracleTx(params) {
|
|
3119
|
-
const governanceAuthority = new PublicKey(params.governanceAuthority);
|
|
3120
|
-
const oracle = new PublicKey(params.oracle);
|
|
3121
|
-
const staker = new PublicKey(params.staker);
|
|
3122
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3123
|
-
const [stakePositionPda] = deriveOracleStakePda({
|
|
3124
|
-
programId,
|
|
3125
|
-
oracle,
|
|
3126
|
-
staker,
|
|
3127
|
-
});
|
|
3128
|
-
const instruction = new TransactionInstruction({
|
|
3129
|
-
programId,
|
|
3130
|
-
keys: [
|
|
3131
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: false },
|
|
3132
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3133
|
-
{ pubkey: stakePositionPda, isSigner: false, isWritable: true },
|
|
3134
|
-
{ pubkey: new PublicKey(params.stakeVault), isSigner: false, isWritable: true },
|
|
3135
|
-
{ pubkey: new PublicKey(params.slashTreasuryTokenAccount), isSigner: false, isWritable: true },
|
|
3136
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3137
|
-
],
|
|
3138
|
-
data: encodeSlashOracleData(params),
|
|
3139
|
-
});
|
|
3140
|
-
return new Transaction({
|
|
3141
|
-
feePayer: governanceAuthority,
|
|
3142
|
-
recentBlockhash: params.recentBlockhash,
|
|
3143
|
-
}).add(instruction);
|
|
3144
|
-
},
|
|
3145
|
-
buildCreatePoolV2Tx(params) {
|
|
3146
|
-
const authority = new PublicKey(params.authority);
|
|
3147
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3148
|
-
const [poolAddress] = derivePoolPda({
|
|
3149
|
-
programId,
|
|
3150
|
-
authority,
|
|
3151
|
-
poolId: params.poolId,
|
|
3152
|
-
});
|
|
3153
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
3154
|
-
programId,
|
|
3155
|
-
poolAddress,
|
|
3156
|
-
});
|
|
3157
|
-
const [oraclePolicyPda] = derivePoolOraclePolicyPda({
|
|
3158
|
-
programId,
|
|
3159
|
-
poolAddress,
|
|
3160
|
-
});
|
|
3161
|
-
const instruction = new TransactionInstruction({
|
|
3162
|
-
programId,
|
|
3163
|
-
keys: [
|
|
3164
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3165
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3166
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
3167
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: true },
|
|
3168
|
-
{ pubkey: oraclePolicyPda, isSigner: false, isWritable: true },
|
|
3169
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3170
|
-
],
|
|
3171
|
-
data: encodeCreatePoolV2Data(params),
|
|
3172
|
-
});
|
|
3173
|
-
return new Transaction({
|
|
3174
|
-
feePayer: authority,
|
|
3175
|
-
recentBlockhash: params.recentBlockhash,
|
|
3176
|
-
}).add(instruction);
|
|
3177
|
-
},
|
|
3178
|
-
buildSetPoolOraclePolicyTx(params) {
|
|
3179
|
-
const authority = new PublicKey(params.authority);
|
|
3180
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3181
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3182
|
-
const [oraclePolicyPda] = derivePoolOraclePolicyPda({
|
|
3183
|
-
programId,
|
|
3184
|
-
poolAddress,
|
|
3185
|
-
});
|
|
3186
|
-
const instruction = new TransactionInstruction({
|
|
3187
|
-
programId,
|
|
3188
|
-
keys: [
|
|
3189
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
3190
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3191
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3192
|
-
{ pubkey: oraclePolicyPda, isSigner: false, isWritable: true },
|
|
3193
|
-
],
|
|
3194
|
-
data: encodeSetPoolOraclePolicyData(params),
|
|
3195
|
-
});
|
|
3196
|
-
return new Transaction({
|
|
3197
|
-
feePayer: authority,
|
|
3198
|
-
recentBlockhash: params.recentBlockhash,
|
|
3199
|
-
}).add(instruction);
|
|
3200
|
-
},
|
|
3201
|
-
buildSetPoolOraclePermissionsTx(params) {
|
|
3202
|
-
const authority = new PublicKey(params.authority);
|
|
3203
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3204
|
-
const oracle = new PublicKey(params.oracle);
|
|
3205
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
3206
|
-
programId,
|
|
3207
|
-
oracle,
|
|
3208
|
-
});
|
|
3209
|
-
const [poolOraclePda] = derivePoolOraclePda({
|
|
3210
|
-
programId,
|
|
3211
|
-
poolAddress,
|
|
3212
|
-
oracle,
|
|
3213
|
-
});
|
|
3214
|
-
const [poolOraclePermissionsPda] = derivePoolOraclePermissionSetPda({
|
|
3215
|
-
programId,
|
|
3216
|
-
poolAddress,
|
|
3217
|
-
oracle,
|
|
3218
|
-
});
|
|
3219
|
-
const instruction = new TransactionInstruction({
|
|
3220
|
-
programId,
|
|
3221
|
-
keys: [
|
|
3222
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3223
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3224
|
-
{ pubkey: oracle, isSigner: false, isWritable: false },
|
|
3225
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: false },
|
|
3226
|
-
{ pubkey: poolOraclePda, isSigner: false, isWritable: false },
|
|
3227
|
-
{ pubkey: poolOraclePermissionsPda, isSigner: false, isWritable: true },
|
|
3228
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3229
|
-
],
|
|
3230
|
-
data: encodeSetPoolOraclePermissionsData(params),
|
|
3231
|
-
});
|
|
3232
|
-
return new Transaction({
|
|
3233
|
-
feePayer: authority,
|
|
3234
|
-
recentBlockhash: params.recentBlockhash,
|
|
3235
|
-
}).add(instruction);
|
|
3236
|
-
},
|
|
3237
|
-
buildSetPoolCoverageReserveFloorTx(params) {
|
|
3238
|
-
const authority = new PublicKey(params.authority);
|
|
3239
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3240
|
-
const paymentMint = new PublicKey(params.paymentMint);
|
|
3241
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3242
|
-
const [poolTreasuryReservePda] = derivePoolTreasuryReservePda({
|
|
3243
|
-
programId,
|
|
3244
|
-
poolAddress,
|
|
3245
|
-
paymentMint,
|
|
3246
|
-
});
|
|
3247
|
-
const instruction = new TransactionInstruction({
|
|
3248
|
-
programId,
|
|
3249
|
-
keys: [
|
|
3250
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3251
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3252
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3253
|
-
{ pubkey: poolTreasuryReservePda, isSigner: false, isWritable: true },
|
|
3254
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3255
|
-
],
|
|
3256
|
-
data: encodeSetPoolCoverageReserveFloorData(params),
|
|
3257
|
-
});
|
|
3258
|
-
return new Transaction({
|
|
3259
|
-
feePayer: authority,
|
|
3260
|
-
recentBlockhash: params.recentBlockhash,
|
|
3261
|
-
}).add(instruction);
|
|
3262
|
-
},
|
|
3263
|
-
buildSetPoolTermsHashTx(params) {
|
|
3264
|
-
const authority = new PublicKey(params.authority);
|
|
3265
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3266
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
3267
|
-
programId,
|
|
3268
|
-
poolAddress,
|
|
3269
|
-
});
|
|
3270
|
-
const instruction = new TransactionInstruction({
|
|
3271
|
-
programId,
|
|
3272
|
-
keys: [
|
|
3273
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
3274
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3275
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: true },
|
|
3276
|
-
],
|
|
3277
|
-
data: encodeSetPoolTermsHashData(params),
|
|
3278
|
-
});
|
|
3279
|
-
return new Transaction({
|
|
3280
|
-
feePayer: authority,
|
|
3281
|
-
recentBlockhash: params.recentBlockhash,
|
|
3282
|
-
}).add(instruction);
|
|
3283
|
-
},
|
|
3284
|
-
buildRegisterOutcomeSchemaTx(params) {
|
|
3285
|
-
const publisher = new PublicKey(params.publisher);
|
|
3286
|
-
const schemaKeyHash = fromHex(params.schemaKeyHashHex, 32);
|
|
3287
|
-
const [schemaPda] = deriveSchemaPda({
|
|
3288
|
-
programId,
|
|
3289
|
-
schemaKeyHash,
|
|
3290
|
-
});
|
|
3291
|
-
const instruction = new TransactionInstruction({
|
|
3292
|
-
programId,
|
|
3293
|
-
keys: [
|
|
3294
|
-
{ pubkey: publisher, isSigner: true, isWritable: true },
|
|
3295
|
-
{ pubkey: schemaPda, isSigner: false, isWritable: true },
|
|
3296
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3297
|
-
],
|
|
3298
|
-
data: encodeRegisterOutcomeSchemaData(params),
|
|
3299
|
-
});
|
|
3300
|
-
return new Transaction({
|
|
3301
|
-
feePayer: publisher,
|
|
3302
|
-
recentBlockhash: params.recentBlockhash,
|
|
3303
|
-
}).add(instruction);
|
|
3304
|
-
},
|
|
3305
|
-
buildVerifyOutcomeSchemaTx(params) {
|
|
3306
|
-
const governanceAuthority = new PublicKey(params.governanceAuthority);
|
|
3307
|
-
const schemaKeyHash = fromHex(params.schemaKeyHashHex, 32);
|
|
3308
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3309
|
-
const [schemaPda] = deriveSchemaPda({
|
|
3310
|
-
programId,
|
|
3311
|
-
schemaKeyHash,
|
|
3312
|
-
});
|
|
3313
|
-
const instruction = new TransactionInstruction({
|
|
3314
|
-
programId,
|
|
3315
|
-
keys: [
|
|
3316
|
-
{ pubkey: governanceAuthority, isSigner: true, isWritable: false },
|
|
3317
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3318
|
-
{ pubkey: schemaPda, isSigner: false, isWritable: true },
|
|
3319
|
-
],
|
|
3320
|
-
data: encodeVerifyOutcomeSchemaData(params),
|
|
3321
|
-
});
|
|
3322
|
-
return new Transaction({
|
|
3323
|
-
feePayer: governanceAuthority,
|
|
3324
|
-
recentBlockhash: params.recentBlockhash,
|
|
3325
|
-
}).add(instruction);
|
|
3326
|
-
},
|
|
3327
|
-
buildSetPoolOutcomeRuleTx(params) {
|
|
3328
|
-
const authority = new PublicKey(params.authority);
|
|
3329
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3330
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
3331
|
-
const schemaKeyHash = fromHex(params.schemaKeyHashHex, 32);
|
|
3332
|
-
const [schemaPda] = deriveSchemaPda({
|
|
3333
|
-
programId,
|
|
3334
|
-
schemaKeyHash,
|
|
3335
|
-
});
|
|
3336
|
-
const [poolRulePda] = derivePoolRulePda({
|
|
3337
|
-
programId,
|
|
3338
|
-
poolAddress,
|
|
3339
|
-
ruleHash,
|
|
3340
|
-
});
|
|
3341
|
-
const instruction = new TransactionInstruction({
|
|
3342
|
-
programId,
|
|
3343
|
-
keys: [
|
|
3344
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3345
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3346
|
-
{ pubkey: schemaPda, isSigner: false, isWritable: false },
|
|
3347
|
-
{ pubkey: poolRulePda, isSigner: false, isWritable: true },
|
|
3348
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3349
|
-
],
|
|
3350
|
-
data: encodeSetPoolOutcomeRuleData(params),
|
|
3351
|
-
});
|
|
3352
|
-
return new Transaction({
|
|
3353
|
-
feePayer: authority,
|
|
3354
|
-
recentBlockhash: params.recentBlockhash,
|
|
3355
|
-
}).add(instruction);
|
|
3356
|
-
},
|
|
3357
|
-
buildRegisterInviteIssuerTx(params) {
|
|
3358
|
-
const issuer = new PublicKey(params.issuer);
|
|
3359
|
-
const [inviteIssuerPda] = deriveInviteIssuerPda({
|
|
3360
|
-
programId,
|
|
3361
|
-
issuer,
|
|
3362
|
-
});
|
|
3363
|
-
const instruction = new TransactionInstruction({
|
|
3364
|
-
programId,
|
|
3365
|
-
keys: [
|
|
3366
|
-
{ pubkey: issuer, isSigner: true, isWritable: true },
|
|
3367
|
-
{ pubkey: inviteIssuerPda, isSigner: false, isWritable: true },
|
|
3368
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3369
|
-
],
|
|
3370
|
-
data: encodeRegisterInviteIssuerData(params),
|
|
3371
|
-
});
|
|
3372
|
-
return new Transaction({
|
|
3373
|
-
feePayer: issuer,
|
|
3374
|
-
recentBlockhash: params.recentBlockhash,
|
|
3375
|
-
}).add(instruction);
|
|
3376
|
-
},
|
|
3377
|
-
buildEnrollMemberOpenTx(params) {
|
|
3378
|
-
const member = new PublicKey(params.member);
|
|
3379
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3380
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3381
|
-
programId,
|
|
3382
|
-
poolAddress,
|
|
3383
|
-
member,
|
|
3384
|
-
});
|
|
3385
|
-
const instruction = new TransactionInstruction({
|
|
3386
|
-
programId,
|
|
3387
|
-
keys: [
|
|
3388
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
3389
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3390
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: true },
|
|
3391
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3392
|
-
],
|
|
3393
|
-
data: encodeEnrollMemberOpenData(params),
|
|
3394
|
-
});
|
|
3395
|
-
return new Transaction({
|
|
3396
|
-
feePayer: member,
|
|
3397
|
-
recentBlockhash: params.recentBlockhash,
|
|
3398
|
-
}).add(instruction);
|
|
3399
|
-
},
|
|
3400
|
-
buildEnrollMemberTokenGateTx(params) {
|
|
3401
|
-
const member = new PublicKey(params.member);
|
|
3402
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3403
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3404
|
-
programId,
|
|
3405
|
-
poolAddress,
|
|
3406
|
-
member,
|
|
3407
|
-
});
|
|
3408
|
-
const instruction = new TransactionInstruction({
|
|
3409
|
-
programId,
|
|
3410
|
-
keys: [
|
|
3411
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
3412
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3413
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: true },
|
|
3414
|
-
{ pubkey: new PublicKey(params.tokenGateAccount), isSigner: false, isWritable: false },
|
|
3415
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3416
|
-
],
|
|
3417
|
-
data: encodeEnrollMemberTokenGateData(params),
|
|
3418
|
-
});
|
|
3419
|
-
return new Transaction({
|
|
3420
|
-
feePayer: member,
|
|
3421
|
-
recentBlockhash: params.recentBlockhash,
|
|
3422
|
-
}).add(instruction);
|
|
3423
|
-
},
|
|
3424
|
-
buildEnrollMemberInvitePermitTx(params) {
|
|
3425
|
-
const member = new PublicKey(params.member);
|
|
3426
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3427
|
-
const issuer = new PublicKey(params.issuer);
|
|
3428
|
-
const nonceHash = fromHex(params.nonceHashHex, 32);
|
|
3429
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3430
|
-
programId,
|
|
3431
|
-
poolAddress,
|
|
3432
|
-
member,
|
|
3433
|
-
});
|
|
3434
|
-
const [inviteIssuerPda] = deriveInviteIssuerPda({
|
|
3435
|
-
programId,
|
|
3436
|
-
issuer,
|
|
3437
|
-
});
|
|
3438
|
-
const [replayPda] = deriveEnrollmentReplayPda({
|
|
3439
|
-
programId,
|
|
3440
|
-
poolAddress,
|
|
3441
|
-
member,
|
|
3442
|
-
nonceHash,
|
|
3443
|
-
});
|
|
3444
|
-
const instruction = new TransactionInstruction({
|
|
3445
|
-
programId,
|
|
3446
|
-
keys: [
|
|
3447
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
3448
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3449
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: true },
|
|
3450
|
-
{ pubkey: issuer, isSigner: true, isWritable: false },
|
|
3451
|
-
{ pubkey: inviteIssuerPda, isSigner: false, isWritable: false },
|
|
3452
|
-
{ pubkey: replayPda, isSigner: false, isWritable: true },
|
|
3453
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3454
|
-
],
|
|
3455
|
-
data: encodeEnrollMemberInvitePermitData(params),
|
|
3456
|
-
});
|
|
3457
|
-
return new Transaction({
|
|
3458
|
-
feePayer: member,
|
|
3459
|
-
recentBlockhash: params.recentBlockhash,
|
|
3460
|
-
}).add(instruction);
|
|
3461
|
-
},
|
|
3462
|
-
buildSetClaimDelegateTx(params) {
|
|
3463
|
-
const member = new PublicKey(params.member);
|
|
3464
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3465
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3466
|
-
programId,
|
|
3467
|
-
poolAddress,
|
|
3468
|
-
member,
|
|
3469
|
-
});
|
|
3470
|
-
const [claimDelegatePda] = deriveClaimDelegatePda({
|
|
3471
|
-
programId,
|
|
3472
|
-
poolAddress,
|
|
3473
|
-
member,
|
|
3474
|
-
});
|
|
3475
|
-
const instruction = new TransactionInstruction({
|
|
3476
|
-
programId,
|
|
3477
|
-
keys: [
|
|
3478
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
3479
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3480
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
3481
|
-
{ pubkey: claimDelegatePda, isSigner: false, isWritable: true },
|
|
3482
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3483
|
-
],
|
|
3484
|
-
data: encodeSetClaimDelegateData(params),
|
|
3485
|
-
});
|
|
3486
|
-
return new Transaction({
|
|
3487
|
-
feePayer: member,
|
|
3488
|
-
recentBlockhash: params.recentBlockhash,
|
|
3489
|
-
}).add(instruction);
|
|
3490
|
-
},
|
|
3491
|
-
buildFundPoolSolTx(params) {
|
|
3492
|
-
const funder = new PublicKey(params.funder);
|
|
3493
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3494
|
-
const instruction = new TransactionInstruction({
|
|
3495
|
-
programId,
|
|
3496
|
-
keys: [
|
|
3497
|
-
{ pubkey: funder, isSigner: true, isWritable: true },
|
|
3498
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
3499
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3500
|
-
],
|
|
3501
|
-
data: encodeFundPoolSolData(params),
|
|
3502
|
-
});
|
|
3503
|
-
return new Transaction({
|
|
3504
|
-
feePayer: funder,
|
|
3505
|
-
recentBlockhash: params.recentBlockhash,
|
|
3506
|
-
}).add(instruction);
|
|
3507
|
-
},
|
|
3508
|
-
buildFundPoolSplTx(params) {
|
|
3509
|
-
const funder = new PublicKey(params.funder);
|
|
3510
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3511
|
-
const payoutMint = new PublicKey(params.payoutMint);
|
|
3512
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
3513
|
-
programId,
|
|
3514
|
-
poolAddress,
|
|
3515
|
-
});
|
|
3516
|
-
const [poolAssetVaultPda] = derivePoolAssetVaultPda({
|
|
3517
|
-
programId,
|
|
3518
|
-
poolAddress,
|
|
3519
|
-
payoutMint,
|
|
3520
|
-
});
|
|
3521
|
-
const instruction = new TransactionInstruction({
|
|
3522
|
-
programId,
|
|
3523
|
-
keys: [
|
|
3524
|
-
{ pubkey: funder, isSigner: true, isWritable: true },
|
|
3525
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3526
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
3527
|
-
{ pubkey: payoutMint, isSigner: false, isWritable: true },
|
|
3528
|
-
{ pubkey: poolAssetVaultPda, isSigner: false, isWritable: true },
|
|
3529
|
-
{ pubkey: new PublicKey(params.poolVaultTokenAccount), isSigner: true, isWritable: true },
|
|
3530
|
-
{ pubkey: new PublicKey(params.funderTokenAccount), isSigner: false, isWritable: true },
|
|
3531
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3532
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3533
|
-
],
|
|
3534
|
-
data: encodeFundPoolSplData(params),
|
|
3535
|
-
});
|
|
3536
|
-
return new Transaction({
|
|
3537
|
-
feePayer: funder,
|
|
3538
|
-
recentBlockhash: params.recentBlockhash,
|
|
3539
|
-
}).add(instruction);
|
|
3540
|
-
},
|
|
3541
|
-
buildSubmitRewardClaimTx(params) {
|
|
3542
|
-
validateRewardClaimOptionalAccounts(params);
|
|
3543
|
-
const claimant = new PublicKey(params.claimant);
|
|
3544
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3545
|
-
const member = new PublicKey(params.member);
|
|
3546
|
-
const payoutMint = new PublicKey(params.payoutMint);
|
|
3547
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
3548
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
3549
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3550
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
3551
|
-
programId,
|
|
3552
|
-
poolAddress,
|
|
3553
|
-
});
|
|
3554
|
-
const [oraclePolicyPda] = derivePoolOraclePolicyPda({
|
|
3555
|
-
programId,
|
|
3556
|
-
poolAddress,
|
|
3557
|
-
});
|
|
3558
|
-
const [poolTreasuryReservePda] = derivePoolTreasuryReservePda({
|
|
3559
|
-
programId,
|
|
3560
|
-
poolAddress,
|
|
3561
|
-
paymentMint: payoutMint,
|
|
3562
|
-
});
|
|
3563
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3564
|
-
programId,
|
|
3565
|
-
poolAddress,
|
|
3566
|
-
member,
|
|
3567
|
-
});
|
|
3568
|
-
const [aggregatePda] = deriveOutcomeAggregatePda({
|
|
3569
|
-
programId,
|
|
3570
|
-
poolAddress,
|
|
3571
|
-
member,
|
|
3572
|
-
cycleHash,
|
|
3573
|
-
ruleHash,
|
|
3574
|
-
});
|
|
3575
|
-
const [claimRecordPda] = deriveClaimV2Pda({
|
|
3576
|
-
programId,
|
|
3577
|
-
poolAddress,
|
|
3578
|
-
member,
|
|
3579
|
-
cycleHash,
|
|
3580
|
-
ruleHash,
|
|
3581
|
-
});
|
|
3582
|
-
const [claimDelegatePda] = deriveClaimDelegatePda({
|
|
3583
|
-
programId,
|
|
3584
|
-
poolAddress,
|
|
3585
|
-
member,
|
|
3586
|
-
});
|
|
3587
|
-
const optionPlaceholder = programId;
|
|
3588
|
-
const claimDelegateAccount = params.claimDelegate ? claimDelegatePda : optionPlaceholder;
|
|
3589
|
-
const poolAssetVaultAccount = params.poolAssetVault
|
|
3590
|
-
? new PublicKey(params.poolAssetVault)
|
|
3591
|
-
: optionPlaceholder;
|
|
3592
|
-
const poolVaultTokenAccount = params.poolVaultTokenAccount
|
|
3593
|
-
? new PublicKey(params.poolVaultTokenAccount)
|
|
3594
|
-
: optionPlaceholder;
|
|
3595
|
-
const recipientTokenAccount = params.recipientTokenAccount
|
|
3596
|
-
? new PublicKey(params.recipientTokenAccount)
|
|
3597
|
-
: optionPlaceholder;
|
|
3598
|
-
const instruction = new TransactionInstruction({
|
|
3599
|
-
programId,
|
|
3600
|
-
keys: [
|
|
3601
|
-
{ pubkey: claimant, isSigner: true, isWritable: true },
|
|
3602
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3603
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
3604
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
3605
|
-
{ pubkey: oraclePolicyPda, isSigner: false, isWritable: false },
|
|
3606
|
-
{ pubkey: poolTreasuryReservePda, isSigner: false, isWritable: true },
|
|
3607
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
3608
|
-
{ pubkey: aggregatePda, isSigner: false, isWritable: true },
|
|
3609
|
-
{ pubkey: new PublicKey(params.recipientSystemAccount), isSigner: false, isWritable: true },
|
|
3610
|
-
{ pubkey: claimDelegateAccount, isSigner: false, isWritable: false },
|
|
3611
|
-
{ pubkey: poolAssetVaultAccount, isSigner: false, isWritable: false },
|
|
3612
|
-
{ pubkey: poolVaultTokenAccount, isSigner: false, isWritable: params.poolVaultTokenAccount != null },
|
|
3613
|
-
{ pubkey: recipientTokenAccount, isSigner: false, isWritable: params.recipientTokenAccount != null },
|
|
3614
|
-
{ pubkey: claimRecordPda, isSigner: false, isWritable: true },
|
|
3615
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3616
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3617
|
-
],
|
|
3618
|
-
data: encodeSubmitRewardClaimData(params),
|
|
3619
|
-
});
|
|
3620
|
-
return new Transaction({
|
|
3621
|
-
feePayer: claimant,
|
|
3622
|
-
recentBlockhash: params.recentBlockhash,
|
|
3623
|
-
}).add(instruction);
|
|
3624
|
-
},
|
|
3625
|
-
buildRegisterCoverageProductV2Tx(params) {
|
|
3626
|
-
const authority = new PublicKey(params.authority);
|
|
3627
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3628
|
-
const productIdHash = fromHex(params.productIdHashHex, 32);
|
|
3629
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3630
|
-
const [coverageProductPda] = deriveCoverageProductPda({
|
|
3631
|
-
programId,
|
|
3632
|
-
poolAddress,
|
|
3633
|
-
productIdHash,
|
|
3634
|
-
});
|
|
3635
|
-
const instruction = new TransactionInstruction({
|
|
3636
|
-
programId,
|
|
3637
|
-
keys: [
|
|
3638
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3639
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3640
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3641
|
-
{ pubkey: coverageProductPda, isSigner: false, isWritable: true },
|
|
3642
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3643
|
-
],
|
|
3644
|
-
data: encodeRegisterCoverageProductV2Data(params),
|
|
3645
|
-
});
|
|
3646
|
-
return new Transaction({
|
|
3647
|
-
feePayer: authority,
|
|
3648
|
-
recentBlockhash: params.recentBlockhash,
|
|
3649
|
-
}).add(instruction);
|
|
3650
|
-
},
|
|
3651
|
-
buildUpsertCoverageProductPaymentOptionTx(params) {
|
|
3652
|
-
const authority = new PublicKey(params.authority);
|
|
3653
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3654
|
-
const paymentMint = new PublicKey(params.paymentMint);
|
|
3655
|
-
const productIdHash = fromHex(params.productIdHashHex, 32);
|
|
3656
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3657
|
-
const [coverageProductPda] = deriveCoverageProductPda({
|
|
3658
|
-
programId,
|
|
3659
|
-
poolAddress,
|
|
3660
|
-
productIdHash,
|
|
3661
|
-
});
|
|
3662
|
-
const [coverageProductPaymentOptionPda] = deriveCoverageProductPaymentOptionPda({
|
|
3663
|
-
programId,
|
|
3664
|
-
poolAddress,
|
|
3665
|
-
productIdHash,
|
|
3666
|
-
paymentMint,
|
|
3667
|
-
});
|
|
3668
|
-
const instruction = new TransactionInstruction({
|
|
3669
|
-
programId,
|
|
3670
|
-
keys: [
|
|
3671
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3672
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3673
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3674
|
-
{ pubkey: coverageProductPda, isSigner: false, isWritable: true },
|
|
3675
|
-
{ pubkey: paymentMint, isSigner: false, isWritable: false },
|
|
3676
|
-
{ pubkey: coverageProductPaymentOptionPda, isSigner: false, isWritable: true },
|
|
3677
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3678
|
-
],
|
|
3679
|
-
data: encodeUpsertCoverageProductPaymentOptionData(params),
|
|
3680
|
-
});
|
|
3681
|
-
return new Transaction({
|
|
3682
|
-
feePayer: authority,
|
|
3683
|
-
recentBlockhash: params.recentBlockhash,
|
|
3684
|
-
}).add(instruction);
|
|
3685
|
-
},
|
|
3686
|
-
buildUpdateCoverageProductV2Tx(params) {
|
|
3687
|
-
const authority = new PublicKey(params.authority);
|
|
3688
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3689
|
-
const productIdHash = fromHex(params.productIdHashHex, 32);
|
|
3690
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3691
|
-
const [coverageProductPda] = deriveCoverageProductPda({
|
|
3692
|
-
programId,
|
|
3693
|
-
poolAddress,
|
|
3694
|
-
productIdHash,
|
|
3695
|
-
});
|
|
3696
|
-
const instruction = new TransactionInstruction({
|
|
3697
|
-
programId,
|
|
3698
|
-
keys: [
|
|
3699
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
3700
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3701
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3702
|
-
{ pubkey: coverageProductPda, isSigner: false, isWritable: true },
|
|
3703
|
-
],
|
|
3704
|
-
data: encodeUpdateCoverageProductV2Data(params),
|
|
3705
|
-
});
|
|
3706
|
-
return new Transaction({
|
|
3707
|
-
feePayer: authority,
|
|
3708
|
-
recentBlockhash: params.recentBlockhash,
|
|
3709
|
-
}).add(instruction);
|
|
3710
|
-
},
|
|
3711
|
-
buildSubscribeCoverageProductV2Tx(params) {
|
|
3712
|
-
const member = new PublicKey(params.member);
|
|
3713
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3714
|
-
const productIdHash = fromHex(params.productIdHashHex, 32);
|
|
3715
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3716
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3717
|
-
programId,
|
|
3718
|
-
poolAddress,
|
|
3719
|
-
member,
|
|
3720
|
-
});
|
|
3721
|
-
const [coverageProductPda] = deriveCoverageProductPda({
|
|
3722
|
-
programId,
|
|
3723
|
-
poolAddress,
|
|
3724
|
-
productIdHash,
|
|
3725
|
-
});
|
|
3726
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3727
|
-
programId,
|
|
3728
|
-
poolAddress,
|
|
3729
|
-
member,
|
|
3730
|
-
});
|
|
3731
|
-
const [coverageNftPda] = deriveCoverageNftPda({
|
|
3732
|
-
programId,
|
|
3733
|
-
poolAddress,
|
|
3734
|
-
member,
|
|
3735
|
-
});
|
|
3736
|
-
const instruction = new TransactionInstruction({
|
|
3737
|
-
programId,
|
|
3738
|
-
keys: [
|
|
3739
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
3740
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3741
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3742
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
3743
|
-
{ pubkey: coverageProductPda, isSigner: false, isWritable: false },
|
|
3744
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3745
|
-
{ pubkey: coverageNftPda, isSigner: false, isWritable: true },
|
|
3746
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3747
|
-
],
|
|
3748
|
-
data: encodeSubscribeCoverageProductV2Data(params),
|
|
3749
|
-
});
|
|
3750
|
-
return new Transaction({
|
|
3751
|
-
feePayer: member,
|
|
3752
|
-
recentBlockhash: params.recentBlockhash,
|
|
3753
|
-
}).add(instruction);
|
|
3754
|
-
},
|
|
3755
|
-
buildIssueCoveragePolicyFromProductV2Tx(params) {
|
|
3756
|
-
const authority = new PublicKey(params.authority);
|
|
3757
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3758
|
-
const member = new PublicKey(params.member);
|
|
3759
|
-
const productIdHash = fromHex(params.productIdHashHex, 32);
|
|
3760
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3761
|
-
const [membershipPda] = deriveMembershipPda({
|
|
3762
|
-
programId,
|
|
3763
|
-
poolAddress,
|
|
3764
|
-
member,
|
|
3765
|
-
});
|
|
3766
|
-
const [coverageProductPda] = deriveCoverageProductPda({
|
|
3767
|
-
programId,
|
|
3768
|
-
poolAddress,
|
|
3769
|
-
productIdHash,
|
|
3770
|
-
});
|
|
3771
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3772
|
-
programId,
|
|
3773
|
-
poolAddress,
|
|
3774
|
-
member,
|
|
3775
|
-
});
|
|
3776
|
-
const [coverageNftPda] = deriveCoverageNftPda({
|
|
3777
|
-
programId,
|
|
3778
|
-
poolAddress,
|
|
3779
|
-
member,
|
|
3780
|
-
});
|
|
3781
|
-
const instruction = new TransactionInstruction({
|
|
3782
|
-
programId,
|
|
3783
|
-
keys: [
|
|
3784
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3785
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3786
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3787
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
3788
|
-
{ pubkey: coverageProductPda, isSigner: false, isWritable: false },
|
|
3789
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3790
|
-
{ pubkey: coverageNftPda, isSigner: false, isWritable: true },
|
|
3791
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3792
|
-
],
|
|
3793
|
-
data: encodeIssueCoveragePolicyFromProductV2Data(params),
|
|
3794
|
-
});
|
|
3795
|
-
return new Transaction({
|
|
3796
|
-
feePayer: authority,
|
|
3797
|
-
recentBlockhash: params.recentBlockhash,
|
|
3798
|
-
}).add(instruction);
|
|
3799
|
-
},
|
|
3800
|
-
buildCreateCoveragePolicyTx(params) {
|
|
3801
|
-
const authority = new PublicKey(params.authority);
|
|
3802
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3803
|
-
const member = new PublicKey(params.member);
|
|
3804
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3805
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3806
|
-
programId,
|
|
3807
|
-
poolAddress,
|
|
3808
|
-
member,
|
|
3809
|
-
});
|
|
3810
|
-
const [coverageNftPda] = deriveCoverageNftPda({
|
|
3811
|
-
programId,
|
|
3812
|
-
poolAddress,
|
|
3813
|
-
member,
|
|
3814
|
-
});
|
|
3815
|
-
const instruction = new TransactionInstruction({
|
|
3816
|
-
programId,
|
|
3817
|
-
keys: [
|
|
3818
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
3819
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3820
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3821
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3822
|
-
{ pubkey: coverageNftPda, isSigner: false, isWritable: true },
|
|
3823
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3824
|
-
],
|
|
3825
|
-
data: encodeCreateCoveragePolicyData(params),
|
|
3826
|
-
});
|
|
3827
|
-
return new Transaction({
|
|
3828
|
-
feePayer: authority,
|
|
3829
|
-
recentBlockhash: params.recentBlockhash,
|
|
3830
|
-
}).add(instruction);
|
|
3831
|
-
},
|
|
3832
|
-
buildMintPolicyNftTx(params) {
|
|
3833
|
-
const authority = new PublicKey(params.authority);
|
|
3834
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3835
|
-
const member = new PublicKey(params.member);
|
|
3836
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3837
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3838
|
-
programId,
|
|
3839
|
-
poolAddress,
|
|
3840
|
-
member,
|
|
3841
|
-
});
|
|
3842
|
-
const [coverageNftPda] = deriveCoverageNftPda({
|
|
3843
|
-
programId,
|
|
3844
|
-
poolAddress,
|
|
3845
|
-
member,
|
|
3846
|
-
});
|
|
3847
|
-
const instruction = new TransactionInstruction({
|
|
3848
|
-
programId,
|
|
3849
|
-
keys: [
|
|
3850
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
3851
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3852
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3853
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3854
|
-
{ pubkey: coverageNftPda, isSigner: false, isWritable: true },
|
|
3855
|
-
],
|
|
3856
|
-
data: encodeMintPolicyNftData(params),
|
|
3857
|
-
});
|
|
3858
|
-
return new Transaction({
|
|
3859
|
-
feePayer: authority,
|
|
3860
|
-
recentBlockhash: params.recentBlockhash,
|
|
3861
|
-
}).add(instruction);
|
|
3862
|
-
},
|
|
3863
|
-
buildPayPremiumOnchainTx(params) {
|
|
3864
|
-
const payer = new PublicKey(params.payer);
|
|
3865
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3866
|
-
const member = new PublicKey(params.member);
|
|
3867
|
-
const payoutMint = new PublicKey(params.payoutMint);
|
|
3868
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3869
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
3870
|
-
programId,
|
|
3871
|
-
poolAddress,
|
|
3872
|
-
});
|
|
3873
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3874
|
-
programId,
|
|
3875
|
-
poolAddress,
|
|
3876
|
-
member,
|
|
3877
|
-
});
|
|
3878
|
-
const [premiumLedgerPda] = derivePremiumLedgerPda({
|
|
3879
|
-
programId,
|
|
3880
|
-
poolAddress,
|
|
3881
|
-
member,
|
|
3882
|
-
});
|
|
3883
|
-
const [poolAssetVaultPda] = derivePoolAssetVaultPda({
|
|
3884
|
-
programId,
|
|
3885
|
-
poolAddress,
|
|
3886
|
-
payoutMint,
|
|
3887
|
-
});
|
|
3888
|
-
const instruction = new TransactionInstruction({
|
|
3889
|
-
programId,
|
|
3890
|
-
keys: [
|
|
3891
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
3892
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3893
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3894
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
3895
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3896
|
-
{ pubkey: member, isSigner: false, isWritable: false },
|
|
3897
|
-
{ pubkey: premiumLedgerPda, isSigner: false, isWritable: true },
|
|
3898
|
-
{ pubkey: poolAssetVaultPda, isSigner: false, isWritable: false },
|
|
3899
|
-
{ pubkey: new PublicKey(params.payerTokenAccount), isSigner: false, isWritable: true },
|
|
3900
|
-
{ pubkey: new PublicKey(params.poolVaultTokenAccount), isSigner: false, isWritable: true },
|
|
3901
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
3902
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3903
|
-
],
|
|
3904
|
-
data: encodePayPremiumOnchainData(params),
|
|
3905
|
-
});
|
|
3906
|
-
return new Transaction({
|
|
3907
|
-
feePayer: payer,
|
|
3908
|
-
recentBlockhash: params.recentBlockhash,
|
|
3909
|
-
}).add(instruction);
|
|
3910
|
-
},
|
|
3911
|
-
buildAttestPremiumPaidOffchainTx(params) {
|
|
3912
|
-
const oracle = new PublicKey(params.oracle);
|
|
3913
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3914
|
-
const member = new PublicKey(params.member);
|
|
3915
|
-
const replayHash = fromHex(params.replayHashHex, 32);
|
|
3916
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3917
|
-
const [oracleEntryPda] = deriveOraclePda({
|
|
3918
|
-
programId,
|
|
3919
|
-
oracle,
|
|
3920
|
-
});
|
|
3921
|
-
const [poolOraclePda] = derivePoolOraclePda({
|
|
3922
|
-
programId,
|
|
3923
|
-
poolAddress,
|
|
3924
|
-
oracle,
|
|
3925
|
-
});
|
|
3926
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3927
|
-
programId,
|
|
3928
|
-
poolAddress,
|
|
3929
|
-
member,
|
|
3930
|
-
});
|
|
3931
|
-
const [premiumLedgerPda] = derivePremiumLedgerPda({
|
|
3932
|
-
programId,
|
|
3933
|
-
poolAddress,
|
|
3934
|
-
member,
|
|
3935
|
-
});
|
|
3936
|
-
const [premiumReplayPda] = derivePremiumReplayPda({
|
|
3937
|
-
programId,
|
|
3938
|
-
poolAddress,
|
|
3939
|
-
member,
|
|
3940
|
-
replayHash,
|
|
3941
|
-
});
|
|
3942
|
-
const instruction = new TransactionInstruction({
|
|
3943
|
-
programId,
|
|
3944
|
-
keys: [
|
|
3945
|
-
{ pubkey: oracle, isSigner: true, isWritable: true },
|
|
3946
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3947
|
-
{ pubkey: oracleEntryPda, isSigner: false, isWritable: false },
|
|
3948
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3949
|
-
{ pubkey: poolOraclePda, isSigner: false, isWritable: false },
|
|
3950
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3951
|
-
{ pubkey: premiumLedgerPda, isSigner: false, isWritable: true },
|
|
3952
|
-
{ pubkey: premiumReplayPda, isSigner: false, isWritable: true },
|
|
3953
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3954
|
-
],
|
|
3955
|
-
data: encodeAttestPremiumPaidOffchainData(params),
|
|
3956
|
-
});
|
|
3957
|
-
return new Transaction({
|
|
3958
|
-
feePayer: oracle,
|
|
3959
|
-
recentBlockhash: params.recentBlockhash,
|
|
3960
|
-
}).add(instruction);
|
|
3961
|
-
},
|
|
3962
|
-
buildSubmitCoverageClaimTx(params) {
|
|
3963
|
-
const claimant = new PublicKey(params.claimant);
|
|
3964
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
3965
|
-
const member = new PublicKey(params.member);
|
|
3966
|
-
const intentHash = fromHex(params.intentHashHex, 32);
|
|
3967
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
3968
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
3969
|
-
programId,
|
|
3970
|
-
poolAddress,
|
|
3971
|
-
member,
|
|
3972
|
-
});
|
|
3973
|
-
const [claimDelegatePda] = deriveClaimDelegatePda({
|
|
3974
|
-
programId,
|
|
3975
|
-
poolAddress,
|
|
3976
|
-
member,
|
|
3977
|
-
});
|
|
3978
|
-
const [coverageClaimPda] = deriveCoverageClaimPda({
|
|
3979
|
-
programId,
|
|
3980
|
-
poolAddress,
|
|
3981
|
-
member,
|
|
3982
|
-
intentHash,
|
|
3983
|
-
});
|
|
3984
|
-
const claimDelegateAccount = params.claimDelegate ? claimDelegatePda : programId;
|
|
3985
|
-
const instruction = new TransactionInstruction({
|
|
3986
|
-
programId,
|
|
3987
|
-
keys: [
|
|
3988
|
-
{ pubkey: claimant, isSigner: true, isWritable: true },
|
|
3989
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
3990
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
3991
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
3992
|
-
{ pubkey: claimDelegateAccount, isSigner: false, isWritable: false },
|
|
3993
|
-
{ pubkey: coverageClaimPda, isSigner: false, isWritable: true },
|
|
3994
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
3995
|
-
],
|
|
3996
|
-
data: encodeSubmitCoverageClaimData(params),
|
|
3997
|
-
});
|
|
3998
|
-
return new Transaction({
|
|
3999
|
-
feePayer: claimant,
|
|
4000
|
-
recentBlockhash: params.recentBlockhash,
|
|
4001
|
-
}).add(instruction);
|
|
4002
|
-
},
|
|
4003
|
-
buildSettleCoverageClaimTx(params) {
|
|
4004
|
-
const authority = new PublicKey(params.authority);
|
|
4005
|
-
const claimant = new PublicKey(params.claimant);
|
|
4006
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
4007
|
-
const member = new PublicKey(params.member);
|
|
4008
|
-
const intentHash = fromHex(params.intentHashHex, 32);
|
|
4009
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
4010
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
4011
|
-
programId,
|
|
4012
|
-
poolAddress,
|
|
4013
|
-
});
|
|
4014
|
-
const [coveragePolicyPda] = deriveCoveragePolicyPda({
|
|
4015
|
-
programId,
|
|
4016
|
-
poolAddress,
|
|
4017
|
-
member,
|
|
4018
|
-
});
|
|
4019
|
-
const [coverageClaimPda] = deriveCoverageClaimPda({
|
|
4020
|
-
programId,
|
|
4021
|
-
poolAddress,
|
|
4022
|
-
member,
|
|
4023
|
-
intentHash,
|
|
4024
|
-
});
|
|
4025
|
-
const instruction = new TransactionInstruction({
|
|
4026
|
-
programId,
|
|
4027
|
-
keys: [
|
|
4028
|
-
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
4029
|
-
{ pubkey: claimant, isSigner: true, isWritable: false },
|
|
4030
|
-
{ pubkey: configV2Pda, isSigner: false, isWritable: false },
|
|
4031
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: true },
|
|
4032
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: false },
|
|
4033
|
-
{ pubkey: coveragePolicyPda, isSigner: false, isWritable: true },
|
|
4034
|
-
{ pubkey: coverageClaimPda, isSigner: false, isWritable: true },
|
|
4035
|
-
{ pubkey: new PublicKey(params.recipientSystemAccount), isSigner: false, isWritable: true },
|
|
4036
|
-
{ pubkey: new PublicKey(params.poolAssetVault), isSigner: false, isWritable: false },
|
|
4037
|
-
{ pubkey: new PublicKey(params.poolVaultTokenAccount), isSigner: false, isWritable: true },
|
|
4038
|
-
{ pubkey: new PublicKey(params.recipientTokenAccount), isSigner: false, isWritable: true },
|
|
4039
|
-
{ pubkey: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), isSigner: false, isWritable: false },
|
|
4040
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
4041
|
-
],
|
|
4042
|
-
data: encodeSettleCoverageClaimData(params),
|
|
4043
|
-
});
|
|
4044
|
-
return new Transaction({
|
|
4045
|
-
feePayer: authority,
|
|
4046
|
-
recentBlockhash: params.recentBlockhash,
|
|
4047
|
-
}).add(instruction);
|
|
4048
|
-
},
|
|
4049
|
-
buildMigratePoolV1ToV2Tx(params) {
|
|
4050
|
-
const authority = new PublicKey(params.authority);
|
|
4051
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
4052
|
-
const [poolTermsPda] = derivePoolTermsPda({
|
|
4053
|
-
programId,
|
|
4054
|
-
poolAddress,
|
|
4055
|
-
});
|
|
4056
|
-
const [oraclePolicyPda] = derivePoolOraclePolicyPda({
|
|
4057
|
-
programId,
|
|
4058
|
-
poolAddress,
|
|
4059
|
-
});
|
|
4060
|
-
const instruction = new TransactionInstruction({
|
|
4061
|
-
programId,
|
|
4062
|
-
keys: [
|
|
4063
|
-
{ pubkey: authority, isSigner: true, isWritable: true },
|
|
4064
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
4065
|
-
{ pubkey: poolTermsPda, isSigner: false, isWritable: true },
|
|
4066
|
-
{ pubkey: oraclePolicyPda, isSigner: false, isWritable: true },
|
|
4067
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
4068
|
-
],
|
|
4069
|
-
data: encodeMigratePoolV1ToV2Data(params),
|
|
4070
|
-
});
|
|
4071
|
-
return new Transaction({
|
|
4072
|
-
feePayer: authority,
|
|
4073
|
-
recentBlockhash: params.recentBlockhash,
|
|
4074
|
-
}).add(instruction);
|
|
4075
|
-
},
|
|
4076
|
-
buildMigrateMembershipV1ToV2Tx(params) {
|
|
4077
|
-
const member = new PublicKey(params.member);
|
|
4078
|
-
const poolAddress = new PublicKey(params.poolAddress);
|
|
4079
|
-
const [membershipPda] = deriveMembershipPda({
|
|
4080
|
-
programId,
|
|
4081
|
-
poolAddress,
|
|
4082
|
-
member,
|
|
4083
|
-
});
|
|
4084
|
-
const [claimDelegatePda] = deriveClaimDelegatePda({
|
|
4085
|
-
programId,
|
|
4086
|
-
poolAddress,
|
|
4087
|
-
member,
|
|
4088
|
-
});
|
|
4089
|
-
const instruction = new TransactionInstruction({
|
|
4090
|
-
programId,
|
|
4091
|
-
keys: [
|
|
4092
|
-
{ pubkey: member, isSigner: true, isWritable: true },
|
|
4093
|
-
{ pubkey: poolAddress, isSigner: false, isWritable: false },
|
|
4094
|
-
{ pubkey: membershipPda, isSigner: false, isWritable: false },
|
|
4095
|
-
{ pubkey: claimDelegatePda, isSigner: false, isWritable: true },
|
|
4096
|
-
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
4097
|
-
],
|
|
4098
|
-
data: IX_MIGRATE_MEMBERSHIP_V1_TO_V2,
|
|
4099
|
-
});
|
|
4100
|
-
return new Transaction({
|
|
4101
|
-
feePayer: member,
|
|
4102
|
-
recentBlockhash: params.recentBlockhash,
|
|
4103
|
-
}).add(instruction);
|
|
4104
|
-
},
|
|
4105
|
-
buildActivateCycleWithQuoteSolTx(params) {
|
|
4106
|
-
return buildActivateCycleWithQuoteSolTransaction(params);
|
|
4107
|
-
},
|
|
4108
|
-
buildActivateCycleWithQuoteSplTx(params) {
|
|
4109
|
-
return buildActivateCycleWithQuoteSplTransaction(params);
|
|
4110
|
-
},
|
|
4111
|
-
buildSettleCycleCommitmentTx(params) {
|
|
4112
|
-
return buildSettleCycleCommitmentTransaction(params);
|
|
4113
|
-
},
|
|
4114
|
-
buildSettleCycleCommitmentSolTx(params) {
|
|
4115
|
-
return buildSettleCycleCommitmentSolTransaction(params);
|
|
4116
|
-
},
|
|
4117
|
-
buildWithdrawPoolTreasurySplTx(params) {
|
|
4118
|
-
return buildWithdrawPoolTreasurySplTransaction(params);
|
|
4119
|
-
},
|
|
4120
|
-
buildWithdrawPoolTreasurySolTx(params) {
|
|
4121
|
-
return buildWithdrawPoolTreasurySolTransaction(params);
|
|
4122
|
-
},
|
|
4123
|
-
buildWithdrawProtocolFeeSplTx(params) {
|
|
4124
|
-
return buildWithdrawProtocolFeeSplTransaction(params);
|
|
4125
|
-
},
|
|
4126
|
-
buildWithdrawProtocolFeeSolTx(params) {
|
|
4127
|
-
return buildWithdrawProtocolFeeSolTransaction(params);
|
|
4128
|
-
},
|
|
4129
|
-
buildWithdrawPoolOracleFeeSplTx(params) {
|
|
4130
|
-
return buildWithdrawPoolOracleFeeSplTransaction(params);
|
|
4131
|
-
},
|
|
4132
|
-
buildWithdrawPoolOracleFeeSolTx(params) {
|
|
4133
|
-
return buildWithdrawPoolOracleFeeSolTransaction(params);
|
|
4134
|
-
},
|
|
4135
|
-
async fetchProtocolConfig() {
|
|
4136
|
-
const [configPda] = deriveConfigPda(programId);
|
|
4137
|
-
const account = await connection.getAccountInfo(configPda, 'confirmed');
|
|
4138
|
-
if (!account)
|
|
4139
|
-
return null;
|
|
4140
|
-
return decodeProtocolConfigAccount(configPda.toBase58(), account.data);
|
|
4141
|
-
},
|
|
4142
|
-
async fetchPool(poolAddress) {
|
|
4143
|
-
const address = new PublicKey(poolAddress);
|
|
4144
|
-
const account = await connection.getAccountInfo(address, 'confirmed');
|
|
4145
|
-
if (!account)
|
|
4146
|
-
return null;
|
|
4147
|
-
return decodePoolAccount(address.toBase58(), account.data);
|
|
4148
|
-
},
|
|
4149
|
-
async fetchOracleRegistryEntry(oracle) {
|
|
4150
|
-
const [pda] = deriveOraclePda({
|
|
4151
|
-
programId,
|
|
4152
|
-
oracle,
|
|
4153
|
-
});
|
|
4154
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4155
|
-
if (!account)
|
|
4156
|
-
return null;
|
|
4157
|
-
return decodeOracleRegistryEntryAccount(pda.toBase58(), account.data);
|
|
4158
|
-
},
|
|
4159
|
-
async fetchPoolOracleApproval(params) {
|
|
4160
|
-
const [pda] = derivePoolOraclePda({
|
|
4161
|
-
programId,
|
|
4162
|
-
poolAddress: params.poolAddress,
|
|
4163
|
-
oracle: params.oracle,
|
|
4164
|
-
});
|
|
4165
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4166
|
-
if (!account)
|
|
4167
|
-
return null;
|
|
4168
|
-
return decodePoolOracleApprovalAccount(pda.toBase58(), account.data);
|
|
4169
|
-
},
|
|
4170
|
-
async fetchMembershipRecord(params) {
|
|
4171
|
-
const [pda] = deriveMembershipPda({
|
|
4172
|
-
programId,
|
|
4173
|
-
poolAddress: params.poolAddress,
|
|
4174
|
-
member: params.member,
|
|
4175
|
-
});
|
|
4176
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4177
|
-
if (!account)
|
|
4178
|
-
return null;
|
|
4179
|
-
return decodeMembershipRecordAccount(pda.toBase58(), account.data);
|
|
4180
|
-
},
|
|
4181
|
-
async fetchCycleOutcome(params) {
|
|
4182
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
4183
|
-
const [pda] = deriveCycleOutcomePda({
|
|
4184
|
-
programId,
|
|
4185
|
-
poolAddress: params.poolAddress,
|
|
4186
|
-
member: params.member,
|
|
4187
|
-
cycleHash,
|
|
4188
|
-
});
|
|
4189
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4190
|
-
if (!account)
|
|
4191
|
-
return null;
|
|
4192
|
-
return decodeCycleOutcomeAccount(pda.toBase58(), account.data);
|
|
4193
|
-
},
|
|
4194
|
-
async fetchCycleWindow(params) {
|
|
4195
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
4196
|
-
const [pda] = deriveCycleWindowPda({
|
|
4197
|
-
programId,
|
|
4198
|
-
poolAddress: params.poolAddress,
|
|
4199
|
-
cycleHash,
|
|
4200
|
-
});
|
|
4201
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4202
|
-
if (!account)
|
|
4203
|
-
return null;
|
|
4204
|
-
return decodeCycleWindowAccount(pda.toBase58(), account.data);
|
|
4205
|
-
},
|
|
4206
|
-
async fetchClaimRecord(params) {
|
|
4207
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
4208
|
-
const [pda] = deriveClaimPda({
|
|
4209
|
-
programId,
|
|
4210
|
-
poolAddress: params.poolAddress,
|
|
4211
|
-
member: params.member,
|
|
4212
|
-
cycleHash,
|
|
4213
|
-
});
|
|
4214
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4215
|
-
if (!account)
|
|
4216
|
-
return null;
|
|
4217
|
-
return decodeClaimRecordAccount(pda.toBase58(), account.data);
|
|
4218
|
-
},
|
|
4219
|
-
async fetchCycleOutcomeAggregate(params) {
|
|
4220
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
4221
|
-
const ruleHash = fromHex(params.ruleHashHex, 32);
|
|
4222
|
-
const [pda] = deriveOutcomeAggregatePda({
|
|
4223
|
-
programId,
|
|
4224
|
-
poolAddress: params.poolAddress,
|
|
4225
|
-
member: params.member,
|
|
4226
|
-
cycleHash,
|
|
4227
|
-
ruleHash,
|
|
4228
|
-
});
|
|
4229
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4230
|
-
if (!account)
|
|
4231
|
-
return null;
|
|
4232
|
-
return decodeCycleOutcomeAggregateAccount(pda.toBase58(), account.data);
|
|
4233
|
-
},
|
|
4234
|
-
async fetchProtocolConfigV2() {
|
|
4235
|
-
const [configV2Pda] = deriveConfigV2Pda(programId);
|
|
4236
|
-
const account = await connection.getAccountInfo(configV2Pda, 'confirmed');
|
|
4237
|
-
if (!account)
|
|
4238
|
-
return null;
|
|
4239
|
-
return decodeProtocolConfigV2Account(configV2Pda.toBase58(), account.data);
|
|
4240
|
-
},
|
|
4241
|
-
async fetchOracleProfile(oracle) {
|
|
4242
|
-
const [pda] = deriveOracleProfilePda({
|
|
4243
|
-
programId,
|
|
4244
|
-
oracle,
|
|
4245
|
-
});
|
|
4246
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4247
|
-
if (!account)
|
|
4248
|
-
return null;
|
|
4249
|
-
return decodeOracleProfileAccount(pda.toBase58(), account.data);
|
|
4250
|
-
},
|
|
4251
|
-
async fetchOracleStakePosition(params) {
|
|
4252
|
-
const [pda] = deriveOracleStakePda({
|
|
4253
|
-
programId,
|
|
4254
|
-
oracle: params.oracle,
|
|
4255
|
-
staker: params.staker,
|
|
4256
|
-
});
|
|
4257
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4258
|
-
if (!account)
|
|
4259
|
-
return null;
|
|
4260
|
-
return decodeOracleStakePositionAccount(pda.toBase58(), account.data);
|
|
4261
|
-
},
|
|
4262
|
-
async fetchPoolOraclePolicy(poolAddress) {
|
|
4263
|
-
const [pda] = derivePoolOraclePolicyPda({
|
|
4264
|
-
programId,
|
|
4265
|
-
poolAddress,
|
|
4266
|
-
});
|
|
4267
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4268
|
-
if (!account)
|
|
4269
|
-
return null;
|
|
4270
|
-
return decodePoolOraclePolicyAccount(pda.toBase58(), account.data);
|
|
4271
|
-
},
|
|
4272
|
-
async fetchPoolTerms(poolAddress) {
|
|
4273
|
-
const [pda] = derivePoolTermsPda({
|
|
4274
|
-
programId,
|
|
4275
|
-
poolAddress,
|
|
4276
|
-
});
|
|
4277
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4278
|
-
if (!account)
|
|
4279
|
-
return null;
|
|
4280
|
-
return decodePoolTermsAccount(pda.toBase58(), account.data);
|
|
4281
|
-
},
|
|
4282
|
-
async fetchPoolAssetVault(params) {
|
|
4283
|
-
const [pda] = derivePoolAssetVaultPda({
|
|
4284
|
-
programId,
|
|
4285
|
-
poolAddress: params.poolAddress,
|
|
4286
|
-
payoutMint: params.payoutMint,
|
|
4287
|
-
});
|
|
4288
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4289
|
-
if (!account)
|
|
4290
|
-
return null;
|
|
4291
|
-
return decodePoolAssetVaultAccount(pda.toBase58(), account.data);
|
|
4292
|
-
},
|
|
4293
|
-
async fetchProtocolFeeVault(paymentMint) {
|
|
4294
|
-
const [pda] = deriveProtocolFeeVaultPda({
|
|
4295
|
-
programId,
|
|
4296
|
-
paymentMint,
|
|
4297
|
-
});
|
|
4298
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4299
|
-
if (!account)
|
|
4300
|
-
return null;
|
|
4301
|
-
return decodeProtocolFeeVaultAccount(pda.toBase58(), account.data);
|
|
4302
|
-
},
|
|
4303
|
-
async fetchPoolOracleFeeVault(params) {
|
|
4304
|
-
const [pda] = derivePoolOracleFeeVaultPda({
|
|
4305
|
-
programId,
|
|
4306
|
-
poolAddress: params.poolAddress,
|
|
4307
|
-
oracle: params.oracle,
|
|
4308
|
-
paymentMint: params.paymentMint,
|
|
4309
|
-
});
|
|
4310
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4311
|
-
if (!account)
|
|
4312
|
-
return null;
|
|
4313
|
-
return decodePoolOracleFeeVaultAccount(pda.toBase58(), account.data);
|
|
4314
|
-
},
|
|
4315
|
-
async fetchPoolOraclePermissionSet(params) {
|
|
4316
|
-
const [pda] = derivePoolOraclePermissionSetPda({
|
|
4317
|
-
programId,
|
|
4318
|
-
poolAddress: params.poolAddress,
|
|
4319
|
-
oracle: params.oracle,
|
|
4320
|
-
});
|
|
4321
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4322
|
-
if (!account)
|
|
4323
|
-
return null;
|
|
4324
|
-
return decodePoolOraclePermissionSetAccount(pda.toBase58(), account.data);
|
|
4325
|
-
},
|
|
4326
|
-
async fetchOutcomeSchema(schemaKeyHashHex) {
|
|
4327
|
-
const [pda] = deriveSchemaPda({
|
|
4328
|
-
programId,
|
|
4329
|
-
schemaKeyHash: fromHex(schemaKeyHashHex, 32),
|
|
4330
|
-
});
|
|
4331
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4332
|
-
if (!account)
|
|
4333
|
-
return null;
|
|
4334
|
-
return decodeOutcomeSchemaAccount(pda.toBase58(), account.data);
|
|
4335
|
-
},
|
|
4336
|
-
async fetchPoolOutcomeRule(params) {
|
|
4337
|
-
const [pda] = derivePoolRulePda({
|
|
4338
|
-
programId,
|
|
4339
|
-
poolAddress: params.poolAddress,
|
|
4340
|
-
ruleHash: fromHex(params.ruleHashHex, 32),
|
|
4341
|
-
});
|
|
4342
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4343
|
-
if (!account)
|
|
4344
|
-
return null;
|
|
4345
|
-
return decodePoolOutcomeRuleAccount(pda.toBase58(), account.data);
|
|
4346
|
-
},
|
|
4347
|
-
async fetchInviteIssuer(issuer) {
|
|
4348
|
-
const [pda] = deriveInviteIssuerPda({
|
|
4349
|
-
programId,
|
|
4350
|
-
issuer,
|
|
4351
|
-
});
|
|
4352
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4353
|
-
if (!account)
|
|
4354
|
-
return null;
|
|
4355
|
-
return decodeInviteIssuerAccount(pda.toBase58(), account.data);
|
|
4356
|
-
},
|
|
4357
|
-
async fetchEnrollmentPermitReplay(params) {
|
|
4358
|
-
const [pda] = deriveEnrollmentReplayPda({
|
|
4359
|
-
programId,
|
|
4360
|
-
poolAddress: params.poolAddress,
|
|
4361
|
-
member: params.member,
|
|
4362
|
-
nonceHash: fromHex(params.nonceHashHex, 32),
|
|
4363
|
-
});
|
|
4364
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4365
|
-
if (!account)
|
|
4366
|
-
return null;
|
|
4367
|
-
return decodeEnrollmentPermitReplayAccount(pda.toBase58(), account.data);
|
|
4368
|
-
},
|
|
4369
|
-
async fetchAttestationVote(params) {
|
|
4370
|
-
const [pda] = deriveAttestationVotePda({
|
|
4371
|
-
programId,
|
|
4372
|
-
poolAddress: params.poolAddress,
|
|
4373
|
-
member: params.member,
|
|
4374
|
-
cycleHash: hashStringTo32(params.cycleId),
|
|
4375
|
-
ruleHash: fromHex(params.ruleHashHex, 32),
|
|
4376
|
-
oracle: params.oracle,
|
|
4377
|
-
});
|
|
4378
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4379
|
-
if (!account)
|
|
4380
|
-
return null;
|
|
4381
|
-
return decodeAttestationVoteAccount(pda.toBase58(), account.data);
|
|
4382
|
-
},
|
|
4383
|
-
async fetchClaimDelegate(params) {
|
|
4384
|
-
const [pda] = deriveClaimDelegatePda({
|
|
4385
|
-
programId,
|
|
4386
|
-
poolAddress: params.poolAddress,
|
|
4387
|
-
member: params.member,
|
|
4388
|
-
});
|
|
4389
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4390
|
-
if (!account)
|
|
4391
|
-
return null;
|
|
4392
|
-
return decodeClaimDelegateAccount(pda.toBase58(), account.data);
|
|
4393
|
-
},
|
|
4394
|
-
async fetchClaimRecordV2(params) {
|
|
4395
|
-
const cycleHash = hashStringTo32(params.cycleId);
|
|
4396
|
-
const [pda] = deriveClaimV2Pda({
|
|
4397
|
-
programId,
|
|
4398
|
-
poolAddress: params.poolAddress,
|
|
4399
|
-
member: params.member,
|
|
4400
|
-
cycleHash,
|
|
4401
|
-
ruleHash: fromHex(params.ruleHashHex, 32),
|
|
4402
|
-
});
|
|
4403
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4404
|
-
if (!account)
|
|
4405
|
-
return null;
|
|
4406
|
-
return decodeClaimRecordV2Account(pda.toBase58(), account.data);
|
|
4407
|
-
},
|
|
4408
|
-
async fetchCoverageProduct(params) {
|
|
4409
|
-
const [pda] = deriveCoverageProductPda({
|
|
4410
|
-
programId,
|
|
4411
|
-
poolAddress: params.poolAddress,
|
|
4412
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
4413
|
-
});
|
|
4414
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4415
|
-
if (!account)
|
|
4416
|
-
return null;
|
|
4417
|
-
return decodeCoverageProductAccount(pda.toBase58(), account.data);
|
|
4418
|
-
},
|
|
4419
|
-
async fetchCoverageProductPaymentOption(params) {
|
|
4420
|
-
const [pda] = deriveCoverageProductPaymentOptionPda({
|
|
4421
|
-
programId,
|
|
4422
|
-
poolAddress: params.poolAddress,
|
|
4423
|
-
productIdHash: fromHex(params.productIdHashHex, 32),
|
|
4424
|
-
paymentMint: params.paymentMint,
|
|
4425
|
-
});
|
|
4426
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4427
|
-
if (!account)
|
|
4428
|
-
return null;
|
|
4429
|
-
return decodeCoverageProductPaymentOptionAccount(pda.toBase58(), account.data);
|
|
4430
|
-
},
|
|
4431
|
-
async fetchCoveragePolicy(params) {
|
|
4432
|
-
const [pda] = deriveCoveragePolicyPda({
|
|
4433
|
-
programId,
|
|
4434
|
-
poolAddress: params.poolAddress,
|
|
4435
|
-
member: params.member,
|
|
4436
|
-
});
|
|
4437
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4438
|
-
if (!account)
|
|
4439
|
-
return null;
|
|
4440
|
-
return decodeCoveragePolicyAccount(pda.toBase58(), account.data);
|
|
4441
|
-
},
|
|
4442
|
-
async fetchCoveragePolicyPositionNft(params) {
|
|
4443
|
-
const [pda] = deriveCoverageNftPda({
|
|
4444
|
-
programId,
|
|
4445
|
-
poolAddress: params.poolAddress,
|
|
4446
|
-
member: params.member,
|
|
4447
|
-
});
|
|
4448
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4449
|
-
if (!account)
|
|
4450
|
-
return null;
|
|
4451
|
-
return decodeCoveragePolicyPositionNftAccount(pda.toBase58(), account.data);
|
|
4452
|
-
},
|
|
4453
|
-
async fetchPremiumLedger(params) {
|
|
4454
|
-
const [pda] = derivePremiumLedgerPda({
|
|
4455
|
-
programId,
|
|
4456
|
-
poolAddress: params.poolAddress,
|
|
4457
|
-
member: params.member,
|
|
4458
|
-
});
|
|
4459
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4460
|
-
if (!account)
|
|
4461
|
-
return null;
|
|
4462
|
-
return decodePremiumLedgerAccount(pda.toBase58(), account.data);
|
|
4463
|
-
},
|
|
4464
|
-
async fetchPremiumAttestationReplay(params) {
|
|
4465
|
-
const [pda] = derivePremiumReplayPda({
|
|
4466
|
-
programId,
|
|
4467
|
-
poolAddress: params.poolAddress,
|
|
4468
|
-
member: params.member,
|
|
4469
|
-
replayHash: fromHex(params.replayHashHex, 32),
|
|
4470
|
-
});
|
|
4471
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4472
|
-
if (!account)
|
|
4473
|
-
return null;
|
|
4474
|
-
return decodePremiumAttestationReplayAccount(pda.toBase58(), account.data);
|
|
4475
|
-
},
|
|
4476
|
-
async fetchMemberCycle(params) {
|
|
4477
|
-
const [pda] = deriveMemberCyclePda({
|
|
4478
|
-
programId,
|
|
4479
|
-
poolAddress: params.poolAddress,
|
|
4480
|
-
member: params.member,
|
|
4481
|
-
periodIndex: typeof params.periodIndex === 'bigint'
|
|
4482
|
-
? params.periodIndex
|
|
4483
|
-
: BigInt(params.periodIndex),
|
|
4484
|
-
});
|
|
4485
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4486
|
-
if (!account)
|
|
4487
|
-
return null;
|
|
4488
|
-
return decodeMemberCycleAccount(pda.toBase58(), account.data);
|
|
4489
|
-
},
|
|
4490
|
-
async fetchCycleQuoteReplay(params) {
|
|
4491
|
-
const [pda] = deriveCycleQuoteReplayPda({
|
|
4492
|
-
programId,
|
|
4493
|
-
poolAddress: params.poolAddress,
|
|
4494
|
-
member: params.member,
|
|
4495
|
-
nonceHash: fromHex(params.nonceHashHex, 32),
|
|
4496
|
-
});
|
|
4497
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4498
|
-
if (!account)
|
|
4499
|
-
return null;
|
|
4500
|
-
return decodeCycleQuoteReplayAccount(pda.toBase58(), account.data);
|
|
4501
|
-
},
|
|
4502
|
-
async fetchPoolTreasuryReserve(params) {
|
|
4503
|
-
const [pda] = derivePoolTreasuryReservePda({
|
|
4504
|
-
programId,
|
|
4505
|
-
poolAddress: params.poolAddress,
|
|
4506
|
-
paymentMint: params.paymentMint,
|
|
4507
|
-
});
|
|
4508
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4509
|
-
if (!account)
|
|
4510
|
-
return null;
|
|
4511
|
-
return decodePoolTreasuryReserveAccount(pda.toBase58(), account.data);
|
|
4512
|
-
},
|
|
4513
|
-
async fetchCoverageClaimRecord(params) {
|
|
4514
|
-
const [pda] = deriveCoverageClaimPda({
|
|
4515
|
-
programId,
|
|
4516
|
-
poolAddress: params.poolAddress,
|
|
4517
|
-
member: params.member,
|
|
4518
|
-
intentHash: fromHex(params.intentHashHex, 32),
|
|
4519
|
-
});
|
|
4520
|
-
const account = await connection.getAccountInfo(pda, 'confirmed');
|
|
4521
|
-
if (!account)
|
|
4522
|
-
return null;
|
|
4523
|
-
return decodeCoverageClaimRecordAccount(pda.toBase58(), account.data);
|
|
4524
|
-
},
|
|
4525
|
-
};
|
|
4526
|
-
}
|
|
4527
|
-
export function derivePoolAddress(params) {
|
|
4528
|
-
const [pool] = derivePoolPda({
|
|
4529
|
-
programId: params.programId,
|
|
4530
|
-
authority: params.authority,
|
|
4531
|
-
poolId: params.poolId,
|
|
4532
|
-
});
|
|
4533
|
-
return pool.toBase58();
|
|
4534
|
-
}
|
|
1
|
+
export { PROTOCOL_PROGRAM_ID } from './internal/protocol/constants.js';
|
|
2
|
+
export { buildCycleQuoteHash, buildCycleQuoteMessage, buildCycleQuoteSignatureMessage, compileTransactionToV0, derivePoolAddress, } from './internal/protocol/shared.js';
|
|
3
|
+
export { createProtocolClient } from './internal/protocol/client.js';
|