@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,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
+ (0, borsh_1.u64)('bountyTotal'),
16
+ (0, borsh_1.u64)('bountyLeft'),
17
+ exports.BountyScheduleLayout.replicate('bountyPerPriceUpdateTask'),
18
+ exports.BountyScheduleLayout.replicate('bountyPerTask')
19
+ ]);
@@ -0,0 +1,101 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Bounty } from "./bounty";
4
+ import { AutomationSettings, FeeSettings, LpSettings, ManagerSettings, MetadataSettings, ScheduleSettings } from "../config";
5
+ import { OracleAggregator } from "../../states/oracles/oracle";
6
+ export declare const INTENT_TASK_DATA_SIZE = 600;
7
+ export declare enum IntentStatus {
8
+ NotActive = 0,
9
+ Active = 1,
10
+ Reverted = 2,
11
+ Completed = 3
12
+ }
13
+ export interface ParsedIntent {
14
+ manager: PublicKey;
15
+ status: IntentStatus;
16
+ activationTimestamp: BN;
17
+ basket: PublicKey;
18
+ bounty: Bounty;
19
+ taskType: TaskType;
20
+ taskData: EditData;
21
+ }
22
+ export interface Intent {
23
+ manager: PublicKey;
24
+ status: IntentStatus;
25
+ activationTimestamp: BN;
26
+ basket: PublicKey;
27
+ bounty: Bounty;
28
+ taskType: TaskType;
29
+ taskData: number[];
30
+ }
31
+ export declare const IntentLayout: any;
32
+ export interface HostFees {
33
+ hostDepositFeeBps: number;
34
+ hostManagementFeeBps: number;
35
+ hostPerformanceFeeBps: number;
36
+ }
37
+ export declare const HostFeesLayout: any;
38
+ export interface MetadataParams {
39
+ name: string;
40
+ symbol: string;
41
+ uri: string;
42
+ }
43
+ export declare const MetadataParamsLayout: any;
44
+ export declare enum TaskType {
45
+ Unknown = 0,
46
+ EditSchedule = 1,
47
+ EditFeeSettings = 2,
48
+ EditManagerSettings = 3,
49
+ EditAutomationSettings = 4,
50
+ EditLpSettings = 5,
51
+ EditMetadataSettings = 6,
52
+ EditAddTokenDelay = 7,
53
+ EditUpdateWeightsDelay = 8,
54
+ AddToken = 9,
55
+ UpdateWeights = 10,
56
+ Swap = 11
57
+ }
58
+ export declare function taskTypeFromU8(value: number): TaskType;
59
+ export interface AuthorityBitmasks {
60
+ scheduleAuthorityBitmask: number;
61
+ feeSettingsAuthorityBitmask: number;
62
+ managerSettingsAuthorityBitmask: number;
63
+ automationSettingsAuthorityBitmask: number;
64
+ lpSettingsAuthorityBitmask: number;
65
+ metadataSettingsAuthorityBitmask: number;
66
+ addTokenIntentAuthorityBitmask: number;
67
+ updateWeightsIntentAuthorityBitmask: number;
68
+ makeDirectSwapIntentAuthorityBitmask: number;
69
+ }
70
+ export declare const AuthorityBitmasksLayout: any;
71
+ export interface ManagerSettingsWithAuthorityBitmasks {
72
+ managerSettings: ManagerSettings;
73
+ authorityBitmasks: AuthorityBitmasks;
74
+ }
75
+ export declare const ManagerSettingsWithAuthorityBitmasksLayout: any;
76
+ export interface AddTokenDelay {
77
+ delay: BN;
78
+ }
79
+ export declare const AddTokenDelayLayout: any;
80
+ export interface UpdateWeightsDelay {
81
+ delay: BN;
82
+ }
83
+ export declare const UpdateWeightsDelayLayout: any;
84
+ export interface AddToken {
85
+ oracleAggregator: OracleAggregator;
86
+ tokenMint: PublicKey;
87
+ oracleAccounts: PublicKey[];
88
+ }
89
+ export declare const AddTokenLayout: any;
90
+ export interface UpdateWeights {
91
+ tokenWeights: number[];
92
+ writeVersion: BN;
93
+ }
94
+ export declare const UpdateWeightsLayout: any;
95
+ export interface Swap {
96
+ fromTokenMint: PublicKey;
97
+ toTokenMint: PublicKey;
98
+ amountFrom: BN;
99
+ }
100
+ export declare const SwapLayout: any;
101
+ export type EditData = ScheduleSettings | FeeSettings | ManagerSettingsWithAuthorityBitmasks | AutomationSettings | LpSettings | MetadataSettings | AddTokenDelay | UpdateWeightsDelay | AddToken | UpdateWeights | Swap;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwapLayout = exports.UpdateWeightsLayout = exports.AddTokenLayout = exports.UpdateWeightsDelayLayout = exports.AddTokenDelayLayout = exports.ManagerSettingsWithAuthorityBitmasksLayout = exports.AuthorityBitmasksLayout = exports.TaskType = exports.MetadataParamsLayout = exports.HostFeesLayout = exports.IntentLayout = exports.IntentStatus = exports.INTENT_TASK_DATA_SIZE = void 0;
4
+ exports.taskTypeFromU8 = taskTypeFromU8;
5
+ const borsh_1 = require("@coral-xyz/borsh");
6
+ const bounty_1 = require("./bounty");
7
+ const config_1 = require("../config");
8
+ const oracle_1 = require("../oracle");
9
+ exports.INTENT_TASK_DATA_SIZE = 600;
10
+ var IntentStatus;
11
+ (function (IntentStatus) {
12
+ IntentStatus[IntentStatus["NotActive"] = 0] = "NotActive";
13
+ IntentStatus[IntentStatus["Active"] = 1] = "Active";
14
+ IntentStatus[IntentStatus["Reverted"] = 2] = "Reverted";
15
+ IntentStatus[IntentStatus["Completed"] = 3] = "Completed";
16
+ })(IntentStatus || (exports.IntentStatus = IntentStatus = {}));
17
+ ;
18
+ ;
19
+ ;
20
+ exports.IntentLayout = (0, borsh_1.struct)([
21
+ (0, borsh_1.publicKey)('manager'),
22
+ (0, borsh_1.u8)('status'),
23
+ (0, borsh_1.u64)('activationTimestamp'),
24
+ (0, borsh_1.publicKey)('basket'),
25
+ bounty_1.BountyLayout.replicate('bounty'),
26
+ (0, borsh_1.u8)('taskType'),
27
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.INTENT_TASK_DATA_SIZE, 'taskData'),
28
+ ]);
29
+ exports.HostFeesLayout = (0, borsh_1.struct)([
30
+ (0, borsh_1.u16)('hostDepositFeeBps'),
31
+ (0, borsh_1.u16)('hostManagementFeeBps'),
32
+ (0, borsh_1.u16)('hostPerformanceFeeBps'),
33
+ ]);
34
+ ;
35
+ exports.MetadataParamsLayout = (0, borsh_1.struct)([
36
+ (0, borsh_1.str)("name"),
37
+ (0, borsh_1.str)("symbol"),
38
+ (0, borsh_1.str)("uri"),
39
+ ]);
40
+ var TaskType;
41
+ (function (TaskType) {
42
+ TaskType[TaskType["Unknown"] = 0] = "Unknown";
43
+ TaskType[TaskType["EditSchedule"] = 1] = "EditSchedule";
44
+ TaskType[TaskType["EditFeeSettings"] = 2] = "EditFeeSettings";
45
+ TaskType[TaskType["EditManagerSettings"] = 3] = "EditManagerSettings";
46
+ TaskType[TaskType["EditAutomationSettings"] = 4] = "EditAutomationSettings";
47
+ TaskType[TaskType["EditLpSettings"] = 5] = "EditLpSettings";
48
+ TaskType[TaskType["EditMetadataSettings"] = 6] = "EditMetadataSettings";
49
+ TaskType[TaskType["EditAddTokenDelay"] = 7] = "EditAddTokenDelay";
50
+ TaskType[TaskType["EditUpdateWeightsDelay"] = 8] = "EditUpdateWeightsDelay";
51
+ TaskType[TaskType["AddToken"] = 9] = "AddToken";
52
+ TaskType[TaskType["UpdateWeights"] = 10] = "UpdateWeights";
53
+ TaskType[TaskType["Swap"] = 11] = "Swap";
54
+ })(TaskType || (exports.TaskType = TaskType = {}));
55
+ function taskTypeFromU8(value) {
56
+ switch (value) {
57
+ case 1: return TaskType.EditSchedule;
58
+ case 2: return TaskType.EditFeeSettings;
59
+ case 3: return TaskType.EditManagerSettings;
60
+ case 4: return TaskType.EditAutomationSettings;
61
+ case 5: return TaskType.EditLpSettings;
62
+ case 6: return TaskType.EditMetadataSettings;
63
+ case 7: return TaskType.EditAddTokenDelay;
64
+ case 8: return TaskType.EditUpdateWeightsDelay;
65
+ case 9: return TaskType.AddToken;
66
+ case 10: return TaskType.UpdateWeights;
67
+ case 11: return TaskType.Swap;
68
+ default: return TaskType.Unknown;
69
+ }
70
+ }
71
+ ;
72
+ ;
73
+ exports.AuthorityBitmasksLayout = (0, borsh_1.struct)([
74
+ (0, borsh_1.u16)('scheduleAuthorityBitmask'),
75
+ (0, borsh_1.u16)('feeSettingsAuthorityBitmask'),
76
+ (0, borsh_1.u16)('managerSettingsAuthorityBitmask'),
77
+ (0, borsh_1.u16)('automationSettingsAuthorityBitmask'),
78
+ (0, borsh_1.u16)('lpSettingsAuthorityBitmask'),
79
+ (0, borsh_1.u16)('metadataSettingsAuthorityBitmask'),
80
+ (0, borsh_1.u16)('addTokenIntentAuthorityBitmask'),
81
+ (0, borsh_1.u16)('updateWeightsIntentAuthorityBitmask'),
82
+ (0, borsh_1.u16)('makeDirectSwapIntentAuthorityBitmask'),
83
+ ]);
84
+ ;
85
+ exports.ManagerSettingsWithAuthorityBitmasksLayout = (0, borsh_1.struct)([
86
+ config_1.ManagerSettingsLayout.replicate('managerSettings'),
87
+ exports.AuthorityBitmasksLayout.replicate('authorityBitmasks'),
88
+ ]);
89
+ ;
90
+ exports.AddTokenDelayLayout = (0, borsh_1.struct)([
91
+ (0, borsh_1.u64)('delay'),
92
+ ]);
93
+ ;
94
+ exports.UpdateWeightsDelayLayout = (0, borsh_1.struct)([
95
+ (0, borsh_1.u64)('delay'),
96
+ ]);
97
+ ;
98
+ exports.AddTokenLayout = (0, borsh_1.struct)([
99
+ oracle_1.OracleAggregatorLayout.replicate('oracleAggregator'),
100
+ (0, borsh_1.publicKey)('tokenMint'),
101
+ (0, borsh_1.array)((0, borsh_1.publicKey)(), 4, 'oracleAccounts'),
102
+ ]);
103
+ ;
104
+ exports.UpdateWeightsLayout = (0, borsh_1.struct)([
105
+ (0, borsh_1.array)((0, borsh_1.u16)(), 100, 'tokenWeights'),
106
+ (0, borsh_1.u64)('writeVersion'),
107
+ ]);
108
+ ;
109
+ exports.SwapLayout = (0, borsh_1.struct)([
110
+ (0, borsh_1.publicKey)('fromTokenMint'),
111
+ (0, borsh_1.publicKey)('toTokenMint'),
112
+ (0, borsh_1.u64)('amountFrom'),
113
+ ]);
@@ -0,0 +1,56 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Fraction } from "../fraction";
4
+ import { Bounty } from "./bounty";
5
+ import { OraclePrice } from "../../states/oracles/oracle";
6
+ export declare enum RebalanceType {
7
+ Deposit = 0,
8
+ Withdraw = 1,
9
+ Basket = 2
10
+ }
11
+ export declare enum RebalanceAction {
12
+ NotActive = 0,
13
+ DepositTokens = 1,
14
+ UpdatePrices = 2,
15
+ AuctionLive = 3
16
+ }
17
+ export interface AuctionTimestamps {
18
+ startTime: BN;
19
+ endTime: BN;
20
+ }
21
+ export declare const AuctionTimestampsLayout: any;
22
+ export interface TokenAuction {
23
+ mint: PublicKey;
24
+ amount: BN;
25
+ targetAmount: BN;
26
+ price: OraclePrice;
27
+ keepToken: number;
28
+ }
29
+ export declare const TokenAuctionLayout: any;
30
+ export interface TaskCompletion {
31
+ completedBounty: BN;
32
+ completedTime: BN;
33
+ completedBy: PublicKey;
34
+ }
35
+ export declare const TaskCompletionLayout: any;
36
+ export interface RebalanceIntent {
37
+ basket: PublicKey;
38
+ owner: PublicKey;
39
+ rentPayer: PublicKey;
40
+ rebalanceType: RebalanceType;
41
+ currentAction: RebalanceAction;
42
+ executionStartTime: BN;
43
+ rebalanceSlippageBps: number;
44
+ initialTvl: Fraction;
45
+ auctionUpdateTimestamp: BN;
46
+ auctions: AuctionTimestamps;
47
+ tokens: TokenAuction[];
48
+ lastActionTimestamp: BN;
49
+ bounty: Bounty;
50
+ startPriceUpdateTask: TaskCompletion;
51
+ priceUpdateTasks: TaskCompletion[];
52
+ finishPriceUpdateTask: TaskCompletion;
53
+ mintBasketTask: TaskCompletion;
54
+ tokenSettlementTasks: TaskCompletion[];
55
+ }
56
+ export declare const RebalanceIntentLayout: any;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RebalanceIntentLayout = exports.TaskCompletionLayout = exports.TokenAuctionLayout = exports.AuctionTimestampsLayout = exports.RebalanceAction = exports.RebalanceType = void 0;
4
+ const borsh_1 = require("@coral-xyz/borsh");
5
+ const fraction_1 = require("../fraction");
6
+ const bounty_1 = require("./bounty");
7
+ const oracle_1 = require("../oracle");
8
+ const basket_1 = require("../basket");
9
+ var RebalanceType;
10
+ (function (RebalanceType) {
11
+ RebalanceType[RebalanceType["Deposit"] = 0] = "Deposit";
12
+ RebalanceType[RebalanceType["Withdraw"] = 1] = "Withdraw";
13
+ RebalanceType[RebalanceType["Basket"] = 2] = "Basket";
14
+ })(RebalanceType || (exports.RebalanceType = RebalanceType = {}));
15
+ ;
16
+ var RebalanceAction;
17
+ (function (RebalanceAction) {
18
+ RebalanceAction[RebalanceAction["NotActive"] = 0] = "NotActive";
19
+ RebalanceAction[RebalanceAction["DepositTokens"] = 1] = "DepositTokens";
20
+ RebalanceAction[RebalanceAction["UpdatePrices"] = 2] = "UpdatePrices";
21
+ RebalanceAction[RebalanceAction["AuctionLive"] = 3] = "AuctionLive";
22
+ })(RebalanceAction || (exports.RebalanceAction = RebalanceAction = {}));
23
+ ;
24
+ ;
25
+ exports.AuctionTimestampsLayout = (0, borsh_1.struct)([
26
+ (0, borsh_1.u64)('startTime'),
27
+ (0, borsh_1.u64)('endTime'),
28
+ ]);
29
+ ;
30
+ exports.TokenAuctionLayout = (0, borsh_1.struct)([
31
+ (0, borsh_1.publicKey)('mint'),
32
+ (0, borsh_1.u64)('amount'),
33
+ (0, borsh_1.u64)('targetAmount'),
34
+ oracle_1.OraclePriceLayout.replicate('price'),
35
+ (0, borsh_1.u8)('keepToken'),
36
+ ]);
37
+ ;
38
+ exports.TaskCompletionLayout = (0, borsh_1.struct)([
39
+ (0, borsh_1.u64)('completedBounty'),
40
+ (0, borsh_1.u64)('completedTime'),
41
+ (0, borsh_1.publicKey)('completedBy'),
42
+ ]);
43
+ ;
44
+ exports.RebalanceIntentLayout = (0, borsh_1.struct)([
45
+ (0, borsh_1.publicKey)('basket'),
46
+ (0, borsh_1.publicKey)('owner'),
47
+ (0, borsh_1.publicKey)('rentPayer'),
48
+ (0, borsh_1.u8)('rebalanceType'),
49
+ (0, borsh_1.u8)('currentAction'),
50
+ (0, borsh_1.u64)('executionStartTime'),
51
+ (0, borsh_1.u16)('rebalanceSlippageBps'),
52
+ fraction_1.FractionLayout.replicate('initialTvl'),
53
+ (0, borsh_1.u64)('auctionUpdateTimestamp'),
54
+ (0, borsh_1.array)(exports.AuctionTimestampsLayout, 3, 'auctions'),
55
+ (0, borsh_1.array)(exports.TokenAuctionLayout, basket_1.MAX_SUPPORTED_TOKENS_PER_BASKET, 'tokens'),
56
+ (0, borsh_1.u64)('lastActionTimestamp'),
57
+ bounty_1.BountyLayout.replicate('bounty'),
58
+ exports.TaskCompletionLayout.replicate('startPriceUpdateTask'),
59
+ (0, borsh_1.array)(exports.TaskCompletionLayout, basket_1.MAX_SUPPORTED_TOKENS_PER_BASKET, 'priceUpdateTasks'),
60
+ exports.TaskCompletionLayout.replicate('finishPriceUpdateTask'),
61
+ exports.TaskCompletionLayout.replicate('mintBasketTask'),
62
+ (0, borsh_1.array)(exports.TaskCompletionLayout, basket_1.MAX_SUPPORTED_TOKENS_PER_BASKET, 'tokenSettlementTasks'),
63
+ ]);
@@ -0,0 +1,7 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ export interface LookupTableInfo {
3
+ lookupTable: PublicKey;
4
+ authority: PublicKey;
5
+ creator: PublicKey;
6
+ }
7
+ export declare const LookupTableInfoLayout: any;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LookupTableInfoLayout = void 0;
4
+ const borsh_1 = require("@coral-xyz/borsh");
5
+ ;
6
+ exports.LookupTableInfoLayout = (0, borsh_1.struct)([
7
+ (0, borsh_1.publicKey)("lookupTable"),
8
+ (0, borsh_1.publicKey)("authority"),
9
+ (0, borsh_1.publicKey)("creator")
10
+ ]);
@@ -0,0 +1,42 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Fraction } from "./fraction";
3
+ export declare const MAX_ORACLES_PER_TOKEN = 4;
4
+ export declare const MAX_ACCOUNTS_PER_ORACLE = 4;
5
+ export interface OraclePrice {
6
+ price: Fraction;
7
+ conf: Fraction;
8
+ updateTime: BN;
9
+ }
10
+ export declare const OraclePriceLayout: any;
11
+ export interface OracleSettings {
12
+ oracleType: number;
13
+ numRequiredAccounts: number;
14
+ weight: number;
15
+ isRequired: number;
16
+ confThreshBps: number;
17
+ stalenessThresh: BN;
18
+ volatilityThreshBps: number;
19
+ minLiquidity: BN;
20
+ stalenessConfRateBps: number;
21
+ tokenDecimals: number;
22
+ twapSecondsAgo: BN;
23
+ twapSecondarySecondsAgo: BN;
24
+ quote: number;
25
+ side: number;
26
+ }
27
+ export declare const OracleSettingsLayout: any;
28
+ export interface OracleData {
29
+ oracleSettings: OracleSettings;
30
+ accountsToLoadLutIds: number[];
31
+ accountsToLoadLutIndices: number[];
32
+ }
33
+ export declare const OracleDataLayout: any;
34
+ export interface OracleAggregator {
35
+ numOracles: number;
36
+ oracles: OracleData[];
37
+ minConfBps: number;
38
+ confThreshBps: number;
39
+ minOraclesThresh: number;
40
+ confMultiplier: Fraction;
41
+ }
42
+ export declare const OracleAggregatorLayout: any;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OracleAggregatorLayout = exports.OracleDataLayout = exports.OracleSettingsLayout = exports.OraclePriceLayout = exports.MAX_ACCOUNTS_PER_ORACLE = exports.MAX_ORACLES_PER_TOKEN = void 0;
4
+ const borsh_1 = require("@coral-xyz/borsh");
5
+ const fraction_1 = require("./fraction");
6
+ exports.MAX_ORACLES_PER_TOKEN = 4;
7
+ exports.MAX_ACCOUNTS_PER_ORACLE = 4;
8
+ ;
9
+ exports.OraclePriceLayout = (0, borsh_1.struct)([
10
+ fraction_1.FractionLayout.replicate('price'),
11
+ fraction_1.FractionLayout.replicate('conf'),
12
+ (0, borsh_1.u64)('updateTime'),
13
+ ]);
14
+ exports.OracleSettingsLayout = (0, borsh_1.struct)([
15
+ (0, borsh_1.u8)('oracleType'),
16
+ (0, borsh_1.u8)('numRequiredAccounts'),
17
+ (0, borsh_1.u16)('weight'),
18
+ (0, borsh_1.u8)('isRequired'),
19
+ (0, borsh_1.u16)('confThreshBps'),
20
+ (0, borsh_1.u64)('stalenessThresh'),
21
+ (0, borsh_1.u16)('volatilityThreshBps'),
22
+ (0, borsh_1.u64)('minLiquidity'),
23
+ (0, borsh_1.u16)('stalenessConfRateBps'),
24
+ (0, borsh_1.u8)('tokenDecimals'),
25
+ (0, borsh_1.u64)('twapSecondsAgo'),
26
+ (0, borsh_1.u64)('twapSecondarySecondsAgo'),
27
+ (0, borsh_1.u8)('quote'),
28
+ (0, borsh_1.u8)('side')
29
+ ]);
30
+ ;
31
+ exports.OracleDataLayout = (0, borsh_1.struct)([
32
+ exports.OracleSettingsLayout.replicate('oracleSettings'),
33
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.MAX_ACCOUNTS_PER_ORACLE, 'accountsToLoadLutIds'),
34
+ (0, borsh_1.array)((0, borsh_1.u8)(), exports.MAX_ACCOUNTS_PER_ORACLE, 'accountsToLoadLutIndices'),
35
+ ]);
36
+ exports.OracleAggregatorLayout = (0, borsh_1.struct)([
37
+ (0, borsh_1.u8)('numOracles'),
38
+ (0, borsh_1.array)(exports.OracleDataLayout, exports.MAX_ORACLES_PER_TOKEN, 'oracles'),
39
+ (0, borsh_1.u16)('minConfBps'),
40
+ (0, borsh_1.u16)('confThreshBps'),
41
+ (0, borsh_1.u8)('minOraclesThresh'),
42
+ fraction_1.FractionLayout.replicate('confMultiplier')
43
+ ]);
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { Basket } from "../layouts/basket";
3
+ export declare function fetchBasket(connection: Connection, basketAddress: PublicKey): Promise<Basket>;
4
+ export interface BasketFilter {
5
+ filterType: "host" | "creator";
6
+ filterValue: PublicKey;
7
+ }
8
+ export declare function fetchBaskets(connection: Connection, filters: BasketFilter[]): Promise<Basket[]>;
@@ -0,0 +1,54 @@
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.fetchBasket = fetchBasket;
13
+ exports.fetchBaskets = fetchBaskets;
14
+ const basket_1 = require("../layouts/basket");
15
+ const constants_1 = require("../constants");
16
+ function fetchBasket(connection, basketAddress) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const basketAi = yield connection.getAccountInfo(basketAddress);
19
+ if (!basketAi) {
20
+ throw new Error("Basket not found");
21
+ }
22
+ return basket_1.BasketLayout.decode(basketAi.data.slice(8));
23
+ });
24
+ }
25
+ function fetchBaskets(connection, filters) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ console.log("fetching baskets with size", basket_1.BasketLayout.getSpan());
28
+ let accountFilters = [
29
+ { dataSize: 8 + basket_1.BasketLayout.getSpan() },
30
+ ];
31
+ for (const filter of filters) {
32
+ if (filter.filterType === "host") {
33
+ accountFilters.push({ memcmp: {
34
+ offset: 8 + 1 + 16 + 32 + 32 + 8 + 16 + 8,
35
+ bytes: filter.filterValue.toBase58()
36
+ } });
37
+ }
38
+ else if (filter.filterType === "creator") {
39
+ accountFilters.push({ memcmp: {
40
+ offset: 8 + 1 + 16 + 32 + 32 + 8 + 16 + 8 + 32,
41
+ bytes: filter.filterValue.toBase58()
42
+ } });
43
+ }
44
+ }
45
+ const accounts = yield connection
46
+ .getProgramAccounts(constants_1.BASKETS_V3_PROGRAM_ID, {
47
+ commitment: "confirmed",
48
+ filters: accountFilters,
49
+ encoding: 'base64'
50
+ });
51
+ const baskets = accounts.map(account => basket_1.BasketLayout.decode(account.account.data.slice(8)));
52
+ return baskets;
53
+ });
54
+ }
@@ -0,0 +1,14 @@
1
+ import { Connection, PublicKey } from '@solana/web3.js';
2
+ import { Intent, ParsedIntent } from '../../layouts/intents/intent';
3
+ /**
4
+ * Decode an Intent account buffer.
5
+ * Returns ParsedIntent.
6
+ */
7
+ export declare function decodeIntent(intent: Intent): ParsedIntent;
8
+ export declare function fetchIntent(connection: Connection, intent: PublicKey): Promise<Intent>;
9
+ export declare function fetchParsedIntent(connection: Connection, intent: PublicKey): Promise<ParsedIntent>;
10
+ export interface IntentFilter {
11
+ filterType: "basket" | "owner";
12
+ filterValue: PublicKey;
13
+ }
14
+ export declare function fetchIntents(connection: Connection, filters: IntentFilter[]): Promise<Intent[]>;
@@ -0,0 +1,90 @@
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.decodeIntent = decodeIntent;
13
+ exports.fetchIntent = fetchIntent;
14
+ exports.fetchParsedIntent = fetchParsedIntent;
15
+ exports.fetchIntents = fetchIntents;
16
+ const constants_1 = require("../../constants");
17
+ const intent_1 = require("../../layouts/intents/intent");
18
+ const config_1 = require("../../layouts/config");
19
+ // Map task type -> layout used to decode taskData prefix
20
+ const taskLayoutMap = new Map([
21
+ [intent_1.TaskType.EditSchedule, config_1.ScheduleSettingsLayout],
22
+ [intent_1.TaskType.EditFeeSettings, config_1.FeeSettingsLayout],
23
+ [intent_1.TaskType.EditManagerSettings, intent_1.ManagerSettingsWithAuthorityBitmasksLayout],
24
+ [intent_1.TaskType.EditAutomationSettings, config_1.AutomationSettingsLayout],
25
+ [intent_1.TaskType.EditLpSettings, config_1.LpSettingsLayout],
26
+ [intent_1.TaskType.EditMetadataSettings, config_1.MetadataSettingsLayout],
27
+ [intent_1.TaskType.EditAddTokenDelay, intent_1.AddTokenDelayLayout],
28
+ [intent_1.TaskType.EditUpdateWeightsDelay, intent_1.UpdateWeightsDelayLayout],
29
+ [intent_1.TaskType.AddToken, intent_1.AddTokenLayout],
30
+ [intent_1.TaskType.UpdateWeights, intent_1.UpdateWeightsLayout],
31
+ [intent_1.TaskType.Swap, intent_1.SwapLayout],
32
+ ]);
33
+ // Decode taskData buffer for a given task type; returns decoded object or raw Buffer on failure
34
+ function decodeTaskDataForType(taskType, taskData) {
35
+ const layout = taskLayoutMap.get(taskType);
36
+ return layout.decode(taskData);
37
+ }
38
+ ;
39
+ /**
40
+ * Decode an Intent account buffer.
41
+ * Returns ParsedIntent.
42
+ */
43
+ function decodeIntent(intent) {
44
+ let parsedTaskData = decodeTaskDataForType(intent.taskType, intent.taskData);
45
+ return Object.assign(Object.assign({}, intent), { taskData: parsedTaskData });
46
+ }
47
+ function fetchIntent(connection, intent) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const intentAi = yield connection.getAccountInfo(intent);
50
+ if (!intentAi)
51
+ throw new Error('Basket intent not found');
52
+ return intent_1.IntentLayout.decode(intentAi.data.slice(8));
53
+ });
54
+ }
55
+ function fetchParsedIntent(connection, intent) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const intentState = yield fetchIntent(connection, intent);
58
+ return decodeIntent(intentState);
59
+ });
60
+ }
61
+ function fetchIntents(connection, filters) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ console.log("fetching intents with size", intent_1.IntentLayout.getSpan());
64
+ let accountFilters = [
65
+ { dataSize: 8 + intent_1.IntentLayout.getSpan() },
66
+ ];
67
+ for (const filter of filters) {
68
+ if (filter.filterType === "basket") {
69
+ accountFilters.push({ memcmp: {
70
+ offset: 8 + 32 + 1 + 8,
71
+ bytes: filter.filterValue.toBase58()
72
+ } });
73
+ }
74
+ else if (filter.filterType === "owner") {
75
+ accountFilters.push({ memcmp: {
76
+ offset: 8,
77
+ bytes: filter.filterValue.toBase58()
78
+ } });
79
+ }
80
+ }
81
+ const accounts = yield connection
82
+ .getProgramAccounts(constants_1.BASKETS_V3_PROGRAM_ID, {
83
+ commitment: "confirmed",
84
+ filters: accountFilters,
85
+ encoding: 'base64'
86
+ });
87
+ const rebalanceIntents = accounts.map(account => intent_1.IntentLayout.decode(account.account.data.slice(8)));
88
+ return rebalanceIntents;
89
+ });
90
+ }
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { RebalanceIntent } from "../../layouts/intents/rebalanceIntent";
3
+ export declare function fetchRebalanceIntent(connection: Connection, rebalanceIntent: PublicKey): Promise<RebalanceIntent>;
4
+ export interface RebalanceIntentFilter {
5
+ filterType: "basket" | "owner";
6
+ filterValue: PublicKey;
7
+ }
8
+ export declare function fetchRebalanceIntents(connection: Connection, filters: RebalanceIntentFilter[]): Promise<RebalanceIntent[]>;