@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.
- package/dist/src/constants.d.ts +23 -0
- package/dist/src/constants.js +38 -0
- package/dist/src/index.d.ts +804 -0
- package/dist/src/index.js +2097 -0
- package/dist/src/instructions/automation/auction.d.ts +6 -0
- package/dist/src/instructions/automation/auction.js +40 -0
- package/dist/src/instructions/automation/claimBounty.d.ts +12 -0
- package/dist/src/instructions/automation/claimBounty.js +44 -0
- package/dist/src/instructions/automation/flashSwap.d.ts +21 -0
- package/dist/src/instructions/automation/flashSwap.js +74 -0
- package/dist/src/instructions/automation/priceUpdate.d.ts +19 -0
- package/dist/src/instructions/automation/priceUpdate.js +89 -0
- package/dist/src/instructions/automation/rebalanceIntent.d.ts +32 -0
- package/dist/src/instructions/automation/rebalanceIntent.js +117 -0
- package/dist/src/instructions/automation/rebalanceSwap.d.ts +11 -0
- package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
- package/dist/src/instructions/management/addBounty.d.ts +7 -0
- package/dist/src/instructions/management/addBounty.js +41 -0
- package/dist/src/instructions/management/admin.d.ts +9 -0
- package/dist/src/instructions/management/admin.js +53 -0
- package/dist/src/instructions/management/claimFees.d.ts +15 -0
- package/dist/src/instructions/management/claimFees.js +95 -0
- package/dist/src/instructions/management/createBasket.d.ts +21 -0
- package/dist/src/instructions/management/createBasket.js +98 -0
- package/dist/src/instructions/management/edit.d.ts +51 -0
- package/dist/src/instructions/management/edit.js +477 -0
- package/dist/src/instructions/management/luts.d.ts +30 -0
- package/dist/src/instructions/management/luts.js +99 -0
- package/dist/src/instructions/pda.d.ts +25 -0
- package/dist/src/instructions/pda.js +128 -0
- package/dist/src/instructions/user/deposit.d.ts +20 -0
- package/dist/src/instructions/user/deposit.js +100 -0
- package/dist/src/instructions/user/withdraw.d.ts +8 -0
- package/dist/src/instructions/user/withdraw.js +36 -0
- package/dist/src/jup.d.ts +49 -0
- package/dist/src/jup.js +80 -0
- package/dist/src/keeperMonitor.d.ts +52 -0
- package/dist/src/keeperMonitor.js +624 -0
- package/dist/src/layouts/basket.d.ts +191 -0
- package/dist/src/layouts/basket.js +51 -0
- package/dist/src/layouts/config.d.ts +281 -0
- package/dist/src/layouts/config.js +237 -0
- package/dist/src/layouts/fraction.d.ts +20 -0
- package/dist/src/layouts/fraction.js +164 -0
- package/dist/src/layouts/intents/bounty.d.ts +18 -0
- package/dist/src/layouts/intents/bounty.js +19 -0
- package/dist/src/layouts/intents/intent.d.ts +209 -0
- package/dist/src/layouts/intents/intent.js +97 -0
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +212 -0
- package/dist/src/layouts/intents/rebalanceIntent.js +94 -0
- package/dist/src/layouts/lookupTable.d.ts +7 -0
- package/dist/src/layouts/lookupTable.js +10 -0
- package/dist/src/layouts/oracle.d.ts +63 -0
- package/dist/src/layouts/oracle.js +96 -0
- package/dist/src/states/basket.d.ts +14 -0
- package/dist/src/states/basket.js +479 -0
- package/dist/src/states/config.d.ts +3 -0
- package/dist/src/states/config.js +71 -0
- package/dist/src/states/intents/intent.d.ts +10 -0
- package/dist/src/states/intents/intent.js +316 -0
- package/dist/src/states/intents/rebalanceIntent.d.ts +42 -0
- package/dist/src/states/intents/rebalanceIntent.js +680 -0
- package/dist/src/states/oracles/constants.d.ts +9 -0
- package/dist/src/states/oracles/constants.js +15 -0
- package/dist/src/states/oracles/oracle.d.ts +24 -0
- package/dist/src/states/oracles/oracle.js +168 -0
- package/dist/src/states/oracles/pythOracle.d.ts +132 -0
- package/dist/src/states/oracles/pythOracle.js +609 -0
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +184 -0
- package/dist/src/states/oracles/raydiumClmmOracle.js +843 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +120 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.js +540 -0
- package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboardOracle.js +1 -0
- package/dist/src/states/withdrawBasketFees.d.ts +10 -0
- package/dist/src/states/withdrawBasketFees.js +154 -0
- package/dist/src/txUtils.d.ts +65 -0
- package/dist/src/txUtils.js +306 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +561 -0
- package/package.json +31 -0
- package/src/constants.ts +40 -0
- package/src/index.ts +2431 -0
- package/src/instructions/automation/auction.ts +55 -0
- package/src/instructions/automation/claimBounty.ts +69 -0
- package/src/instructions/automation/flashSwap.ts +104 -0
- package/src/instructions/automation/priceUpdate.ts +117 -0
- package/src/instructions/automation/rebalanceIntent.ts +181 -0
- package/src/instructions/management/addBounty.ts +55 -0
- package/src/instructions/management/admin.ts +72 -0
- package/src/instructions/management/claimFees.ts +129 -0
- package/src/instructions/management/createBasket.ts +138 -0
- package/src/instructions/management/edit.ts +602 -0
- package/src/instructions/management/luts.ts +157 -0
- package/src/instructions/pda.ts +151 -0
- package/src/instructions/user/deposit.ts +143 -0
- package/src/instructions/user/withdraw.ts +53 -0
- package/src/jup.ts +113 -0
- package/src/keeperMonitor.ts +585 -0
- package/src/layouts/basket.ts +233 -0
- package/src/layouts/config.ts +576 -0
- package/src/layouts/fraction.ts +164 -0
- package/src/layouts/intents/bounty.ts +35 -0
- package/src/layouts/intents/intent.ts +324 -0
- package/src/layouts/intents/rebalanceIntent.ts +306 -0
- package/src/layouts/lookupTable.ts +14 -0
- package/src/layouts/oracle.ts +157 -0
- package/src/states/basket.ts +527 -0
- package/src/states/config.ts +62 -0
- package/src/states/intents/intent.ts +311 -0
- package/src/states/intents/rebalanceIntent.ts +751 -0
- package/src/states/oracles/constants.ts +13 -0
- package/src/states/oracles/oracle.ts +212 -0
- package/src/states/oracles/pythOracle.ts +874 -0
- package/src/states/oracles/raydiumClmmOracle.ts +1193 -0
- package/src/states/oracles/raydiumCpmmOracle.ts +784 -0
- package/src/states/oracles/switchboardOracle.ts +0 -0
- package/src/states/withdrawBasketFees.ts +160 -0
- package/src/txUtils.ts +424 -0
- package/test.ts +609 -0
- package/tsconfig.json +101 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { array, publicKey, str, struct, u128, u16, u64, u8 } from '@coral-xyz/borsh';
|
|
4
|
+
import { AddressLookupTableAccount, PublicKey } from '@solana/web3.js';
|
|
5
|
+
|
|
6
|
+
import { Fraction, FractionLayout } from './fraction';
|
|
7
|
+
import { OracleAggregator, OracleAggregatorLayout } from './oracle';
|
|
8
|
+
import { OraclePrice } from '../states/oracles/oracle';
|
|
9
|
+
import Decimal from 'decimal.js';
|
|
10
|
+
import { BasketSettings, BasketSettingsLayout } from './config';
|
|
11
|
+
import { MAX_MANAGERS_PER_BASKET, MAX_SUPPORTED_TOKENS_PER_BASKET } from '../constants';
|
|
12
|
+
import { EditAddTokenSettings, EditAutomationSettings, EditCreatorSettings, EditCustomRebalanceSettings, EditDepositsSettings, EditFeeSettings, EditForceRebalanceSettings, EditLpSettings, EditMakeDirectSwapSettings, EditManagerSettings, EditMetadataSettings, EditScheduleSettings, EditUpdateWeightsSettings, OracleInput } from './intents/intent';
|
|
13
|
+
|
|
14
|
+
export type FormattedBasketType = "private" | "public";
|
|
15
|
+
export const BASKET_TYPES_STRINGS: Map<number, FormattedBasketType> = new Map([
|
|
16
|
+
[0, "private"],
|
|
17
|
+
[1, "public"],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export interface FormattedAccumulatedFees {
|
|
21
|
+
symmetry_fees: number;
|
|
22
|
+
creator_fees: number;
|
|
23
|
+
host_fees: number;
|
|
24
|
+
managers_fees: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FormattedLookupTables {
|
|
28
|
+
active: {
|
|
29
|
+
pubkey: string;
|
|
30
|
+
contents: string[];
|
|
31
|
+
}[];
|
|
32
|
+
temp: {
|
|
33
|
+
pubkey: string;
|
|
34
|
+
contents: string[];
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface FormattedOracleSettings extends OracleInput {
|
|
39
|
+
quote: string;
|
|
40
|
+
side: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface FormattedOracle {
|
|
44
|
+
oracle_settings: FormattedOracleSettings;
|
|
45
|
+
accounts_to_load_lut_ids: number[];
|
|
46
|
+
accounts_to_load_lut_indices: number[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface FormattedOracleAggregator {
|
|
50
|
+
num_oracles: number;
|
|
51
|
+
min_oracles_thresh: number;
|
|
52
|
+
oracles: FormattedOracle[];
|
|
53
|
+
min_conf_bps: number,
|
|
54
|
+
conf_thresh_bps: number,
|
|
55
|
+
conf_multiplier: number,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface FormattedAsset {
|
|
59
|
+
mint: string;
|
|
60
|
+
amount: number;
|
|
61
|
+
weight: number;
|
|
62
|
+
active: boolean;
|
|
63
|
+
oracle_aggregator: FormattedOracleAggregator;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface FormattedCreatorSettings extends EditCreatorSettings {}
|
|
67
|
+
export interface FormattedManagersSettings extends EditManagerSettings { updated_at: number; }
|
|
68
|
+
export interface FormattedFeeSettings extends EditFeeSettings {
|
|
69
|
+
host_deposit_fee_bps: number;
|
|
70
|
+
host_withdraw_fee_bps: number;
|
|
71
|
+
host_management_fee_bps: number;
|
|
72
|
+
host_performance_fee_bps: number;
|
|
73
|
+
updated_at: number;
|
|
74
|
+
}
|
|
75
|
+
export interface FormattedScheduleSettings extends EditScheduleSettings { updated_at: number; }
|
|
76
|
+
export interface FormattedAutomationSettings extends EditAutomationSettings { updated_at: number; }
|
|
77
|
+
export interface FormattedLpSettings extends EditLpSettings { updated_at: number; }
|
|
78
|
+
export interface FormattedMetadataSettings extends EditMetadataSettings { updated_at: number; }
|
|
79
|
+
export interface FormattedDepositsSettings extends EditDepositsSettings {}
|
|
80
|
+
export interface FormattedForceRebalanceSettings extends EditForceRebalanceSettings { updated_at: number; }
|
|
81
|
+
export interface FormattedCustomRebalanceSettings extends EditCustomRebalanceSettings { updated_at: number; }
|
|
82
|
+
export interface FormattedAddTokenSettings extends EditAddTokenSettings { updated_at: number; }
|
|
83
|
+
export interface FormattedUpdateWeightsSettings extends EditUpdateWeightsSettings { updated_at: number; }
|
|
84
|
+
export interface FormattedMakeDirectSwapSettings extends EditMakeDirectSwapSettings { updated_at: number; }
|
|
85
|
+
|
|
86
|
+
export interface FormattedBasket {
|
|
87
|
+
pubkey: string;
|
|
88
|
+
name: string;
|
|
89
|
+
symbol: string;
|
|
90
|
+
uri: string;
|
|
91
|
+
version: number;
|
|
92
|
+
own_address: string;
|
|
93
|
+
mint: string;
|
|
94
|
+
supply_outstanding: number;
|
|
95
|
+
creator: string;
|
|
96
|
+
host: string;
|
|
97
|
+
basket_type: FormattedBasketType;
|
|
98
|
+
bounty_mint: string;
|
|
99
|
+
bounty_balance: number;
|
|
100
|
+
start_price: number;
|
|
101
|
+
high_watermark: number;
|
|
102
|
+
active_rebalance: number;
|
|
103
|
+
active_withdraws: number;
|
|
104
|
+
active_managements: number;
|
|
105
|
+
last_automation_execution_timestamp: number;
|
|
106
|
+
creator_settings: FormattedCreatorSettings;
|
|
107
|
+
manager_settings: FormattedManagersSettings;
|
|
108
|
+
fee_settings: FormattedFeeSettings;
|
|
109
|
+
schedule_settings: FormattedScheduleSettings;
|
|
110
|
+
automation_settings: FormattedAutomationSettings;
|
|
111
|
+
lp_settings: FormattedLpSettings;
|
|
112
|
+
metadata_settings: FormattedMetadataSettings;
|
|
113
|
+
deposits_settings: FormattedDepositsSettings;
|
|
114
|
+
force_rebalance_settings: FormattedForceRebalanceSettings;
|
|
115
|
+
custom_rebalance_settings: FormattedCustomRebalanceSettings;
|
|
116
|
+
add_token_settings: FormattedAddTokenSettings;
|
|
117
|
+
update_weights_settings: FormattedUpdateWeightsSettings;
|
|
118
|
+
make_direct_swap_settings: FormattedMakeDirectSwapSettings;
|
|
119
|
+
accumulated_fees: FormattedAccumulatedFees;
|
|
120
|
+
lookup_tables: FormattedLookupTables;
|
|
121
|
+
composition: FormattedAsset[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface BasketFees {
|
|
125
|
+
symmetryFees: BN; // u64
|
|
126
|
+
creatorFees: BN; // u64
|
|
127
|
+
hostFees: BN; // u64
|
|
128
|
+
managersFees: BN; // u64
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const BasketFeesLayout = struct<BasketFees>([
|
|
132
|
+
u64("symmetryFees"),
|
|
133
|
+
u64("creatorFees"),
|
|
134
|
+
u64("hostFees"),
|
|
135
|
+
u64("managersFees"),
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
export interface FormattedWithdrawBasketFees {
|
|
139
|
+
pubkey: string;
|
|
140
|
+
basket: string;
|
|
141
|
+
rent_payer: string;
|
|
142
|
+
owners: string[];
|
|
143
|
+
owners_weights: number[];
|
|
144
|
+
accumulated_tokens: string[];
|
|
145
|
+
accumulated_fees: number[];
|
|
146
|
+
}
|
|
147
|
+
export interface WithdrawBasketFees {
|
|
148
|
+
basket: PublicKey;
|
|
149
|
+
rentPayer: PublicKey;
|
|
150
|
+
owners: PublicKey[]; // MAX_MANAGERS_PER_BASKET
|
|
151
|
+
ownersWeights: number[]; // MAX_MANAGERS_PER_BASKET, u16
|
|
152
|
+
accumulatedTokens: PublicKey[]; // MAX_SUPPORTED_TOKENS_PER_BASKET
|
|
153
|
+
accumulatedFees: BN[]; // MAX_SUPPORTED_TOKENS_PER_BASKET, u64
|
|
154
|
+
ownAddress?: PublicKey;
|
|
155
|
+
formatted?: FormattedWithdrawBasketFees;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const WithdrawBasketFeesLayout = struct<WithdrawBasketFees>([
|
|
159
|
+
publicKey('basket'),
|
|
160
|
+
publicKey('rentPayer'),
|
|
161
|
+
array(publicKey(), MAX_MANAGERS_PER_BASKET, 'owners'),
|
|
162
|
+
array(u16(), MAX_MANAGERS_PER_BASKET, 'ownersWeights'),
|
|
163
|
+
array(publicKey(), MAX_SUPPORTED_TOKENS_PER_BASKET, 'accumulatedTokens'),
|
|
164
|
+
array(u64(), MAX_SUPPORTED_TOKENS_PER_BASKET, 'accumulatedFees'),
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
export interface LookupTables {
|
|
168
|
+
active: PublicKey[]; // length 2
|
|
169
|
+
temp: PublicKey[]; // length 2
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const LookupTablesLayout = struct<LookupTables>([
|
|
173
|
+
array(publicKey(), 2, "active"),
|
|
174
|
+
array(publicKey(), 2, "temp"),
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
export interface Asset {
|
|
178
|
+
mint: PublicKey;
|
|
179
|
+
amount: BN; // u64
|
|
180
|
+
weight: number; // u16
|
|
181
|
+
active: number; // u8
|
|
182
|
+
oracleAggregator: OracleAggregator;
|
|
183
|
+
price?: OraclePrice;
|
|
184
|
+
value?: Decimal;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const AssetLayout = struct<Asset>([
|
|
188
|
+
publicKey('mint'),
|
|
189
|
+
u64('amount'),
|
|
190
|
+
u16('weight'),
|
|
191
|
+
u8('active'),
|
|
192
|
+
OracleAggregatorLayout.replicate('oracleAggregator'),
|
|
193
|
+
]);
|
|
194
|
+
|
|
195
|
+
export interface Metadata {
|
|
196
|
+
symbol: string,
|
|
197
|
+
name: string,
|
|
198
|
+
uri: string
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface Basket {
|
|
202
|
+
version: number; // u8
|
|
203
|
+
|
|
204
|
+
ownAddress: PublicKey;
|
|
205
|
+
mint: PublicKey;
|
|
206
|
+
supplyOutstanding: BN; // u64
|
|
207
|
+
|
|
208
|
+
settings: BasketSettings;
|
|
209
|
+
|
|
210
|
+
accumulatedFees: BasketFees;
|
|
211
|
+
lookupTables: LookupTables;
|
|
212
|
+
|
|
213
|
+
numTokens: number; // u8
|
|
214
|
+
composition: Asset[]; // length MAX_SUPPORTED_TOKENS_PER_BASKET
|
|
215
|
+
|
|
216
|
+
lutPubkeys?: AddressLookupTableAccount[];
|
|
217
|
+
metadata?: Metadata;
|
|
218
|
+
tvl?: Decimal;
|
|
219
|
+
price?: Decimal;
|
|
220
|
+
formatted?: FormattedBasket;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const BasketLayout = struct<Basket>([
|
|
224
|
+
u8('version'),
|
|
225
|
+
publicKey('ownAddress'),
|
|
226
|
+
publicKey('mint'),
|
|
227
|
+
u64('supplyOutstanding'),
|
|
228
|
+
BasketSettingsLayout.replicate('settings'),
|
|
229
|
+
BasketFeesLayout.replicate('accumulatedFees'),
|
|
230
|
+
LookupTablesLayout.replicate('lookupTables'),
|
|
231
|
+
u8('numTokens'),
|
|
232
|
+
array(AssetLayout, MAX_SUPPORTED_TOKENS_PER_BASKET, 'composition'),
|
|
233
|
+
]);
|