Fix null checks on getters for PerpMarket and Bank (#505)
* Export OracleProvider * Fix null checks on getters
This commit is contained in:
parent
1f1f04a40c
commit
a7ee8fb2c0
|
@ -337,7 +337,7 @@ export class Bank implements BankForHealth {
|
||||||
}
|
}
|
||||||
|
|
||||||
get price(): I80F48 {
|
get price(): I80F48 {
|
||||||
if (!this._price) {
|
if (this._price === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined price for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
`Undefined price for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -346,7 +346,7 @@ export class Bank implements BankForHealth {
|
||||||
}
|
}
|
||||||
|
|
||||||
get uiPrice(): number {
|
get uiPrice(): number {
|
||||||
if (!this._uiPrice) {
|
if (this._uiPrice === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined uiPrice for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
`Undefined uiPrice for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -355,7 +355,7 @@ export class Bank implements BankForHealth {
|
||||||
}
|
}
|
||||||
|
|
||||||
get oracleLastUpdatedSlot(): number {
|
get oracleLastUpdatedSlot(): number {
|
||||||
if (!this._oracleLastUpdatedSlot) {
|
if (this._oracleLastUpdatedSlot === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined oracleLastUpdatedSlot for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
`Undefined oracleLastUpdatedSlot for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -364,7 +364,7 @@ export class Bank implements BankForHealth {
|
||||||
}
|
}
|
||||||
|
|
||||||
get oracleProvider(): OracleProvider {
|
get oracleProvider(): OracleProvider {
|
||||||
if (!this._oracleProvider) {
|
if (this._oracleProvider === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined oracleProvider for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
`Undefined oracleProvider for bank ${this.publicKey} with tokenIndex ${this.tokenIndex}!`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -242,7 +242,7 @@ export class PerpMarket {
|
||||||
}
|
}
|
||||||
|
|
||||||
get price(): I80F48 {
|
get price(): I80F48 {
|
||||||
if (!this._price) {
|
if (this._price === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -251,7 +251,7 @@ export class PerpMarket {
|
||||||
}
|
}
|
||||||
|
|
||||||
get uiPrice(): number {
|
get uiPrice(): number {
|
||||||
if (!this._uiPrice) {
|
if (this._uiPrice === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
`Undefined price for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -260,7 +260,7 @@ export class PerpMarket {
|
||||||
}
|
}
|
||||||
|
|
||||||
get oracleLastUpdatedSlot(): number {
|
get oracleLastUpdatedSlot(): number {
|
||||||
if (!this._oracleLastUpdatedSlot) {
|
if (this._oracleLastUpdatedSlot === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined oracleLastUpdatedSlot for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
`Undefined oracleLastUpdatedSlot for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
||||||
);
|
);
|
||||||
|
@ -269,7 +269,7 @@ export class PerpMarket {
|
||||||
}
|
}
|
||||||
|
|
||||||
get oracleProvider(): OracleProvider {
|
get oracleProvider(): OracleProvider {
|
||||||
if (!this._oracleProvider) {
|
if (this._oracleProvider === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Undefined oracleProvider for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
`Undefined oracleProvider for perpMarket ${this.publicKey} with marketIndex ${this.perpMarketIndex}!`,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Group } from './accounts/group';
|
import { Group } from './accounts/group';
|
||||||
import { StubOracle } from './accounts/oracle';
|
import { OracleProvider, StubOracle } from './accounts/oracle';
|
||||||
import { MangoClient } from './client';
|
import { MangoClient } from './client';
|
||||||
import { MANGO_V4_ID } from './constants';
|
import { MANGO_V4_ID } from './constants';
|
||||||
|
|
||||||
|
@ -22,4 +22,4 @@ export * from './constants';
|
||||||
export * from './numbers/I80F48';
|
export * from './numbers/I80F48';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export { Group, StubOracle, MangoClient, MANGO_V4_ID };
|
export { Group, OracleProvider, StubOracle, MangoClient, MANGO_V4_ID };
|
||||||
|
|
Loading…
Reference in New Issue