@symmetry-hq/sdk 1.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 (121) hide show
  1. package/dist/src/constants.d.ts +23 -0
  2. package/dist/src/constants.js +38 -0
  3. package/dist/src/index.d.ts +804 -0
  4. package/dist/src/index.js +2097 -0
  5. package/dist/src/instructions/automation/auction.d.ts +6 -0
  6. package/dist/src/instructions/automation/auction.js +40 -0
  7. package/dist/src/instructions/automation/claimBounty.d.ts +12 -0
  8. package/dist/src/instructions/automation/claimBounty.js +44 -0
  9. package/dist/src/instructions/automation/flashSwap.d.ts +21 -0
  10. package/dist/src/instructions/automation/flashSwap.js +74 -0
  11. package/dist/src/instructions/automation/priceUpdate.d.ts +19 -0
  12. package/dist/src/instructions/automation/priceUpdate.js +89 -0
  13. package/dist/src/instructions/automation/rebalanceIntent.d.ts +32 -0
  14. package/dist/src/instructions/automation/rebalanceIntent.js +117 -0
  15. package/dist/src/instructions/automation/rebalanceSwap.d.ts +11 -0
  16. package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
  17. package/dist/src/instructions/management/addBounty.d.ts +7 -0
  18. package/dist/src/instructions/management/addBounty.js +41 -0
  19. package/dist/src/instructions/management/admin.d.ts +9 -0
  20. package/dist/src/instructions/management/admin.js +53 -0
  21. package/dist/src/instructions/management/claimFees.d.ts +15 -0
  22. package/dist/src/instructions/management/claimFees.js +95 -0
  23. package/dist/src/instructions/management/createBasket.d.ts +21 -0
  24. package/dist/src/instructions/management/createBasket.js +98 -0
  25. package/dist/src/instructions/management/edit.d.ts +51 -0
  26. package/dist/src/instructions/management/edit.js +477 -0
  27. package/dist/src/instructions/management/luts.d.ts +30 -0
  28. package/dist/src/instructions/management/luts.js +99 -0
  29. package/dist/src/instructions/pda.d.ts +25 -0
  30. package/dist/src/instructions/pda.js +128 -0
  31. package/dist/src/instructions/user/deposit.d.ts +20 -0
  32. package/dist/src/instructions/user/deposit.js +100 -0
  33. package/dist/src/instructions/user/withdraw.d.ts +8 -0
  34. package/dist/src/instructions/user/withdraw.js +36 -0
  35. package/dist/src/jup.d.ts +49 -0
  36. package/dist/src/jup.js +80 -0
  37. package/dist/src/keeperMonitor.d.ts +52 -0
  38. package/dist/src/keeperMonitor.js +624 -0
  39. package/dist/src/layouts/basket.d.ts +191 -0
  40. package/dist/src/layouts/basket.js +51 -0
  41. package/dist/src/layouts/config.d.ts +281 -0
  42. package/dist/src/layouts/config.js +237 -0
  43. package/dist/src/layouts/fraction.d.ts +20 -0
  44. package/dist/src/layouts/fraction.js +164 -0
  45. package/dist/src/layouts/intents/bounty.d.ts +18 -0
  46. package/dist/src/layouts/intents/bounty.js +19 -0
  47. package/dist/src/layouts/intents/intent.d.ts +209 -0
  48. package/dist/src/layouts/intents/intent.js +97 -0
  49. package/dist/src/layouts/intents/rebalanceIntent.d.ts +212 -0
  50. package/dist/src/layouts/intents/rebalanceIntent.js +94 -0
  51. package/dist/src/layouts/lookupTable.d.ts +7 -0
  52. package/dist/src/layouts/lookupTable.js +10 -0
  53. package/dist/src/layouts/oracle.d.ts +63 -0
  54. package/dist/src/layouts/oracle.js +96 -0
  55. package/dist/src/states/basket.d.ts +14 -0
  56. package/dist/src/states/basket.js +479 -0
  57. package/dist/src/states/config.d.ts +3 -0
  58. package/dist/src/states/config.js +71 -0
  59. package/dist/src/states/intents/intent.d.ts +10 -0
  60. package/dist/src/states/intents/intent.js +316 -0
  61. package/dist/src/states/intents/rebalanceIntent.d.ts +42 -0
  62. package/dist/src/states/intents/rebalanceIntent.js +680 -0
  63. package/dist/src/states/oracles/constants.d.ts +9 -0
  64. package/dist/src/states/oracles/constants.js +15 -0
  65. package/dist/src/states/oracles/oracle.d.ts +24 -0
  66. package/dist/src/states/oracles/oracle.js +168 -0
  67. package/dist/src/states/oracles/pythOracle.d.ts +132 -0
  68. package/dist/src/states/oracles/pythOracle.js +609 -0
  69. package/dist/src/states/oracles/raydiumClmmOracle.d.ts +184 -0
  70. package/dist/src/states/oracles/raydiumClmmOracle.js +843 -0
  71. package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +120 -0
  72. package/dist/src/states/oracles/raydiumCpmmOracle.js +540 -0
  73. package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
  74. package/dist/src/states/oracles/switchboardOracle.js +1 -0
  75. package/dist/src/states/withdrawBasketFees.d.ts +10 -0
  76. package/dist/src/states/withdrawBasketFees.js +154 -0
  77. package/dist/src/txUtils.d.ts +65 -0
  78. package/dist/src/txUtils.js +306 -0
  79. package/dist/test.d.ts +1 -0
  80. package/dist/test.js +561 -0
  81. package/package.json +31 -0
  82. package/src/constants.ts +40 -0
  83. package/src/index.ts +2431 -0
  84. package/src/instructions/automation/auction.ts +55 -0
  85. package/src/instructions/automation/claimBounty.ts +69 -0
  86. package/src/instructions/automation/flashSwap.ts +104 -0
  87. package/src/instructions/automation/priceUpdate.ts +117 -0
  88. package/src/instructions/automation/rebalanceIntent.ts +181 -0
  89. package/src/instructions/management/addBounty.ts +55 -0
  90. package/src/instructions/management/admin.ts +72 -0
  91. package/src/instructions/management/claimFees.ts +129 -0
  92. package/src/instructions/management/createBasket.ts +138 -0
  93. package/src/instructions/management/edit.ts +602 -0
  94. package/src/instructions/management/luts.ts +157 -0
  95. package/src/instructions/pda.ts +151 -0
  96. package/src/instructions/user/deposit.ts +143 -0
  97. package/src/instructions/user/withdraw.ts +53 -0
  98. package/src/jup.ts +113 -0
  99. package/src/keeperMonitor.ts +585 -0
  100. package/src/layouts/basket.ts +233 -0
  101. package/src/layouts/config.ts +576 -0
  102. package/src/layouts/fraction.ts +164 -0
  103. package/src/layouts/intents/bounty.ts +35 -0
  104. package/src/layouts/intents/intent.ts +324 -0
  105. package/src/layouts/intents/rebalanceIntent.ts +306 -0
  106. package/src/layouts/lookupTable.ts +14 -0
  107. package/src/layouts/oracle.ts +157 -0
  108. package/src/states/basket.ts +527 -0
  109. package/src/states/config.ts +62 -0
  110. package/src/states/intents/intent.ts +311 -0
  111. package/src/states/intents/rebalanceIntent.ts +751 -0
  112. package/src/states/oracles/constants.ts +13 -0
  113. package/src/states/oracles/oracle.ts +212 -0
  114. package/src/states/oracles/pythOracle.ts +874 -0
  115. package/src/states/oracles/raydiumClmmOracle.ts +1193 -0
  116. package/src/states/oracles/raydiumCpmmOracle.ts +784 -0
  117. package/src/states/oracles/switchboardOracle.ts +0 -0
  118. package/src/states/withdrawBasketFees.ts +160 -0
  119. package/src/txUtils.ts +424 -0
  120. package/test.ts +609 -0
  121. package/tsconfig.json +101 -0
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GlobalConfigLayout = exports.BasketSettingsLayout = exports.MakeDirectSwapLayout = exports.UpdateWeightsLayout = exports.EditMakeDirectSwapDelayLayout = exports.EditUpdateWeightsDelayLayout = exports.EditAddTokenDelayLayout = exports.MetadataSettingsLayout = exports.MetadataParamsLayout = exports.LpSettingsLayout = exports.AutomationSettingsLayout = exports.ScheduleSettingsLayout = exports.FeeSettingsLayout = exports.HostFeesLayout = exports.ManagerSettingsWithAuthorityBitmasksLayout = exports.ManagerSettingsLayout = exports.AuthorityBitmasksLayout = exports.EditCreatorLayout = exports.BasketType = exports.MAX_URI_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_SYMBOL_LENGTH = exports.MAX_MANAGERS_PER_BASKET = void 0;
4
+ const borsh_1 = require("@coral-xyz/borsh");
5
+ const fraction_1 = require("./fraction");
6
+ const bounty_1 = require("./intents/bounty");
7
+ const constants_1 = require("../constants");
8
+ exports.MAX_MANAGERS_PER_BASKET = 10;
9
+ exports.MAX_SYMBOL_LENGTH = 10;
10
+ exports.MAX_NAME_LENGTH = 32;
11
+ exports.MAX_URI_LENGTH = 200;
12
+ var BasketType;
13
+ (function (BasketType) {
14
+ BasketType[BasketType["Private"] = 0] = "Private";
15
+ BasketType[BasketType["Public"] = 1] = "Public";
16
+ })(BasketType || (exports.BasketType = BasketType = {}));
17
+ ;
18
+ ;
19
+ exports.EditCreatorLayout = (0, borsh_1.struct)([
20
+ (0, borsh_1.publicKey)('creator'),
21
+ ]);
22
+ exports.AuthorityBitmasksLayout = (0, borsh_1.struct)([
23
+ (0, borsh_1.u16)('scheduleAuthorityBitmask'),
24
+ (0, borsh_1.u16)('feesAuthorityBitmask'),
25
+ (0, borsh_1.u16)('managersAuthorityBitmask'),
26
+ (0, borsh_1.u16)('automationAuthorityBitmask'),
27
+ (0, borsh_1.u16)('lpAuthorityBitmask'),
28
+ (0, borsh_1.u16)('metadataAuthorityBitmask'),
29
+ (0, borsh_1.u16)('depositsAuthorityBitmask'),
30
+ (0, borsh_1.u16)('forceRebalanceAuthorityBitmask'),
31
+ (0, borsh_1.u16)('customRebalanceAuthorityBitmask'),
32
+ (0, borsh_1.u16)('addTokenIntentAuthorityBitmask'),
33
+ (0, borsh_1.u16)('updateWeightsIntentAuthorityBitmask'),
34
+ (0, borsh_1.u16)('makeDirectSwapIntentAuthorityBitmask'),
35
+ (0, borsh_1.u16)('extraData'),
36
+ (0, borsh_1.u16)('extraData1'),
37
+ (0, borsh_1.u16)('extraData2'),
38
+ ]);
39
+ exports.ManagerSettingsLayout = (0, borsh_1.struct)([
40
+ (0, borsh_1.array)((0, borsh_1.publicKey)(), exports.MAX_MANAGERS_PER_BASKET, 'managers'),
41
+ (0, borsh_1.array)((0, borsh_1.u16)(), exports.MAX_MANAGERS_PER_BASKET, 'managersWeightBps'),
42
+ (0, borsh_1.u64)('modificationDelay'),
43
+ ]);
44
+ ;
45
+ exports.ManagerSettingsWithAuthorityBitmasksLayout = (0, borsh_1.struct)([
46
+ exports.ManagerSettingsLayout.replicate('managerSettings'),
47
+ exports.AuthorityBitmasksLayout.replicate('authorityBitmasks'),
48
+ ]);
49
+ exports.HostFeesLayout = (0, borsh_1.struct)([
50
+ (0, borsh_1.u16)('hostDepositFeeBps'),
51
+ (0, borsh_1.u16)('hostWithdrawalFeeBps'),
52
+ (0, borsh_1.u16)('hostManagementFeeBps'),
53
+ (0, borsh_1.u16)('hostPerformanceFeeBps'),
54
+ ]);
55
+ ;
56
+ exports.FeeSettingsLayout = (0, borsh_1.struct)([
57
+ (0, borsh_1.u16)('hostDepositFeeBps'),
58
+ (0, borsh_1.u16)('hostWithdrawFeeBps'),
59
+ (0, borsh_1.u16)('hostManagementFeeBps'),
60
+ (0, borsh_1.u16)('hostPerformanceFeeBps'),
61
+ (0, borsh_1.u16)('creatorDepositFeeBps'),
62
+ (0, borsh_1.u16)('creatorWithdrawFeeBps'),
63
+ (0, borsh_1.u16)('creatorManagementFeeBps'),
64
+ (0, borsh_1.u16)('creatorPerformanceFeeBps'),
65
+ (0, borsh_1.u16)('managersDepositFeeBps'),
66
+ (0, borsh_1.u16)('managersWithdrawFeeBps'),
67
+ (0, borsh_1.u16)('managersManagementFeeBps'),
68
+ (0, borsh_1.u16)('managersPerformanceFeeBps'),
69
+ (0, borsh_1.u16)('basketDepositFeeBps'),
70
+ (0, borsh_1.u16)('basketWithdrawFeeBps'),
71
+ (0, borsh_1.array)((0, borsh_1.u8)(), 32, 'extraData'),
72
+ (0, borsh_1.u64)('modificationDelay'),
73
+ ]);
74
+ ;
75
+ exports.ScheduleSettingsLayout = (0, borsh_1.struct)([
76
+ (0, borsh_1.u64)('cycleStartTime'),
77
+ (0, borsh_1.u64)('cycleDuration'),
78
+ (0, borsh_1.u64)('depositsStart'),
79
+ (0, borsh_1.u64)('depositsEnd'),
80
+ (0, borsh_1.u64)('automationStart'),
81
+ (0, borsh_1.u64)('automationEnd'),
82
+ (0, borsh_1.u64)('managementStart'),
83
+ (0, borsh_1.u64)('managementEnd'),
84
+ (0, borsh_1.u64)('modificationDelay'),
85
+ ]);
86
+ ;
87
+ exports.AutomationSettingsLayout = (0, borsh_1.struct)([
88
+ (0, borsh_1.u8)('allowAutomation'),
89
+ (0, borsh_1.u16)('rebalanceSlippageThresholdBps'),
90
+ (0, borsh_1.u16)('perTradeRebalanceSlippageThresholdBps'),
91
+ (0, borsh_1.u16)('rebalanceActivationThresholdAbsBps'),
92
+ (0, borsh_1.u16)('rebalanceActivationThresholdRelBps'),
93
+ (0, borsh_1.u64)('rebalanceActivationCooldown'),
94
+ (0, borsh_1.array)((0, borsh_1.publicKey)(), 4, 'extraData'),
95
+ (0, borsh_1.u64)('modificationDelay'),
96
+ ]);
97
+ ;
98
+ exports.LpSettingsLayout = (0, borsh_1.struct)([
99
+ (0, borsh_1.u8)('allowLp'),
100
+ (0, borsh_1.u16)('lpThresholdBps'),
101
+ (0, borsh_1.array)((0, borsh_1.u8)(), 32, 'extraData'),
102
+ (0, borsh_1.u64)('modificationDelay'),
103
+ ]);
104
+ ;
105
+ exports.MetadataParamsLayout = (0, borsh_1.struct)([
106
+ (0, borsh_1.str)("name"),
107
+ (0, borsh_1.str)("symbol"),
108
+ (0, borsh_1.str)("uri"),
109
+ ]);
110
+ ;
111
+ exports.MetadataSettingsLayout = (0, borsh_1.struct)([
112
+ (0, borsh_1.u8)('symbolLength'),
113
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.MAX_SYMBOL_LENGTH, 'symbol'),
114
+ (0, borsh_1.u8)('nameLength'),
115
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.MAX_NAME_LENGTH, 'name'),
116
+ (0, borsh_1.u8)('uriLength'),
117
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.MAX_URI_LENGTH, 'uri'),
118
+ (0, borsh_1.u64)('modificationDelay'),
119
+ ]);
120
+ ;
121
+ exports.EditAddTokenDelayLayout = (0, borsh_1.struct)([
122
+ (0, borsh_1.u64)('modificationDelay'),
123
+ ]);
124
+ ;
125
+ exports.EditUpdateWeightsDelayLayout = (0, borsh_1.struct)([
126
+ (0, borsh_1.u64)('modificationDelay'),
127
+ ]);
128
+ ;
129
+ exports.EditMakeDirectSwapDelayLayout = (0, borsh_1.struct)([
130
+ (0, borsh_1.u64)('modificationDelay'),
131
+ ]);
132
+ ;
133
+ exports.UpdateWeightsLayout = (0, borsh_1.struct)([
134
+ (0, borsh_1.array)((0, borsh_1.u16)(), constants_1.MAX_SUPPORTED_TOKENS_PER_BASKET, 'tokenWeights'),
135
+ (0, borsh_1.array)((0, borsh_1.u8)(), 32, 'tokenMintsHash'),
136
+ ]);
137
+ ;
138
+ exports.MakeDirectSwapLayout = (0, borsh_1.struct)([
139
+ (0, borsh_1.publicKey)('fromTokenMint'),
140
+ (0, borsh_1.publicKey)('toTokenMint'),
141
+ (0, borsh_1.u64)('amountFrom'),
142
+ (0, borsh_1.u64)('amountTo'),
143
+ ]);
144
+ exports.BasketSettingsLayout = (0, borsh_1.struct)([
145
+ (0, borsh_1.publicKey)('creator'),
146
+ (0, borsh_1.publicKey)('host'),
147
+ (0, borsh_1.u8)('basketType'),
148
+ (0, borsh_1.publicKey)('bountyMint'),
149
+ (0, borsh_1.u64)('bountyBalance'),
150
+ fraction_1.FractionLayout.replicate('startPrice'),
151
+ fraction_1.FractionLayout.replicate('highWaterMark'),
152
+ (0, borsh_1.u64)('activeRebalance'),
153
+ (0, borsh_1.u64)('activeWithdraws'),
154
+ (0, borsh_1.u64)('activeManagements'),
155
+ (0, borsh_1.u64)('lastAutomationExecutionTimestamp'),
156
+ exports.ManagerSettingsLayout.replicate('managers'),
157
+ (0, borsh_1.u64)('managersLastUpdateTimestamp'),
158
+ (0, borsh_1.u16)('managersAuthorityBitmask'),
159
+ exports.FeeSettingsLayout.replicate('fees'),
160
+ (0, borsh_1.u64)('feesLastUpdateTimestamp'),
161
+ (0, borsh_1.u16)('feesAuthorityBitmask'),
162
+ exports.ScheduleSettingsLayout.replicate('schedule'),
163
+ (0, borsh_1.u64)('scheduleLastUpdateTimestamp'),
164
+ (0, borsh_1.u16)('scheduleAuthorityBitmask'),
165
+ exports.AutomationSettingsLayout.replicate('automation'),
166
+ (0, borsh_1.u64)('automationLastUpdateTimestamp'),
167
+ (0, borsh_1.u16)('automationAuthorityBitmask'),
168
+ exports.LpSettingsLayout.replicate('lp'),
169
+ (0, borsh_1.u64)('lpLastUpdateTimestamp'),
170
+ (0, borsh_1.u16)('lpAuthorityBitmask'),
171
+ exports.MetadataSettingsLayout.replicate('metadata'),
172
+ (0, borsh_1.u64)('metadataLastUpdateTimestamp'),
173
+ (0, borsh_1.u16)('metadataAuthorityBitmask'),
174
+ (0, borsh_1.u8)('depositsAreAllowed'),
175
+ (0, borsh_1.u16)('depositsAuthorityBitmask'),
176
+ (0, borsh_1.u8)('forceRebalanceIsAllowed'),
177
+ (0, borsh_1.u64)('forceRebalanceModificationDelay'),
178
+ (0, borsh_1.u64)('forceRebalanceLastUpdateTimestamp'),
179
+ (0, borsh_1.u16)('forceRebalanceAuthorityBitmask'),
180
+ (0, borsh_1.u8)('customRebalanceIsAllowed'),
181
+ (0, borsh_1.u64)('customRebalanceModificationDelay'),
182
+ (0, borsh_1.u64)('customRebalanceLastUpdateTimestamp'),
183
+ (0, borsh_1.u16)('customRebalanceAuthorityBitmask'),
184
+ (0, borsh_1.u64)('addTokenDelay'),
185
+ (0, borsh_1.u64)('addTokenLastUpdateTimestamp'),
186
+ (0, borsh_1.u16)('addTokenIntentAuthorityBitmask'),
187
+ (0, borsh_1.u64)('updateWeightsDelay'),
188
+ (0, borsh_1.u64)('updateWeightsLastUpdateTimestamp'),
189
+ (0, borsh_1.u16)('updateWeightsIntentAuthorityBitmask'),
190
+ (0, borsh_1.u64)('makeDirectSwapDelay'),
191
+ (0, borsh_1.u64)('makeDirectSwapLastUpdateTimestamp'),
192
+ (0, borsh_1.u16)('makeDirectSwapIntentAuthorityBitmask'),
193
+ (0, borsh_1.array)((0, borsh_1.u64)(), 32, 'extraData'),
194
+ ]);
195
+ exports.GlobalConfigLayout = (0, borsh_1.struct)([
196
+ (0, borsh_1.publicKey)('admin'),
197
+ (0, borsh_1.array)((0, borsh_1.publicKey)(), 3, 'owners'),
198
+ (0, borsh_1.u64)('totalNumberOfBaskets'),
199
+ (0, borsh_1.u8)('allowInteractions'),
200
+ (0, borsh_1.u8)('allowCreation'),
201
+ (0, borsh_1.u8)('allowManagement'),
202
+ (0, borsh_1.u8)('allowAutomation'),
203
+ (0, borsh_1.u8)('allowDeposits'),
204
+ (0, borsh_1.u8)('allowWithdraws'),
205
+ (0, borsh_1.u16)('maxDepositFeeBps'),
206
+ (0, borsh_1.u16)('maxWithdrawFeeBps'),
207
+ (0, borsh_1.u16)('maxManagementFeeBps'),
208
+ (0, borsh_1.u16)('maxPerformanceFeeBps'),
209
+ (0, borsh_1.publicKey)('symmetryFeeCollector'),
210
+ (0, borsh_1.u16)('symmetryDepositFeeBps'),
211
+ (0, borsh_1.u16)('symmetryDepositFeeShareBps'),
212
+ (0, borsh_1.u16)('symmetryWithdrawFeeBps'),
213
+ (0, borsh_1.u16)('symmetryWithdrawFeeShareBps'),
214
+ (0, borsh_1.u16)('symmetryManagementFeeBps'),
215
+ (0, borsh_1.u16)('symmetryManagementFeeShareBps'),
216
+ (0, borsh_1.u16)('symmetryPerformanceFeeBps'),
217
+ (0, borsh_1.u16)('symmetryPerformanceFeeShareBps'),
218
+ (0, borsh_1.u16)('symmetryTradeFeeBps'),
219
+ (0, borsh_1.u16)('symmetryLimitOrderFeeBps'),
220
+ (0, borsh_1.array)((0, borsh_1.u8)(), 16, 'symmetryFeesExtraData'),
221
+ (0, borsh_1.publicKey)('bountyMint'),
222
+ (0, borsh_1.u64)('minBountyForBasketAutomation'),
223
+ (0, borsh_1.u64)('bountyBondAmount'),
224
+ bounty_1.BountyScheduleLayout.replicate('bountyPerTask'),
225
+ (0, borsh_1.u64)('bountyPerPriceUpdateTaskDivisor'),
226
+ fraction_1.FractionLayout.replicate('minRemainingValue'),
227
+ fraction_1.FractionLayout.replicate('minMintRatio'),
228
+ (0, borsh_1.u16)('aprBpsPerYear'),
229
+ (0, borsh_1.u64)('rebalanceIntentLifetime'),
230
+ (0, borsh_1.u64)('rebalanceAuction1Timeframe'),
231
+ (0, borsh_1.u64)('rebalanceAuction2Timeframe'),
232
+ (0, borsh_1.u64)('rebalanceAuction3Timeframe'),
233
+ (0, borsh_1.u64)('priceUpdateDelayAfterCreation'),
234
+ (0, borsh_1.u64)('priceUpdateLifetime'),
235
+ (0, borsh_1.u64)('priceUpdateReexecutionDelay'),
236
+ (0, borsh_1.array)((0, borsh_1.u64)(), 32, 'extraData'),
237
+ ]);
@@ -0,0 +1,20 @@
1
+ import BN from "bn.js";
2
+ import Decimal from "decimal.js";
3
+ export interface Fraction {
4
+ high: BN;
5
+ low: BN;
6
+ }
7
+ export declare const FractionLayout: any;
8
+ export declare function fractionToDecimal(fraction: Fraction): Decimal;
9
+ export declare function decimalToFraction(decimal: Decimal): Fraction;
10
+ export declare function fractionAdd(a: Fraction, b: Fraction): Fraction;
11
+ export declare function fractionSub(a: Fraction, b: Fraction): Fraction;
12
+ export declare function fractionMul(a: Fraction, b: Fraction): Fraction;
13
+ export declare function fractionDiv(a: Fraction, b: Fraction): Fraction;
14
+ export declare function fractionLt(a: Fraction, b: Fraction): boolean;
15
+ export declare function fractionLte(a: Fraction, b: Fraction): boolean;
16
+ export declare function fractionGt(a: Fraction, b: Fraction): boolean;
17
+ export declare function fractionGte(a: Fraction, b: Fraction): boolean;
18
+ export declare function fractionEq(a: Fraction, b: Fraction): boolean;
19
+ export declare function fractionRoundDown(fraction: Fraction): BN;
20
+ export declare function fractionRoundUp(fraction: Fraction): BN;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FractionLayout = void 0;
7
+ exports.fractionToDecimal = fractionToDecimal;
8
+ exports.decimalToFraction = decimalToFraction;
9
+ exports.fractionAdd = fractionAdd;
10
+ exports.fractionSub = fractionSub;
11
+ exports.fractionMul = fractionMul;
12
+ exports.fractionDiv = fractionDiv;
13
+ exports.fractionLt = fractionLt;
14
+ exports.fractionLte = fractionLte;
15
+ exports.fractionGt = fractionGt;
16
+ exports.fractionGte = fractionGte;
17
+ exports.fractionEq = fractionEq;
18
+ exports.fractionRoundDown = fractionRoundDown;
19
+ exports.fractionRoundUp = fractionRoundUp;
20
+ const bn_js_1 = __importDefault(require("bn.js"));
21
+ const borsh_1 = require("@coral-xyz/borsh");
22
+ const decimal_js_1 = __importDefault(require("decimal.js"));
23
+ const constants_1 = require("../constants");
24
+ ;
25
+ exports.FractionLayout = (0, borsh_1.struct)([
26
+ (0, borsh_1.u64)('high'),
27
+ (0, borsh_1.u64)('low'),
28
+ ]);
29
+ function fractionToDecimal(fraction) {
30
+ let high = new decimal_js_1.default(fraction.high.toString());
31
+ let low = new decimal_js_1.default(fraction.low.toString());
32
+ let res = high.add(low.div(constants_1.X64));
33
+ return res;
34
+ }
35
+ function decimalToFraction(decimal) {
36
+ let res = decimal.mul(constants_1.X64).floor();
37
+ let high = res.div(constants_1.X64).floor();
38
+ let low = res.sub(high.mul(constants_1.X64));
39
+ return { high: new bn_js_1.default(high.toString()), low: new bn_js_1.default(low.toString()) };
40
+ }
41
+ // X64 = 2^64
42
+ const X64_BN = new bn_js_1.default(2).pow(new bn_js_1.default(64));
43
+ const U64_MAX = new bn_js_1.default(2).pow(new bn_js_1.default(64)).sub(new bn_js_1.default(1));
44
+ // Fraction addition: (a + b)
45
+ // a = high_a * 2^64 + low_a, b = high_b * 2^64 + low_b
46
+ // result = (high_a + high_b) * 2^64 + (low_a + low_b)
47
+ // Handle carry from low to high
48
+ function fractionAdd(a, b) {
49
+ const lowSum = a.low.add(b.low);
50
+ const carry = lowSum.gt(U64_MAX) ? new bn_js_1.default(1) : new bn_js_1.default(0);
51
+ const low = lowSum.mod(X64_BN);
52
+ const high = a.high.add(b.high).add(carry);
53
+ // Check overflow: high should fit in u64
54
+ if (high.gt(U64_MAX)) {
55
+ throw new Error("MathError");
56
+ }
57
+ return { high, low };
58
+ }
59
+ // Fraction subtraction: (a - b)
60
+ // a = high_a * 2^64 + low_a, b = high_b * 2^64 + low_b
61
+ // result = (high_a - high_b) * 2^64 + (low_a - low_b)
62
+ // Handle borrow from high to low
63
+ function fractionSub(a, b) {
64
+ // Check if a < b
65
+ if (a.high.lt(b.high) || (a.high.eq(b.high) && a.low.lt(b.low))) {
66
+ throw new Error("MathError");
67
+ }
68
+ let low = a.low.sub(b.low);
69
+ let high = a.high.sub(b.high);
70
+ // Handle borrow if low < 0
71
+ if (low.isNeg()) {
72
+ low = low.add(X64_BN);
73
+ high = high.sub(new bn_js_1.default(1));
74
+ }
75
+ if (high.isNeg()) {
76
+ throw new Error("MathError");
77
+ }
78
+ return { high, low };
79
+ }
80
+ // Fraction multiplication: (a * b) / X64
81
+ // (high_a * 2^64 + low_a) * (high_b * 2^64 + low_b) / 2^64
82
+ // = high_a * high_b * 2^64 + high_a * low_b + low_a * high_b + (low_a * low_b) / 2^64
83
+ function fractionMul(a, b) {
84
+ // Calculate all components
85
+ const highHigh = a.high.mul(b.high).mul(X64_BN);
86
+ const highLow = a.high.mul(b.low);
87
+ const lowHigh = a.low.mul(b.high);
88
+ const lowLow = a.low.mul(b.low).div(X64_BN);
89
+ // Sum: highHigh + highLow + lowHigh + lowLow
90
+ const sum = highHigh.add(highLow).add(lowHigh).add(lowLow);
91
+ // Split into high and low
92
+ const high = sum.div(X64_BN);
93
+ const low = sum.mod(X64_BN);
94
+ // Check overflow: high should fit in u64
95
+ if (high.gt(U64_MAX)) {
96
+ throw new Error("MathError");
97
+ }
98
+ return { high, low };
99
+ }
100
+ // Fraction division: (a * X64) / b
101
+ // (high_a * 2^64 + low_a) * 2^64 / (high_b * 2^64 + low_b)
102
+ function fractionDiv(a, b) {
103
+ // Check division by zero
104
+ if (b.high.isZero() && b.low.isZero()) {
105
+ throw new Error("MathError");
106
+ }
107
+ // numerator = a * X64 = (high_a * 2^64 + low_a) * 2^64
108
+ const numerator = a.high.mul(X64_BN).add(a.low).mul(X64_BN);
109
+ // denominator = b = high_b * 2^64 + low_b
110
+ const denominator = b.high.mul(X64_BN).add(b.low);
111
+ // result = numerator / denominator
112
+ const result = numerator.div(denominator);
113
+ // Split into high and low
114
+ const high = result.div(X64_BN);
115
+ const low = result.mod(X64_BN);
116
+ // Check overflow: high should fit in u64
117
+ if (high.gt(U64_MAX)) {
118
+ throw new Error("MathError");
119
+ }
120
+ return { high, low };
121
+ }
122
+ // Comparison functions
123
+ function fractionLt(a, b) {
124
+ if (a.high.lt(b.high))
125
+ return true;
126
+ if (a.high.gt(b.high))
127
+ return false;
128
+ return a.low.lt(b.low);
129
+ }
130
+ function fractionLte(a, b) {
131
+ if (a.high.lt(b.high))
132
+ return true;
133
+ if (a.high.gt(b.high))
134
+ return false;
135
+ return a.low.lte(b.low);
136
+ }
137
+ function fractionGt(a, b) {
138
+ if (a.high.gt(b.high))
139
+ return true;
140
+ if (a.high.lt(b.high))
141
+ return false;
142
+ return a.low.gt(b.low);
143
+ }
144
+ function fractionGte(a, b) {
145
+ if (a.high.gt(b.high))
146
+ return true;
147
+ if (a.high.lt(b.high))
148
+ return false;
149
+ return a.low.gte(b.low);
150
+ }
151
+ function fractionEq(a, b) {
152
+ return a.high.eq(b.high) && a.low.eq(b.low);
153
+ }
154
+ // Round Fraction down to BN (floor)
155
+ function fractionRoundDown(fraction) {
156
+ return fraction.high;
157
+ }
158
+ // Round Fraction up to BN (ceiling)
159
+ function fractionRoundUp(fraction) {
160
+ if (fraction.low.isZero()) {
161
+ return fraction.high;
162
+ }
163
+ return fraction.high.add(new bn_js_1.default(1));
164
+ }
@@ -0,0 +1,18 @@
1
+ import BN from "bn.js";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ export interface BountySchedule {
4
+ minBounty: BN;
5
+ maxBounty: BN;
6
+ minBountyUntil: BN;
7
+ maxBountyAfter: BN;
8
+ }
9
+ export declare const BountyScheduleLayout: any;
10
+ export interface Bounty {
11
+ bountyDepositor: PublicKey;
12
+ bountyMint: PublicKey;
13
+ bountyPerPriceUpdateTask: BountySchedule;
14
+ bountyPerTask: BountySchedule;
15
+ bountyTotal: BN;
16
+ bountyLeft: BN;
17
+ }
18
+ export declare const BountyLayout: any;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BountyLayout = exports.BountyScheduleLayout = void 0;
4
+ const borsh_1 = require("@coral-xyz/borsh");
5
+ ;
6
+ exports.BountyScheduleLayout = (0, borsh_1.struct)([
7
+ (0, borsh_1.u64)('minBounty'),
8
+ (0, borsh_1.u64)('maxBounty'),
9
+ (0, borsh_1.u64)('minBountyUntil'),
10
+ (0, borsh_1.u64)('maxBountyAfter'),
11
+ ]);
12
+ exports.BountyLayout = (0, borsh_1.struct)([
13
+ (0, borsh_1.publicKey)('bountyDepositor'),
14
+ (0, borsh_1.publicKey)('bountyMint'),
15
+ exports.BountyScheduleLayout.replicate('bountyPerPriceUpdateTask'),
16
+ exports.BountyScheduleLayout.replicate('bountyPerTask'),
17
+ (0, borsh_1.u64)('bountyTotal'),
18
+ (0, borsh_1.u64)('bountyLeft'),
19
+ ]);
@@ -0,0 +1,209 @@
1
+ import BN from 'bn.js';
2
+ import { PublicKey } from '@solana/web3.js';
3
+ import { Bounty } from './bounty';
4
+ import { FormattedOracleType } from '../oracle';
5
+ export type FormattedIntentStatus = "not_active" | "active" | "reverted" | "completed";
6
+ export declare const INTENT_STATUS_STRINGS: Map<number, FormattedIntentStatus>;
7
+ export type FormattedTaskType = "unknown" | "edit_creator" | "edit_manager_settings" | "edit_fee_settings" | "edit_schedule_settings" | "edit_automation_settings" | "edit_lp_settings" | "edit_metadata_settings" | "edit_deposits_settings" | "edit_force_rebalance_settings" | "edit_custom_rebalance_settings" | "edit_add_token_delay" | "edit_update_weights_delay" | "edit_make_direct_swap_delay" | "add_token" | "update_weights" | "make_direct_swap";
8
+ export declare const TASK_TYPE_STRINGS: Map<number, FormattedTaskType>;
9
+ export interface FormattedBountySchedule {
10
+ min_bounty: number;
11
+ max_bounty: number;
12
+ min_bounty_until: number;
13
+ max_bounty_after: number;
14
+ }
15
+ export interface FormattedBounty {
16
+ bounty_depositor: string;
17
+ bounty_mint: string;
18
+ bounty_per_price_update_task: FormattedBountySchedule;
19
+ bounty_per_task: FormattedBountySchedule;
20
+ bounty_total: number;
21
+ bounty_left: number;
22
+ }
23
+ export interface FormattedIntent {
24
+ pubkey: string;
25
+ manager: string;
26
+ status: FormattedIntentStatus;
27
+ activation_timestamp: number;
28
+ expiration_timestamp: number;
29
+ basket: string;
30
+ bounty: FormattedBounty;
31
+ task_type: FormattedTaskType;
32
+ task_data: Settings;
33
+ }
34
+ export declare const INTENT_TASK_DATA_SIZE = 600;
35
+ export declare enum IntentStatus {
36
+ NotActive = 0,
37
+ Active = 1,
38
+ Reverted = 2,
39
+ Completed = 3
40
+ }
41
+ export interface Intent {
42
+ manager: PublicKey;
43
+ status: IntentStatus;
44
+ activationTimestamp: BN;
45
+ expirationTimestamp: BN;
46
+ basket: PublicKey;
47
+ bounty: Bounty;
48
+ taskType: TaskType;
49
+ taskData: number[];
50
+ ownAddress?: PublicKey;
51
+ formatted?: FormattedIntent;
52
+ }
53
+ export declare const IntentLayout: any;
54
+ export declare enum TaskType {
55
+ Unknown = 0,
56
+ EditCreator = 1,
57
+ EditManagerSettings = 2,
58
+ EditFeeSettings = 3,
59
+ EditScheduleSettings = 4,
60
+ EditAutomationSettings = 5,
61
+ EditLpSettings = 6,
62
+ EditMetadataSettings = 7,
63
+ EditDepositsSettings = 8,
64
+ EditForceRebalanceSettings = 9,
65
+ EditCustomRebalanceSettings = 10,
66
+ EditAddTokenDelay = 11,
67
+ EditUpdateWeightsDelay = 12,
68
+ EditMakeDirectSwapDelay = 13,
69
+ AddToken = 14,
70
+ UpdateWeights = 15,
71
+ MakeDirectSwap = 16
72
+ }
73
+ export declare function taskTypeFromU8(value: number): TaskType;
74
+ export interface TaskContext {
75
+ basket: string;
76
+ manager: string;
77
+ activation_timestamp?: number;
78
+ expiration_timestamp?: number;
79
+ min_bounty?: number;
80
+ max_bounty?: number;
81
+ }
82
+ export interface EditCreatorSettings {
83
+ creator: string;
84
+ }
85
+ export interface EditManagerSettings {
86
+ managers: {
87
+ pubkey: string;
88
+ fee_split_weight_bps: number;
89
+ authorities: {
90
+ managers: boolean;
91
+ fees: boolean;
92
+ schedule: boolean;
93
+ automation: boolean;
94
+ lp: boolean;
95
+ metadata: boolean;
96
+ deposits: boolean;
97
+ force_rebalance: boolean;
98
+ custom_rebalance: boolean;
99
+ add_token: boolean;
100
+ update_weights: boolean;
101
+ make_direct_swap: boolean;
102
+ };
103
+ }[];
104
+ modification_delay: number;
105
+ }
106
+ export interface EditFeeSettings {
107
+ creator_deposit_fee_bps: number;
108
+ creator_withdraw_fee_bps: number;
109
+ creator_management_fee_bps: number;
110
+ creator_performance_fee_bps: number;
111
+ managers_deposit_fee_bps: number;
112
+ managers_withdraw_fee_bps: number;
113
+ managers_management_fee_bps: number;
114
+ managers_performance_fee_bps: number;
115
+ basket_deposit_fee_bps: number;
116
+ basket_withdraw_fee_bps: number;
117
+ modification_delay: number;
118
+ }
119
+ export interface EditScheduleSettings {
120
+ cycle_start_time: number;
121
+ cycle_duration: number;
122
+ deposits_start: number;
123
+ deposits_end: number;
124
+ automation_start: number;
125
+ automation_end: number;
126
+ management_start: number;
127
+ management_end: number;
128
+ modification_delay: number;
129
+ }
130
+ export interface EditAutomationSettings {
131
+ enabled: boolean;
132
+ rebalance_slippage_threshold_bps: number;
133
+ per_trade_rebalance_slippage_threshold_bps: number;
134
+ rebalance_activation_threshold_abs_bps: number;
135
+ rebalance_activation_threshold_rel_bps: number;
136
+ rebalance_activation_cooldown: number;
137
+ modification_delay: number;
138
+ }
139
+ export interface EditLpSettings {
140
+ enabled: boolean;
141
+ lp_threshold_bps: number;
142
+ modification_delay: number;
143
+ }
144
+ export interface EditMetadataSettings {
145
+ symbol: string;
146
+ name: string;
147
+ uri: string;
148
+ modification_delay: number;
149
+ }
150
+ export interface EditDepositsSettings {
151
+ enabled: boolean;
152
+ }
153
+ export interface EditForceRebalanceSettings {
154
+ enabled: boolean;
155
+ modification_delay: number;
156
+ }
157
+ export interface EditCustomRebalanceSettings {
158
+ enabled: boolean;
159
+ modification_delay: number;
160
+ }
161
+ export interface EditAddTokenSettings {
162
+ modification_delay: number;
163
+ }
164
+ export interface EditUpdateWeightsSettings {
165
+ modification_delay: number;
166
+ }
167
+ export interface EditMakeDirectSwapSettings {
168
+ modification_delay: number;
169
+ }
170
+ export interface OracleInput {
171
+ oracle_type: FormattedOracleType;
172
+ account_lut_id: number;
173
+ account_lut_index: number;
174
+ account: string;
175
+ weight: number;
176
+ is_required: boolean;
177
+ conf_thresh_bps: number;
178
+ volatility_thresh_bps: number;
179
+ max_slippage_bps: number;
180
+ min_liquidity: number;
181
+ staleness_thresh: number;
182
+ staleness_conf_rate_bps: number;
183
+ token_decimals: number;
184
+ twap_seconds_ago: number;
185
+ twap_secondary_seconds_ago: number;
186
+ }
187
+ export interface AddOrEditTokenInput {
188
+ token_mint: string;
189
+ active: boolean;
190
+ min_oracles_thresh: number;
191
+ min_conf_bps: number;
192
+ conf_thresh_bps: number;
193
+ conf_multiplier: number;
194
+ oracles: OracleInput[];
195
+ }
196
+ export interface UpdateWeightsInput {
197
+ token_weights: {
198
+ mint: string;
199
+ weight_bps: number;
200
+ }[];
201
+ token_mints_hash?: number[];
202
+ }
203
+ export interface MakeDirectSwapInput {
204
+ from_token_mint: string;
205
+ to_token_mint: string;
206
+ amount_from: number;
207
+ amount_to: number;
208
+ }
209
+ export type Settings = EditCreatorSettings | EditManagerSettings | EditFeeSettings | EditScheduleSettings | EditAutomationSettings | EditLpSettings | EditMetadataSettings | EditDepositsSettings | EditForceRebalanceSettings | EditCustomRebalanceSettings | EditAddTokenSettings | EditUpdateWeightsSettings | EditMakeDirectSwapSettings | AddOrEditTokenInput | UpdateWeightsInput | MakeDirectSwapInput;