@epicentral/sos-sdk 0.2.0 → 0.2.2

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.
@@ -7,25 +7,62 @@
7
7
  */
8
8
 
9
9
  import {
10
+ assertIsInstructionWithAccounts,
10
11
  containsBytes,
11
12
  fixEncoderSize,
12
13
  getBytesEncoder,
13
14
  type Address,
15
+ type Instruction,
16
+ type InstructionWithData,
14
17
  type ReadonlyUint8Array,
15
18
  } from "@solana/kit";
16
19
  import {
20
+ parseAcceptAdminInstruction,
21
+ parseAutoExerciseAllExpiredInstruction,
22
+ parseAutoExerciseExpiredInstruction,
23
+ parseBorrowFromPoolInstruction,
24
+ parseBuyFromPoolInstruction,
25
+ parseClaimThetaInstruction,
26
+ parseCloseLongToPoolInstruction,
27
+ parseCloseOptionInstruction,
28
+ parseCreateEscrowV2Instruction,
29
+ parseCreateLiquidityRouterInstruction,
30
+ parseDepositCollateralInstruction,
31
+ parseDepositToPositionInstruction,
32
+ parseInitCollateralPoolInstruction,
33
+ parseInitConfigInstruction,
34
+ parseInitializeMarketDataInstruction,
35
+ parseInitOptionPoolInstruction,
36
+ parseLiquidateWriterPositionInstruction,
37
+ parseOmlpCreateVaultInstruction,
38
+ parseOmlpTakeOfferWithFailoverInstruction,
39
+ parseOmlpUpdateMaxLeverageInstruction,
40
+ parseOmlpUpdateProtocolFeeInstruction,
41
+ parseOmlpUpdateSupplyLimitInstruction,
42
+ parseOptionExerciseInstruction,
43
+ parseOptionMintInstruction,
44
+ parseOptionValidateInstruction,
45
+ parseRepayPoolLoanFromCollateralInstruction,
46
+ parseRepayPoolLoanInstruction,
47
+ parseSettleMakerCollateralInstruction,
48
+ parseSyncWriterPositionInstruction,
49
+ parseTransferAdminInstruction,
50
+ parseUnwindWriterUnsoldInstruction,
51
+ parseUpdateImpliedVolatilityInstruction,
52
+ parseUpdateMarketDataInstruction,
53
+ parseWithdrawFromPositionInstruction,
54
+ parseWriteToPoolInstruction,
17
55
  type ParsedAcceptAdminInstruction,
18
56
  type ParsedAutoExerciseAllExpiredInstruction,
19
57
  type ParsedAutoExerciseExpiredInstruction,
20
58
  type ParsedBorrowFromPoolInstruction,
21
59
  type ParsedBuyFromPoolInstruction,
22
- type ParsedClaimPremiumInstruction,
60
+ type ParsedClaimThetaInstruction,
23
61
  type ParsedCloseLongToPoolInstruction,
24
62
  type ParsedCloseOptionInstruction,
25
63
  type ParsedCreateEscrowV2Instruction,
26
64
  type ParsedCreateLiquidityRouterInstruction,
27
65
  type ParsedDepositCollateralInstruction,
28
- type ParsedDepositToPoolInstruction,
29
66
  type ParsedDepositToPositionInstruction,
30
67
  type ParsedInitCollateralPoolInstruction,
31
68
  type ParsedInitConfigInstruction,
@@ -48,7 +85,6 @@ import {
48
85
  type ParsedUnwindWriterUnsoldInstruction,
49
86
  type ParsedUpdateImpliedVolatilityInstruction,
50
87
  type ParsedUpdateMarketDataInstruction,
51
- type ParsedWithdrawFromPoolInstruction,
52
88
  type ParsedWithdrawFromPositionInstruction,
53
89
  type ParsedWriteToPoolInstruction,
54
90
  } from "../instructions";
@@ -64,7 +100,6 @@ export enum OptionProgramAccount {
64
100
  LenderPosition,
65
101
  LiquidityRouter,
66
102
  MakerCollateralShare,
67
- MakerPoolShare,
68
103
  MarketDataAccount,
69
104
  OptionAccount,
70
105
  OptionPool,
@@ -156,17 +191,6 @@ export function identifyOptionProgramAccount(
156
191
  ) {
157
192
  return OptionProgramAccount.MakerCollateralShare;
158
193
  }
159
- if (
160
- containsBytes(
161
- data,
162
- fixEncoderSize(getBytesEncoder(), 8).encode(
163
- new Uint8Array([171, 211, 240, 11, 182, 141, 59, 217]),
164
- ),
165
- 0,
166
- )
167
- ) {
168
- return OptionProgramAccount.MakerPoolShare;
169
- }
170
194
  if (
171
195
  containsBytes(
172
196
  data,
@@ -266,13 +290,12 @@ export enum OptionProgramInstruction {
266
290
  AutoExerciseExpired,
267
291
  BorrowFromPool,
268
292
  BuyFromPool,
269
- ClaimPremium,
293
+ ClaimTheta,
270
294
  CloseLongToPool,
271
295
  CloseOption,
272
296
  CreateEscrowV2,
273
297
  CreateLiquidityRouter,
274
298
  DepositCollateral,
275
- DepositToPool,
276
299
  DepositToPosition,
277
300
  InitCollateralPool,
278
301
  InitConfig,
@@ -295,7 +318,6 @@ export enum OptionProgramInstruction {
295
318
  UnwindWriterUnsold,
296
319
  UpdateImpliedVolatility,
297
320
  UpdateMarketData,
298
- WithdrawFromPool,
299
321
  WithdrawFromPosition,
300
322
  WriteToPool,
301
323
  }
@@ -363,12 +385,12 @@ export function identifyOptionProgramInstruction(
363
385
  containsBytes(
364
386
  data,
365
387
  fixEncoderSize(getBytesEncoder(), 8).encode(
366
- new Uint8Array([225, 124, 12, 107, 24, 154, 37, 100]),
388
+ new Uint8Array([151, 147, 69, 241, 135, 166, 23, 62]),
367
389
  ),
368
390
  0,
369
391
  )
370
392
  ) {
371
- return OptionProgramInstruction.ClaimPremium;
393
+ return OptionProgramInstruction.ClaimTheta;
372
394
  }
373
395
  if (
374
396
  containsBytes(
@@ -425,17 +447,6 @@ export function identifyOptionProgramInstruction(
425
447
  ) {
426
448
  return OptionProgramInstruction.DepositCollateral;
427
449
  }
428
- if (
429
- containsBytes(
430
- data,
431
- fixEncoderSize(getBytesEncoder(), 8).encode(
432
- new Uint8Array([99, 136, 15, 66, 85, 146, 24, 89]),
433
- ),
434
- 0,
435
- )
436
- ) {
437
- return OptionProgramInstruction.DepositToPool;
438
- }
439
450
  if (
440
451
  containsBytes(
441
452
  data,
@@ -678,17 +689,6 @@ export function identifyOptionProgramInstruction(
678
689
  ) {
679
690
  return OptionProgramInstruction.UpdateMarketData;
680
691
  }
681
- if (
682
- containsBytes(
683
- data,
684
- fixEncoderSize(getBytesEncoder(), 8).encode(
685
- new Uint8Array([62, 33, 128, 81, 40, 234, 29, 77]),
686
- ),
687
- 0,
688
- )
689
- ) {
690
- return OptionProgramInstruction.WithdrawFromPool;
691
- }
692
692
  if (
693
693
  containsBytes(
694
694
  data,
@@ -735,8 +735,8 @@ export type ParsedOptionProgramInstruction<
735
735
  instructionType: OptionProgramInstruction.BuyFromPool;
736
736
  } & ParsedBuyFromPoolInstruction<TProgram>)
737
737
  | ({
738
- instructionType: OptionProgramInstruction.ClaimPremium;
739
- } & ParsedClaimPremiumInstruction<TProgram>)
738
+ instructionType: OptionProgramInstruction.ClaimTheta;
739
+ } & ParsedClaimThetaInstruction<TProgram>)
740
740
  | ({
741
741
  instructionType: OptionProgramInstruction.CloseLongToPool;
742
742
  } & ParsedCloseLongToPoolInstruction<TProgram>)
@@ -752,9 +752,6 @@ export type ParsedOptionProgramInstruction<
752
752
  | ({
753
753
  instructionType: OptionProgramInstruction.DepositCollateral;
754
754
  } & ParsedDepositCollateralInstruction<TProgram>)
755
- | ({
756
- instructionType: OptionProgramInstruction.DepositToPool;
757
- } & ParsedDepositToPoolInstruction<TProgram>)
758
755
  | ({
759
756
  instructionType: OptionProgramInstruction.DepositToPosition;
760
757
  } & ParsedDepositToPositionInstruction<TProgram>)
@@ -821,12 +818,266 @@ export type ParsedOptionProgramInstruction<
821
818
  | ({
822
819
  instructionType: OptionProgramInstruction.UpdateMarketData;
823
820
  } & ParsedUpdateMarketDataInstruction<TProgram>)
824
- | ({
825
- instructionType: OptionProgramInstruction.WithdrawFromPool;
826
- } & ParsedWithdrawFromPoolInstruction<TProgram>)
827
821
  | ({
828
822
  instructionType: OptionProgramInstruction.WithdrawFromPosition;
829
823
  } & ParsedWithdrawFromPositionInstruction<TProgram>)
830
824
  | ({
831
825
  instructionType: OptionProgramInstruction.WriteToPool;
832
826
  } & ParsedWriteToPoolInstruction<TProgram>);
827
+
828
+ export function parseOptionProgramInstruction<TProgram extends string>(
829
+ instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
830
+ ): ParsedOptionProgramInstruction<TProgram> {
831
+ const instructionType = identifyOptionProgramInstruction(instruction);
832
+ switch (instructionType) {
833
+ case OptionProgramInstruction.AcceptAdmin: {
834
+ assertIsInstructionWithAccounts(instruction);
835
+ return {
836
+ instructionType: OptionProgramInstruction.AcceptAdmin,
837
+ ...parseAcceptAdminInstruction(instruction),
838
+ };
839
+ }
840
+ case OptionProgramInstruction.AutoExerciseAllExpired: {
841
+ assertIsInstructionWithAccounts(instruction);
842
+ return {
843
+ instructionType: OptionProgramInstruction.AutoExerciseAllExpired,
844
+ ...parseAutoExerciseAllExpiredInstruction(instruction),
845
+ };
846
+ }
847
+ case OptionProgramInstruction.AutoExerciseExpired: {
848
+ assertIsInstructionWithAccounts(instruction);
849
+ return {
850
+ instructionType: OptionProgramInstruction.AutoExerciseExpired,
851
+ ...parseAutoExerciseExpiredInstruction(instruction),
852
+ };
853
+ }
854
+ case OptionProgramInstruction.BorrowFromPool: {
855
+ assertIsInstructionWithAccounts(instruction);
856
+ return {
857
+ instructionType: OptionProgramInstruction.BorrowFromPool,
858
+ ...parseBorrowFromPoolInstruction(instruction),
859
+ };
860
+ }
861
+ case OptionProgramInstruction.BuyFromPool: {
862
+ assertIsInstructionWithAccounts(instruction);
863
+ return {
864
+ instructionType: OptionProgramInstruction.BuyFromPool,
865
+ ...parseBuyFromPoolInstruction(instruction),
866
+ };
867
+ }
868
+ case OptionProgramInstruction.ClaimTheta: {
869
+ assertIsInstructionWithAccounts(instruction);
870
+ return {
871
+ instructionType: OptionProgramInstruction.ClaimTheta,
872
+ ...parseClaimThetaInstruction(instruction),
873
+ };
874
+ }
875
+ case OptionProgramInstruction.CloseLongToPool: {
876
+ assertIsInstructionWithAccounts(instruction);
877
+ return {
878
+ instructionType: OptionProgramInstruction.CloseLongToPool,
879
+ ...parseCloseLongToPoolInstruction(instruction),
880
+ };
881
+ }
882
+ case OptionProgramInstruction.CloseOption: {
883
+ assertIsInstructionWithAccounts(instruction);
884
+ return {
885
+ instructionType: OptionProgramInstruction.CloseOption,
886
+ ...parseCloseOptionInstruction(instruction),
887
+ };
888
+ }
889
+ case OptionProgramInstruction.CreateEscrowV2: {
890
+ assertIsInstructionWithAccounts(instruction);
891
+ return {
892
+ instructionType: OptionProgramInstruction.CreateEscrowV2,
893
+ ...parseCreateEscrowV2Instruction(instruction),
894
+ };
895
+ }
896
+ case OptionProgramInstruction.CreateLiquidityRouter: {
897
+ assertIsInstructionWithAccounts(instruction);
898
+ return {
899
+ instructionType: OptionProgramInstruction.CreateLiquidityRouter,
900
+ ...parseCreateLiquidityRouterInstruction(instruction),
901
+ };
902
+ }
903
+ case OptionProgramInstruction.DepositCollateral: {
904
+ assertIsInstructionWithAccounts(instruction);
905
+ return {
906
+ instructionType: OptionProgramInstruction.DepositCollateral,
907
+ ...parseDepositCollateralInstruction(instruction),
908
+ };
909
+ }
910
+ case OptionProgramInstruction.DepositToPosition: {
911
+ assertIsInstructionWithAccounts(instruction);
912
+ return {
913
+ instructionType: OptionProgramInstruction.DepositToPosition,
914
+ ...parseDepositToPositionInstruction(instruction),
915
+ };
916
+ }
917
+ case OptionProgramInstruction.InitCollateralPool: {
918
+ assertIsInstructionWithAccounts(instruction);
919
+ return {
920
+ instructionType: OptionProgramInstruction.InitCollateralPool,
921
+ ...parseInitCollateralPoolInstruction(instruction),
922
+ };
923
+ }
924
+ case OptionProgramInstruction.InitConfig: {
925
+ assertIsInstructionWithAccounts(instruction);
926
+ return {
927
+ instructionType: OptionProgramInstruction.InitConfig,
928
+ ...parseInitConfigInstruction(instruction),
929
+ };
930
+ }
931
+ case OptionProgramInstruction.InitOptionPool: {
932
+ assertIsInstructionWithAccounts(instruction);
933
+ return {
934
+ instructionType: OptionProgramInstruction.InitOptionPool,
935
+ ...parseInitOptionPoolInstruction(instruction),
936
+ };
937
+ }
938
+ case OptionProgramInstruction.InitializeMarketData: {
939
+ assertIsInstructionWithAccounts(instruction);
940
+ return {
941
+ instructionType: OptionProgramInstruction.InitializeMarketData,
942
+ ...parseInitializeMarketDataInstruction(instruction),
943
+ };
944
+ }
945
+ case OptionProgramInstruction.LiquidateWriterPosition: {
946
+ assertIsInstructionWithAccounts(instruction);
947
+ return {
948
+ instructionType: OptionProgramInstruction.LiquidateWriterPosition,
949
+ ...parseLiquidateWriterPositionInstruction(instruction),
950
+ };
951
+ }
952
+ case OptionProgramInstruction.OmlpCreateVault: {
953
+ assertIsInstructionWithAccounts(instruction);
954
+ return {
955
+ instructionType: OptionProgramInstruction.OmlpCreateVault,
956
+ ...parseOmlpCreateVaultInstruction(instruction),
957
+ };
958
+ }
959
+ case OptionProgramInstruction.OmlpTakeOfferWithFailover: {
960
+ assertIsInstructionWithAccounts(instruction);
961
+ return {
962
+ instructionType: OptionProgramInstruction.OmlpTakeOfferWithFailover,
963
+ ...parseOmlpTakeOfferWithFailoverInstruction(instruction),
964
+ };
965
+ }
966
+ case OptionProgramInstruction.OmlpUpdateMaxLeverage: {
967
+ assertIsInstructionWithAccounts(instruction);
968
+ return {
969
+ instructionType: OptionProgramInstruction.OmlpUpdateMaxLeverage,
970
+ ...parseOmlpUpdateMaxLeverageInstruction(instruction),
971
+ };
972
+ }
973
+ case OptionProgramInstruction.OmlpUpdateProtocolFee: {
974
+ assertIsInstructionWithAccounts(instruction);
975
+ return {
976
+ instructionType: OptionProgramInstruction.OmlpUpdateProtocolFee,
977
+ ...parseOmlpUpdateProtocolFeeInstruction(instruction),
978
+ };
979
+ }
980
+ case OptionProgramInstruction.OmlpUpdateSupplyLimit: {
981
+ assertIsInstructionWithAccounts(instruction);
982
+ return {
983
+ instructionType: OptionProgramInstruction.OmlpUpdateSupplyLimit,
984
+ ...parseOmlpUpdateSupplyLimitInstruction(instruction),
985
+ };
986
+ }
987
+ case OptionProgramInstruction.OptionExercise: {
988
+ assertIsInstructionWithAccounts(instruction);
989
+ return {
990
+ instructionType: OptionProgramInstruction.OptionExercise,
991
+ ...parseOptionExerciseInstruction(instruction),
992
+ };
993
+ }
994
+ case OptionProgramInstruction.OptionMint: {
995
+ assertIsInstructionWithAccounts(instruction);
996
+ return {
997
+ instructionType: OptionProgramInstruction.OptionMint,
998
+ ...parseOptionMintInstruction(instruction),
999
+ };
1000
+ }
1001
+ case OptionProgramInstruction.OptionValidate: {
1002
+ assertIsInstructionWithAccounts(instruction);
1003
+ return {
1004
+ instructionType: OptionProgramInstruction.OptionValidate,
1005
+ ...parseOptionValidateInstruction(instruction),
1006
+ };
1007
+ }
1008
+ case OptionProgramInstruction.RepayPoolLoan: {
1009
+ assertIsInstructionWithAccounts(instruction);
1010
+ return {
1011
+ instructionType: OptionProgramInstruction.RepayPoolLoan,
1012
+ ...parseRepayPoolLoanInstruction(instruction),
1013
+ };
1014
+ }
1015
+ case OptionProgramInstruction.RepayPoolLoanFromCollateral: {
1016
+ assertIsInstructionWithAccounts(instruction);
1017
+ return {
1018
+ instructionType: OptionProgramInstruction.RepayPoolLoanFromCollateral,
1019
+ ...parseRepayPoolLoanFromCollateralInstruction(instruction),
1020
+ };
1021
+ }
1022
+ case OptionProgramInstruction.SettleMakerCollateral: {
1023
+ assertIsInstructionWithAccounts(instruction);
1024
+ return {
1025
+ instructionType: OptionProgramInstruction.SettleMakerCollateral,
1026
+ ...parseSettleMakerCollateralInstruction(instruction),
1027
+ };
1028
+ }
1029
+ case OptionProgramInstruction.SyncWriterPosition: {
1030
+ assertIsInstructionWithAccounts(instruction);
1031
+ return {
1032
+ instructionType: OptionProgramInstruction.SyncWriterPosition,
1033
+ ...parseSyncWriterPositionInstruction(instruction),
1034
+ };
1035
+ }
1036
+ case OptionProgramInstruction.TransferAdmin: {
1037
+ assertIsInstructionWithAccounts(instruction);
1038
+ return {
1039
+ instructionType: OptionProgramInstruction.TransferAdmin,
1040
+ ...parseTransferAdminInstruction(instruction),
1041
+ };
1042
+ }
1043
+ case OptionProgramInstruction.UnwindWriterUnsold: {
1044
+ assertIsInstructionWithAccounts(instruction);
1045
+ return {
1046
+ instructionType: OptionProgramInstruction.UnwindWriterUnsold,
1047
+ ...parseUnwindWriterUnsoldInstruction(instruction),
1048
+ };
1049
+ }
1050
+ case OptionProgramInstruction.UpdateImpliedVolatility: {
1051
+ assertIsInstructionWithAccounts(instruction);
1052
+ return {
1053
+ instructionType: OptionProgramInstruction.UpdateImpliedVolatility,
1054
+ ...parseUpdateImpliedVolatilityInstruction(instruction),
1055
+ };
1056
+ }
1057
+ case OptionProgramInstruction.UpdateMarketData: {
1058
+ assertIsInstructionWithAccounts(instruction);
1059
+ return {
1060
+ instructionType: OptionProgramInstruction.UpdateMarketData,
1061
+ ...parseUpdateMarketDataInstruction(instruction),
1062
+ };
1063
+ }
1064
+ case OptionProgramInstruction.WithdrawFromPosition: {
1065
+ assertIsInstructionWithAccounts(instruction);
1066
+ return {
1067
+ instructionType: OptionProgramInstruction.WithdrawFromPosition,
1068
+ ...parseWithdrawFromPositionInstruction(instruction),
1069
+ };
1070
+ }
1071
+ case OptionProgramInstruction.WriteToPool: {
1072
+ assertIsInstructionWithAccounts(instruction);
1073
+ return {
1074
+ instructionType: OptionProgramInstruction.WriteToPool,
1075
+ ...parseWriteToPoolInstruction(instruction),
1076
+ };
1077
+ }
1078
+ default:
1079
+ throw new Error(
1080
+ `Unrecognized instruction type: ${instructionType as string}`,
1081
+ );
1082
+ }
1083
+ }
package/index.ts CHANGED
@@ -18,9 +18,17 @@ export * from "./long/exercise";
18
18
  export * from "./long/quotes";
19
19
 
20
20
  export * from "./short/builders";
21
- export * from "./short/claim-premium";
21
+ export * from "./short/claim-theta";
22
22
  export * from "./short/close-option";
23
23
  export * from "./short/pool";
24
24
 
25
25
  export * from "./omlp/builders";
26
26
  export * from "./omlp/service";
27
+
28
+ export {
29
+ getWrapSOLInstructions,
30
+ getUnwrapSOLInstructions,
31
+ getSyncNativeInstruction,
32
+ getCloseAccountInstruction,
33
+ NATIVE_MINT,
34
+ } from "./wsol/instructions";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "description": "Solana Option Standard SDK. The frontend-first SDK for Native Options Trading on Solana. Created by Epicentral Labs.",
6
6
  "type": "module",
@@ -17,6 +17,7 @@
17
17
  "dependencies": {
18
18
  "@solana-program/address-lookup-table": "^0.11.0",
19
19
  "@solana-program/compute-budget": "^0.13.0",
20
+ "@solana-program/system": "^0.11.0",
20
21
  "@solana/kit": "^6.1.0",
21
22
  "bs58": "^6.0.0",
22
23
  "decimal.js": "^10.4.3"
@@ -0,0 +1,38 @@
1
+ import { getClaimThetaInstructionAsync } from "../generated/instructions";
2
+ import type { Instruction } from "@solana/kit";
3
+ import { toAddress } from "../client/program";
4
+ import type { AddressLike, BuiltTransaction } from "../client/types";
5
+
6
+ export interface BuildClaimThetaParams {
7
+ optionPool: AddressLike;
8
+ writerPosition?: AddressLike;
9
+ writerPaymentAccount: AddressLike;
10
+ premiumVault: AddressLike;
11
+ writer: AddressLike;
12
+ tokenProgram?: AddressLike;
13
+ }
14
+
15
+ export async function buildClaimThetaInstruction(
16
+ params: BuildClaimThetaParams
17
+ ): Promise<Instruction<string>> {
18
+ return getClaimThetaInstructionAsync({
19
+ optionPool: toAddress(params.optionPool),
20
+ writerPosition: params.writerPosition ? toAddress(params.writerPosition) : undefined,
21
+ writerPaymentAccount: toAddress(params.writerPaymentAccount),
22
+ premiumVault: toAddress(params.premiumVault),
23
+ writer: toAddress(params.writer) as any,
24
+ tokenProgram: params.tokenProgram ? toAddress(params.tokenProgram) : undefined,
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Builds a theta claim transaction for a writer's position.
30
+ * Writers claim their reserved theta (time-decay share) only.
31
+ * `writerPosition` is optional and can be derived by the generated instruction helper.
32
+ */
33
+ export async function buildClaimThetaTransaction(
34
+ params: BuildClaimThetaParams
35
+ ): Promise<BuiltTransaction> {
36
+ const instruction = await buildClaimThetaInstruction(params);
37
+ return { instructions: [instruction] };
38
+ }
package/short/pool.ts CHANGED
@@ -1,39 +1,13 @@
1
1
  import {
2
2
  getBorrowFromPoolInstructionAsync,
3
- getDepositToPoolInstructionAsync,
4
3
  getRepayPoolLoanInstructionAsync,
5
4
  getRepayPoolLoanFromCollateralInstructionAsync,
6
- getWithdrawFromPoolInstructionAsync,
7
5
  } from "../generated/instructions";
8
6
  import type { Instruction } from "@solana/kit";
9
7
  import { toAddress } from "../client/program";
10
8
  import type { AddressLike, BuiltTransaction } from "../client/types";
11
9
  import { assertNonNegativeAmount, assertPositiveAmount } from "../shared/amounts";
12
10
 
13
- export interface BuildDepositToPoolParams {
14
- optionPool: AddressLike;
15
- optionAccount: AddressLike;
16
- makerOptionAccount: AddressLike;
17
- escrowLongAccount: AddressLike;
18
- maker: AddressLike;
19
- amount: bigint | number;
20
- makerPoolShare?: AddressLike;
21
- tokenProgram?: AddressLike;
22
- associatedTokenProgram?: AddressLike;
23
- systemProgram?: AddressLike;
24
- }
25
-
26
- export interface BuildWithdrawFromPoolParams {
27
- optionPool: AddressLike;
28
- optionAccount: AddressLike;
29
- makerOptionAccount: AddressLike;
30
- escrowLongAccount: AddressLike;
31
- maker: AddressLike;
32
- amount: bigint | number;
33
- makerPoolShare?: AddressLike;
34
- tokenProgram?: AddressLike;
35
- }
36
-
37
11
  export interface BuildBorrowFromPoolParams {
38
12
  vault: AddressLike;
39
13
  vaultTokenAccount: AddressLike;
@@ -77,61 +51,6 @@ export interface BuildRepayPoolLoanFromCollateralParams {
77
51
  tokenProgram?: AddressLike;
78
52
  }
79
53
 
80
- export async function buildDepositToPoolInstruction(
81
- params: BuildDepositToPoolParams
82
- ): Promise<Instruction<string>> {
83
- assertPositiveAmount(params.amount, "amount");
84
-
85
- return getDepositToPoolInstructionAsync({
86
- optionPool: toAddress(params.optionPool),
87
- optionAccount: toAddress(params.optionAccount),
88
- makerPoolShare: params.makerPoolShare ? toAddress(params.makerPoolShare) : undefined,
89
- makerOptionAccount: toAddress(params.makerOptionAccount),
90
- escrowLongAccount: toAddress(params.escrowLongAccount),
91
- maker: toAddress(params.maker) as any,
92
- tokenProgram: params.tokenProgram ? toAddress(params.tokenProgram) : undefined,
93
- associatedTokenProgram: params.associatedTokenProgram
94
- ? toAddress(params.associatedTokenProgram)
95
- : undefined,
96
- systemProgram: params.systemProgram ? toAddress(params.systemProgram) : undefined,
97
- amount: params.amount,
98
- });
99
- }
100
-
101
- export async function buildDepositToPoolTransaction(
102
- params: BuildDepositToPoolParams
103
- ): Promise<BuiltTransaction> {
104
- const instruction = await buildDepositToPoolInstruction(params);
105
- return { instructions: [instruction] };
106
- }
107
-
108
- export async function buildWithdrawFromPoolInstruction(
109
- params: BuildWithdrawFromPoolParams
110
- ): Promise<Instruction<string>> {
111
- assertPositiveAmount(params.amount, "amount");
112
-
113
- return getWithdrawFromPoolInstructionAsync({
114
- optionPool: toAddress(params.optionPool),
115
- optionAccount: toAddress(params.optionAccount),
116
- makerPoolShare: params.makerPoolShare ? toAddress(params.makerPoolShare) : undefined,
117
- makerOptionAccount: toAddress(params.makerOptionAccount),
118
- escrowLongAccount: toAddress(params.escrowLongAccount),
119
- maker: toAddress(params.maker) as any,
120
- tokenProgram: params.tokenProgram ? toAddress(params.tokenProgram) : undefined,
121
- amount: params.amount,
122
- });
123
- }
124
-
125
- /**
126
- * Builds a pool withdraw instruction set for an LP maker position.
127
- */
128
- export async function buildWithdrawFromPoolTransaction(
129
- params: BuildWithdrawFromPoolParams
130
- ): Promise<BuiltTransaction> {
131
- const instruction = await buildWithdrawFromPoolInstruction(params);
132
- return { instructions: [instruction] };
133
- }
134
-
135
54
  export async function buildBorrowFromPoolInstruction(
136
55
  params: BuildBorrowFromPoolParams
137
56
  ): Promise<Instruction<string>> {