@epicentral/sos-sdk 0.5.0-alpha.8 → 0.6.1-alpha

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.

Potentially problematic release.


This version of @epicentral/sos-sdk might be problematic. Click here for more details.

@@ -59,7 +59,7 @@ export type OptionValidateInstruction<
59
59
  TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
60
60
  TAccountOptionAccount extends string | AccountMeta<string> = string,
61
61
  TAccountMarketData extends string | AccountMeta<string> = string,
62
- TAccountPriceUpdate extends string | AccountMeta<string> = string,
62
+ TAccountSwitchboardFeed extends string | AccountMeta<string> = string,
63
63
  TAccountAuthority extends string | AccountMeta<string> = string,
64
64
  TRemainingAccounts extends readonly AccountMeta<string>[] = [],
65
65
  > = Instruction<TProgram> &
@@ -72,9 +72,9 @@ export type OptionValidateInstruction<
72
72
  TAccountMarketData extends string
73
73
  ? ReadonlyAccount<TAccountMarketData>
74
74
  : TAccountMarketData,
75
- TAccountPriceUpdate extends string
76
- ? ReadonlyAccount<TAccountPriceUpdate>
77
- : TAccountPriceUpdate,
75
+ TAccountSwitchboardFeed extends string
76
+ ? ReadonlyAccount<TAccountSwitchboardFeed>
77
+ : TAccountSwitchboardFeed,
78
78
  TAccountAuthority extends string
79
79
  ? ReadonlySignerAccount<TAccountAuthority> &
80
80
  AccountSignerMeta<TAccountAuthority>
@@ -134,13 +134,12 @@ export function getOptionValidateInstructionDataCodec(): FixedSizeCodec<
134
134
  export type OptionValidateInput<
135
135
  TAccountOptionAccount extends string = string,
136
136
  TAccountMarketData extends string = string,
137
- TAccountPriceUpdate extends string = string,
137
+ TAccountSwitchboardFeed extends string = string,
138
138
  TAccountAuthority extends string = string,
139
139
  > = {
140
140
  optionAccount: Address<TAccountOptionAccount>;
141
141
  marketData: Address<TAccountMarketData>;
142
- /** Pyth price update account (ownership validated by Anchor) */
143
- priceUpdate: Address<TAccountPriceUpdate>;
142
+ switchboardFeed: Address<TAccountSwitchboardFeed>;
144
143
  authority: TransactionSigner<TAccountAuthority>;
145
144
  optionType: OptionValidateInstructionDataArgs["optionType"];
146
145
  strikePrice: OptionValidateInstructionDataArgs["strikePrice"];
@@ -151,14 +150,14 @@ export type OptionValidateInput<
151
150
  export function getOptionValidateInstruction<
152
151
  TAccountOptionAccount extends string,
153
152
  TAccountMarketData extends string,
154
- TAccountPriceUpdate extends string,
153
+ TAccountSwitchboardFeed extends string,
155
154
  TAccountAuthority extends string,
156
155
  TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
157
156
  >(
158
157
  input: OptionValidateInput<
159
158
  TAccountOptionAccount,
160
159
  TAccountMarketData,
161
- TAccountPriceUpdate,
160
+ TAccountSwitchboardFeed,
162
161
  TAccountAuthority
163
162
  >,
164
163
  config?: { programAddress?: TProgramAddress },
@@ -166,7 +165,7 @@ export function getOptionValidateInstruction<
166
165
  TProgramAddress,
167
166
  TAccountOptionAccount,
168
167
  TAccountMarketData,
169
- TAccountPriceUpdate,
168
+ TAccountSwitchboardFeed,
170
169
  TAccountAuthority
171
170
  > {
172
171
  // Program address.
@@ -177,7 +176,10 @@ export function getOptionValidateInstruction<
177
176
  const originalAccounts = {
178
177
  optionAccount: { value: input.optionAccount ?? null, isWritable: true },
179
178
  marketData: { value: input.marketData ?? null, isWritable: false },
180
- priceUpdate: { value: input.priceUpdate ?? null, isWritable: false },
179
+ switchboardFeed: {
180
+ value: input.switchboardFeed ?? null,
181
+ isWritable: false,
182
+ },
181
183
  authority: { value: input.authority ?? null, isWritable: false },
182
184
  };
183
185
  const accounts = originalAccounts as Record<
@@ -193,7 +195,7 @@ export function getOptionValidateInstruction<
193
195
  accounts: [
194
196
  getAccountMeta(accounts.optionAccount),
195
197
  getAccountMeta(accounts.marketData),
196
- getAccountMeta(accounts.priceUpdate),
198
+ getAccountMeta(accounts.switchboardFeed),
197
199
  getAccountMeta(accounts.authority),
198
200
  ],
199
201
  data: getOptionValidateInstructionDataEncoder().encode(
@@ -204,7 +206,7 @@ export function getOptionValidateInstruction<
204
206
  TProgramAddress,
205
207
  TAccountOptionAccount,
206
208
  TAccountMarketData,
207
- TAccountPriceUpdate,
209
+ TAccountSwitchboardFeed,
208
210
  TAccountAuthority
209
211
  >);
210
212
  }
@@ -217,8 +219,7 @@ export type ParsedOptionValidateInstruction<
217
219
  accounts: {
218
220
  optionAccount: TAccountMetas[0];
219
221
  marketData: TAccountMetas[1];
220
- /** Pyth price update account (ownership validated by Anchor) */
221
- priceUpdate: TAccountMetas[2];
222
+ switchboardFeed: TAccountMetas[2];
222
223
  authority: TAccountMetas[3];
223
224
  };
224
225
  data: OptionValidateInstructionData;
@@ -247,7 +248,7 @@ export function parseOptionValidateInstruction<
247
248
  accounts: {
248
249
  optionAccount: getNextAccount(),
249
250
  marketData: getNextAccount(),
250
- priceUpdate: getNextAccount(),
251
+ switchboardFeed: getNextAccount(),
251
252
  authority: getNextAccount(),
252
253
  },
253
254
  data: getOptionValidateInstructionDataDecoder().decode(instruction.data),
@@ -7,50 +7,13 @@
7
7
  */
8
8
 
9
9
  import {
10
- assertIsInstructionWithAccounts,
11
10
  containsBytes,
12
11
  fixEncoderSize,
13
12
  getBytesEncoder,
14
13
  type Address,
15
- type Instruction,
16
- type InstructionWithData,
17
14
  type ReadonlyUint8Array,
18
15
  } from "@solana/kit";
19
16
  import {
20
- parseAcceptAdminInstruction,
21
- parseAutoExerciseAllExpiredInstruction,
22
- parseAutoExerciseExpiredInstruction,
23
- parseBorrowFromPoolInstruction,
24
- parseBuyFromPoolInstruction,
25
- parseClaimThetaInstruction,
26
- parseCloseLongToPoolInstruction,
27
- parseCloseOptionInstruction,
28
- parseCreateEscrowV2Instruction,
29
- parseDepositCollateralInstruction,
30
- parseDepositToPositionInstruction,
31
- parseInitCollateralPoolInstruction,
32
- parseInitConfigInstruction,
33
- parseInitializeMarketDataInstruction,
34
- parseInitOptionPoolInstruction,
35
- parseLiquidateWriterPositionInstruction,
36
- parseOmlpCreateVaultInstruction,
37
- parseOmlpUpdateMaxLeverageInstruction,
38
- parseOmlpUpdateProtocolFeeInstruction,
39
- parseOmlpUpdateSupplyLimitInstruction,
40
- parseOptionExerciseInstruction,
41
- parseOptionMintInstruction,
42
- parseOptionValidateInstruction,
43
- parseRepayPoolLoanFromCollateralInstruction,
44
- parseRepayPoolLoanFromWalletInstruction,
45
- parseRepayPoolLoanInstruction,
46
- parseSettleMakerCollateralInstruction,
47
- parseSyncWriterPositionInstruction,
48
- parseTransferAdminInstruction,
49
- parseUnwindWriterUnsoldInstruction,
50
- parseUpdateImpliedVolatilityInstruction,
51
- parseUpdateMarketDataInstruction,
52
- parseWithdrawFromPositionInstruction,
53
- parseWriteToPoolInstruction,
54
17
  type ParsedAcceptAdminInstruction,
55
18
  type ParsedAutoExerciseAllExpiredInstruction,
56
19
  type ParsedAutoExerciseExpiredInstruction,
@@ -88,7 +51,7 @@ import {
88
51
  } from "../instructions";
89
52
 
90
53
  export const OPTION_PROGRAM_PROGRAM_ADDRESS =
91
- "AA1nq9oeALQRYoN6WJvmFw6oRuek5X4KfTr7vb1i2dMQ" as Address<"AA1nq9oeALQRYoN6WJvmFw6oRuek5X4KfTr7vb1i2dMQ">;
54
+ "ASTGCefQVGEQ79ZSC6d2G9oMqmn2dk1onb4N75Bc5djQ" as Address<"ASTGCefQVGEQ79ZSC6d2G9oMqmn2dk1onb4N75Bc5djQ">;
92
55
 
93
56
  export enum OptionProgramAccount {
94
57
  CollateralPool,
@@ -101,7 +64,6 @@ export enum OptionProgramAccount {
101
64
  OptionPool,
102
65
  PoolLoan,
103
66
  PositionAccount,
104
- PriceUpdateV2,
105
67
  Vault,
106
68
  WriterPosition,
107
69
  }
@@ -220,17 +182,6 @@ export function identifyOptionProgramAccount(
220
182
  ) {
221
183
  return OptionProgramAccount.PositionAccount;
222
184
  }
223
- if (
224
- containsBytes(
225
- data,
226
- fixEncoderSize(getBytesEncoder(), 8).encode(
227
- new Uint8Array([34, 241, 35, 99, 157, 126, 244, 205]),
228
- ),
229
- 0,
230
- )
231
- ) {
232
- return OptionProgramAccount.PriceUpdateV2;
233
- }
234
185
  if (
235
186
  containsBytes(
236
187
  data,
@@ -679,7 +630,7 @@ export function identifyOptionProgramInstruction(
679
630
  }
680
631
 
681
632
  export type ParsedOptionProgramInstruction<
682
- TProgram extends string = "AA1nq9oeALQRYoN6WJvmFw6oRuek5X4KfTr7vb1i2dMQ",
633
+ TProgram extends string = "ASTGCefQVGEQ79ZSC6d2G9oMqmn2dk1onb4N75Bc5djQ",
683
634
  > =
684
635
  | ({
685
636
  instructionType: OptionProgramInstruction.AcceptAdmin;
@@ -783,253 +734,3 @@ export type ParsedOptionProgramInstruction<
783
734
  | ({
784
735
  instructionType: OptionProgramInstruction.WriteToPool;
785
736
  } & ParsedWriteToPoolInstruction<TProgram>);
786
-
787
- export function parseOptionProgramInstruction<TProgram extends string>(
788
- instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
789
- ): ParsedOptionProgramInstruction<TProgram> {
790
- const instructionType = identifyOptionProgramInstruction(instruction);
791
- switch (instructionType) {
792
- case OptionProgramInstruction.AcceptAdmin: {
793
- assertIsInstructionWithAccounts(instruction);
794
- return {
795
- instructionType: OptionProgramInstruction.AcceptAdmin,
796
- ...parseAcceptAdminInstruction(instruction),
797
- };
798
- }
799
- case OptionProgramInstruction.AutoExerciseAllExpired: {
800
- assertIsInstructionWithAccounts(instruction);
801
- return {
802
- instructionType: OptionProgramInstruction.AutoExerciseAllExpired,
803
- ...parseAutoExerciseAllExpiredInstruction(instruction),
804
- };
805
- }
806
- case OptionProgramInstruction.AutoExerciseExpired: {
807
- assertIsInstructionWithAccounts(instruction);
808
- return {
809
- instructionType: OptionProgramInstruction.AutoExerciseExpired,
810
- ...parseAutoExerciseExpiredInstruction(instruction),
811
- };
812
- }
813
- case OptionProgramInstruction.BorrowFromPool: {
814
- assertIsInstructionWithAccounts(instruction);
815
- return {
816
- instructionType: OptionProgramInstruction.BorrowFromPool,
817
- ...parseBorrowFromPoolInstruction(instruction),
818
- };
819
- }
820
- case OptionProgramInstruction.BuyFromPool: {
821
- assertIsInstructionWithAccounts(instruction);
822
- return {
823
- instructionType: OptionProgramInstruction.BuyFromPool,
824
- ...parseBuyFromPoolInstruction(instruction),
825
- };
826
- }
827
- case OptionProgramInstruction.ClaimTheta: {
828
- assertIsInstructionWithAccounts(instruction);
829
- return {
830
- instructionType: OptionProgramInstruction.ClaimTheta,
831
- ...parseClaimThetaInstruction(instruction),
832
- };
833
- }
834
- case OptionProgramInstruction.CloseLongToPool: {
835
- assertIsInstructionWithAccounts(instruction);
836
- return {
837
- instructionType: OptionProgramInstruction.CloseLongToPool,
838
- ...parseCloseLongToPoolInstruction(instruction),
839
- };
840
- }
841
- case OptionProgramInstruction.CloseOption: {
842
- assertIsInstructionWithAccounts(instruction);
843
- return {
844
- instructionType: OptionProgramInstruction.CloseOption,
845
- ...parseCloseOptionInstruction(instruction),
846
- };
847
- }
848
- case OptionProgramInstruction.CreateEscrowV2: {
849
- assertIsInstructionWithAccounts(instruction);
850
- return {
851
- instructionType: OptionProgramInstruction.CreateEscrowV2,
852
- ...parseCreateEscrowV2Instruction(instruction),
853
- };
854
- }
855
- case OptionProgramInstruction.DepositCollateral: {
856
- assertIsInstructionWithAccounts(instruction);
857
- return {
858
- instructionType: OptionProgramInstruction.DepositCollateral,
859
- ...parseDepositCollateralInstruction(instruction),
860
- };
861
- }
862
- case OptionProgramInstruction.DepositToPosition: {
863
- assertIsInstructionWithAccounts(instruction);
864
- return {
865
- instructionType: OptionProgramInstruction.DepositToPosition,
866
- ...parseDepositToPositionInstruction(instruction),
867
- };
868
- }
869
- case OptionProgramInstruction.InitCollateralPool: {
870
- assertIsInstructionWithAccounts(instruction);
871
- return {
872
- instructionType: OptionProgramInstruction.InitCollateralPool,
873
- ...parseInitCollateralPoolInstruction(instruction),
874
- };
875
- }
876
- case OptionProgramInstruction.InitConfig: {
877
- assertIsInstructionWithAccounts(instruction);
878
- return {
879
- instructionType: OptionProgramInstruction.InitConfig,
880
- ...parseInitConfigInstruction(instruction),
881
- };
882
- }
883
- case OptionProgramInstruction.InitOptionPool: {
884
- assertIsInstructionWithAccounts(instruction);
885
- return {
886
- instructionType: OptionProgramInstruction.InitOptionPool,
887
- ...parseInitOptionPoolInstruction(instruction),
888
- };
889
- }
890
- case OptionProgramInstruction.InitializeMarketData: {
891
- assertIsInstructionWithAccounts(instruction);
892
- return {
893
- instructionType: OptionProgramInstruction.InitializeMarketData,
894
- ...parseInitializeMarketDataInstruction(instruction),
895
- };
896
- }
897
- case OptionProgramInstruction.LiquidateWriterPosition: {
898
- assertIsInstructionWithAccounts(instruction);
899
- return {
900
- instructionType: OptionProgramInstruction.LiquidateWriterPosition,
901
- ...parseLiquidateWriterPositionInstruction(instruction),
902
- };
903
- }
904
- case OptionProgramInstruction.OmlpCreateVault: {
905
- assertIsInstructionWithAccounts(instruction);
906
- return {
907
- instructionType: OptionProgramInstruction.OmlpCreateVault,
908
- ...parseOmlpCreateVaultInstruction(instruction),
909
- };
910
- }
911
- case OptionProgramInstruction.OmlpUpdateMaxLeverage: {
912
- assertIsInstructionWithAccounts(instruction);
913
- return {
914
- instructionType: OptionProgramInstruction.OmlpUpdateMaxLeverage,
915
- ...parseOmlpUpdateMaxLeverageInstruction(instruction),
916
- };
917
- }
918
- case OptionProgramInstruction.OmlpUpdateProtocolFee: {
919
- assertIsInstructionWithAccounts(instruction);
920
- return {
921
- instructionType: OptionProgramInstruction.OmlpUpdateProtocolFee,
922
- ...parseOmlpUpdateProtocolFeeInstruction(instruction),
923
- };
924
- }
925
- case OptionProgramInstruction.OmlpUpdateSupplyLimit: {
926
- assertIsInstructionWithAccounts(instruction);
927
- return {
928
- instructionType: OptionProgramInstruction.OmlpUpdateSupplyLimit,
929
- ...parseOmlpUpdateSupplyLimitInstruction(instruction),
930
- };
931
- }
932
- case OptionProgramInstruction.OptionExercise: {
933
- assertIsInstructionWithAccounts(instruction);
934
- return {
935
- instructionType: OptionProgramInstruction.OptionExercise,
936
- ...parseOptionExerciseInstruction(instruction),
937
- };
938
- }
939
- case OptionProgramInstruction.OptionMint: {
940
- assertIsInstructionWithAccounts(instruction);
941
- return {
942
- instructionType: OptionProgramInstruction.OptionMint,
943
- ...parseOptionMintInstruction(instruction),
944
- };
945
- }
946
- case OptionProgramInstruction.OptionValidate: {
947
- assertIsInstructionWithAccounts(instruction);
948
- return {
949
- instructionType: OptionProgramInstruction.OptionValidate,
950
- ...parseOptionValidateInstruction(instruction),
951
- };
952
- }
953
- case OptionProgramInstruction.RepayPoolLoan: {
954
- assertIsInstructionWithAccounts(instruction);
955
- return {
956
- instructionType: OptionProgramInstruction.RepayPoolLoan,
957
- ...parseRepayPoolLoanInstruction(instruction),
958
- };
959
- }
960
- case OptionProgramInstruction.RepayPoolLoanFromCollateral: {
961
- assertIsInstructionWithAccounts(instruction);
962
- return {
963
- instructionType: OptionProgramInstruction.RepayPoolLoanFromCollateral,
964
- ...parseRepayPoolLoanFromCollateralInstruction(instruction),
965
- };
966
- }
967
- case OptionProgramInstruction.RepayPoolLoanFromWallet: {
968
- assertIsInstructionWithAccounts(instruction);
969
- return {
970
- instructionType: OptionProgramInstruction.RepayPoolLoanFromWallet,
971
- ...parseRepayPoolLoanFromWalletInstruction(instruction),
972
- };
973
- }
974
- case OptionProgramInstruction.SettleMakerCollateral: {
975
- assertIsInstructionWithAccounts(instruction);
976
- return {
977
- instructionType: OptionProgramInstruction.SettleMakerCollateral,
978
- ...parseSettleMakerCollateralInstruction(instruction),
979
- };
980
- }
981
- case OptionProgramInstruction.SyncWriterPosition: {
982
- assertIsInstructionWithAccounts(instruction);
983
- return {
984
- instructionType: OptionProgramInstruction.SyncWriterPosition,
985
- ...parseSyncWriterPositionInstruction(instruction),
986
- };
987
- }
988
- case OptionProgramInstruction.TransferAdmin: {
989
- assertIsInstructionWithAccounts(instruction);
990
- return {
991
- instructionType: OptionProgramInstruction.TransferAdmin,
992
- ...parseTransferAdminInstruction(instruction),
993
- };
994
- }
995
- case OptionProgramInstruction.UnwindWriterUnsold: {
996
- assertIsInstructionWithAccounts(instruction);
997
- return {
998
- instructionType: OptionProgramInstruction.UnwindWriterUnsold,
999
- ...parseUnwindWriterUnsoldInstruction(instruction),
1000
- };
1001
- }
1002
- case OptionProgramInstruction.UpdateImpliedVolatility: {
1003
- assertIsInstructionWithAccounts(instruction);
1004
- return {
1005
- instructionType: OptionProgramInstruction.UpdateImpliedVolatility,
1006
- ...parseUpdateImpliedVolatilityInstruction(instruction),
1007
- };
1008
- }
1009
- case OptionProgramInstruction.UpdateMarketData: {
1010
- assertIsInstructionWithAccounts(instruction);
1011
- return {
1012
- instructionType: OptionProgramInstruction.UpdateMarketData,
1013
- ...parseUpdateMarketDataInstruction(instruction),
1014
- };
1015
- }
1016
- case OptionProgramInstruction.WithdrawFromPosition: {
1017
- assertIsInstructionWithAccounts(instruction);
1018
- return {
1019
- instructionType: OptionProgramInstruction.WithdrawFromPosition,
1020
- ...parseWithdrawFromPositionInstruction(instruction),
1021
- };
1022
- }
1023
- case OptionProgramInstruction.WriteToPool: {
1024
- assertIsInstructionWithAccounts(instruction);
1025
- return {
1026
- instructionType: OptionProgramInstruction.WriteToPool,
1027
- ...parseWriteToPoolInstruction(instruction),
1028
- };
1029
- }
1030
- default:
1031
- throw new Error(
1032
- `Unrecognized instruction type: ${instructionType as string}`,
1033
- );
1034
- }
1035
- }
@@ -20,7 +20,5 @@ export * from "./poolLoanCreated";
20
20
  export * from "./poolLoanRepaid";
21
21
  export * from "./positionDeposited";
22
22
  export * from "./positionWithdrawn";
23
- export * from "./priceFeedMessage";
24
23
  export * from "./protocolFeeUpdated";
25
24
  export * from "./vaultCreated";
26
- export * from "./verificationLevel";
package/index.ts CHANGED
@@ -30,6 +30,12 @@ export * from "./short/preflight";
30
30
 
31
31
  export * from "./omlp/builders";
32
32
  export * from "./omlp/service";
33
+ export {
34
+ resolveSwitchboardFeedFromMarketData,
35
+ buildSwitchboardPullFeedUpdate,
36
+ type SwitchboardPullFeedLike,
37
+ type BuildSwitchboardPullFeedUpdateParams,
38
+ } from "./oracle/switchboard";
33
39
 
34
40
  export {
35
41
  getWrapSOLInstructions,