Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program: refactor oracle map to allow same oracle w diff oracle sources #1346

Merged
merged 22 commits into from
Dec 2, 2024

Conversation

crispheaney
Copy link
Member

No description provided.

@@ -0,0 +1,27 @@
import { PublicKey } from '@solana/web3.js';
import { OracleSource, OracleSourceNum } from '../types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doens't look like OracleSourceNum exists

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt check it in 🤦

}

public getOraclePriceDataAndSlotForPerpMarket(
marketIndex: number
): DataAndSlot<OraclePriceData> | undefined {
const perpMarketAccount = this.getMarketAccountAndSlot(marketIndex);
const oracle = this.perpOracleMap.get(marketIndex);
const oracleString = this.perpOracleStringMap.get(marketIndex);
if (!perpMarketAccount || !oracle) {
const oracleId = this.perpOracleStringMap.get(marketIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.perpOracleStringMap.set(perpMarketIndex, oracle.toBase58());

i think you need to populate this map with oracleId

}

public getOraclePriceDataAndSlotForSpotMarket(
marketIndex: number
): DataAndSlot<OraclePriceData> | undefined {
const spotMarketAccount = this.getSpotMarketAccountAndSlot(marketIndex);
const oracle = this.spotOracleMap.get(marketIndex);
const oracleString = this.spotOracleStringMap.get(marketIndex);
if (!spotMarketAccount || !oracle) {
const oracleId = this.spotOracleStringMap.get(marketIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.spotOracleStringMap.set(spotMarketIndex, oracle.toBase58());

needa populate this map with oracleId

@@ -31,7 +35,7 @@ export function findDelistedPerpMarketsAndOracles(
continue;
}

if (spotMarket.data.oracle.equals(delistedOracle)) {
if (spotMarket.data.oracle.equals(delistedOracle.publicKey)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to compare against oracleId instead of just the pubkey?

@crispheaney crispheaney merged commit d09652a into master Dec 2, 2024
6 of 8 checks passed
crispheaney added a commit that referenced this pull request Dec 2, 2024
crispheaney added a commit that referenced this pull request Dec 2, 2024
…es (#1346)

* program: refactor oracle map to allow same oracle w diff oracle sources

* rm some code

* rename get_oracle_id to oracle_id

* start fixing tests

* fix remainder of tests

* add another test

* more red diffs

* fix a compiler warning

* start adding ts changes

* add ws drift client account sub

* add grpc implementation

* prettify:fix

* check in missing OracleSourceNum

* update some missing use of getOracleId

* tweak findDelistedPerpMarketsAndOracles logic

* add bankrun test

* prettify:fix

* fix findDelistedPerpMarketsAndOracles

* update test

* fix linters

* CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants