Skip to content

Commit

Permalink
Override asset loading on devnet (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipzeta authored Dec 12, 2023
1 parent 9d995e7 commit 92a2c64
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Version changes are pinned to SDK releases.

## Unreleased

## [1.15.3]

- Override asset loading for devnet ([#320](https://github.com/zetamarkets/sdk/pull/320))

## [1.15.2]

- Bugfix getMaxTradeSize being too conservative with positive uPnL ([#315](https://github.com/zetamarkets/sdk/pull/315))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zetamarkets/sdk",
"repository": "https://github.com/zetamarkets/sdk/",
"version": "1.15.1",
"version": "1.15.3",
"description": "Zeta SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 17 additions & 1 deletion src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { objectEquals } from "./utils";
import { Asset } from "./constants";

import * as constants from "./constants";
import { Network } from "./network";

export function isValidType(asset: Asset): boolean {
try {
Expand All @@ -22,13 +23,28 @@ export function isValidStr(asset: string): boolean {
return true;
}

export function allAssets(): Asset[] {
export function allAssets(network: Network = Network.MAINNET): Asset[] {
let allAssets: Asset[] = [];
for (var a in Asset) {
if (typeof Asset[a] === "string" && a != "UNDEFINED") {
allAssets.push(nameToAsset(a));
}
}

// Keep devnet assets constant for ease of development and testing
if (network == Network.DEVNET) {
return [
constants.Asset.SOL,
constants.Asset.BTC,
constants.Asset.ETH,
constants.Asset.ARB,
constants.Asset.APT,
constants.Asset.PYTH,
constants.Asset.BNB,
constants.Asset.TIA,
];
}

return allAssets;
}

Expand Down
2 changes: 1 addition & 1 deletion src/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class Exchange {
if (this.isSetup) {
throw "Exchange already setup";
}
this._assets = assets.allAssets();
this._assets = assets.allAssets(loadConfig.network);
this._provider = new anchor.AnchorProvider(
loadConfig.connection,
wallet instanceof types.DummyWallet ? null : wallet,
Expand Down

0 comments on commit 92a2c64

Please sign in to comment.