@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,164 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
import { array, publicKey, str, struct, u128, u16, u64, u8 } from '@coral-xyz/borsh';
|
|
3
|
+
import Decimal from "decimal.js";
|
|
4
|
+
import { X64 } from "../constants";
|
|
5
|
+
|
|
6
|
+
export interface Fraction {
|
|
7
|
+
high: BN; // u64 -> BN
|
|
8
|
+
low: BN; // u64 -> BN
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const FractionLayout = struct<Fraction>([
|
|
12
|
+
u64('high'),
|
|
13
|
+
u64('low'),
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export function fractionToDecimal(fraction: Fraction): Decimal {
|
|
17
|
+
let high = new Decimal(fraction.high.toString());
|
|
18
|
+
let low = new Decimal(fraction.low.toString());
|
|
19
|
+
let res = high.add(low.div(X64));
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function decimalToFraction(decimal: Decimal): Fraction {
|
|
24
|
+
let res = decimal.mul(X64).floor();
|
|
25
|
+
let high = res.div(X64).floor();
|
|
26
|
+
let low = res.sub(high.mul(X64));
|
|
27
|
+
return { high: new BN(high.toString()), low: new BN(low.toString()) };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// X64 = 2^64
|
|
31
|
+
const X64_BN = new BN(2).pow(new BN(64));
|
|
32
|
+
const U64_MAX = new BN(2).pow(new BN(64)).sub(new BN(1));
|
|
33
|
+
|
|
34
|
+
// Fraction addition: (a + b)
|
|
35
|
+
// a = high_a * 2^64 + low_a, b = high_b * 2^64 + low_b
|
|
36
|
+
// result = (high_a + high_b) * 2^64 + (low_a + low_b)
|
|
37
|
+
// Handle carry from low to high
|
|
38
|
+
export function fractionAdd(a: Fraction, b: Fraction): Fraction {
|
|
39
|
+
const lowSum = a.low.add(b.low);
|
|
40
|
+
const carry = lowSum.gt(U64_MAX) ? new BN(1) : new BN(0);
|
|
41
|
+
const low = lowSum.mod(X64_BN);
|
|
42
|
+
const high = a.high.add(b.high).add(carry);
|
|
43
|
+
// Check overflow: high should fit in u64
|
|
44
|
+
if (high.gt(U64_MAX)) {
|
|
45
|
+
throw new Error("MathError");
|
|
46
|
+
}
|
|
47
|
+
return { high, low };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Fraction subtraction: (a - b)
|
|
51
|
+
// a = high_a * 2^64 + low_a, b = high_b * 2^64 + low_b
|
|
52
|
+
// result = (high_a - high_b) * 2^64 + (low_a - low_b)
|
|
53
|
+
// Handle borrow from high to low
|
|
54
|
+
export function fractionSub(a: Fraction, b: Fraction): Fraction {
|
|
55
|
+
// Check if a < b
|
|
56
|
+
if (a.high.lt(b.high) || (a.high.eq(b.high) && a.low.lt(b.low))) {
|
|
57
|
+
throw new Error("MathError");
|
|
58
|
+
}
|
|
59
|
+
let low = a.low.sub(b.low);
|
|
60
|
+
let high = a.high.sub(b.high);
|
|
61
|
+
// Handle borrow if low < 0
|
|
62
|
+
if (low.isNeg()) {
|
|
63
|
+
low = low.add(X64_BN);
|
|
64
|
+
high = high.sub(new BN(1));
|
|
65
|
+
}
|
|
66
|
+
if (high.isNeg()) {
|
|
67
|
+
throw new Error("MathError");
|
|
68
|
+
}
|
|
69
|
+
return { high, low };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Fraction multiplication: (a * b) / X64
|
|
73
|
+
// (high_a * 2^64 + low_a) * (high_b * 2^64 + low_b) / 2^64
|
|
74
|
+
// = high_a * high_b * 2^64 + high_a * low_b + low_a * high_b + (low_a * low_b) / 2^64
|
|
75
|
+
export function fractionMul(a: Fraction, b: Fraction): Fraction {
|
|
76
|
+
// Calculate all components
|
|
77
|
+
const highHigh = a.high.mul(b.high).mul(X64_BN);
|
|
78
|
+
const highLow = a.high.mul(b.low);
|
|
79
|
+
const lowHigh = a.low.mul(b.high);
|
|
80
|
+
const lowLow = a.low.mul(b.low).div(X64_BN);
|
|
81
|
+
|
|
82
|
+
// Sum: highHigh + highLow + lowHigh + lowLow
|
|
83
|
+
const sum = highHigh.add(highLow).add(lowHigh).add(lowLow);
|
|
84
|
+
|
|
85
|
+
// Split into high and low
|
|
86
|
+
const high = sum.div(X64_BN);
|
|
87
|
+
const low = sum.mod(X64_BN);
|
|
88
|
+
|
|
89
|
+
// Check overflow: high should fit in u64
|
|
90
|
+
if (high.gt(U64_MAX)) {
|
|
91
|
+
throw new Error("MathError");
|
|
92
|
+
}
|
|
93
|
+
return { high, low };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Fraction division: (a * X64) / b
|
|
97
|
+
// (high_a * 2^64 + low_a) * 2^64 / (high_b * 2^64 + low_b)
|
|
98
|
+
export function fractionDiv(a: Fraction, b: Fraction): Fraction {
|
|
99
|
+
// Check division by zero
|
|
100
|
+
if (b.high.isZero() && b.low.isZero()) {
|
|
101
|
+
throw new Error("MathError");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// numerator = a * X64 = (high_a * 2^64 + low_a) * 2^64
|
|
105
|
+
const numerator = a.high.mul(X64_BN).add(a.low).mul(X64_BN);
|
|
106
|
+
|
|
107
|
+
// denominator = b = high_b * 2^64 + low_b
|
|
108
|
+
const denominator = b.high.mul(X64_BN).add(b.low);
|
|
109
|
+
|
|
110
|
+
// result = numerator / denominator
|
|
111
|
+
const result = numerator.div(denominator);
|
|
112
|
+
|
|
113
|
+
// Split into high and low
|
|
114
|
+
const high = result.div(X64_BN);
|
|
115
|
+
const low = result.mod(X64_BN);
|
|
116
|
+
|
|
117
|
+
// Check overflow: high should fit in u64
|
|
118
|
+
if (high.gt(U64_MAX)) {
|
|
119
|
+
throw new Error("MathError");
|
|
120
|
+
}
|
|
121
|
+
return { high, low };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Comparison functions
|
|
125
|
+
export function fractionLt(a: Fraction, b: Fraction): boolean {
|
|
126
|
+
if (a.high.lt(b.high)) return true;
|
|
127
|
+
if (a.high.gt(b.high)) return false;
|
|
128
|
+
return a.low.lt(b.low);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function fractionLte(a: Fraction, b: Fraction): boolean {
|
|
132
|
+
if (a.high.lt(b.high)) return true;
|
|
133
|
+
if (a.high.gt(b.high)) return false;
|
|
134
|
+
return a.low.lte(b.low);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function fractionGt(a: Fraction, b: Fraction): boolean {
|
|
138
|
+
if (a.high.gt(b.high)) return true;
|
|
139
|
+
if (a.high.lt(b.high)) return false;
|
|
140
|
+
return a.low.gt(b.low);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function fractionGte(a: Fraction, b: Fraction): boolean {
|
|
144
|
+
if (a.high.gt(b.high)) return true;
|
|
145
|
+
if (a.high.lt(b.high)) return false;
|
|
146
|
+
return a.low.gte(b.low);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function fractionEq(a: Fraction, b: Fraction): boolean {
|
|
150
|
+
return a.high.eq(b.high) && a.low.eq(b.low);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Round Fraction down to BN (floor)
|
|
154
|
+
export function fractionRoundDown(fraction: Fraction): BN {
|
|
155
|
+
return fraction.high;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Round Fraction up to BN (ceiling)
|
|
159
|
+
export function fractionRoundUp(fraction: Fraction): BN {
|
|
160
|
+
if (fraction.low.isZero()) {
|
|
161
|
+
return fraction.high;
|
|
162
|
+
}
|
|
163
|
+
return fraction.high.add(new BN(1));
|
|
164
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { array, publicKey, str, struct, u128, u16, u64, u8 } from '@coral-xyz/borsh';
|
|
4
|
+
|
|
5
|
+
export interface BountySchedule {
|
|
6
|
+
minBounty: BN; // u64
|
|
7
|
+
maxBounty: BN; // u64
|
|
8
|
+
minBountyUntil: BN; // u64
|
|
9
|
+
maxBountyAfter: BN; // u64
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const BountyScheduleLayout = struct<BountySchedule>([
|
|
13
|
+
u64('minBounty'),
|
|
14
|
+
u64('maxBounty'),
|
|
15
|
+
u64('minBountyUntil'),
|
|
16
|
+
u64('maxBountyAfter'),
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export interface Bounty {
|
|
20
|
+
bountyDepositor: PublicKey;
|
|
21
|
+
bountyMint: PublicKey;
|
|
22
|
+
bountyPerPriceUpdateTask: BountySchedule;
|
|
23
|
+
bountyPerTask: BountySchedule;
|
|
24
|
+
bountyTotal: BN; // u64
|
|
25
|
+
bountyLeft: BN; // u64
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const BountyLayout = struct<Bounty>([
|
|
29
|
+
publicKey('bountyDepositor'),
|
|
30
|
+
publicKey('bountyMint'),
|
|
31
|
+
BountyScheduleLayout.replicate('bountyPerPriceUpdateTask'),
|
|
32
|
+
BountyScheduleLayout.replicate('bountyPerTask'),
|
|
33
|
+
u64('bountyTotal'),
|
|
34
|
+
u64('bountyLeft'),
|
|
35
|
+
]);
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { array, publicKey, str, struct, u128, u16, u64, u8 } from '@coral-xyz/borsh';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
import { Bounty, BountyLayout } from './bounty';
|
|
6
|
+
import { FormattedOracleType } from '../oracle';
|
|
7
|
+
|
|
8
|
+
export type FormattedIntentStatus = "not_active" | "active" | "reverted" | "completed";
|
|
9
|
+
export const INTENT_STATUS_STRINGS: Map<number, FormattedIntentStatus> = new Map([
|
|
10
|
+
[0, "not_active"],
|
|
11
|
+
[1, "active"],
|
|
12
|
+
[2, "reverted"],
|
|
13
|
+
[3, "completed"],
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
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";
|
|
17
|
+
export const TASK_TYPE_STRINGS: Map<number, FormattedTaskType> = new Map([
|
|
18
|
+
[0, "unknown"],
|
|
19
|
+
[1, "edit_creator"],
|
|
20
|
+
[2, "edit_manager_settings"],
|
|
21
|
+
[3, "edit_fee_settings"],
|
|
22
|
+
[4, "edit_schedule_settings"],
|
|
23
|
+
[5, "edit_automation_settings"],
|
|
24
|
+
[6, "edit_lp_settings"],
|
|
25
|
+
[7, "edit_metadata_settings"],
|
|
26
|
+
[8, "edit_deposits_settings"],
|
|
27
|
+
[9, "edit_force_rebalance_settings"],
|
|
28
|
+
[10, "edit_custom_rebalance_settings"],
|
|
29
|
+
[11, "edit_add_token_delay"],
|
|
30
|
+
[12, "edit_update_weights_delay"],
|
|
31
|
+
[13, "edit_make_direct_swap_delay"],
|
|
32
|
+
[14, "add_token"],
|
|
33
|
+
[15, "update_weights"],
|
|
34
|
+
[16, "make_direct_swap"],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export interface FormattedBountySchedule {
|
|
38
|
+
min_bounty: number,
|
|
39
|
+
max_bounty: number,
|
|
40
|
+
min_bounty_until: number,
|
|
41
|
+
max_bounty_after: number,
|
|
42
|
+
}
|
|
43
|
+
export interface FormattedBounty {
|
|
44
|
+
bounty_depositor: string,
|
|
45
|
+
bounty_mint: string,
|
|
46
|
+
bounty_per_price_update_task: FormattedBountySchedule,
|
|
47
|
+
bounty_per_task: FormattedBountySchedule,
|
|
48
|
+
bounty_total: number,
|
|
49
|
+
bounty_left: number,
|
|
50
|
+
}
|
|
51
|
+
export interface FormattedIntent {
|
|
52
|
+
pubkey: string,
|
|
53
|
+
manager: string,
|
|
54
|
+
status: FormattedIntentStatus,
|
|
55
|
+
activation_timestamp: number,
|
|
56
|
+
expiration_timestamp: number,
|
|
57
|
+
basket: string,
|
|
58
|
+
bounty: FormattedBounty,
|
|
59
|
+
task_type: FormattedTaskType,
|
|
60
|
+
task_data: Settings,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const INTENT_TASK_DATA_SIZE = 600;
|
|
64
|
+
|
|
65
|
+
export enum IntentStatus {
|
|
66
|
+
NotActive,
|
|
67
|
+
Active,
|
|
68
|
+
Reverted,
|
|
69
|
+
Completed,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface Intent {
|
|
73
|
+
manager: PublicKey;
|
|
74
|
+
status : IntentStatus;
|
|
75
|
+
activationTimestamp: BN; // u64
|
|
76
|
+
expirationTimestamp: BN; // u64
|
|
77
|
+
basket: PublicKey;
|
|
78
|
+
bounty: Bounty;
|
|
79
|
+
taskType: TaskType;
|
|
80
|
+
taskData: number[]; // length of 600
|
|
81
|
+
ownAddress?: PublicKey;
|
|
82
|
+
formatted?: FormattedIntent;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const IntentLayout = struct<Intent>([
|
|
86
|
+
publicKey('manager'),
|
|
87
|
+
u8('status'),
|
|
88
|
+
u64('activationTimestamp'),
|
|
89
|
+
u64('expirationTimestamp'),
|
|
90
|
+
publicKey('basket'),
|
|
91
|
+
BountyLayout.replicate('bounty'),
|
|
92
|
+
u8('taskType'),
|
|
93
|
+
array(u8(), INTENT_TASK_DATA_SIZE, 'taskData'),
|
|
94
|
+
]);
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export enum TaskType {
|
|
98
|
+
Unknown = 0,
|
|
99
|
+
|
|
100
|
+
EditCreator = 1,
|
|
101
|
+
EditManagerSettings = 2,
|
|
102
|
+
EditFeeSettings = 3,
|
|
103
|
+
EditScheduleSettings = 4,
|
|
104
|
+
EditAutomationSettings = 5,
|
|
105
|
+
EditLpSettings = 6,
|
|
106
|
+
EditMetadataSettings = 7,
|
|
107
|
+
EditDepositsSettings = 8,
|
|
108
|
+
EditForceRebalanceSettings = 9,
|
|
109
|
+
EditCustomRebalanceSettings = 10,
|
|
110
|
+
|
|
111
|
+
EditAddTokenDelay = 11,
|
|
112
|
+
EditUpdateWeightsDelay = 12,
|
|
113
|
+
EditMakeDirectSwapDelay = 13,
|
|
114
|
+
|
|
115
|
+
AddToken = 14,
|
|
116
|
+
UpdateWeights = 15,
|
|
117
|
+
MakeDirectSwap = 16,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Maps raw u8 values from on-chain Borsh-serialized storage to TaskType enum.
|
|
121
|
+
// The on-chain program uses sequential Borsh discriminants (11-16) for storage,
|
|
122
|
+
// but the SDK enum uses non-sequential values (101-103, 201-203) for instruction input.
|
|
123
|
+
export function taskTypeFromU8(value: number): TaskType {
|
|
124
|
+
switch (value) {
|
|
125
|
+
case 1: return TaskType.EditCreator;
|
|
126
|
+
case 2: return TaskType.EditManagerSettings;
|
|
127
|
+
case 3: return TaskType.EditFeeSettings;
|
|
128
|
+
case 4: return TaskType.EditScheduleSettings;
|
|
129
|
+
case 5: return TaskType.EditAutomationSettings;
|
|
130
|
+
case 6: return TaskType.EditLpSettings;
|
|
131
|
+
case 7: return TaskType.EditMetadataSettings;
|
|
132
|
+
case 8: return TaskType.EditDepositsSettings;
|
|
133
|
+
case 9: return TaskType.EditForceRebalanceSettings;
|
|
134
|
+
case 10: return TaskType.EditCustomRebalanceSettings;
|
|
135
|
+
|
|
136
|
+
case 11: return TaskType.EditAddTokenDelay;
|
|
137
|
+
case 12: return TaskType.EditUpdateWeightsDelay;
|
|
138
|
+
case 13: return TaskType.EditMakeDirectSwapDelay;
|
|
139
|
+
|
|
140
|
+
case 14: return TaskType.AddToken;
|
|
141
|
+
case 15: return TaskType.UpdateWeights;
|
|
142
|
+
case 16: return TaskType.MakeDirectSwap;
|
|
143
|
+
|
|
144
|
+
default: return TaskType.Unknown;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
export interface TaskContext {
|
|
153
|
+
basket: string,
|
|
154
|
+
manager: string,
|
|
155
|
+
activation_timestamp?: number,
|
|
156
|
+
expiration_timestamp?: number,
|
|
157
|
+
min_bounty?: number,
|
|
158
|
+
max_bounty?: number,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface EditCreatorSettings {
|
|
162
|
+
creator: string,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface EditManagerSettings {
|
|
166
|
+
managers: {
|
|
167
|
+
pubkey: string;
|
|
168
|
+
fee_split_weight_bps: number;
|
|
169
|
+
authorities: {
|
|
170
|
+
managers: boolean;
|
|
171
|
+
fees: boolean;
|
|
172
|
+
schedule: boolean;
|
|
173
|
+
automation: boolean;
|
|
174
|
+
lp: boolean;
|
|
175
|
+
metadata: boolean;
|
|
176
|
+
deposits: boolean;
|
|
177
|
+
force_rebalance: boolean;
|
|
178
|
+
custom_rebalance: boolean;
|
|
179
|
+
add_token: boolean;
|
|
180
|
+
update_weights: boolean;
|
|
181
|
+
make_direct_swap: boolean;
|
|
182
|
+
},
|
|
183
|
+
}[],
|
|
184
|
+
modification_delay: number,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface EditFeeSettings {
|
|
188
|
+
creator_deposit_fee_bps: number,
|
|
189
|
+
creator_withdraw_fee_bps: number,
|
|
190
|
+
creator_management_fee_bps: number,
|
|
191
|
+
creator_performance_fee_bps: number,
|
|
192
|
+
managers_deposit_fee_bps: number,
|
|
193
|
+
managers_withdraw_fee_bps: number,
|
|
194
|
+
managers_management_fee_bps: number,
|
|
195
|
+
managers_performance_fee_bps: number,
|
|
196
|
+
basket_deposit_fee_bps: number,
|
|
197
|
+
basket_withdraw_fee_bps: number,
|
|
198
|
+
modification_delay: number,
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface EditScheduleSettings {
|
|
202
|
+
cycle_start_time: number,
|
|
203
|
+
cycle_duration: number,
|
|
204
|
+
deposits_start: number,
|
|
205
|
+
deposits_end: number,
|
|
206
|
+
automation_start: number,
|
|
207
|
+
automation_end: number,
|
|
208
|
+
management_start: number,
|
|
209
|
+
management_end: number,
|
|
210
|
+
modification_delay: number,
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface EditAutomationSettings {
|
|
214
|
+
enabled: boolean,
|
|
215
|
+
rebalance_slippage_threshold_bps: number,
|
|
216
|
+
per_trade_rebalance_slippage_threshold_bps: number,
|
|
217
|
+
rebalance_activation_threshold_abs_bps: number,
|
|
218
|
+
rebalance_activation_threshold_rel_bps: number,
|
|
219
|
+
rebalance_activation_cooldown: number,
|
|
220
|
+
modification_delay: number,
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface EditLpSettings {
|
|
224
|
+
enabled: boolean,
|
|
225
|
+
lp_threshold_bps: number,
|
|
226
|
+
modification_delay: number,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface EditMetadataSettings {
|
|
230
|
+
symbol: string,
|
|
231
|
+
name: string,
|
|
232
|
+
uri: string,
|
|
233
|
+
modification_delay: number,
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface EditDepositsSettings {
|
|
237
|
+
enabled: boolean,
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface EditForceRebalanceSettings {
|
|
241
|
+
enabled: boolean,
|
|
242
|
+
modification_delay: number,
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface EditCustomRebalanceSettings {
|
|
246
|
+
enabled: boolean,
|
|
247
|
+
modification_delay: number,
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
export interface EditAddTokenSettings {
|
|
252
|
+
modification_delay: number,
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface EditUpdateWeightsSettings {
|
|
256
|
+
modification_delay: number,
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface EditMakeDirectSwapSettings {
|
|
260
|
+
modification_delay: number,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface OracleInput {
|
|
264
|
+
oracle_type: FormattedOracleType,
|
|
265
|
+
account_lut_id: number,
|
|
266
|
+
account_lut_index: number,
|
|
267
|
+
account: string,
|
|
268
|
+
weight: number,
|
|
269
|
+
is_required: boolean,
|
|
270
|
+
conf_thresh_bps: number,
|
|
271
|
+
volatility_thresh_bps: number,
|
|
272
|
+
max_slippage_bps: number,
|
|
273
|
+
min_liquidity: number,
|
|
274
|
+
staleness_thresh: number,
|
|
275
|
+
staleness_conf_rate_bps: number,
|
|
276
|
+
token_decimals: number,
|
|
277
|
+
twap_seconds_ago: number,
|
|
278
|
+
twap_secondary_seconds_ago: number,
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface AddOrEditTokenInput {
|
|
282
|
+
token_mint: string,
|
|
283
|
+
active: boolean,
|
|
284
|
+
min_oracles_thresh: number;
|
|
285
|
+
min_conf_bps: number;
|
|
286
|
+
conf_thresh_bps: number;
|
|
287
|
+
conf_multiplier: number;
|
|
288
|
+
oracles: OracleInput[];
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export interface UpdateWeightsInput {
|
|
292
|
+
token_weights: {
|
|
293
|
+
mint: string,
|
|
294
|
+
weight_bps: number,
|
|
295
|
+
}[],
|
|
296
|
+
token_mints_hash?: number[],
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface MakeDirectSwapInput {
|
|
300
|
+
from_token_mint: string,
|
|
301
|
+
to_token_mint: string,
|
|
302
|
+
amount_from: number,
|
|
303
|
+
amount_to: number,
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export type Settings =
|
|
307
|
+
EditCreatorSettings |
|
|
308
|
+
EditManagerSettings |
|
|
309
|
+
EditFeeSettings |
|
|
310
|
+
EditScheduleSettings |
|
|
311
|
+
EditAutomationSettings |
|
|
312
|
+
EditLpSettings |
|
|
313
|
+
EditMetadataSettings |
|
|
314
|
+
EditDepositsSettings |
|
|
315
|
+
EditForceRebalanceSettings |
|
|
316
|
+
EditCustomRebalanceSettings |
|
|
317
|
+
|
|
318
|
+
EditAddTokenSettings |
|
|
319
|
+
EditUpdateWeightsSettings |
|
|
320
|
+
EditMakeDirectSwapSettings |
|
|
321
|
+
|
|
322
|
+
AddOrEditTokenInput |
|
|
323
|
+
UpdateWeightsInput |
|
|
324
|
+
MakeDirectSwapInput;
|