@symmetry-hq/temp-v3-sdk 0.0.1

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 (148) hide show
  1. package/dist/idl/idl.d.ts +8 -0
  2. package/dist/idl/idl.js +4958 -0
  3. package/dist/idl/types.d.ts +4955 -0
  4. package/dist/idl/types.js +2 -0
  5. package/dist/index.d.ts +24 -0
  6. package/dist/index.js +60 -0
  7. package/dist/layouts/basket.d.ts +42 -0
  8. package/dist/layouts/basket.js +43 -0
  9. package/dist/layouts/config.d.ts +97 -0
  10. package/dist/layouts/config.js +102 -0
  11. package/dist/layouts/fraction.d.ts +6 -0
  12. package/dist/layouts/fraction.js +9 -0
  13. package/dist/layouts/oracle.d.ts +36 -0
  14. package/dist/layouts/oracle.js +37 -0
  15. package/dist/src/constants.d.ts +15 -0
  16. package/dist/src/constants.js +19 -0
  17. package/dist/src/idl/idl.d.ts +8 -0
  18. package/dist/src/idl/idl.js +4958 -0
  19. package/dist/src/idl/types.d.ts +4955 -0
  20. package/dist/src/idl/types.js +2 -0
  21. package/dist/src/index.d.ts +53 -0
  22. package/dist/src/index.js +199 -0
  23. package/dist/src/instructions/accounts.d.ts +27 -0
  24. package/dist/src/instructions/accounts.js +110 -0
  25. package/dist/src/instructions/auction.d.ts +7 -0
  26. package/dist/src/instructions/auction.js +43 -0
  27. package/dist/src/instructions/automation/auction.d.ts +6 -0
  28. package/dist/src/instructions/automation/auction.js +40 -0
  29. package/dist/src/instructions/automation/claimBounty.d.ts +12 -0
  30. package/dist/src/instructions/automation/claimBounty.js +44 -0
  31. package/dist/src/instructions/automation/priceUpdate.d.ts +15 -0
  32. package/dist/src/instructions/automation/priceUpdate.js +47 -0
  33. package/dist/src/instructions/automation/rebalanceSwap.d.ts +10 -0
  34. package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
  35. package/dist/src/instructions/basket.d.ts +120 -0
  36. package/dist/src/instructions/basket.js +622 -0
  37. package/dist/src/instructions/bounty.d.ts +18 -0
  38. package/dist/src/instructions/bounty.js +81 -0
  39. package/dist/src/instructions/fee.d.ts +8 -0
  40. package/dist/src/instructions/fee.js +46 -0
  41. package/dist/src/instructions/globalConfig.d.ts +11 -0
  42. package/dist/src/instructions/globalConfig.js +43 -0
  43. package/dist/src/instructions/luts.d.ts +33 -0
  44. package/dist/src/instructions/luts.js +91 -0
  45. package/dist/src/instructions/management/addBounty.d.ts +7 -0
  46. package/dist/src/instructions/management/addBounty.js +39 -0
  47. package/dist/src/instructions/management/admin.d.ts +9 -0
  48. package/dist/src/instructions/management/admin.js +43 -0
  49. package/dist/src/instructions/management/claimFees.d.ts +7 -0
  50. package/dist/src/instructions/management/claimFees.js +47 -0
  51. package/dist/src/instructions/management/createBasket.d.ts +22 -0
  52. package/dist/src/instructions/management/createBasket.js +101 -0
  53. package/dist/src/instructions/management/edit.d.ts +34 -0
  54. package/dist/src/instructions/management/edit.js +192 -0
  55. package/dist/src/instructions/management/luts.d.ts +29 -0
  56. package/dist/src/instructions/management/luts.js +88 -0
  57. package/dist/src/instructions/pda.d.ts +26 -0
  58. package/dist/src/instructions/pda.js +110 -0
  59. package/dist/src/instructions/price.d.ts +17 -0
  60. package/dist/src/instructions/price.js +47 -0
  61. package/dist/src/instructions/user/deposit.d.ts +32 -0
  62. package/dist/src/instructions/user/deposit.js +168 -0
  63. package/dist/src/instructions/user/withdraw.d.ts +16 -0
  64. package/dist/src/instructions/user/withdraw.js +82 -0
  65. package/dist/src/layouts/basket.d.ts +41 -0
  66. package/dist/src/layouts/basket.js +43 -0
  67. package/dist/src/layouts/config.d.ts +133 -0
  68. package/dist/src/layouts/config.js +137 -0
  69. package/dist/src/layouts/fraction.d.ts +6 -0
  70. package/dist/src/layouts/fraction.js +9 -0
  71. package/dist/src/layouts/intents/bounty.d.ts +18 -0
  72. package/dist/src/layouts/intents/bounty.js +19 -0
  73. package/dist/src/layouts/intents/intent.d.ts +101 -0
  74. package/dist/src/layouts/intents/intent.js +113 -0
  75. package/dist/src/layouts/intents/rebalanceIntent.d.ts +56 -0
  76. package/dist/src/layouts/intents/rebalanceIntent.js +63 -0
  77. package/dist/src/layouts/lookupTable.d.ts +7 -0
  78. package/dist/src/layouts/lookupTable.js +10 -0
  79. package/dist/src/layouts/oracle.d.ts +42 -0
  80. package/dist/src/layouts/oracle.js +43 -0
  81. package/dist/src/states/basket.d.ts +8 -0
  82. package/dist/src/states/basket.js +54 -0
  83. package/dist/src/states/intents/intent.d.ts +14 -0
  84. package/dist/src/states/intents/intent.js +90 -0
  85. package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
  86. package/dist/src/states/intents/rebalanceIntent.js +54 -0
  87. package/dist/src/states/oracles/clmm_oracle.d.ts +178 -0
  88. package/dist/src/states/oracles/clmm_oracle.js +546 -0
  89. package/dist/src/states/oracles/constants.d.ts +8 -0
  90. package/dist/src/states/oracles/constants.js +12 -0
  91. package/dist/src/states/oracles/oracle.d.ts +60 -0
  92. package/dist/src/states/oracles/oracle.js +237 -0
  93. package/dist/src/states/oracles/pythOracle.d.ts +39 -0
  94. package/dist/src/states/oracles/pythOracle.js +202 -0
  95. package/dist/src/states/oracles/pyth_oracle.d.ts +39 -0
  96. package/dist/src/states/oracles/pyth_oracle.js +202 -0
  97. package/dist/src/states/oracles/raydiumClmmOracle.d.ts +178 -0
  98. package/dist/src/states/oracles/raydiumClmmOracle.js +546 -0
  99. package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +139 -0
  100. package/dist/src/states/oracles/raydiumCpmmOracle.js +420 -0
  101. package/dist/src/states/oracles/raydium_cpmm_oracle.d.ts +139 -0
  102. package/dist/src/states/oracles/raydium_cpmm_oracle.js +420 -0
  103. package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
  104. package/dist/src/states/oracles/switchboardOracle.js +1 -0
  105. package/dist/src/states/oracles/switchboard_oracle.d.ts +0 -0
  106. package/dist/src/states/oracles/switchboard_oracle.js +1 -0
  107. package/dist/src/txUtils.d.ts +26 -0
  108. package/dist/src/txUtils.js +183 -0
  109. package/dist/states/basket.d.ts +8 -0
  110. package/dist/states/basket.js +57 -0
  111. package/dist/test.d.ts +1 -0
  112. package/dist/test.js +39 -0
  113. package/package.json +30 -0
  114. package/src/constants.ts +24 -0
  115. package/src/index.ts +260 -0
  116. package/src/instructions/automation/auction.ts +55 -0
  117. package/src/instructions/automation/claimBounty.ts +69 -0
  118. package/src/instructions/automation/priceUpdate.ts +73 -0
  119. package/src/instructions/automation/rebalanceSwap.ts +60 -0
  120. package/src/instructions/management/addBounty.ts +56 -0
  121. package/src/instructions/management/admin.ts +65 -0
  122. package/src/instructions/management/claimFees.ts +59 -0
  123. package/src/instructions/management/createBasket.ts +148 -0
  124. package/src/instructions/management/edit.ts +255 -0
  125. package/src/instructions/management/luts.ts +134 -0
  126. package/src/instructions/pda.ts +160 -0
  127. package/src/instructions/user/deposit.ts +237 -0
  128. package/src/instructions/user/withdraw.ts +130 -0
  129. package/src/layouts/basket.ts +82 -0
  130. package/src/layouts/config.ts +301 -0
  131. package/src/layouts/fraction.ts +12 -0
  132. package/src/layouts/intents/bounty.ts +35 -0
  133. package/src/layouts/intents/intent.ts +204 -0
  134. package/src/layouts/intents/rebalanceIntent.ts +111 -0
  135. package/src/layouts/lookupTable.ts +14 -0
  136. package/src/layouts/oracle.ts +96 -0
  137. package/src/states/basket.ts +56 -0
  138. package/src/states/intents/intent.ts +107 -0
  139. package/src/states/intents/rebalanceIntent.ts +57 -0
  140. package/src/states/oracles/constants.ts +13 -0
  141. package/src/states/oracles/oracle.ts +260 -0
  142. package/src/states/oracles/pythOracle.ts +270 -0
  143. package/src/states/oracles/raydiumClmmOracle.ts +812 -0
  144. package/src/states/oracles/raydiumCpmmOracle.ts +614 -0
  145. package/src/states/oracles/switchboardOracle.ts +0 -0
  146. package/src/txUtils.ts +250 -0
  147. package/test.ts +30 -0
  148. package/tsconfig.json +101 -0
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PythOracle = void 0;
13
+ const decimal_js_1 = require("decimal.js");
14
+ const anchor_1 = require("@coral-xyz/anchor");
15
+ const hermes_client_1 = require("@pythnetwork/hermes-client");
16
+ const pyth_solana_receiver_1 = require("@pythnetwork/pyth-solana-receiver");
17
+ const web3_js_1 = require("@solana/web3.js");
18
+ const constants_1 = require("./constants");
19
+ const oracle_1 = require("./oracle");
20
+ ;
21
+ class PythOracle extends oracle_1.Oracle {
22
+ constructor(price_feed_account, connection, price_client, state, weight, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps) {
23
+ super(weight, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps);
24
+ this.price_feed_id = "";
25
+ this.price_feed_account = price_feed_account;
26
+ this.connection = connection;
27
+ this.price_client = price_client;
28
+ this.state = state;
29
+ }
30
+ ;
31
+ static create() {
32
+ return __awaiter(this, arguments, void 0, function* (connection = new web3_js_1.Connection(constants_1.SOLANA_DEVNET_ENDPOINT), price_feed_account, weight, price_client, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps) {
33
+ price_client = price_client !== null && price_client !== void 0 ? price_client : new hermes_client_1.HermesClient(constants_1.HERMES_PUBLIC_ENDPOINT, {});
34
+ const price_account_info = yield connection.getAccountInfo(price_feed_account);
35
+ if (!price_account_info) {
36
+ throw new Error(`Failed to fetch price account info for ${price_feed_account.toBase58()}`);
37
+ }
38
+ else {
39
+ let buffer = price_account_info.data;
40
+ let offset = 8;
41
+ let write_authority = new web3_js_1.PublicKey(buffer.slice(offset, offset + 32));
42
+ offset += 32;
43
+ let { level, size } = parseVerificationLevel(buffer, offset);
44
+ offset += size;
45
+ let price_message = new web3_js_1.PublicKey(buffer.slice(offset, offset + 32));
46
+ offset += 32;
47
+ let price = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').toString();
48
+ offset += 8;
49
+ let conf = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').toString();
50
+ offset += 8;
51
+ let exp = new anchor_1.BN(buffer.slice(offset, offset + 4), 'le').fromTwos(32).toString();
52
+ offset += 4;
53
+ let publish_time = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').fromTwos(64).toString();
54
+ offset += 8;
55
+ let state = {
56
+ price: new anchor_1.BN(price),
57
+ conf: new anchor_1.BN(conf),
58
+ expo: parseInt(exp),
59
+ publishTime: new anchor_1.BN(publish_time)
60
+ };
61
+ return new PythOracle(
62
+ // price_feed_id,
63
+ price_feed_account, connection, price_client, state, weight, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps);
64
+ }
65
+ });
66
+ }
67
+ ;
68
+ static createWithId() {
69
+ return __awaiter(this, arguments, void 0, function* (connection = new web3_js_1.Connection(constants_1.SOLANA_DEVNET_ENDPOINT), price_feed_id, wallet, weight, price_client, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps) {
70
+ const pythSolanaReceiver = new pyth_solana_receiver_1.PythSolanaReceiver({
71
+ connection,
72
+ wallet,
73
+ });
74
+ price_client = price_client !== null && price_client !== void 0 ? price_client : new hermes_client_1.HermesClient(constants_1.HERMES_PUBLIC_ENDPOINT, {});
75
+ const price_account = pythSolanaReceiver.getPriceFeedAccountAddress(1, price_feed_id);
76
+ const price_account_info = yield connection.getAccountInfo(price_account);
77
+ if (!price_account_info) {
78
+ throw new Error(`Failed to fetch price account info for ${price_account.toBase58()}`);
79
+ }
80
+ else {
81
+ let buffer = price_account_info.data;
82
+ let offset = 8;
83
+ let write_authority = new web3_js_1.PublicKey(buffer.slice(offset, offset + 32));
84
+ offset += 32;
85
+ let { level, size } = parseVerificationLevel(buffer, offset);
86
+ offset += size;
87
+ let price_message = new web3_js_1.PublicKey(buffer.slice(offset, offset + 32));
88
+ offset += 32;
89
+ let price = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').toString();
90
+ offset += 8;
91
+ let conf = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').toString();
92
+ offset += 8;
93
+ let exp = new anchor_1.BN(buffer.slice(offset, offset + 4), 'le').fromTwos(32).toString();
94
+ offset += 4;
95
+ let publish_time = new anchor_1.BN(buffer.slice(offset, offset + 8), 'le').fromTwos(64).toString();
96
+ offset += 8;
97
+ let state = {
98
+ price: new anchor_1.BN(price),
99
+ conf: new anchor_1.BN(conf),
100
+ expo: parseInt(exp),
101
+ publishTime: new anchor_1.BN(publish_time)
102
+ };
103
+ let pythOracle = new PythOracle(price_account, connection, price_client, state, weight, conf_thresh_bps, staleness_thresh, volatility_thresh, min_liquidity, staleness_conf_rate_bps);
104
+ pythOracle.set_price_feed_id(price_feed_id);
105
+ return pythOracle;
106
+ }
107
+ });
108
+ }
109
+ ;
110
+ get_confidence() {
111
+ return new decimal_js_1.Decimal(this.state.conf.toString()).mul(10 ** this.state.expo);
112
+ }
113
+ set_price_feed_id(price_feed_id) {
114
+ this.price_feed_id = price_feed_id;
115
+ }
116
+ fetch() {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ const currentTime = new anchor_1.BN(Math.floor(Date.now() / 1000));
119
+ if (currentTime.sub(this.state.publishTime).gt(new anchor_1.BN(this.staleness_thresh))) {
120
+ this.state = yield this.fetchPriceFromHermes(this.price_feed_id);
121
+ }
122
+ let errors = 0;
123
+ console.log(this.conf_thresh_bps);
124
+ console.log(this.state.conf.toString());
125
+ let pr = new decimal_js_1.Decimal(this.state.price.toString()).mul(10 ** this.state.expo);
126
+ let cf = new decimal_js_1.Decimal(this.state.conf.toString()).mul(10 ** this.state.expo);
127
+ console.log(cf.div(pr).mul(10000));
128
+ if (this.get_confidence().div(this.state.price.toString()).mul(10000).gt(this.conf_thresh_bps)) {
129
+ errors |= oracle_1.ErrorCode.TOO_UNCERTAIN;
130
+ }
131
+ let err = new oracle_1.OracleErrors(errors);
132
+ console.log(this.state.publishTime);
133
+ let oracle_price = new oracle_1.OraclePrice(new decimal_js_1.Decimal(this.state.price.toString()).mul(10 ** this.state.expo), new decimal_js_1.Decimal(this.state.conf.toString()).mul(10 ** this.state.expo), this.state.publishTime);
134
+ return new oracle_1.OracleResult(oracle_price, err);
135
+ });
136
+ }
137
+ fetchPriceFromHermes(price_feed_id) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const priceUpdate = yield this.price_client.getLatestPriceUpdates([price_feed_id], { encoding: "base64" });
140
+ if (priceUpdate && priceUpdate.parsed && priceUpdate.parsed.length > 0) {
141
+ const priceData = priceUpdate.parsed[0].price;
142
+ console.log(priceData.publish_time);
143
+ return {
144
+ price: new anchor_1.BN(priceData.price),
145
+ conf: new anchor_1.BN(priceData.conf),
146
+ expo: priceData.expo,
147
+ publishTime: new anchor_1.BN(priceData.publish_time)
148
+ };
149
+ }
150
+ else {
151
+ throw new Error(`Failed to fetch price update from Hermes for ${price_feed_id}`);
152
+ }
153
+ });
154
+ }
155
+ /**
156
+ * Get parsed baskets by manager. Uses 10 paralel rpc calls so might get heavy. Should set feed_id before running this
157
+ * @param {number} shardId - between 0-2^64, default is 0
158
+ * @param {number} [computeUnitPrice] - compute unit price in microlamports, default is 100_000
159
+ */
160
+ updateFeedTx(wallet_1) {
161
+ return __awaiter(this, arguments, void 0, function* (wallet, shardId = 0, computeUnitPrice = 100000) {
162
+ if (!shardId)
163
+ shardId = 0;
164
+ if (!computeUnitPrice)
165
+ computeUnitPrice = 100000;
166
+ let price_update = yield this.price_client.getLatestPriceUpdates([this.price_feed_id], { encoding: "base64" });
167
+ const pythSolanaReceiver = new pyth_solana_receiver_1.PythSolanaReceiver({
168
+ connection: this.connection,
169
+ wallet: wallet,
170
+ });
171
+ const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({
172
+ // closeUpdateAccounts: false
173
+ });
174
+ yield transactionBuilder.addUpdatePriceFeed(price_update.binary.data, shardId);
175
+ let build = yield transactionBuilder.buildVersionedTransactions({
176
+ computeUnitPriceMicroLamports: computeUnitPrice,
177
+ });
178
+ return build;
179
+ });
180
+ }
181
+ ;
182
+ sendUpdateTx(provider, updateFeedTx) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ let txs = yield provider.sendAll(updateFeedTx, { skipPreflight: true, commitment: "confirmed" });
185
+ return txs;
186
+ });
187
+ }
188
+ }
189
+ exports.PythOracle = PythOracle;
190
+ function parseVerificationLevel(buf, offset) {
191
+ const discr = buf.readUInt8(offset);
192
+ if (discr === 0) { // Partial
193
+ const numSignatures = buf.readUInt8(offset + 1);
194
+ return { level: `Partial(${numSignatures})`, size: 2 };
195
+ }
196
+ else if (discr === 1) { // Full
197
+ return { level: "Full", size: 1 };
198
+ }
199
+ else {
200
+ throw new Error(`Unknown verification level: ${discr}`);
201
+ }
202
+ }
@@ -0,0 +1,178 @@
1
+ import Decimal from 'decimal.js';
2
+ import { BN } from '@coral-xyz/anchor';
3
+ import { Connection, PublicKey } from '@solana/web3.js';
4
+ import { Oracle, OracleResult } from './oracle';
5
+ declare class Observation {
6
+ blockTimestamp: BN;
7
+ tickCumulative: BN;
8
+ padding: BN[];
9
+ constructor(params: {
10
+ blockTimestamp: BN;
11
+ tickCumulative: BN;
12
+ padding: BN[];
13
+ });
14
+ static decode(data: Buffer, offset?: number): [Observation, number];
15
+ sub(other: Observation): Observation;
16
+ add(other: Observation): Observation;
17
+ getWeightedObservation(time: BN): Observation;
18
+ adjustToTimestamp(targetTimestamp: BN, observationPrev: Observation): Observation;
19
+ }
20
+ declare class ObservationState {
21
+ initialized: boolean;
22
+ recentEpoch: BN;
23
+ observationIndex: number;
24
+ poolId: PublicKey;
25
+ observations: Observation[];
26
+ padding: BN[];
27
+ constructor(params: {
28
+ initialized: boolean;
29
+ recentEpoch: BN;
30
+ observationIndex: number;
31
+ poolId: PublicKey;
32
+ observations: Observation[];
33
+ padding: BN[];
34
+ });
35
+ static decode(data: Buffer, offset?: number): [ObservationState, number];
36
+ }
37
+ declare class RewardInfo {
38
+ rewardState: number;
39
+ openTime: BN;
40
+ endTime: BN;
41
+ lastUpdateTime: BN;
42
+ emissionsPerSecondX64: BN;
43
+ rewardTotalEmissioned: BN;
44
+ rewardClaimed: BN;
45
+ tokenMint: PublicKey;
46
+ tokenVault: PublicKey;
47
+ authority: PublicKey;
48
+ rewardGrowthGlobalX64: BN;
49
+ constructor(params: {
50
+ rewardState: number;
51
+ openTime: BN;
52
+ endTime: BN;
53
+ lastUpdateTime: BN;
54
+ emissionsPerSecondX64: BN;
55
+ rewardTotalEmissioned: BN;
56
+ rewardClaimed: BN;
57
+ tokenMint: PublicKey;
58
+ tokenVault: PublicKey;
59
+ authority: PublicKey;
60
+ rewardGrowthGlobalX64: BN;
61
+ });
62
+ static decode(data: Buffer, offset?: number): [RewardInfo, number];
63
+ }
64
+ declare class PoolState {
65
+ bump: number[];
66
+ ammConfig: PublicKey;
67
+ owner: PublicKey;
68
+ tokenMint0: PublicKey;
69
+ tokenMint1: PublicKey;
70
+ tokenVault0: PublicKey;
71
+ tokenVault1: PublicKey;
72
+ observationKey: PublicKey;
73
+ mintDecimals0: number;
74
+ mintDecimals1: number;
75
+ tickSpacing: number;
76
+ liquidity: BN;
77
+ sqrtPriceX64: BN;
78
+ tickCurrent: BN;
79
+ padding3: number;
80
+ padding4: number;
81
+ feeGrowthGlobal0X64: BN;
82
+ feeGrowthGlobal1X64: BN;
83
+ protocolFeesToken0: BN;
84
+ protocolFeesToken1: BN;
85
+ swapInAmountToken0: BN;
86
+ swapOutAmountToken1: BN;
87
+ swapInAmountToken1: BN;
88
+ swapOutAmountToken0: BN;
89
+ status: number;
90
+ padding: number[];
91
+ rewardInfos: RewardInfo[];
92
+ tickArrayBitmap: BN[];
93
+ totalFeesToken0: BN;
94
+ totalFeesClaimedToken0: BN;
95
+ totalFeesToken1: BN;
96
+ totalFeesClaimedToken1: BN;
97
+ fundFeesToken0: BN;
98
+ fundFeesToken1: BN;
99
+ openTime: BN;
100
+ recentEpoch: BN;
101
+ padding1: BN[];
102
+ padding2: BN[];
103
+ constructor(params: {
104
+ bump: number[];
105
+ ammConfig: PublicKey;
106
+ owner: PublicKey;
107
+ tokenMint0: PublicKey;
108
+ tokenMint1: PublicKey;
109
+ tokenVault0: PublicKey;
110
+ tokenVault1: PublicKey;
111
+ observationKey: PublicKey;
112
+ mintDecimals0: number;
113
+ mintDecimals1: number;
114
+ tickSpacing: BN;
115
+ liquidity: BN;
116
+ sqrtPriceX64: BN;
117
+ tickCurrent: BN;
118
+ padding3: number;
119
+ padding4: number;
120
+ feeGrowthGlobal0X64: BN;
121
+ feeGrowthGlobal1X64: BN;
122
+ protocolFeesToken0: BN;
123
+ protocolFeesToken1: BN;
124
+ swapInAmountToken0: BN;
125
+ swapOutAmountToken1: BN;
126
+ swapInAmountToken1: BN;
127
+ swapOutAmountToken0: BN;
128
+ status: number;
129
+ padding: number[];
130
+ rewardInfos: RewardInfo[];
131
+ tickArrayBitmap: BN[];
132
+ totalFeesToken0: BN;
133
+ totalFeesClaimedToken0: BN;
134
+ totalFeesToken1: BN;
135
+ totalFeesClaimedToken1: BN;
136
+ fundFeesToken0: BN;
137
+ fundFeesToken1: BN;
138
+ openTime: BN;
139
+ recentEpoch: BN;
140
+ padding1: BN[];
141
+ padding2: BN[];
142
+ });
143
+ static decode(data: Buffer, offset?: number): [PoolState, number];
144
+ }
145
+ export declare class RaydiumCLMMOracle extends Oracle {
146
+ poolId: PublicKey;
147
+ quoteToken: number;
148
+ poolState: PoolState;
149
+ observationState: ObservationState;
150
+ primarySeconds: number;
151
+ secondarySeconds: number;
152
+ private constructor();
153
+ static create(params: {
154
+ connection: Connection;
155
+ poolId: PublicKey;
156
+ quoteToken: number;
157
+ weight: number;
158
+ primarySeconds: number;
159
+ secondarySeconds: number;
160
+ confThreshBps?: number;
161
+ stalenessThresh?: number;
162
+ volatilityThresh?: number | Decimal;
163
+ minLiquidity?: number | Decimal;
164
+ stalenessConfRateBps?: number;
165
+ }): Promise<RaydiumCLMMOracle>;
166
+ static deriveObservationKey(poolId: PublicKey): [PublicKey, number];
167
+ getObservationAtIndex(index: number): Observation;
168
+ getObservationAtTimestamp(timestamp: BN, startIndex: number): Observation;
169
+ getDeltaObservations(currentTime: BN, primarySeconds: number, secondarySeconds: number): Observation[];
170
+ getSqrtPriceX64FromTick(tick: BN): BN;
171
+ sqrtPriceX64ToPrice(sqrtPriceX64: BN, decimalsA: number, decimalsB: number): Decimal;
172
+ x64ToDecimal(num: BN, decimalPlaces?: number): Decimal;
173
+ getTwapPrimary(currentTime: BN): Decimal;
174
+ getTwapSecondary(currentTime: BN): Decimal;
175
+ getConfidence(currentTime: BN): Decimal;
176
+ fetch(): Promise<OracleResult>;
177
+ }
178
+ export {};