@epicentral/sos-sdk 0.1.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.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +239 -0
  3. package/accounts/fetchers.ts +140 -0
  4. package/accounts/list.ts +152 -0
  5. package/accounts/pdas.ts +308 -0
  6. package/client/lookup-table.ts +32 -0
  7. package/client/program.ts +13 -0
  8. package/client/types.ts +8 -0
  9. package/generated/accounts/collateralPool.ts +217 -0
  10. package/generated/accounts/config.ts +156 -0
  11. package/generated/accounts/dualSourceContract.ts +235 -0
  12. package/generated/accounts/escrowState.ts +183 -0
  13. package/generated/accounts/index.ts +24 -0
  14. package/generated/accounts/lenderPosition.ts +211 -0
  15. package/generated/accounts/liquidityRouter.ts +223 -0
  16. package/generated/accounts/makerCollateralShare.ts +229 -0
  17. package/generated/accounts/makerPoolShare.ts +203 -0
  18. package/generated/accounts/marketDataAccount.ts +176 -0
  19. package/generated/accounts/optionAccount.ts +247 -0
  20. package/generated/accounts/optionPool.ts +253 -0
  21. package/generated/accounts/poolLoan.ts +220 -0
  22. package/generated/accounts/positionAccount.ts +187 -0
  23. package/generated/accounts/priceUpdateV2.ts +163 -0
  24. package/generated/accounts/vault.ts +304 -0
  25. package/generated/accounts/writerPosition.ts +297 -0
  26. package/generated/errors/index.ts +9 -0
  27. package/generated/errors/optionProgram.ts +392 -0
  28. package/generated/index.ts +13 -0
  29. package/generated/instructions/acceptAdmin.ts +230 -0
  30. package/generated/instructions/autoExerciseAllExpired.ts +523 -0
  31. package/generated/instructions/autoExerciseExpired.ts +623 -0
  32. package/generated/instructions/borrowFromPool.ts +554 -0
  33. package/generated/instructions/buyFromPool.ts +684 -0
  34. package/generated/instructions/claimPremium.ts +377 -0
  35. package/generated/instructions/closeLongToPool.ts +716 -0
  36. package/generated/instructions/closeOption.ts +235 -0
  37. package/generated/instructions/createEscrowV2.ts +518 -0
  38. package/generated/instructions/createLiquidityRouter.ts +361 -0
  39. package/generated/instructions/depositCollateral.ts +624 -0
  40. package/generated/instructions/depositToPool.ts +497 -0
  41. package/generated/instructions/depositToPosition.ts +429 -0
  42. package/generated/instructions/index.ts +45 -0
  43. package/generated/instructions/initCollateralPool.ts +513 -0
  44. package/generated/instructions/initConfig.ts +279 -0
  45. package/generated/instructions/initOptionPool.ts +587 -0
  46. package/generated/instructions/initializeMarketData.ts +359 -0
  47. package/generated/instructions/liquidateWriterPosition.ts +592 -0
  48. package/generated/instructions/omlpCreateVault.ts +547 -0
  49. package/generated/instructions/omlpTakeOfferWithFailover.ts +606 -0
  50. package/generated/instructions/omlpUpdateMaxLeverage.ts +304 -0
  51. package/generated/instructions/omlpUpdateProtocolFee.ts +304 -0
  52. package/generated/instructions/omlpUpdateSupplyLimit.ts +304 -0
  53. package/generated/instructions/optionExercise.ts +540 -0
  54. package/generated/instructions/optionMint.ts +1349 -0
  55. package/generated/instructions/optionValidate.ts +255 -0
  56. package/generated/instructions/repayPoolLoan.ts +499 -0
  57. package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
  58. package/generated/instructions/settleMakerCollateral.ts +472 -0
  59. package/generated/instructions/syncWriterPosition.ts +206 -0
  60. package/generated/instructions/transferAdmin.ts +245 -0
  61. package/generated/instructions/unwindWriterUnsold.ts +668 -0
  62. package/generated/instructions/updateImpliedVolatility.ts +226 -0
  63. package/generated/instructions/updateMarketData.ts +315 -0
  64. package/generated/instructions/withdrawFromPool.ts +429 -0
  65. package/generated/instructions/withdrawFromPosition.ts +405 -0
  66. package/generated/instructions/writeToPool.ts +594 -0
  67. package/generated/programs/index.ts +9 -0
  68. package/generated/programs/optionProgram.ts +832 -0
  69. package/generated/shared/index.ts +164 -0
  70. package/generated/types/borrowedFromSAP1.ts +75 -0
  71. package/generated/types/borrowedFromSAP2.ts +83 -0
  72. package/generated/types/failoverTriggered.ts +85 -0
  73. package/generated/types/impliedVolatilityUpdated.ts +73 -0
  74. package/generated/types/index.ts +32 -0
  75. package/generated/types/liquidationExecuted.ts +73 -0
  76. package/generated/types/liquidityMetrics.ts +69 -0
  77. package/generated/types/liquidityRouterCreated.ts +79 -0
  78. package/generated/types/marketDataInitialized.ts +61 -0
  79. package/generated/types/marketDataUpdated.ts +69 -0
  80. package/generated/types/optionClosed.ts +56 -0
  81. package/generated/types/optionExercised.ts +62 -0
  82. package/generated/types/optionExpired.ts +49 -0
  83. package/generated/types/optionMinted.ts +78 -0
  84. package/generated/types/optionType.ts +38 -0
  85. package/generated/types/optionValidated.ts +82 -0
  86. package/generated/types/poolLoanCreated.ts +74 -0
  87. package/generated/types/poolLoanRepaid.ts +74 -0
  88. package/generated/types/positionDeposited.ts +73 -0
  89. package/generated/types/positionWithdrawn.ts +81 -0
  90. package/generated/types/priceFeedMessage.ts +117 -0
  91. package/generated/types/protocolFeeUpdated.ts +69 -0
  92. package/generated/types/sap2Provider.ts +38 -0
  93. package/generated/types/vaultCreated.ts +60 -0
  94. package/generated/types/verificationLevel.ts +95 -0
  95. package/index.ts +25 -0
  96. package/long/builders.ts +126 -0
  97. package/long/exercise.ts +49 -0
  98. package/long/quotes.ts +48 -0
  99. package/omlp/builders.ts +74 -0
  100. package/omlp/service.ts +94 -0
  101. package/package.json +22 -0
  102. package/shared/amounts.ts +32 -0
  103. package/shared/errors.ts +12 -0
  104. package/shared/remaining-accounts.ts +41 -0
  105. package/shared/transactions.ts +49 -0
  106. package/short/builders.ts +268 -0
  107. package/short/claim-premium.ts +37 -0
  108. package/short/close-option.ts +34 -0
  109. package/short/pool.ts +224 -0
  110. package/tsconfig.json +12 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getI64Decoder,
14
+ getI64Encoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU64Decoder,
18
+ getU64Encoder,
19
+ type Address,
20
+ type FixedSizeCodec,
21
+ type FixedSizeDecoder,
22
+ type FixedSizeEncoder,
23
+ } from "@solana/kit";
24
+
25
+ export type PoolLoanRepaid = {
26
+ poolLoan: Address;
27
+ maker: Address;
28
+ principal: bigint;
29
+ interest: bigint;
30
+ protocolFees: bigint;
31
+ totalRepaid: bigint;
32
+ repaidAt: bigint;
33
+ };
34
+
35
+ export type PoolLoanRepaidArgs = {
36
+ poolLoan: Address;
37
+ maker: Address;
38
+ principal: number | bigint;
39
+ interest: number | bigint;
40
+ protocolFees: number | bigint;
41
+ totalRepaid: number | bigint;
42
+ repaidAt: number | bigint;
43
+ };
44
+
45
+ export function getPoolLoanRepaidEncoder(): FixedSizeEncoder<PoolLoanRepaidArgs> {
46
+ return getStructEncoder([
47
+ ["poolLoan", getAddressEncoder()],
48
+ ["maker", getAddressEncoder()],
49
+ ["principal", getU64Encoder()],
50
+ ["interest", getU64Encoder()],
51
+ ["protocolFees", getU64Encoder()],
52
+ ["totalRepaid", getU64Encoder()],
53
+ ["repaidAt", getI64Encoder()],
54
+ ]);
55
+ }
56
+
57
+ export function getPoolLoanRepaidDecoder(): FixedSizeDecoder<PoolLoanRepaid> {
58
+ return getStructDecoder([
59
+ ["poolLoan", getAddressDecoder()],
60
+ ["maker", getAddressDecoder()],
61
+ ["principal", getU64Decoder()],
62
+ ["interest", getU64Decoder()],
63
+ ["protocolFees", getU64Decoder()],
64
+ ["totalRepaid", getU64Decoder()],
65
+ ["repaidAt", getI64Decoder()],
66
+ ]);
67
+ }
68
+
69
+ export function getPoolLoanRepaidCodec(): FixedSizeCodec<
70
+ PoolLoanRepaidArgs,
71
+ PoolLoanRepaid
72
+ > {
73
+ return combineCodec(getPoolLoanRepaidEncoder(), getPoolLoanRepaidDecoder());
74
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getI64Decoder,
14
+ getI64Encoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU64Decoder,
18
+ getU64Encoder,
19
+ type Address,
20
+ type FixedSizeCodec,
21
+ type FixedSizeDecoder,
22
+ type FixedSizeEncoder,
23
+ } from "@solana/kit";
24
+
25
+ export type PositionDeposited = {
26
+ position: Address;
27
+ lender: Address;
28
+ vault: Address;
29
+ amount: bigint;
30
+ totalBalance: bigint;
31
+ timestamp: bigint;
32
+ };
33
+
34
+ export type PositionDepositedArgs = {
35
+ position: Address;
36
+ lender: Address;
37
+ vault: Address;
38
+ amount: number | bigint;
39
+ totalBalance: number | bigint;
40
+ timestamp: number | bigint;
41
+ };
42
+
43
+ export function getPositionDepositedEncoder(): FixedSizeEncoder<PositionDepositedArgs> {
44
+ return getStructEncoder([
45
+ ["position", getAddressEncoder()],
46
+ ["lender", getAddressEncoder()],
47
+ ["vault", getAddressEncoder()],
48
+ ["amount", getU64Encoder()],
49
+ ["totalBalance", getU64Encoder()],
50
+ ["timestamp", getI64Encoder()],
51
+ ]);
52
+ }
53
+
54
+ export function getPositionDepositedDecoder(): FixedSizeDecoder<PositionDeposited> {
55
+ return getStructDecoder([
56
+ ["position", getAddressDecoder()],
57
+ ["lender", getAddressDecoder()],
58
+ ["vault", getAddressDecoder()],
59
+ ["amount", getU64Decoder()],
60
+ ["totalBalance", getU64Decoder()],
61
+ ["timestamp", getI64Decoder()],
62
+ ]);
63
+ }
64
+
65
+ export function getPositionDepositedCodec(): FixedSizeCodec<
66
+ PositionDepositedArgs,
67
+ PositionDeposited
68
+ > {
69
+ return combineCodec(
70
+ getPositionDepositedEncoder(),
71
+ getPositionDepositedDecoder(),
72
+ );
73
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getI64Decoder,
14
+ getI64Encoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU64Decoder,
18
+ getU64Encoder,
19
+ type Address,
20
+ type FixedSizeCodec,
21
+ type FixedSizeDecoder,
22
+ type FixedSizeEncoder,
23
+ } from "@solana/kit";
24
+
25
+ export type PositionWithdrawn = {
26
+ position: Address;
27
+ lender: Address;
28
+ vault: Address;
29
+ amount: bigint;
30
+ principalPortion: bigint;
31
+ interestPortion: bigint;
32
+ remainingBalance: bigint;
33
+ timestamp: bigint;
34
+ };
35
+
36
+ export type PositionWithdrawnArgs = {
37
+ position: Address;
38
+ lender: Address;
39
+ vault: Address;
40
+ amount: number | bigint;
41
+ principalPortion: number | bigint;
42
+ interestPortion: number | bigint;
43
+ remainingBalance: number | bigint;
44
+ timestamp: number | bigint;
45
+ };
46
+
47
+ export function getPositionWithdrawnEncoder(): FixedSizeEncoder<PositionWithdrawnArgs> {
48
+ return getStructEncoder([
49
+ ["position", getAddressEncoder()],
50
+ ["lender", getAddressEncoder()],
51
+ ["vault", getAddressEncoder()],
52
+ ["amount", getU64Encoder()],
53
+ ["principalPortion", getU64Encoder()],
54
+ ["interestPortion", getU64Encoder()],
55
+ ["remainingBalance", getU64Encoder()],
56
+ ["timestamp", getI64Encoder()],
57
+ ]);
58
+ }
59
+
60
+ export function getPositionWithdrawnDecoder(): FixedSizeDecoder<PositionWithdrawn> {
61
+ return getStructDecoder([
62
+ ["position", getAddressDecoder()],
63
+ ["lender", getAddressDecoder()],
64
+ ["vault", getAddressDecoder()],
65
+ ["amount", getU64Decoder()],
66
+ ["principalPortion", getU64Decoder()],
67
+ ["interestPortion", getU64Decoder()],
68
+ ["remainingBalance", getU64Decoder()],
69
+ ["timestamp", getI64Decoder()],
70
+ ]);
71
+ }
72
+
73
+ export function getPositionWithdrawnCodec(): FixedSizeCodec<
74
+ PositionWithdrawnArgs,
75
+ PositionWithdrawn
76
+ > {
77
+ return combineCodec(
78
+ getPositionWithdrawnEncoder(),
79
+ getPositionWithdrawnDecoder(),
80
+ );
81
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ fixDecoderSize,
12
+ fixEncoderSize,
13
+ getBytesDecoder,
14
+ getBytesEncoder,
15
+ getI32Decoder,
16
+ getI32Encoder,
17
+ getI64Decoder,
18
+ getI64Encoder,
19
+ getStructDecoder,
20
+ getStructEncoder,
21
+ getU64Decoder,
22
+ getU64Encoder,
23
+ type FixedSizeCodec,
24
+ type FixedSizeDecoder,
25
+ type FixedSizeEncoder,
26
+ type ReadonlyUint8Array,
27
+ } from "@solana/kit";
28
+
29
+ export type PriceFeedMessage = {
30
+ /** `FeedId` but avoid the type alias because of compatibility issues with Anchor's `idl-build` feature. */
31
+ feedId: ReadonlyUint8Array;
32
+ price: bigint;
33
+ conf: bigint;
34
+ exponent: number;
35
+ /** The timestamp of this price update in seconds */
36
+ publishTime: bigint;
37
+ /**
38
+ * The timestamp of the previous price update. This field is intended to allow users to
39
+ * identify the single unique price update for any moment in time:
40
+ * for any time t, the unique update is the one such that prev_publish_time < t <= publish_time.
41
+ *
42
+ * Note that there may not be such an update while we are migrating to the new message-sending logic,
43
+ * as some price updates on pythnet may not be sent to other chains (because the message-sending
44
+ * logic may not have triggered). We can solve this problem by making the message-sending mandatory
45
+ * (which we can do once publishers have migrated over).
46
+ *
47
+ * Additionally, this field may be equal to publish_time if the message is sent on a slot where
48
+ * where the aggregation was unsuccesful. This problem will go away once all publishers have
49
+ * migrated over to a recent version of pyth-agent.
50
+ */
51
+ prevPublishTime: bigint;
52
+ emaPrice: bigint;
53
+ emaConf: bigint;
54
+ };
55
+
56
+ export type PriceFeedMessageArgs = {
57
+ /** `FeedId` but avoid the type alias because of compatibility issues with Anchor's `idl-build` feature. */
58
+ feedId: ReadonlyUint8Array;
59
+ price: number | bigint;
60
+ conf: number | bigint;
61
+ exponent: number;
62
+ /** The timestamp of this price update in seconds */
63
+ publishTime: number | bigint;
64
+ /**
65
+ * The timestamp of the previous price update. This field is intended to allow users to
66
+ * identify the single unique price update for any moment in time:
67
+ * for any time t, the unique update is the one such that prev_publish_time < t <= publish_time.
68
+ *
69
+ * Note that there may not be such an update while we are migrating to the new message-sending logic,
70
+ * as some price updates on pythnet may not be sent to other chains (because the message-sending
71
+ * logic may not have triggered). We can solve this problem by making the message-sending mandatory
72
+ * (which we can do once publishers have migrated over).
73
+ *
74
+ * Additionally, this field may be equal to publish_time if the message is sent on a slot where
75
+ * where the aggregation was unsuccesful. This problem will go away once all publishers have
76
+ * migrated over to a recent version of pyth-agent.
77
+ */
78
+ prevPublishTime: number | bigint;
79
+ emaPrice: number | bigint;
80
+ emaConf: number | bigint;
81
+ };
82
+
83
+ export function getPriceFeedMessageEncoder(): FixedSizeEncoder<PriceFeedMessageArgs> {
84
+ return getStructEncoder([
85
+ ["feedId", fixEncoderSize(getBytesEncoder(), 32)],
86
+ ["price", getI64Encoder()],
87
+ ["conf", getU64Encoder()],
88
+ ["exponent", getI32Encoder()],
89
+ ["publishTime", getI64Encoder()],
90
+ ["prevPublishTime", getI64Encoder()],
91
+ ["emaPrice", getI64Encoder()],
92
+ ["emaConf", getU64Encoder()],
93
+ ]);
94
+ }
95
+
96
+ export function getPriceFeedMessageDecoder(): FixedSizeDecoder<PriceFeedMessage> {
97
+ return getStructDecoder([
98
+ ["feedId", fixDecoderSize(getBytesDecoder(), 32)],
99
+ ["price", getI64Decoder()],
100
+ ["conf", getU64Decoder()],
101
+ ["exponent", getI32Decoder()],
102
+ ["publishTime", getI64Decoder()],
103
+ ["prevPublishTime", getI64Decoder()],
104
+ ["emaPrice", getI64Decoder()],
105
+ ["emaConf", getU64Decoder()],
106
+ ]);
107
+ }
108
+
109
+ export function getPriceFeedMessageCodec(): FixedSizeCodec<
110
+ PriceFeedMessageArgs,
111
+ PriceFeedMessage
112
+ > {
113
+ return combineCodec(
114
+ getPriceFeedMessageEncoder(),
115
+ getPriceFeedMessageDecoder(),
116
+ );
117
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getI64Decoder,
14
+ getI64Encoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ getU16Decoder,
18
+ getU16Encoder,
19
+ type Address,
20
+ type FixedSizeCodec,
21
+ type FixedSizeDecoder,
22
+ type FixedSizeEncoder,
23
+ } from "@solana/kit";
24
+
25
+ export type ProtocolFeeUpdated = {
26
+ vault: Address;
27
+ oldFeeBps: number;
28
+ newFeeBps: number;
29
+ updatedBy: Address;
30
+ updatedAt: bigint;
31
+ };
32
+
33
+ export type ProtocolFeeUpdatedArgs = {
34
+ vault: Address;
35
+ oldFeeBps: number;
36
+ newFeeBps: number;
37
+ updatedBy: Address;
38
+ updatedAt: number | bigint;
39
+ };
40
+
41
+ export function getProtocolFeeUpdatedEncoder(): FixedSizeEncoder<ProtocolFeeUpdatedArgs> {
42
+ return getStructEncoder([
43
+ ["vault", getAddressEncoder()],
44
+ ["oldFeeBps", getU16Encoder()],
45
+ ["newFeeBps", getU16Encoder()],
46
+ ["updatedBy", getAddressEncoder()],
47
+ ["updatedAt", getI64Encoder()],
48
+ ]);
49
+ }
50
+
51
+ export function getProtocolFeeUpdatedDecoder(): FixedSizeDecoder<ProtocolFeeUpdated> {
52
+ return getStructDecoder([
53
+ ["vault", getAddressDecoder()],
54
+ ["oldFeeBps", getU16Decoder()],
55
+ ["newFeeBps", getU16Decoder()],
56
+ ["updatedBy", getAddressDecoder()],
57
+ ["updatedAt", getI64Decoder()],
58
+ ]);
59
+ }
60
+
61
+ export function getProtocolFeeUpdatedCodec(): FixedSizeCodec<
62
+ ProtocolFeeUpdatedArgs,
63
+ ProtocolFeeUpdated
64
+ > {
65
+ return combineCodec(
66
+ getProtocolFeeUpdatedEncoder(),
67
+ getProtocolFeeUpdatedDecoder(),
68
+ );
69
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getEnumDecoder,
12
+ getEnumEncoder,
13
+ type FixedSizeCodec,
14
+ type FixedSizeDecoder,
15
+ type FixedSizeEncoder,
16
+ } from "@solana/kit";
17
+
18
+ /** SAP2 (External Liquidity) Provider Type */
19
+ export enum Sap2Provider {
20
+ Kamino,
21
+ }
22
+
23
+ export type Sap2ProviderArgs = Sap2Provider;
24
+
25
+ export function getSap2ProviderEncoder(): FixedSizeEncoder<Sap2ProviderArgs> {
26
+ return getEnumEncoder(Sap2Provider);
27
+ }
28
+
29
+ export function getSap2ProviderDecoder(): FixedSizeDecoder<Sap2Provider> {
30
+ return getEnumDecoder(Sap2Provider);
31
+ }
32
+
33
+ export function getSap2ProviderCodec(): FixedSizeCodec<
34
+ Sap2ProviderArgs,
35
+ Sap2Provider
36
+ > {
37
+ return combineCodec(getSap2ProviderEncoder(), getSap2ProviderDecoder());
38
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getAddressDecoder,
12
+ getAddressEncoder,
13
+ getI64Decoder,
14
+ getI64Encoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ type Address,
18
+ type FixedSizeCodec,
19
+ type FixedSizeDecoder,
20
+ type FixedSizeEncoder,
21
+ } from "@solana/kit";
22
+
23
+ export type VaultCreated = {
24
+ vault: Address;
25
+ mint: Address;
26
+ keeper: Address;
27
+ createdAt: bigint;
28
+ };
29
+
30
+ export type VaultCreatedArgs = {
31
+ vault: Address;
32
+ mint: Address;
33
+ keeper: Address;
34
+ createdAt: number | bigint;
35
+ };
36
+
37
+ export function getVaultCreatedEncoder(): FixedSizeEncoder<VaultCreatedArgs> {
38
+ return getStructEncoder([
39
+ ["vault", getAddressEncoder()],
40
+ ["mint", getAddressEncoder()],
41
+ ["keeper", getAddressEncoder()],
42
+ ["createdAt", getI64Encoder()],
43
+ ]);
44
+ }
45
+
46
+ export function getVaultCreatedDecoder(): FixedSizeDecoder<VaultCreated> {
47
+ return getStructDecoder([
48
+ ["vault", getAddressDecoder()],
49
+ ["mint", getAddressDecoder()],
50
+ ["keeper", getAddressDecoder()],
51
+ ["createdAt", getI64Decoder()],
52
+ ]);
53
+ }
54
+
55
+ export function getVaultCreatedCodec(): FixedSizeCodec<
56
+ VaultCreatedArgs,
57
+ VaultCreated
58
+ > {
59
+ return combineCodec(getVaultCreatedEncoder(), getVaultCreatedDecoder());
60
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ combineCodec,
11
+ getDiscriminatedUnionDecoder,
12
+ getDiscriminatedUnionEncoder,
13
+ getStructDecoder,
14
+ getStructEncoder,
15
+ getU8Decoder,
16
+ getU8Encoder,
17
+ getUnitDecoder,
18
+ getUnitEncoder,
19
+ type Codec,
20
+ type Decoder,
21
+ type Encoder,
22
+ type GetDiscriminatedUnionVariant,
23
+ type GetDiscriminatedUnionVariantContent,
24
+ } from "@solana/kit";
25
+
26
+ /**
27
+ * Pyth price updates are bridged to all blockchains via Wormhole.
28
+ * Using the price updates on another chain requires verifying the signatures of the Wormhole guardians.
29
+ * The usual process is to check the signatures for two thirds of the total number of guardians, but this can be cumbersome on Solana because of the transaction size limits,
30
+ * so we also allow for partial verification.
31
+ *
32
+ * This enum represents how much a price update has been verified:
33
+ * - If `Full`, we have verified the signatures for two thirds of the current guardians.
34
+ * - If `Partial`, only `num_signatures` guardian signatures have been checked.
35
+ *
36
+ * # Warning
37
+ * Using partially verified price updates is dangerous, as it lowers the threshold of guardians that need to collude to produce a malicious price update.
38
+ */
39
+ export type VerificationLevel =
40
+ | { __kind: "Partial"; numSignatures: number }
41
+ | { __kind: "Full" };
42
+
43
+ export type VerificationLevelArgs = VerificationLevel;
44
+
45
+ export function getVerificationLevelEncoder(): Encoder<VerificationLevelArgs> {
46
+ return getDiscriminatedUnionEncoder([
47
+ ["Partial", getStructEncoder([["numSignatures", getU8Encoder()]])],
48
+ ["Full", getUnitEncoder()],
49
+ ]);
50
+ }
51
+
52
+ export function getVerificationLevelDecoder(): Decoder<VerificationLevel> {
53
+ return getDiscriminatedUnionDecoder([
54
+ ["Partial", getStructDecoder([["numSignatures", getU8Decoder()]])],
55
+ ["Full", getUnitDecoder()],
56
+ ]);
57
+ }
58
+
59
+ export function getVerificationLevelCodec(): Codec<
60
+ VerificationLevelArgs,
61
+ VerificationLevel
62
+ > {
63
+ return combineCodec(
64
+ getVerificationLevelEncoder(),
65
+ getVerificationLevelDecoder(),
66
+ );
67
+ }
68
+
69
+ // Data Enum Helpers.
70
+ export function verificationLevel(
71
+ kind: "Partial",
72
+ data: GetDiscriminatedUnionVariantContent<
73
+ VerificationLevelArgs,
74
+ "__kind",
75
+ "Partial"
76
+ >,
77
+ ): GetDiscriminatedUnionVariant<VerificationLevelArgs, "__kind", "Partial">;
78
+ export function verificationLevel(
79
+ kind: "Full",
80
+ ): GetDiscriminatedUnionVariant<VerificationLevelArgs, "__kind", "Full">;
81
+ export function verificationLevel<
82
+ K extends VerificationLevelArgs["__kind"],
83
+ Data,
84
+ >(kind: K, data?: Data) {
85
+ return Array.isArray(data)
86
+ ? { __kind: kind, fields: data }
87
+ : { __kind: kind, ...(data ?? {}) };
88
+ }
89
+
90
+ export function isVerificationLevel<K extends VerificationLevel["__kind"]>(
91
+ kind: K,
92
+ value: VerificationLevel,
93
+ ): value is VerificationLevel & { __kind: K } {
94
+ return value.__kind === kind;
95
+ }
package/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ export * from "./client/program";
2
+ export * from "./client/types";
3
+ export * from "./client/lookup-table";
4
+ export { OptionType } from "./generated/types";
5
+
6
+ export * from "./accounts/pdas";
7
+ export * from "./accounts/fetchers";
8
+ export * from "./accounts/list";
9
+
10
+ export * from "./shared/amounts";
11
+ export * from "./shared/errors";
12
+ export * from "./shared/remaining-accounts";
13
+ export * from "./shared/transactions";
14
+
15
+ export * from "./long/builders";
16
+ export * from "./long/exercise";
17
+ export * from "./long/quotes";
18
+
19
+ export * from "./short/builders";
20
+ export * from "./short/claim-premium";
21
+ export * from "./short/close-option";
22
+ export * from "./short/pool";
23
+
24
+ export * from "./omlp/builders";
25
+ export * from "./omlp/service";