@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.
- package/dist/idl/idl.d.ts +8 -0
- package/dist/idl/idl.js +4958 -0
- package/dist/idl/types.d.ts +4955 -0
- package/dist/idl/types.js +2 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +60 -0
- package/dist/layouts/basket.d.ts +42 -0
- package/dist/layouts/basket.js +43 -0
- package/dist/layouts/config.d.ts +97 -0
- package/dist/layouts/config.js +102 -0
- package/dist/layouts/fraction.d.ts +6 -0
- package/dist/layouts/fraction.js +9 -0
- package/dist/layouts/oracle.d.ts +36 -0
- package/dist/layouts/oracle.js +37 -0
- package/dist/src/constants.d.ts +15 -0
- package/dist/src/constants.js +19 -0
- package/dist/src/idl/idl.d.ts +8 -0
- package/dist/src/idl/idl.js +4958 -0
- package/dist/src/idl/types.d.ts +4955 -0
- package/dist/src/idl/types.js +2 -0
- package/dist/src/index.d.ts +53 -0
- package/dist/src/index.js +199 -0
- package/dist/src/instructions/accounts.d.ts +27 -0
- package/dist/src/instructions/accounts.js +110 -0
- package/dist/src/instructions/auction.d.ts +7 -0
- package/dist/src/instructions/auction.js +43 -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/priceUpdate.d.ts +15 -0
- package/dist/src/instructions/automation/priceUpdate.js +47 -0
- package/dist/src/instructions/automation/rebalanceSwap.d.ts +10 -0
- package/dist/src/instructions/automation/rebalanceSwap.js +42 -0
- package/dist/src/instructions/basket.d.ts +120 -0
- package/dist/src/instructions/basket.js +622 -0
- package/dist/src/instructions/bounty.d.ts +18 -0
- package/dist/src/instructions/bounty.js +81 -0
- package/dist/src/instructions/fee.d.ts +8 -0
- package/dist/src/instructions/fee.js +46 -0
- package/dist/src/instructions/globalConfig.d.ts +11 -0
- package/dist/src/instructions/globalConfig.js +43 -0
- package/dist/src/instructions/luts.d.ts +33 -0
- package/dist/src/instructions/luts.js +91 -0
- package/dist/src/instructions/management/addBounty.d.ts +7 -0
- package/dist/src/instructions/management/addBounty.js +39 -0
- package/dist/src/instructions/management/admin.d.ts +9 -0
- package/dist/src/instructions/management/admin.js +43 -0
- package/dist/src/instructions/management/claimFees.d.ts +7 -0
- package/dist/src/instructions/management/claimFees.js +47 -0
- package/dist/src/instructions/management/createBasket.d.ts +22 -0
- package/dist/src/instructions/management/createBasket.js +101 -0
- package/dist/src/instructions/management/edit.d.ts +34 -0
- package/dist/src/instructions/management/edit.js +192 -0
- package/dist/src/instructions/management/luts.d.ts +29 -0
- package/dist/src/instructions/management/luts.js +88 -0
- package/dist/src/instructions/pda.d.ts +26 -0
- package/dist/src/instructions/pda.js +110 -0
- package/dist/src/instructions/price.d.ts +17 -0
- package/dist/src/instructions/price.js +47 -0
- package/dist/src/instructions/user/deposit.d.ts +32 -0
- package/dist/src/instructions/user/deposit.js +168 -0
- package/dist/src/instructions/user/withdraw.d.ts +16 -0
- package/dist/src/instructions/user/withdraw.js +82 -0
- package/dist/src/layouts/basket.d.ts +41 -0
- package/dist/src/layouts/basket.js +43 -0
- package/dist/src/layouts/config.d.ts +133 -0
- package/dist/src/layouts/config.js +137 -0
- package/dist/src/layouts/fraction.d.ts +6 -0
- package/dist/src/layouts/fraction.js +9 -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 +101 -0
- package/dist/src/layouts/intents/intent.js +113 -0
- package/dist/src/layouts/intents/rebalanceIntent.d.ts +56 -0
- package/dist/src/layouts/intents/rebalanceIntent.js +63 -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 +42 -0
- package/dist/src/layouts/oracle.js +43 -0
- package/dist/src/states/basket.d.ts +8 -0
- package/dist/src/states/basket.js +54 -0
- package/dist/src/states/intents/intent.d.ts +14 -0
- package/dist/src/states/intents/intent.js +90 -0
- package/dist/src/states/intents/rebalanceIntent.d.ts +8 -0
- package/dist/src/states/intents/rebalanceIntent.js +54 -0
- package/dist/src/states/oracles/clmm_oracle.d.ts +178 -0
- package/dist/src/states/oracles/clmm_oracle.js +546 -0
- package/dist/src/states/oracles/constants.d.ts +8 -0
- package/dist/src/states/oracles/constants.js +12 -0
- package/dist/src/states/oracles/oracle.d.ts +60 -0
- package/dist/src/states/oracles/oracle.js +237 -0
- package/dist/src/states/oracles/pythOracle.d.ts +39 -0
- package/dist/src/states/oracles/pythOracle.js +202 -0
- package/dist/src/states/oracles/pyth_oracle.d.ts +39 -0
- package/dist/src/states/oracles/pyth_oracle.js +202 -0
- package/dist/src/states/oracles/raydiumClmmOracle.d.ts +178 -0
- package/dist/src/states/oracles/raydiumClmmOracle.js +546 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.d.ts +139 -0
- package/dist/src/states/oracles/raydiumCpmmOracle.js +420 -0
- package/dist/src/states/oracles/raydium_cpmm_oracle.d.ts +139 -0
- package/dist/src/states/oracles/raydium_cpmm_oracle.js +420 -0
- package/dist/src/states/oracles/switchboardOracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboardOracle.js +1 -0
- package/dist/src/states/oracles/switchboard_oracle.d.ts +0 -0
- package/dist/src/states/oracles/switchboard_oracle.js +1 -0
- package/dist/src/txUtils.d.ts +26 -0
- package/dist/src/txUtils.js +183 -0
- package/dist/states/basket.d.ts +8 -0
- package/dist/states/basket.js +57 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +39 -0
- package/package.json +30 -0
- package/src/constants.ts +24 -0
- package/src/index.ts +260 -0
- package/src/instructions/automation/auction.ts +55 -0
- package/src/instructions/automation/claimBounty.ts +69 -0
- package/src/instructions/automation/priceUpdate.ts +73 -0
- package/src/instructions/automation/rebalanceSwap.ts +60 -0
- package/src/instructions/management/addBounty.ts +56 -0
- package/src/instructions/management/admin.ts +65 -0
- package/src/instructions/management/claimFees.ts +59 -0
- package/src/instructions/management/createBasket.ts +148 -0
- package/src/instructions/management/edit.ts +255 -0
- package/src/instructions/management/luts.ts +134 -0
- package/src/instructions/pda.ts +160 -0
- package/src/instructions/user/deposit.ts +237 -0
- package/src/instructions/user/withdraw.ts +130 -0
- package/src/layouts/basket.ts +82 -0
- package/src/layouts/config.ts +301 -0
- package/src/layouts/fraction.ts +12 -0
- package/src/layouts/intents/bounty.ts +35 -0
- package/src/layouts/intents/intent.ts +204 -0
- package/src/layouts/intents/rebalanceIntent.ts +111 -0
- package/src/layouts/lookupTable.ts +14 -0
- package/src/layouts/oracle.ts +96 -0
- package/src/states/basket.ts +56 -0
- package/src/states/intents/intent.ts +107 -0
- package/src/states/intents/rebalanceIntent.ts +57 -0
- package/src/states/oracles/constants.ts +13 -0
- package/src/states/oracles/oracle.ts +260 -0
- package/src/states/oracles/pythOracle.ts +270 -0
- package/src/states/oracles/raydiumClmmOracle.ts +812 -0
- package/src/states/oracles/raydiumCpmmOracle.ts +614 -0
- package/src/states/oracles/switchboardOracle.ts +0 -0
- package/src/txUtils.ts +250 -0
- package/test.ts +30 -0
- package/tsconfig.json +101 -0
|
@@ -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.fetchRebalanceIntent = fetchRebalanceIntent;
|
|
13
|
+
exports.fetchRebalanceIntents = fetchRebalanceIntents;
|
|
14
|
+
const rebalanceIntent_1 = require("../../layouts/intents/rebalanceIntent");
|
|
15
|
+
const constants_1 = require("../../constants");
|
|
16
|
+
function fetchRebalanceIntent(connection, rebalanceIntent) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const rebalanceIntentAi = yield connection.getAccountInfo(rebalanceIntent);
|
|
19
|
+
if (!rebalanceIntentAi) {
|
|
20
|
+
throw new Error("Rebalance intent not found");
|
|
21
|
+
}
|
|
22
|
+
return rebalanceIntent_1.RebalanceIntentLayout.decode(rebalanceIntentAi.data.slice(8));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function fetchRebalanceIntents(connection, filters) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
console.log("fetching rebalance intents with size", rebalanceIntent_1.RebalanceIntentLayout.getSpan());
|
|
28
|
+
let accountFilters = [
|
|
29
|
+
{ dataSize: 8 + rebalanceIntent_1.RebalanceIntentLayout.getSpan() },
|
|
30
|
+
];
|
|
31
|
+
for (const filter of filters) {
|
|
32
|
+
if (filter.filterType === "basket") {
|
|
33
|
+
accountFilters.push({ memcmp: {
|
|
34
|
+
offset: 8,
|
|
35
|
+
bytes: filter.filterValue.toBase58()
|
|
36
|
+
} });
|
|
37
|
+
}
|
|
38
|
+
else if (filter.filterType === "owner") {
|
|
39
|
+
accountFilters.push({ memcmp: {
|
|
40
|
+
offset: 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 rebalanceIntents = accounts.map(account => rebalanceIntent_1.RebalanceIntentLayout.decode(account.account.data.slice(8)));
|
|
52
|
+
return rebalanceIntents;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { Oracle, OracleResult } from './oracle';
|
|
5
|
+
declare class Observation {
|
|
6
|
+
block_timestamp: BN;
|
|
7
|
+
tick_cumulative: BN;
|
|
8
|
+
padding: BN[];
|
|
9
|
+
constructor(params: {
|
|
10
|
+
block_timestamp: BN;
|
|
11
|
+
tick_cumulative: BN;
|
|
12
|
+
padding: BN[];
|
|
13
|
+
});
|
|
14
|
+
static decode(data: Buffer, offset?: number): [Observation, number];
|
|
15
|
+
sub(other: Observation): Observation;
|
|
16
|
+
add(other: Observation): Observation;
|
|
17
|
+
get_weighted_observation(time: BN): Observation;
|
|
18
|
+
adjust_to_timestamp(target_timestamp: BN, observation_prev: Observation): Observation;
|
|
19
|
+
}
|
|
20
|
+
declare class ObservationState {
|
|
21
|
+
initialized: boolean;
|
|
22
|
+
recent_epoch: BN;
|
|
23
|
+
observation_index: number;
|
|
24
|
+
pool_id: PublicKey;
|
|
25
|
+
observations: Observation[];
|
|
26
|
+
padding: BN[];
|
|
27
|
+
constructor(params: {
|
|
28
|
+
initialized: boolean;
|
|
29
|
+
recent_epoch: BN;
|
|
30
|
+
observation_index: number;
|
|
31
|
+
pool_id: PublicKey;
|
|
32
|
+
observations: Observation[];
|
|
33
|
+
padding: BN[];
|
|
34
|
+
});
|
|
35
|
+
static decode(data: Buffer, offset?: number): [ObservationState, number];
|
|
36
|
+
}
|
|
37
|
+
declare class RewardInfo {
|
|
38
|
+
reward_state: number;
|
|
39
|
+
open_time: BN;
|
|
40
|
+
end_time: BN;
|
|
41
|
+
last_update_time: BN;
|
|
42
|
+
emissions_per_second_x64: BN;
|
|
43
|
+
reward_total_emissioned: BN;
|
|
44
|
+
reward_claimed: BN;
|
|
45
|
+
token_mint: PublicKey;
|
|
46
|
+
token_vault: PublicKey;
|
|
47
|
+
authority: PublicKey;
|
|
48
|
+
reward_growth_global_x64: BN;
|
|
49
|
+
constructor(params: {
|
|
50
|
+
reward_state: number;
|
|
51
|
+
open_time: BN;
|
|
52
|
+
end_time: BN;
|
|
53
|
+
last_update_time: BN;
|
|
54
|
+
emissions_per_second_x64: BN;
|
|
55
|
+
reward_total_emissioned: BN;
|
|
56
|
+
reward_claimed: BN;
|
|
57
|
+
token_mint: PublicKey;
|
|
58
|
+
token_vault: PublicKey;
|
|
59
|
+
authority: PublicKey;
|
|
60
|
+
reward_growth_global_x64: BN;
|
|
61
|
+
});
|
|
62
|
+
static decode(data: Buffer, offset?: number): [RewardInfo, number];
|
|
63
|
+
}
|
|
64
|
+
declare class PoolState {
|
|
65
|
+
bump: number[];
|
|
66
|
+
amm_config: PublicKey;
|
|
67
|
+
owner: PublicKey;
|
|
68
|
+
token_mint_0: PublicKey;
|
|
69
|
+
token_mint_1: PublicKey;
|
|
70
|
+
token_vault_0: PublicKey;
|
|
71
|
+
token_vault_1: PublicKey;
|
|
72
|
+
observation_key: PublicKey;
|
|
73
|
+
mint_decimals_0: number;
|
|
74
|
+
mint_decimals_1: number;
|
|
75
|
+
tick_spacing: number;
|
|
76
|
+
liquidity: BN;
|
|
77
|
+
sqrt_price_x64: BN;
|
|
78
|
+
tick_current: BN;
|
|
79
|
+
padding3: number;
|
|
80
|
+
padding4: number;
|
|
81
|
+
fee_growth_global_0_x64: BN;
|
|
82
|
+
fee_growth_global_1_x64: BN;
|
|
83
|
+
protocol_fees_token_0: BN;
|
|
84
|
+
protocol_fees_token_1: BN;
|
|
85
|
+
swap_in_amount_token_0: BN;
|
|
86
|
+
swap_out_amount_token_1: BN;
|
|
87
|
+
swap_in_amount_token_1: BN;
|
|
88
|
+
swap_out_amount_token_0: BN;
|
|
89
|
+
status: number;
|
|
90
|
+
padding: number[];
|
|
91
|
+
reward_infos: RewardInfo[];
|
|
92
|
+
tick_array_bitmap: BN[];
|
|
93
|
+
total_fees_token_0: BN;
|
|
94
|
+
total_fees_claimed_token_0: BN;
|
|
95
|
+
total_fees_token_1: BN;
|
|
96
|
+
total_fees_claimed_token_1: BN;
|
|
97
|
+
fund_fees_token_0: BN;
|
|
98
|
+
fund_fees_token_1: BN;
|
|
99
|
+
open_time: BN;
|
|
100
|
+
recent_epoch: BN;
|
|
101
|
+
padding1: BN[];
|
|
102
|
+
padding2: BN[];
|
|
103
|
+
constructor(params: {
|
|
104
|
+
bump: number[];
|
|
105
|
+
amm_config: PublicKey;
|
|
106
|
+
owner: PublicKey;
|
|
107
|
+
token_mint_0: PublicKey;
|
|
108
|
+
token_mint_1: PublicKey;
|
|
109
|
+
token_vault_0: PublicKey;
|
|
110
|
+
token_vault_1: PublicKey;
|
|
111
|
+
observation_key: PublicKey;
|
|
112
|
+
mint_decimals_0: number;
|
|
113
|
+
mint_decimals_1: number;
|
|
114
|
+
tick_spacing: BN;
|
|
115
|
+
liquidity: BN;
|
|
116
|
+
sqrt_price_x64: BN;
|
|
117
|
+
tick_current: BN;
|
|
118
|
+
padding3: number;
|
|
119
|
+
padding4: number;
|
|
120
|
+
fee_growth_global_0_x64: BN;
|
|
121
|
+
fee_growth_global_1_x64: BN;
|
|
122
|
+
protocol_fees_token_0: BN;
|
|
123
|
+
protocol_fees_token_1: BN;
|
|
124
|
+
swap_in_amount_token_0: BN;
|
|
125
|
+
swap_out_amount_token_1: BN;
|
|
126
|
+
swap_in_amount_token_1: BN;
|
|
127
|
+
swap_out_amount_token_0: BN;
|
|
128
|
+
status: number;
|
|
129
|
+
padding: number[];
|
|
130
|
+
reward_infos: RewardInfo[];
|
|
131
|
+
tick_array_bitmap: BN[];
|
|
132
|
+
total_fees_token_0: BN;
|
|
133
|
+
total_fees_claimed_token_0: BN;
|
|
134
|
+
total_fees_token_1: BN;
|
|
135
|
+
total_fees_claimed_token_1: BN;
|
|
136
|
+
fund_fees_token_0: BN;
|
|
137
|
+
fund_fees_token_1: BN;
|
|
138
|
+
open_time: BN;
|
|
139
|
+
recent_epoch: BN;
|
|
140
|
+
padding1: BN[];
|
|
141
|
+
padding2: BN[];
|
|
142
|
+
});
|
|
143
|
+
static decode(data: Buffer, offset?: number): [PoolState, number];
|
|
144
|
+
}
|
|
145
|
+
export declare class RaydiumCLMMOracle extends Oracle {
|
|
146
|
+
pool_id: PublicKey;
|
|
147
|
+
quote_token: number;
|
|
148
|
+
pool_state: PoolState;
|
|
149
|
+
observation_state: ObservationState;
|
|
150
|
+
primary_seconds: number;
|
|
151
|
+
secondary_seconds: number;
|
|
152
|
+
private constructor();
|
|
153
|
+
static create(params: {
|
|
154
|
+
connection: Connection;
|
|
155
|
+
pool_id: PublicKey;
|
|
156
|
+
quote_token: number;
|
|
157
|
+
weight: number;
|
|
158
|
+
primary_seconds: number;
|
|
159
|
+
secondary_seconds: number;
|
|
160
|
+
conf_thresh_bps?: number;
|
|
161
|
+
staleness_thresh?: number;
|
|
162
|
+
volatility_thresh?: number | Decimal;
|
|
163
|
+
min_liquidity?: number | Decimal;
|
|
164
|
+
staleness_conf_rate_bps?: number;
|
|
165
|
+
}): Promise<RaydiumCLMMOracle>;
|
|
166
|
+
static derive_observation_key(poolId: PublicKey): [PublicKey, number];
|
|
167
|
+
get_observation_at_index(index: number): Observation;
|
|
168
|
+
get_observation_at_timestamp(timestamp: BN, startIndex: number): Observation;
|
|
169
|
+
get_delta_observations(currentTime: BN, primary_seconds: number, secondary_seconds: number): Observation[];
|
|
170
|
+
get_sqrt_price_x64_from_tick(tick: BN): BN;
|
|
171
|
+
sqrt_price_x64_to_price(sqrtPriceX64: BN, decimalsA: number, decimalsB: number): Decimal;
|
|
172
|
+
x64_to_decimal(num: BN, decimalPlaces?: number): Decimal;
|
|
173
|
+
get_twap_primary(current_time: BN): Decimal;
|
|
174
|
+
get_twap_secondary(current_time: BN): Decimal;
|
|
175
|
+
get_confidence(currentTime: BN): Decimal;
|
|
176
|
+
fetch(): Promise<OracleResult>;
|
|
177
|
+
}
|
|
178
|
+
export {};
|