@scallop-io/sui-scallop-sdk 2.0.0-alpha.8 → 2.0.0
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/README.md +28 -5
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +29 -31
- package/dist/index.mjs +4 -6
- package/package.json +1 -2
- package/src/builders/oracles/index.ts +13 -13
- package/src/builders/oracles/switchboard.ts +240 -240
- package/src/constants/testAddress.ts +9 -5
- package/src/models/scallopConstants.ts +14 -3
- package/src/models/scallopUtils.ts +3 -1
- package/src/queries/portfolioQuery.ts +3 -2
- package/src/types/constant/common.ts +1 -0
- package/src/types/query/portfolio.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@pythnetwork/pyth-sui-js": "2.1.0",
|
|
47
47
|
"@scallop-io/sui-kit": "1.3.1",
|
|
48
48
|
"@scure/bip39": "^1.2.1",
|
|
49
|
-
"@switchboard-xyz/sui-sdk": "0.0.21",
|
|
50
49
|
"@tanstack/query-core": "5.51.15",
|
|
51
50
|
"axios": "^1.6.0",
|
|
52
51
|
"bech32": "^2.0.0",
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from 'src/types';
|
|
10
10
|
import { xOracleList as X_ORACLE_LIST } from 'src/constants';
|
|
11
11
|
import { updatePythPriceFeeds } from './pyth';
|
|
12
|
-
import { updateSwitchboardAggregators } from './switchboard';
|
|
12
|
+
// import { updateSwitchboardAggregators } from './switchboard';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Update the price of the oracle for multiple coin.
|
|
@@ -67,18 +67,18 @@ export const updateOracles = async (
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Handle Switchboard on-demand aggregator
|
|
70
|
-
if (flattenedRules.has('switchboard')) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
70
|
+
// if (flattenedRules.has('switchboard')) {
|
|
71
|
+
// const switchboardAssetCoinNames = assetCoinNames.filter((assetCoinName) =>
|
|
72
|
+
// filterAssetCoinNames(assetCoinName, 'switchboard')
|
|
73
|
+
// );
|
|
74
|
+
// if (switchboardAssetCoinNames.length > 0) {
|
|
75
|
+
// await updateSwitchboardAggregators(
|
|
76
|
+
// builder,
|
|
77
|
+
// switchboardAssetCoinNames,
|
|
78
|
+
// txBlock
|
|
79
|
+
// );
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
82
|
|
|
83
83
|
// Remove duplicate coin names.
|
|
84
84
|
const updateAssetCoinNames = [...new Set(assetCoinNames)];
|
|
@@ -1,270 +1,270 @@
|
|
|
1
|
-
import { ScallopBuilder } from 'src/models';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from '@scallop-io/sui-kit';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from '@switchboard-xyz/sui-sdk';
|
|
17
|
-
import { queryMultipleObjects } from 'src/queries';
|
|
18
|
-
import { MoveValue, SuiParsedData } from '@mysten/sui/client';
|
|
19
|
-
import { toHex } from '@mysten/bcs';
|
|
20
|
-
// import { CrossbarClient, IOracleJob, OracleJob } from '@switchboard-xyz/common';
|
|
21
|
-
// import axios from 'axios';
|
|
1
|
+
// import { ScallopBuilder } from 'src/models';
|
|
2
|
+
// import {
|
|
3
|
+
// // SUI_CLOCK_OBJECT_ID,
|
|
4
|
+
// // SUI_TYPE_ARG,
|
|
5
|
+
// type SuiTxBlock as SuiKitTxBlock,
|
|
6
|
+
// } from '@scallop-io/sui-kit';
|
|
7
|
+
// import {
|
|
8
|
+
// Aggregator,
|
|
9
|
+
// AggregatorData,
|
|
10
|
+
// ObjectParsingHelper,
|
|
11
|
+
// // AggregatorData,
|
|
12
|
+
// // FeedEvalResponse,
|
|
13
|
+
// // ObjectParsingHelper,
|
|
14
|
+
// // Queue,
|
|
15
|
+
// SwitchboardClient,
|
|
16
|
+
// } from '@switchboard-xyz/sui-sdk';
|
|
17
|
+
// import { queryMultipleObjects } from 'src/queries';
|
|
18
|
+
// import { MoveValue, SuiParsedData } from '@mysten/sui/client';
|
|
19
|
+
// import { toHex } from '@mysten/bcs';
|
|
20
|
+
// // import { CrossbarClient, IOracleJob, OracleJob } from '@switchboard-xyz/common';
|
|
21
|
+
// // import axios from 'axios';
|
|
22
22
|
|
|
23
|
-
const getFieldsFromObject = (
|
|
24
|
-
|
|
25
|
-
): {
|
|
26
|
-
|
|
27
|
-
} => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
// const getFieldsFromObject = (
|
|
24
|
+
// response: SuiParsedData
|
|
25
|
+
// ): {
|
|
26
|
+
// [key: string]: MoveValue;
|
|
27
|
+
// } => {
|
|
28
|
+
// // Check if 'data' and 'content' exist and are of the expected type
|
|
29
|
+
// if (response.dataType === 'moveObject') {
|
|
30
|
+
// // Safely return 'fields' from 'content'
|
|
31
|
+
// return response.fields as any;
|
|
32
|
+
// }
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const parseFeedConfigs = (responses: SuiParsedData[]): AggregatorData[] => {
|
|
38
|
-
return responses.map(getFieldsFromObject).map((aggregatorData) => {
|
|
39
|
-
const currentResult = (aggregatorData.current_result as any).fields;
|
|
40
|
-
const updateState = (aggregatorData.update_state as any).fields;
|
|
34
|
+
// throw new Error('Invalid response data');
|
|
35
|
+
// };
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
createdAtMs: ObjectParsingHelper.asNumber(aggregatorData.created_at_ms),
|
|
47
|
-
currentResult: {
|
|
48
|
-
maxResult: ObjectParsingHelper.asBN(currentResult.max_result),
|
|
49
|
-
maxTimestamp: ObjectParsingHelper.asNumber(
|
|
50
|
-
currentResult.max_timestamp_ms
|
|
51
|
-
),
|
|
52
|
-
mean: ObjectParsingHelper.asBN(currentResult.mean),
|
|
53
|
-
minResult: ObjectParsingHelper.asBN(currentResult.min_result),
|
|
54
|
-
minTimestamp: ObjectParsingHelper.asNumber(
|
|
55
|
-
currentResult.min_timestamp_ms
|
|
56
|
-
),
|
|
57
|
-
range: ObjectParsingHelper.asBN(currentResult.range),
|
|
58
|
-
result: ObjectParsingHelper.asBN(currentResult.result),
|
|
59
|
-
stdev: ObjectParsingHelper.asBN(currentResult.stdev),
|
|
60
|
-
},
|
|
61
|
-
feedHash: toHex(
|
|
62
|
-
ObjectParsingHelper.asUint8Array(aggregatorData.feed_hash)
|
|
63
|
-
),
|
|
64
|
-
maxStalenessSeconds: ObjectParsingHelper.asNumber(
|
|
65
|
-
aggregatorData.max_staleness_seconds
|
|
66
|
-
),
|
|
67
|
-
maxVariance: ObjectParsingHelper.asNumber(aggregatorData.max_variance),
|
|
68
|
-
minResponses: ObjectParsingHelper.asNumber(aggregatorData.min_responses),
|
|
69
|
-
minSampleSize: ObjectParsingHelper.asNumber(
|
|
70
|
-
aggregatorData.min_sample_size
|
|
71
|
-
),
|
|
72
|
-
name: ObjectParsingHelper.asString(aggregatorData.name),
|
|
73
|
-
queue: ObjectParsingHelper.asString(aggregatorData.queue),
|
|
74
|
-
updateState: {
|
|
75
|
-
currIdx: ObjectParsingHelper.asNumber(updateState.curr_idx),
|
|
76
|
-
results: updateState.results.map((r: any) => {
|
|
77
|
-
const oracleId = r.fields.oracle;
|
|
78
|
-
const value = ObjectParsingHelper.asBN(r.fields.result.fields);
|
|
79
|
-
const timestamp = parseInt(r.fields.timestamp_ms);
|
|
80
|
-
return {
|
|
81
|
-
oracle: oracleId,
|
|
82
|
-
value,
|
|
83
|
-
timestamp,
|
|
84
|
-
};
|
|
85
|
-
}),
|
|
86
|
-
},
|
|
87
|
-
};
|
|
37
|
+
// const parseFeedConfigs = (responses: SuiParsedData[]): AggregatorData[] => {
|
|
38
|
+
// return responses.map(getFieldsFromObject).map((aggregatorData) => {
|
|
39
|
+
// const currentResult = (aggregatorData.current_result as any).fields;
|
|
40
|
+
// const updateState = (aggregatorData.update_state as any).fields;
|
|
88
41
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
42
|
+
// // build the data object
|
|
43
|
+
// const data: AggregatorData = {
|
|
44
|
+
// id: ObjectParsingHelper.asId(aggregatorData.id),
|
|
45
|
+
// authority: ObjectParsingHelper.asString(aggregatorData.authority),
|
|
46
|
+
// createdAtMs: ObjectParsingHelper.asNumber(aggregatorData.created_at_ms),
|
|
47
|
+
// currentResult: {
|
|
48
|
+
// maxResult: ObjectParsingHelper.asBN(currentResult.max_result),
|
|
49
|
+
// maxTimestamp: ObjectParsingHelper.asNumber(
|
|
50
|
+
// currentResult.max_timestamp_ms
|
|
51
|
+
// ),
|
|
52
|
+
// mean: ObjectParsingHelper.asBN(currentResult.mean),
|
|
53
|
+
// minResult: ObjectParsingHelper.asBN(currentResult.min_result),
|
|
54
|
+
// minTimestamp: ObjectParsingHelper.asNumber(
|
|
55
|
+
// currentResult.min_timestamp_ms
|
|
56
|
+
// ),
|
|
57
|
+
// range: ObjectParsingHelper.asBN(currentResult.range),
|
|
58
|
+
// result: ObjectParsingHelper.asBN(currentResult.result),
|
|
59
|
+
// stdev: ObjectParsingHelper.asBN(currentResult.stdev),
|
|
60
|
+
// },
|
|
61
|
+
// feedHash: toHex(
|
|
62
|
+
// ObjectParsingHelper.asUint8Array(aggregatorData.feed_hash)
|
|
63
|
+
// ),
|
|
64
|
+
// maxStalenessSeconds: ObjectParsingHelper.asNumber(
|
|
65
|
+
// aggregatorData.max_staleness_seconds
|
|
66
|
+
// ),
|
|
67
|
+
// maxVariance: ObjectParsingHelper.asNumber(aggregatorData.max_variance),
|
|
68
|
+
// minResponses: ObjectParsingHelper.asNumber(aggregatorData.min_responses),
|
|
69
|
+
// minSampleSize: ObjectParsingHelper.asNumber(
|
|
70
|
+
// aggregatorData.min_sample_size
|
|
71
|
+
// ),
|
|
72
|
+
// name: ObjectParsingHelper.asString(aggregatorData.name),
|
|
73
|
+
// queue: ObjectParsingHelper.asString(aggregatorData.queue),
|
|
74
|
+
// updateState: {
|
|
75
|
+
// currIdx: ObjectParsingHelper.asNumber(updateState.curr_idx),
|
|
76
|
+
// results: updateState.results.map((r: any) => {
|
|
77
|
+
// const oracleId = r.fields.oracle;
|
|
78
|
+
// const value = ObjectParsingHelper.asBN(r.fields.result.fields);
|
|
79
|
+
// const timestamp = parseInt(r.fields.timestamp_ms);
|
|
80
|
+
// return {
|
|
81
|
+
// oracle: oracleId,
|
|
82
|
+
// value,
|
|
83
|
+
// timestamp,
|
|
84
|
+
// };
|
|
85
|
+
// }),
|
|
86
|
+
// },
|
|
87
|
+
// };
|
|
92
88
|
|
|
93
|
-
//
|
|
94
|
-
//
|
|
89
|
+
// return data;
|
|
90
|
+
// });
|
|
95
91
|
// };
|
|
96
92
|
|
|
97
|
-
// const
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
// const parseJobObject = (jobData: Record<string, any>) => {
|
|
101
|
-
// if (!jobData) {
|
|
102
|
-
// throw new Error(`No job data provided: ${jobData}`);
|
|
103
|
-
// } else if (!('tasks' in jobData)) {
|
|
104
|
-
// throw new Error('"tasks" property is required');
|
|
105
|
-
// } else if (!(Array.isArray(jobData.tasks) && jobData.tasks.length > 0)) {
|
|
106
|
-
// throw new Error('"tasks" property must be a non-empty array');
|
|
107
|
-
// }
|
|
108
|
-
// return OracleJob.fromObject(jobData);
|
|
109
|
-
// };
|
|
110
|
-
// const parseJobString = (jobString: string) => {
|
|
111
|
-
// // Strip comments using regex from https://regex101.com/r/B8WkuX/1
|
|
112
|
-
// const cleanJson = jobString.replace(
|
|
113
|
-
// /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/g,
|
|
114
|
-
// ''
|
|
115
|
-
// );
|
|
116
|
-
// return parseJobObject(JSON.parse(cleanJson));
|
|
117
|
-
// };
|
|
118
|
-
// return typeof data === 'string' ? parseJobString(data) : parseJobObject(data);
|
|
119
|
-
// };
|
|
93
|
+
// // const encodeJobs = (jobArray: OracleJob[]) => {
|
|
94
|
+
// // return jobArray.map((job) => serializeOracleJob(job).toString('base64'));
|
|
95
|
+
// // };
|
|
120
96
|
|
|
121
|
-
// const
|
|
122
|
-
// data: string | IOracleJob | Record<string, any>
|
|
123
|
-
// ):
|
|
124
|
-
// const
|
|
125
|
-
//
|
|
126
|
-
// };
|
|
97
|
+
// // const normalizeOracleJob = (
|
|
98
|
+
// // data: string | IOracleJob | Record<string, any>
|
|
99
|
+
// // ): OracleJob => {
|
|
100
|
+
// // const parseJobObject = (jobData: Record<string, any>) => {
|
|
101
|
+
// // if (!jobData) {
|
|
102
|
+
// // throw new Error(`No job data provided: ${jobData}`);
|
|
103
|
+
// // } else if (!('tasks' in jobData)) {
|
|
104
|
+
// // throw new Error('"tasks" property is required');
|
|
105
|
+
// // } else if (!(Array.isArray(jobData.tasks) && jobData.tasks.length > 0)) {
|
|
106
|
+
// // throw new Error('"tasks" property must be a non-empty array');
|
|
107
|
+
// // }
|
|
108
|
+
// // return OracleJob.fromObject(jobData);
|
|
109
|
+
// // };
|
|
110
|
+
// // const parseJobString = (jobString: string) => {
|
|
111
|
+
// // // Strip comments using regex from https://regex101.com/r/B8WkuX/1
|
|
112
|
+
// // const cleanJson = jobString.replace(
|
|
113
|
+
// // /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/g,
|
|
114
|
+
// // ''
|
|
115
|
+
// // );
|
|
116
|
+
// // return parseJobObject(JSON.parse(cleanJson));
|
|
117
|
+
// // };
|
|
118
|
+
// // return typeof data === 'string' ? parseJobString(data) : parseJobObject(data);
|
|
119
|
+
// // };
|
|
127
120
|
|
|
128
|
-
// const
|
|
129
|
-
//
|
|
130
|
-
// ):
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
// }
|
|
134
|
-
// const crossbarClient = new CrossbarClient('https://crossbar.switchboard.xyz');
|
|
121
|
+
// // const serializeOracleJob = (
|
|
122
|
+
// // data: string | IOracleJob | Record<string, any>
|
|
123
|
+
// // ): Buffer => {
|
|
124
|
+
// // const job = normalizeOracleJob(data);
|
|
125
|
+
// // return Buffer.from(OracleJob.encodeDelimited(job).finish());
|
|
126
|
+
// // };
|
|
135
127
|
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
//
|
|
128
|
+
// // const fetchSignatures = async (
|
|
129
|
+
// // feedConfig: AggregatorData
|
|
130
|
+
// // ): Promise<{
|
|
131
|
+
// // responses: FeedEvalResponse[];
|
|
132
|
+
// // failures: string[];
|
|
133
|
+
// // }> => {
|
|
134
|
+
// // const crossbarClient = new CrossbarClient('https://crossbar.switchboard.xyz');
|
|
139
135
|
|
|
140
|
-
// const
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
// const numSignatures = feedConfig.minSampleSize;
|
|
144
|
-
// const recentHash = toBase58(new Uint8Array(32));
|
|
145
|
-
// const useTimestamp = true;
|
|
136
|
+
// // const jobs: OracleJob[] = await crossbarClient
|
|
137
|
+
// // .fetch(feedConfig.feedHash)
|
|
138
|
+
// // .then((res) => res.jobs.map((job) => OracleJob.fromObject(job)));
|
|
146
139
|
|
|
147
|
-
// const
|
|
148
|
-
// const
|
|
149
|
-
// const
|
|
150
|
-
// const
|
|
140
|
+
// // const encodedJobs = encodeJobs(jobs);
|
|
141
|
+
// // const maxVariance = Math.floor(feedConfig.maxVariance / 1e9) * 1e9;
|
|
142
|
+
// // const minResponses = feedConfig.minResponses;
|
|
143
|
+
// // const numSignatures = feedConfig.minSampleSize;
|
|
144
|
+
// // const recentHash = toBase58(new Uint8Array(32));
|
|
145
|
+
// // const useTimestamp = true;
|
|
151
146
|
|
|
152
|
-
// const
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
// signature_scheme: 'Secp256k1',
|
|
157
|
-
// hash_scheme: 'Sha256',
|
|
158
|
-
// num_oracles: numSignatures,
|
|
159
|
-
// max_variance: maxVariance,
|
|
160
|
-
// min_responses: minResponses,
|
|
161
|
-
// use_timestamp: useTimestamp,
|
|
162
|
-
// });
|
|
147
|
+
// // const GATEWAY_URL = 'https://api.mainnet-beta.solana.com';
|
|
148
|
+
// // const TIMEOUT = 10000;
|
|
149
|
+
// // const url = `${GATEWAY_URL}/gateway/api/v1/fetch_signatures`;
|
|
150
|
+
// // const headers = { 'Content-Type': 'application/json' };
|
|
163
151
|
|
|
164
|
-
//
|
|
165
|
-
// .
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
152
|
+
// // const body = JSON.stringify({
|
|
153
|
+
// // api_version: '1.0.0',
|
|
154
|
+
// // jobs_b64_encoded: encodedJobs,
|
|
155
|
+
// // recent_chainhash: recentHash,
|
|
156
|
+
// // signature_scheme: 'Secp256k1',
|
|
157
|
+
// // hash_scheme: 'Sha256',
|
|
158
|
+
// // num_oracles: numSignatures,
|
|
159
|
+
// // max_variance: maxVariance,
|
|
160
|
+
// // min_responses: minResponses,
|
|
161
|
+
// // use_timestamp: useTimestamp,
|
|
162
|
+
// // });
|
|
163
|
+
|
|
164
|
+
// // return await axios
|
|
165
|
+
// // .post(url, body, {
|
|
166
|
+
// // headers,
|
|
167
|
+
// // timeout: TIMEOUT,
|
|
168
|
+
// // })
|
|
169
|
+
// // .then((r) => r.data);
|
|
170
|
+
// // };
|
|
171
171
|
|
|
172
|
-
export const updateSwitchboardAggregators = async (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
172
|
+
// export const updateSwitchboardAggregators = async (
|
|
173
|
+
// builder: ScallopBuilder,
|
|
174
|
+
// assetCoinNames: string[],
|
|
175
|
+
// txBlock: SuiKitTxBlock
|
|
176
|
+
// ) => {
|
|
177
|
+
// const switchboardClient = new SwitchboardClient(builder.suiKit.client());
|
|
178
|
+
// const onDemandAggObjects = await queryMultipleObjects(
|
|
179
|
+
// builder.cache,
|
|
180
|
+
// await builder.query.getSwitchboardOnDemandAggregatorObjectIds(
|
|
181
|
+
// assetCoinNames
|
|
182
|
+
// )
|
|
183
|
+
// );
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
// const feedConfigs = parseFeedConfigs(
|
|
186
|
+
// onDemandAggObjects.map((t) => t.content) as SuiParsedData[]
|
|
187
|
+
// );
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
// for (const idx in assetCoinNames) {
|
|
190
|
+
// // const { switchboardAddress, oracleQueueId } =
|
|
191
|
+
// // await switchboardClient.fetchState();
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
// // const feedConfig = feedConfigs[idx];
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
// // const suiQueue = await new Queue(
|
|
196
|
+
// // switchboardClient,
|
|
197
|
+
// // oracleQueueId
|
|
198
|
+
// // ).loadData();
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
// // const { responses, failures } = await fetchSignatures(feedConfig);
|
|
201
|
+
// // const validOracles = new Set(
|
|
202
|
+
// // suiQueue.existingOracles.map((o) => o.oracleKey)
|
|
203
|
+
// // );
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
// // const validResponses = responses.filter((r) => {
|
|
206
|
+
// // return validOracles.has(toBase58(fromHex(r.oracle_pubkey)));
|
|
207
|
+
// // });
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
// // // if we have no valid responses (or not enough), fail out
|
|
210
|
+
// // if (
|
|
211
|
+
// // !validResponses.length ||
|
|
212
|
+
// // validResponses.length < feedConfig.minSampleSize
|
|
213
|
+
// // ) {
|
|
214
|
+
// // // maybe retry by recursing into the same function / add a retry count
|
|
215
|
+
// // throw new Error('Not enough valid oracle responses.');
|
|
216
|
+
// // }
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
// // // split the gas coin into the right amount for each response
|
|
219
|
+
// // const coins = txBlock.splitCoins(
|
|
220
|
+
// // txBlock.gas,
|
|
221
|
+
// // validResponses.map(() => suiQueue.fee)
|
|
222
|
+
// // );
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
// // // map the responses into the tx
|
|
225
|
+
// // validResponses.forEach((response, i) => {
|
|
226
|
+
// // const oracle = suiQueue.existingOracles.find(
|
|
227
|
+
// // (o) => o.oracleKey === toBase58(fromHex(response.oracle_pubkey))
|
|
228
|
+
// // )!;
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
// // const signature = Array.from(fromBase64(response.signature));
|
|
231
|
+
// // signature.push(response.recovery_id);
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
233
|
+
// // txBlock.moveCall(
|
|
234
|
+
// // `${switchboardAddress}::aggregator_submit_result_action::run`,
|
|
235
|
+
// // [
|
|
236
|
+
// // txBlock.object(onDemandAggObjects[idx].objectId),
|
|
237
|
+
// // txBlock.object(suiQueue.id),
|
|
238
|
+
// // txBlock.pure.u128(response.success_value),
|
|
239
|
+
// // txBlock.pure.bool(response.success_value.startsWith('-')),
|
|
240
|
+
// // txBlock.pure.u64(response.timestamp!),
|
|
241
|
+
// // txBlock.object(oracle.oracleId),
|
|
242
|
+
// // txBlock.pure.vector('u8', signature),
|
|
243
|
+
// // txBlock.sharedObjectRef({
|
|
244
|
+
// // objectId: SUI_CLOCK_OBJECT_ID,
|
|
245
|
+
// // initialSharedVersion: '1',
|
|
246
|
+
// // mutable: false,
|
|
247
|
+
// // }),
|
|
248
|
+
// // coins[i],
|
|
249
|
+
// // ],
|
|
250
|
+
// // [SUI_TYPE_ARG]
|
|
251
|
+
// // );
|
|
252
|
+
// // });
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
// // return { responses, failures };
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
// const switchboardAgg = new Aggregator(
|
|
257
|
+
// switchboardClient,
|
|
258
|
+
// onDemandAggObjects[idx].objectId
|
|
259
|
+
// );
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
// const { responses, failures } = await switchboardAgg.fetchUpdateTx(
|
|
262
|
+
// txBlock.txBlock,
|
|
263
|
+
// {
|
|
264
|
+
// feedConfigs: feedConfigs[idx],
|
|
265
|
+
// }
|
|
266
|
+
// );
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
268
|
+
// return { responses, failures };
|
|
269
|
+
// }
|
|
270
|
+
// };
|
|
@@ -122,12 +122,16 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
122
122
|
'0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90',
|
|
123
123
|
primaryPriceUpdatePolicyObject:
|
|
124
124
|
'0xbcd908d0ee6d63d726e61676f3feeec3d19817f4849bbecf372dd3399f247f6b',
|
|
125
|
+
// '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee' // prod
|
|
125
126
|
secondaryPriceUpdatePolicyObject:
|
|
126
127
|
'0x624a6f120777bb30e718b86e836c205ef4229448052377dc3d78272a6662b2c0',
|
|
128
|
+
// '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705' // prod
|
|
127
129
|
primaryPriceUpdatePolicyVecsetId:
|
|
128
130
|
'0xfb1330aa028ed6a159b742c71b5a79b3b6824cf71efa40ea82b52486ad209264',
|
|
131
|
+
// '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c', // prod
|
|
129
132
|
secondaryPriceUpdatePolicyVecsetId:
|
|
130
133
|
'0x4b827acc73f3f53f808dd73a7ee0a60ae61e84322176bece72b26467030b467c',
|
|
134
|
+
// '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3' // prod
|
|
131
135
|
supra: {
|
|
132
136
|
registry: '',
|
|
133
137
|
registryCap: '',
|
|
@@ -304,7 +308,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
304
308
|
coinType:
|
|
305
309
|
'0x88618204de2dfdc2597681a8441ee726b0dc13494c41e319c3264eb7b35fea90::scallop_sui::SCALLOP_SUI',
|
|
306
310
|
metaData: '',
|
|
307
|
-
symbol: '',
|
|
311
|
+
symbol: 'sSUI',
|
|
308
312
|
treasury:
|
|
309
313
|
'0x03f1d94a40bd9f5d556bacb5c5245732b185572f6a29b36ad8b555d9a8a24f09',
|
|
310
314
|
},
|
|
@@ -312,7 +316,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
312
316
|
coinType:
|
|
313
317
|
'0x9f64a180373a6b66595025ae16a4ab701f0af1dd5c7ce1ac91dc112e52c2a3f8::scallop_sca::SCALLOP_SCA',
|
|
314
318
|
metaData: '',
|
|
315
|
-
symbol: '',
|
|
319
|
+
symbol: 'sSCA',
|
|
316
320
|
treasury:
|
|
317
321
|
'0x1b05d2cd8b20dba19da073a54195fc52d2f438ea19dea0713bae7a7dab308199',
|
|
318
322
|
},
|
|
@@ -321,7 +325,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
321
325
|
'0x55ed015f9f006c0c96ad36ebe3b3570d088e8498f52defea48e5634c110e485c::scallop_usdc::SCALLOP_USDC',
|
|
322
326
|
treasury:
|
|
323
327
|
'0x6ef82ef94472dcb8c2cdeac8df38874024c08570ca165986ba56d1e38fe0c0a3',
|
|
324
|
-
symbol: '',
|
|
328
|
+
symbol: 'sUSDC',
|
|
325
329
|
metaData:
|
|
326
330
|
'0x763a21eba338e00bc684aaad80491c89eea5f247b59c47df45b17610c9ad58f2',
|
|
327
331
|
},
|
|
@@ -329,7 +333,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
329
333
|
coinType:
|
|
330
334
|
'0x34f0a2e793e1f79ceac72cfe3bb95f65541da449418289ccd12922d16140c882::scallop_deep::SCALLOP_DEEP',
|
|
331
335
|
metaData: '',
|
|
332
|
-
symbol: '',
|
|
336
|
+
symbol: 'sDEEP',
|
|
333
337
|
treasury:
|
|
334
338
|
'0x71d41465cf2d16fa0206126526bebdf65c8871d1fcfbd0c2237db2306afd67ba',
|
|
335
339
|
},
|
|
@@ -337,7 +341,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
337
341
|
coinType:
|
|
338
342
|
'0x3b23c05f917052255a0b16a534dbd4446911aa4a30bd3497cdf5b736551e7ef8::scallop_fud::SCALLOP_FUD',
|
|
339
343
|
metaData: '',
|
|
340
|
-
symbol: '',
|
|
344
|
+
symbol: 'sFUD',
|
|
341
345
|
treasury:
|
|
342
346
|
'0x858c492d51425b922c040c1a389e185b3b00d565e7d72ead1a81dc733104660d',
|
|
343
347
|
},
|