Fix null checks on getters for PerpMarket and Bank (#505)

* Export OracleProvider

* Fix null checks on getters
This commit is contained in:
riordanp 2023-03-16 09:10:52 +00:00 committed by GitHub
parent 1f1f04a40c
commit a7ee8fb2c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -337,7 +337,7 @@ export class Bank implements BankForHealth {
}
get price(): I80F48 {
if (!this._price) {
if (this._price === undefined) {
throw new Error(
`Undefined price for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
);
@ -346,7 +346,7 @@ export class Bank implements BankForHealth {
}
get uiPrice(): number {
if (!this._uiPrice) {
if (this._uiPrice === undefined) {
throw new Error(
`Undefined uiPrice for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
);
@ -355,7 +355,7 @@ export class Bank implements BankForHealth {
}
get oracleLastUpdatedSlot(): number {
if (!this._oracleLastUpdatedSlot) {
if (this._oracleLastUpdatedSlot === undefined) {
throw new Error(
`Undefined oracleLastUpdatedSlot for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
);
@ -364,7 +364,7 @@ export class Bank implements BankForHealth {
}
get oracleProvider(): OracleProvider {
if (!this._oracleProvider) {
if (this._oracleProvider === undefined) {
throw new Error(
`Undefined oracleProvider for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
);

View File

@ -242,7 +242,7 @@ export class PerpMarket {
}
get price(): I80F48 {
if (!this._price) {
if (this._price === undefined) {
throw new Error(
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
);
@ -251,7 +251,7 @@ export class PerpMarket {
}
get uiPrice(): number {
if (!this._uiPrice) {
if (this._uiPrice === undefined) {
throw new Error(
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
);
@ -260,7 +260,7 @@ export class PerpMarket {
}
get oracleLastUpdatedSlot(): number {
if (!this._oracleLastUpdatedSlot) {
if (this._oracleLastUpdatedSlot === undefined) {
throw new Error(
`Undefined oracleLastUpdatedSlot for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
);
@ -269,7 +269,7 @@ export class PerpMarket {
}
get oracleProvider(): OracleProvider {
if (!this._oracleProvider) {
if (this._oracleProvider === undefined) {
throw new Error(
`Undefined oracleProvider for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
);

View File

@ -1,5 +1,5 @@
import { Group } from './accounts/group';
import { StubOracle } from './accounts/oracle';
import { OracleProvider, StubOracle } from './accounts/oracle';
import { MangoClient } from './client';
import { MANGO_V4_ID } from './constants';
@ -22,4 +22,4 @@ export * from './constants';
export * from './numbers/I80F48';
export * from './utils';
export * from './types';
export { Group, StubOracle, MangoClient, MANGO_V4_ID };
export { Group, OracleProvider, StubOracle, MangoClient, MANGO_V4_ID };