@symmetry-hq/temp-v3-sdk 0.0.14 → 0.0.16
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/index.d.ts +2 -2
- package/dist/src/layouts/basket.d.ts +108 -1
- package/dist/src/states/basket.js +16 -16
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/layouts/basket.ts +87 -1
- package/src/states/basket.ts +35 -28
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BN } from '@coral-xyz/anchor';
|
|
2
2
|
import { Connection, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { Basket } from './layouts/basket';
|
|
3
|
+
import { Basket, FormattedBasket } from './layouts/basket';
|
|
4
4
|
import { GlobalConfig } from './layouts/config';
|
|
5
5
|
import { FormattedCreatorSettings, FormattedManagersSettings, FormattedFeeSettings, FormattedScheduleSettings, FormattedAutomationSettings, FormattedLpSettings, FormattedMetadataSettings, FormattedDepositsSettings, FormattedForceRebalanceSettings, FormattedCustomRebalanceSettings, FormattedAddTokenSettings, FormattedUpdateWeightsSettings, FormattedMakeDirectSwapSettings, TaskContext, Settings, AddTokenInput, UpdateWeightsInput, MakeDirectSwapInput, TaskType, Intent } from './layouts/intents/intent';
|
|
6
6
|
import { RebalanceIntent } from './layouts/intents/rebalanceIntent';
|
|
@@ -127,5 +127,5 @@ export declare class SymmetryCore {
|
|
|
127
127
|
wallet: Wallet;
|
|
128
128
|
}): Promise<TransactionSignature[][]>;
|
|
129
129
|
}
|
|
130
|
-
export { Basket, BasketFilter, Intent, IntentFilter, RebalanceIntent, RebalanceIntentFilter };
|
|
130
|
+
export { Basket, FormattedBasket, BasketFilter, Intent, IntentFilter, RebalanceIntent, RebalanceIntentFilter };
|
|
131
131
|
export { FormattedCreatorSettings, FormattedManagersSettings, FormattedFeeSettings, FormattedScheduleSettings, FormattedAutomationSettings, FormattedLpSettings, FormattedMetadataSettings, FormattedDepositsSettings, FormattedForceRebalanceSettings, FormattedCustomRebalanceSettings, FormattedAddTokenSettings, FormattedUpdateWeightsSettings, FormattedMakeDirectSwapSettings, AddTokenInput, UpdateWeightsInput, MakeDirectSwapInput, Settings, TaskContext, TaskType, };
|
|
@@ -4,6 +4,113 @@ import { OracleAggregator } from './oracle';
|
|
|
4
4
|
import { OraclePrice } from '../states/oracles/oracle';
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
6
|
import { BasketSettings } from './config';
|
|
7
|
+
import { FormattedAddTokenSettings, FormattedAutomationSettings, FormattedCreatorSettings, FormattedCustomRebalanceSettings, FormattedDepositsSettings, FormattedFeeSettings, FormattedForceRebalanceSettings, FormattedLpSettings, FormattedMakeDirectSwapSettings, FormattedManagersSettings, FormattedMetadataSettings, FormattedScheduleSettings, FormattedUpdateWeightsSettings } from './intents/intent';
|
|
8
|
+
export interface FormattedBasket {
|
|
9
|
+
pubkey: string;
|
|
10
|
+
name: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
uri: string;
|
|
13
|
+
version: number;
|
|
14
|
+
own_address: string;
|
|
15
|
+
mint: string;
|
|
16
|
+
supply_outstanding: number;
|
|
17
|
+
creator: string;
|
|
18
|
+
host: string;
|
|
19
|
+
basket_type: string;
|
|
20
|
+
bounty_mint: string;
|
|
21
|
+
bounty_balance: number;
|
|
22
|
+
start_price: number;
|
|
23
|
+
high_watermark: number;
|
|
24
|
+
active_rebalance: number;
|
|
25
|
+
active_deposits: number;
|
|
26
|
+
active_managements: number;
|
|
27
|
+
last_automation_execution_timestamp: number;
|
|
28
|
+
creator_settings: FormattedCreatorSettings;
|
|
29
|
+
manager_settings: FormattedManagersSettings & {
|
|
30
|
+
updated_at: number;
|
|
31
|
+
};
|
|
32
|
+
fee_settings: FormattedFeeSettings & {
|
|
33
|
+
updated_at: number;
|
|
34
|
+
};
|
|
35
|
+
schedule_settings: FormattedScheduleSettings & {
|
|
36
|
+
updated_at: number;
|
|
37
|
+
};
|
|
38
|
+
automation_settings: FormattedAutomationSettings & {
|
|
39
|
+
updated_at: number;
|
|
40
|
+
};
|
|
41
|
+
lp_settings: FormattedLpSettings & {
|
|
42
|
+
updated_at: number;
|
|
43
|
+
};
|
|
44
|
+
metadata_settings: FormattedMetadataSettings & {
|
|
45
|
+
updated_at: number;
|
|
46
|
+
};
|
|
47
|
+
deposits_settings: FormattedDepositsSettings;
|
|
48
|
+
force_rebalance_settings: FormattedForceRebalanceSettings & {
|
|
49
|
+
updated_at: number;
|
|
50
|
+
};
|
|
51
|
+
custom_rebalance_settings: FormattedCustomRebalanceSettings & {
|
|
52
|
+
updated_at: number;
|
|
53
|
+
};
|
|
54
|
+
add_token_settings: FormattedAddTokenSettings & {
|
|
55
|
+
updated_at: number;
|
|
56
|
+
};
|
|
57
|
+
update_weights_settings: FormattedUpdateWeightsSettings & {
|
|
58
|
+
updated_at: number;
|
|
59
|
+
};
|
|
60
|
+
make_direct_swap_settings: FormattedMakeDirectSwapSettings & {
|
|
61
|
+
updated_at: number;
|
|
62
|
+
};
|
|
63
|
+
accumulated_fees: {
|
|
64
|
+
symmetry_fees: number;
|
|
65
|
+
creator_fees: number;
|
|
66
|
+
host_fees: number;
|
|
67
|
+
managers_fees: number;
|
|
68
|
+
};
|
|
69
|
+
lookup_tables: {
|
|
70
|
+
active: {
|
|
71
|
+
pubkey: string;
|
|
72
|
+
contents: string[];
|
|
73
|
+
}[];
|
|
74
|
+
temp: {
|
|
75
|
+
pubkey: string;
|
|
76
|
+
contents: string[];
|
|
77
|
+
}[];
|
|
78
|
+
};
|
|
79
|
+
composition: {
|
|
80
|
+
mint: string;
|
|
81
|
+
amount: number;
|
|
82
|
+
weight: number;
|
|
83
|
+
active: boolean;
|
|
84
|
+
oracle_aggregator: {
|
|
85
|
+
num_oracles: number;
|
|
86
|
+
min_oracles_thresh: number;
|
|
87
|
+
oracles: {
|
|
88
|
+
oracle_settings: {
|
|
89
|
+
oracle_type: string;
|
|
90
|
+
num_required_accounts: number;
|
|
91
|
+
weight: number;
|
|
92
|
+
is_required: boolean;
|
|
93
|
+
conf_thresh_bps: number;
|
|
94
|
+
volatility_thresh_bps: number;
|
|
95
|
+
max_slippage_bps: number;
|
|
96
|
+
min_liquidity: number;
|
|
97
|
+
staleness_thresh: number;
|
|
98
|
+
staleness_conf_rate_bps: number;
|
|
99
|
+
token_decimals: number;
|
|
100
|
+
twap_seconds_ago: number;
|
|
101
|
+
twap_secondary_seconds_ago: number;
|
|
102
|
+
quote: string;
|
|
103
|
+
side: string;
|
|
104
|
+
};
|
|
105
|
+
accounts_to_load_lut_ids: number[];
|
|
106
|
+
accounts_to_load_lut_indices: number[];
|
|
107
|
+
}[];
|
|
108
|
+
min_conf_bps: number;
|
|
109
|
+
conf_thresh_bps: number;
|
|
110
|
+
conf_multiplier: number;
|
|
111
|
+
};
|
|
112
|
+
}[];
|
|
113
|
+
}
|
|
7
114
|
export interface BasketFees {
|
|
8
115
|
symmetryFees: BN;
|
|
9
116
|
creatorFees: BN;
|
|
@@ -45,6 +152,6 @@ export interface Basket {
|
|
|
45
152
|
metadata?: Metadata;
|
|
46
153
|
tvl?: Decimal;
|
|
47
154
|
price?: Decimal;
|
|
48
|
-
formatted?:
|
|
155
|
+
formatted?: FormattedBasket;
|
|
49
156
|
}
|
|
50
157
|
export declare const BasketLayout: any;
|
|
@@ -79,7 +79,7 @@ function addFieldsToBasket(basket) {
|
|
|
79
79
|
make_direct_swap: (((2 ** i) & basket.settings.makeDirectSwapIntentAuthorityBitmask) != 0),
|
|
80
80
|
},
|
|
81
81
|
})),
|
|
82
|
-
modification_delay: parseInt(basket.settings.managers.modificationDelay.toString()),
|
|
82
|
+
modification_delay: parseInt(basket.settings.managers.modificationDelay.toString()),
|
|
83
83
|
updated_at: parseInt(basket.settings.managersLastUpdateTimestamp.toString()),
|
|
84
84
|
};
|
|
85
85
|
let fee_settings = {
|
|
@@ -97,7 +97,7 @@ function addFieldsToBasket(basket) {
|
|
|
97
97
|
managers_performance_fee_bps: basket.settings.fees.managersPerformanceFeeBps,
|
|
98
98
|
basket_deposit_fee_bps: basket.settings.fees.basketDepositFeeBps,
|
|
99
99
|
basket_withdraw_fee_bps: basket.settings.fees.basketWithdrawFeeBps,
|
|
100
|
-
modification_delay: parseInt(basket.settings.fees.modificationDelay.toString()),
|
|
100
|
+
modification_delay: parseInt(basket.settings.fees.modificationDelay.toString()),
|
|
101
101
|
updated_at: parseInt(basket.settings.feesLastUpdateTimestamp.toString()),
|
|
102
102
|
};
|
|
103
103
|
let schedule_settings = {
|
|
@@ -109,7 +109,7 @@ function addFieldsToBasket(basket) {
|
|
|
109
109
|
automation_end: parseInt(basket.settings.schedule.automationEnd.toString()),
|
|
110
110
|
management_start: parseInt(basket.settings.schedule.managementStart.toString()),
|
|
111
111
|
management_end: parseInt(basket.settings.schedule.managementEnd.toString()),
|
|
112
|
-
modification_delay: parseInt(basket.settings.schedule.modificationDelay.toString()),
|
|
112
|
+
modification_delay: parseInt(basket.settings.schedule.modificationDelay.toString()),
|
|
113
113
|
updated_at: parseInt(basket.settings.scheduleLastUpdateTimestamp.toString()),
|
|
114
114
|
};
|
|
115
115
|
let automation_settings = {
|
|
@@ -119,20 +119,20 @@ function addFieldsToBasket(basket) {
|
|
|
119
119
|
rebalance_activation_threshold_abs_bps: basket.settings.automation.rebalanceActivationThresholdAbsBps,
|
|
120
120
|
rebalance_activation_threshold_rel_bps: basket.settings.automation.rebalanceActivationThresholdRelBps,
|
|
121
121
|
rebalance_activation_cooldown: parseInt(basket.settings.automation.rebalanceActivationCooldown.toString()),
|
|
122
|
-
modification_delay: parseInt(basket.settings.automation.modificationDelay.toString()),
|
|
122
|
+
modification_delay: parseInt(basket.settings.automation.modificationDelay.toString()),
|
|
123
123
|
updated_at: parseInt(basket.settings.automationLastUpdateTimestamp.toString()),
|
|
124
124
|
};
|
|
125
125
|
let lp_settings = {
|
|
126
126
|
allow: basket.settings.lp.allowLp == 1 ? true : false,
|
|
127
127
|
lp_threshold_bps: basket.settings.lp.lpThresholdBps,
|
|
128
|
-
modification_delay: parseInt(basket.settings.lp.modificationDelay.toString()),
|
|
128
|
+
modification_delay: parseInt(basket.settings.lp.modificationDelay.toString()),
|
|
129
129
|
updated_at: parseInt(basket.settings.lpLastUpdateTimestamp.toString()),
|
|
130
130
|
};
|
|
131
131
|
let metadata_settings = {
|
|
132
132
|
symbol: metadata.symbol,
|
|
133
133
|
name: metadata.name,
|
|
134
134
|
uri: metadata.uri,
|
|
135
|
-
modification_delay: parseInt(basket.settings.metadata.modificationDelay.toString()),
|
|
135
|
+
modification_delay: parseInt(basket.settings.metadata.modificationDelay.toString()),
|
|
136
136
|
updated_at: parseInt(basket.settings.metadataLastUpdateTimestamp.toString()),
|
|
137
137
|
};
|
|
138
138
|
let deposits_settings = {
|
|
@@ -140,31 +140,31 @@ function addFieldsToBasket(basket) {
|
|
|
140
140
|
};
|
|
141
141
|
let force_rebalance_settings = {
|
|
142
142
|
allow: basket.settings.forceRebalanceIsAllowed == 1 ? true : false,
|
|
143
|
-
modification_delay: parseInt(basket.settings.forceRebalanceModificationDelay.toString()),
|
|
143
|
+
modification_delay: parseInt(basket.settings.forceRebalanceModificationDelay.toString()),
|
|
144
144
|
updated_at: parseInt(basket.settings.forceRebalanceLastUpdateTimestamp.toString()),
|
|
145
145
|
};
|
|
146
146
|
let custom_rebalance_settings = {
|
|
147
147
|
allow: basket.settings.customRebalanceIsAllowed == 1 ? true : false,
|
|
148
|
-
modification_delay: parseInt(basket.settings.customRebalanceModificationDelay.toString()),
|
|
148
|
+
modification_delay: parseInt(basket.settings.customRebalanceModificationDelay.toString()),
|
|
149
149
|
updated_at: parseInt(basket.settings.customRebalanceLastUpdateTimestamp.toString()),
|
|
150
150
|
};
|
|
151
151
|
let add_token_settings = {
|
|
152
|
-
modification_delay: parseInt(basket.settings.addTokenDelay.toString()),
|
|
152
|
+
modification_delay: parseInt(basket.settings.addTokenDelay.toString()),
|
|
153
153
|
updated_at: parseInt(basket.settings.addTokenLastUpdateTimestamp.toString()),
|
|
154
154
|
};
|
|
155
155
|
let update_weights_settings = {
|
|
156
|
-
modification_delay: parseInt(basket.settings.updateWeightsDelay.toString()),
|
|
156
|
+
modification_delay: parseInt(basket.settings.updateWeightsDelay.toString()),
|
|
157
157
|
updated_at: parseInt(basket.settings.updateWeightsLastUpdateTimestamp.toString()),
|
|
158
158
|
};
|
|
159
159
|
let make_direct_swap_settings = {
|
|
160
|
-
modification_delay: parseInt(basket.settings.makeDirectSwapDelay.toString()),
|
|
160
|
+
modification_delay: parseInt(basket.settings.makeDirectSwapDelay.toString()),
|
|
161
161
|
updated_at: parseInt(basket.settings.makeDirectSwapLastUpdateTimestamp.toString()),
|
|
162
162
|
};
|
|
163
163
|
let formatted = {
|
|
164
164
|
pubkey: basket.ownAddress.toBase58(),
|
|
165
|
-
name: (_a = basket.metadata) === null || _a === void 0 ? void 0 : _a.name,
|
|
166
|
-
symbol: (_b = basket.metadata) === null || _b === void 0 ? void 0 : _b.symbol,
|
|
167
|
-
uri: (_c = basket.metadata) === null || _c === void 0 ? void 0 : _c.uri,
|
|
165
|
+
name: ((_a = basket.metadata) === null || _a === void 0 ? void 0 : _a.name) || "",
|
|
166
|
+
symbol: ((_b = basket.metadata) === null || _b === void 0 ? void 0 : _b.symbol) || "",
|
|
167
|
+
uri: ((_c = basket.metadata) === null || _c === void 0 ? void 0 : _c.uri) || "",
|
|
168
168
|
version: basket.version,
|
|
169
169
|
own_address: basket.ownAddress.toBase58(),
|
|
170
170
|
mint: basket.mint.toBase58(),
|
|
@@ -244,8 +244,8 @@ function addFieldsToBasket(basket) {
|
|
|
244
244
|
token_decimals: oracle.oracleSettings.tokenDecimals,
|
|
245
245
|
twap_seconds_ago: parseInt(oracle.oracleSettings.twapSecondsAgo.toString()),
|
|
246
246
|
twap_secondary_seconds_ago: parseInt(oracle.oracleSettings.twapSecondarySecondsAgo.toString()),
|
|
247
|
-
quote: oracle.oracleSettings.quote == 0 ? "
|
|
248
|
-
side: oracle.oracleSettings.side == 0 ? "
|
|
247
|
+
quote: oracle.oracleSettings.quote == 0 ? "usdc" : "wsol",
|
|
248
|
+
side: oracle.oracleSettings.side == 0 ? "base" : "quote",
|
|
249
249
|
},
|
|
250
250
|
accounts_to_load_lut_ids: oracle.accountsToLoadLutIds.map(id => id),
|
|
251
251
|
accounts_to_load_lut_indices: oracle.accountsToLoadLutIndices.map(index => index),
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from './instructions/pda';
|
|
27
27
|
import { depositTokensIx, lockDepositsIx, mintBasketIx } from './instructions/user/deposit';
|
|
28
28
|
import { redeemTokensIx } from './instructions/user/withdraw';
|
|
29
|
-
import { Basket, BasketLayout } from './layouts/basket';
|
|
29
|
+
import { Basket, BasketLayout, FormattedBasket } from './layouts/basket';
|
|
30
30
|
import {
|
|
31
31
|
AutomationSettings, FeeSettings, GlobalConfig, GlobalConfigLayout, LpSettings, ManagerSettings,
|
|
32
32
|
MetadataSettings, ScheduleSettings
|
|
@@ -810,6 +810,7 @@ export class SymmetryCore {
|
|
|
810
810
|
|
|
811
811
|
export {
|
|
812
812
|
Basket,
|
|
813
|
+
FormattedBasket,
|
|
813
814
|
BasketFilter,
|
|
814
815
|
Intent,
|
|
815
816
|
IntentFilter,
|
package/src/layouts/basket.ts
CHANGED
|
@@ -9,6 +9,92 @@ import { OraclePrice } from '../states/oracles/oracle';
|
|
|
9
9
|
import Decimal from 'decimal.js';
|
|
10
10
|
import { BasketSettings, BasketSettingsLayout } from './config';
|
|
11
11
|
import { MAX_SUPPORTED_TOKENS_PER_BASKET } from '../constants';
|
|
12
|
+
import { FormattedAddTokenSettings, FormattedAutomationSettings, FormattedCreatorSettings, FormattedCustomRebalanceSettings, FormattedDepositsSettings, FormattedFeeSettings, FormattedForceRebalanceSettings, FormattedLpSettings, FormattedMakeDirectSwapSettings, FormattedManagersSettings, FormattedMetadataSettings, FormattedScheduleSettings, FormattedUpdateWeightsSettings } from './intents/intent';
|
|
13
|
+
|
|
14
|
+
export interface FormattedBasket {
|
|
15
|
+
pubkey: string;
|
|
16
|
+
name: string;
|
|
17
|
+
symbol: string;
|
|
18
|
+
uri: string;
|
|
19
|
+
version: number;
|
|
20
|
+
own_address: string;
|
|
21
|
+
mint: string;
|
|
22
|
+
supply_outstanding: number;
|
|
23
|
+
creator: string;
|
|
24
|
+
host: string;
|
|
25
|
+
basket_type: string;
|
|
26
|
+
bounty_mint: string;
|
|
27
|
+
bounty_balance: number;
|
|
28
|
+
start_price: number;
|
|
29
|
+
high_watermark: number;
|
|
30
|
+
active_rebalance: number;
|
|
31
|
+
active_deposits: number;
|
|
32
|
+
active_managements: number;
|
|
33
|
+
last_automation_execution_timestamp: number;
|
|
34
|
+
creator_settings: FormattedCreatorSettings;
|
|
35
|
+
manager_settings: FormattedManagersSettings & { updated_at: number };
|
|
36
|
+
fee_settings: FormattedFeeSettings & { updated_at: number };
|
|
37
|
+
schedule_settings: FormattedScheduleSettings & { updated_at: number };
|
|
38
|
+
automation_settings: FormattedAutomationSettings & { updated_at: number };
|
|
39
|
+
lp_settings: FormattedLpSettings & { updated_at: number };
|
|
40
|
+
metadata_settings: FormattedMetadataSettings & { updated_at: number };
|
|
41
|
+
deposits_settings: FormattedDepositsSettings;
|
|
42
|
+
force_rebalance_settings: FormattedForceRebalanceSettings & { updated_at: number };
|
|
43
|
+
custom_rebalance_settings: FormattedCustomRebalanceSettings & { updated_at: number };
|
|
44
|
+
add_token_settings: FormattedAddTokenSettings & { updated_at: number };
|
|
45
|
+
update_weights_settings: FormattedUpdateWeightsSettings & { updated_at: number };
|
|
46
|
+
make_direct_swap_settings: FormattedMakeDirectSwapSettings & { updated_at: number };
|
|
47
|
+
accumulated_fees: {
|
|
48
|
+
symmetry_fees: number;
|
|
49
|
+
creator_fees: number;
|
|
50
|
+
host_fees: number;
|
|
51
|
+
managers_fees: number;
|
|
52
|
+
};
|
|
53
|
+
lookup_tables: {
|
|
54
|
+
active: {
|
|
55
|
+
pubkey: string;
|
|
56
|
+
contents: string[];
|
|
57
|
+
}[];
|
|
58
|
+
temp: {
|
|
59
|
+
pubkey: string;
|
|
60
|
+
contents: string[];
|
|
61
|
+
}[];
|
|
62
|
+
};
|
|
63
|
+
composition: {
|
|
64
|
+
mint: string,
|
|
65
|
+
amount: number,
|
|
66
|
+
weight: number,
|
|
67
|
+
active: boolean,
|
|
68
|
+
oracle_aggregator: {
|
|
69
|
+
num_oracles: number,
|
|
70
|
+
min_oracles_thresh: number,
|
|
71
|
+
oracles: {
|
|
72
|
+
oracle_settings: {
|
|
73
|
+
oracle_type: string,
|
|
74
|
+
num_required_accounts: number,
|
|
75
|
+
weight: number,
|
|
76
|
+
is_required: boolean,
|
|
77
|
+
conf_thresh_bps: number,
|
|
78
|
+
volatility_thresh_bps: number,
|
|
79
|
+
max_slippage_bps: number,
|
|
80
|
+
min_liquidity: number,
|
|
81
|
+
staleness_thresh: number,
|
|
82
|
+
staleness_conf_rate_bps: number,
|
|
83
|
+
token_decimals: number,
|
|
84
|
+
twap_seconds_ago: number,
|
|
85
|
+
twap_secondary_seconds_ago: number,
|
|
86
|
+
quote: string,
|
|
87
|
+
side: string,
|
|
88
|
+
},
|
|
89
|
+
accounts_to_load_lut_ids: number[],
|
|
90
|
+
accounts_to_load_lut_indices: number[],
|
|
91
|
+
}[],
|
|
92
|
+
min_conf_bps: number,
|
|
93
|
+
conf_thresh_bps: number,
|
|
94
|
+
conf_multiplier: number,
|
|
95
|
+
},
|
|
96
|
+
}[],
|
|
97
|
+
}
|
|
12
98
|
|
|
13
99
|
export interface BasketFees {
|
|
14
100
|
symmetryFees: BN; // u64
|
|
@@ -77,7 +163,7 @@ export interface Basket {
|
|
|
77
163
|
metadata?: Metadata;
|
|
78
164
|
tvl?: Decimal;
|
|
79
165
|
price?: Decimal;
|
|
80
|
-
formatted?:
|
|
166
|
+
formatted?: FormattedBasket;
|
|
81
167
|
};
|
|
82
168
|
|
|
83
169
|
export const BasketLayout = struct<Basket>([
|
package/src/states/basket.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from './oracles/raydiumClmmOracle';
|
|
21
21
|
import { fractionToDecimal } from '../layouts/fraction';
|
|
22
22
|
import { FormattedAddTokenSettings, FormattedAutomationSettings, FormattedCreatorSettings, FormattedCustomRebalanceSettings, FormattedDepositsSettings, FormattedFeeSettings, FormattedForceRebalanceSettings, FormattedLpSettings, FormattedMakeDirectSwapSettings, FormattedManagersSettings, FormattedMetadataSettings, FormattedScheduleSettings, FormattedUpdateWeightsSettings } from '../layouts/intents/intent';
|
|
23
|
+
import { FormattedBasket } from '../layouts/basket';
|
|
23
24
|
|
|
24
25
|
export function addFieldsToBasket(basket: Basket): Basket {
|
|
25
26
|
let metadataSettings = basket.settings.metadata;
|
|
@@ -51,7 +52,7 @@ export function addFieldsToBasket(basket: Basket): Basket {
|
|
|
51
52
|
let creator_settings: FormattedCreatorSettings = {
|
|
52
53
|
creator: basket.settings.creator.toBase58(),
|
|
53
54
|
}
|
|
54
|
-
let manager_settings: FormattedManagersSettings = {
|
|
55
|
+
let manager_settings: FormattedManagersSettings & { updated_at: number } = {
|
|
55
56
|
managers: basket.settings.managers.managers.map((manager, i) => ({
|
|
56
57
|
pubkey: manager.toBase58(),
|
|
57
58
|
fee_split_weight_bps: basket.settings.managers.managersWeightBps[i],
|
|
@@ -70,10 +71,16 @@ export function addFieldsToBasket(basket: Basket): Basket {
|
|
|
70
71
|
make_direct_swap: (((2 ** i) & basket.settings.makeDirectSwapIntentAuthorityBitmask) != 0),
|
|
71
72
|
},
|
|
72
73
|
})),
|
|
73
|
-
modification_delay: parseInt(basket.settings.managers.modificationDelay.toString()),
|
|
74
|
+
modification_delay: parseInt(basket.settings.managers.modificationDelay.toString()),
|
|
74
75
|
updated_at: parseInt(basket.settings.managersLastUpdateTimestamp.toString()),
|
|
75
76
|
}
|
|
76
|
-
let fee_settings: FormattedFeeSettings
|
|
77
|
+
let fee_settings: FormattedFeeSettings & {
|
|
78
|
+
host_deposit_fee_bps: number;
|
|
79
|
+
host_withdraw_fee_bps: number;
|
|
80
|
+
host_management_fee_bps: number;
|
|
81
|
+
host_performance_fee_bps: number;
|
|
82
|
+
updated_at: number
|
|
83
|
+
} = {
|
|
77
84
|
host_deposit_fee_bps: basket.settings.fees.hostDepositFeeBps,
|
|
78
85
|
host_withdraw_fee_bps: basket.settings.fees.hostWithdrawFeeBps,
|
|
79
86
|
host_management_fee_bps: basket.settings.fees.hostManagementFeeBps,
|
|
@@ -88,10 +95,10 @@ export function addFieldsToBasket(basket: Basket): Basket {
|
|
|
88
95
|
managers_performance_fee_bps: basket.settings.fees.managersPerformanceFeeBps,
|
|
89
96
|
basket_deposit_fee_bps: basket.settings.fees.basketDepositFeeBps,
|
|
90
97
|
basket_withdraw_fee_bps: basket.settings.fees.basketWithdrawFeeBps,
|
|
91
|
-
modification_delay: parseInt(basket.settings.fees.modificationDelay.toString()),
|
|
98
|
+
modification_delay: parseInt(basket.settings.fees.modificationDelay.toString()),
|
|
92
99
|
updated_at: parseInt(basket.settings.feesLastUpdateTimestamp.toString()),
|
|
93
100
|
}
|
|
94
|
-
let schedule_settings: FormattedScheduleSettings = {
|
|
101
|
+
let schedule_settings: FormattedScheduleSettings & { updated_at: number } = {
|
|
95
102
|
cycle_start_time: parseInt(basket.settings.schedule.cycleStartTime.toString()),
|
|
96
103
|
cycle_duration: parseInt(basket.settings.schedule.cycleDuration.toString()),
|
|
97
104
|
deposits_start: parseInt(basket.settings.schedule.depositsStart.toString()),
|
|
@@ -100,62 +107,62 @@ export function addFieldsToBasket(basket: Basket): Basket {
|
|
|
100
107
|
automation_end: parseInt(basket.settings.schedule.automationEnd.toString()),
|
|
101
108
|
management_start: parseInt(basket.settings.schedule.managementStart.toString()),
|
|
102
109
|
management_end: parseInt(basket.settings.schedule.managementEnd.toString()),
|
|
103
|
-
modification_delay: parseInt(basket.settings.schedule.modificationDelay.toString()),
|
|
110
|
+
modification_delay: parseInt(basket.settings.schedule.modificationDelay.toString()),
|
|
104
111
|
updated_at: parseInt(basket.settings.scheduleLastUpdateTimestamp.toString()),
|
|
105
112
|
}
|
|
106
|
-
let automation_settings: FormattedAutomationSettings = {
|
|
113
|
+
let automation_settings: FormattedAutomationSettings & { updated_at: number } = {
|
|
107
114
|
allow: basket.settings.automation.allowAutomation == 1 ? true : false,
|
|
108
115
|
rebalance_slippage_threshold_bps: basket.settings.automation.rebalanceSlippageThresholdBps,
|
|
109
116
|
per_trade_rebalance_slippage_threshold_bps: basket.settings.automation.perTradeRebalanceSlippageThresholdBps,
|
|
110
117
|
rebalance_activation_threshold_abs_bps: basket.settings.automation.rebalanceActivationThresholdAbsBps,
|
|
111
118
|
rebalance_activation_threshold_rel_bps: basket.settings.automation.rebalanceActivationThresholdRelBps,
|
|
112
119
|
rebalance_activation_cooldown: parseInt(basket.settings.automation.rebalanceActivationCooldown.toString()),
|
|
113
|
-
modification_delay: parseInt(basket.settings.automation.modificationDelay.toString()),
|
|
120
|
+
modification_delay: parseInt(basket.settings.automation.modificationDelay.toString()),
|
|
114
121
|
updated_at: parseInt(basket.settings.automationLastUpdateTimestamp.toString()),
|
|
115
122
|
}
|
|
116
|
-
let lp_settings: FormattedLpSettings = {
|
|
123
|
+
let lp_settings: FormattedLpSettings & { updated_at: number } = {
|
|
117
124
|
allow: basket.settings.lp.allowLp == 1 ? true : false,
|
|
118
125
|
lp_threshold_bps: basket.settings.lp.lpThresholdBps,
|
|
119
|
-
modification_delay: parseInt(basket.settings.lp.modificationDelay.toString()),
|
|
126
|
+
modification_delay: parseInt(basket.settings.lp.modificationDelay.toString()),
|
|
120
127
|
updated_at: parseInt(basket.settings.lpLastUpdateTimestamp.toString()),
|
|
121
128
|
}
|
|
122
|
-
let metadata_settings: FormattedMetadataSettings = {
|
|
129
|
+
let metadata_settings: FormattedMetadataSettings & { updated_at: number } = {
|
|
123
130
|
symbol: metadata.symbol,
|
|
124
131
|
name: metadata.name,
|
|
125
132
|
uri: metadata.uri,
|
|
126
|
-
modification_delay: parseInt(basket.settings.metadata.modificationDelay.toString()),
|
|
133
|
+
modification_delay: parseInt(basket.settings.metadata.modificationDelay.toString()),
|
|
127
134
|
updated_at: parseInt(basket.settings.metadataLastUpdateTimestamp.toString()),
|
|
128
135
|
}
|
|
129
136
|
let deposits_settings: FormattedDepositsSettings = {
|
|
130
137
|
allow: basket.settings.depositsAreAllowed == 1 ? true : false,
|
|
131
138
|
}
|
|
132
|
-
let force_rebalance_settings: FormattedForceRebalanceSettings = {
|
|
139
|
+
let force_rebalance_settings: FormattedForceRebalanceSettings & { updated_at: number } = {
|
|
133
140
|
allow: basket.settings.forceRebalanceIsAllowed == 1 ? true : false,
|
|
134
|
-
modification_delay: parseInt(basket.settings.forceRebalanceModificationDelay.toString()),
|
|
141
|
+
modification_delay: parseInt(basket.settings.forceRebalanceModificationDelay.toString()),
|
|
135
142
|
updated_at: parseInt(basket.settings.forceRebalanceLastUpdateTimestamp.toString()),
|
|
136
143
|
}
|
|
137
|
-
let custom_rebalance_settings: FormattedCustomRebalanceSettings = {
|
|
144
|
+
let custom_rebalance_settings: FormattedCustomRebalanceSettings & { updated_at: number } = {
|
|
138
145
|
allow: basket.settings.customRebalanceIsAllowed == 1 ? true : false,
|
|
139
|
-
modification_delay: parseInt(basket.settings.customRebalanceModificationDelay.toString()),
|
|
146
|
+
modification_delay: parseInt(basket.settings.customRebalanceModificationDelay.toString()),
|
|
140
147
|
updated_at: parseInt(basket.settings.customRebalanceLastUpdateTimestamp.toString()),
|
|
141
148
|
}
|
|
142
|
-
let add_token_settings: FormattedAddTokenSettings = {
|
|
143
|
-
modification_delay: parseInt(basket.settings.addTokenDelay.toString()),
|
|
149
|
+
let add_token_settings: FormattedAddTokenSettings & { updated_at: number } = {
|
|
150
|
+
modification_delay: parseInt(basket.settings.addTokenDelay.toString()),
|
|
144
151
|
updated_at: parseInt(basket.settings.addTokenLastUpdateTimestamp.toString()),
|
|
145
152
|
}
|
|
146
|
-
let update_weights_settings: FormattedUpdateWeightsSettings = {
|
|
147
|
-
modification_delay: parseInt(basket.settings.updateWeightsDelay.toString()),
|
|
153
|
+
let update_weights_settings: FormattedUpdateWeightsSettings & { updated_at: number } = {
|
|
154
|
+
modification_delay: parseInt(basket.settings.updateWeightsDelay.toString()),
|
|
148
155
|
updated_at: parseInt(basket.settings.updateWeightsLastUpdateTimestamp.toString()),
|
|
149
156
|
}
|
|
150
|
-
let make_direct_swap_settings: FormattedMakeDirectSwapSettings = {
|
|
151
|
-
modification_delay: parseInt(basket.settings.makeDirectSwapDelay.toString()),
|
|
157
|
+
let make_direct_swap_settings: FormattedMakeDirectSwapSettings & { updated_at: number } = {
|
|
158
|
+
modification_delay: parseInt(basket.settings.makeDirectSwapDelay.toString()),
|
|
152
159
|
updated_at: parseInt(basket.settings.makeDirectSwapLastUpdateTimestamp.toString()),
|
|
153
160
|
}
|
|
154
|
-
let formatted = {
|
|
161
|
+
let formatted: FormattedBasket = {
|
|
155
162
|
pubkey: basket.ownAddress.toBase58(),
|
|
156
|
-
name: basket.metadata?.name,
|
|
157
|
-
symbol: basket.metadata?.symbol,
|
|
158
|
-
uri: basket.metadata?.uri,
|
|
163
|
+
name: basket.metadata?.name || "",
|
|
164
|
+
symbol: basket.metadata?.symbol || "",
|
|
165
|
+
uri: basket.metadata?.uri || "",
|
|
159
166
|
|
|
160
167
|
version: basket.version,
|
|
161
168
|
own_address: basket.ownAddress.toBase58(),
|
|
@@ -239,8 +246,8 @@ export function addFieldsToBasket(basket: Basket): Basket {
|
|
|
239
246
|
token_decimals: oracle.oracleSettings.tokenDecimals,
|
|
240
247
|
twap_seconds_ago: parseInt(oracle.oracleSettings.twapSecondsAgo.toString()),
|
|
241
248
|
twap_secondary_seconds_ago: parseInt(oracle.oracleSettings.twapSecondarySecondsAgo.toString()),
|
|
242
|
-
quote: oracle.oracleSettings.quote == 0 ? "
|
|
243
|
-
side: oracle.oracleSettings.side == 0 ? "
|
|
249
|
+
quote: oracle.oracleSettings.quote == 0 ? "usdc" : "wsol",
|
|
250
|
+
side: oracle.oracleSettings.side == 0 ? "base" : "quote",
|
|
244
251
|
},
|
|
245
252
|
accounts_to_load_lut_ids: oracle.accountsToLoadLutIds.map(id => id),
|
|
246
253
|
accounts_to_load_lut_indices: oracle.accountsToLoadLutIndices.map(index => index),
|