update client to get all latest markets, add workaround for missing ada decimals for now

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2021-11-16 19:13:03 +01:00
parent b00313ecbd
commit 9f220d2e85
3 changed files with 51 additions and 17 deletions

View File

@ -12,7 +12,7 @@
"author": "microwavedcola1",
"license": "MIT",
"dependencies": {
"@blockworks-foundation/mango-client": "^3.0.13",
"@blockworks-foundation/mango-client": "^3.2.5",
"ansi-regex": "^6.0.1",
"big.js": "^6.1.1",
"body-parser": "^1.19.0",

View File

@ -185,12 +185,15 @@ class MarketsController implements Controller {
if (market instanceof Market && market.minOrderSize) {
minOrderSize = market.minOrderSize;
} else if (market instanceof PerpMarket) {
const token = getTokenBySymbol(
this.mangoSimpleClient.mangoGroupConfig,
marketConfig.baseSymbol
);
// todo: remove hardcoding
// const baseDecimals = getTokenBySymbol(
// this.mangoSimpleClient.mangoGroupConfig,
// marketConfig.baseSymbol
// ).decimals;
const baseDecimals = 6;
minOrderSize = new Big(market.baseLotSize.toString())
.div(new Big(10).pow(token.decimals))
.div(new Big(10).pow(baseDecimals))
.toNumber();
}
@ -199,10 +202,13 @@ class MarketsController implements Controller {
if (market instanceof Market) {
tickSize = market.tickSize;
} else if (market instanceof PerpMarket) {
const baseDecimals = getTokenBySymbol(
this.mangoSimpleClient.mangoGroupConfig,
marketConfig.baseSymbol
).decimals;
// todo: remove hardcoding
// const baseDecimals = getTokenBySymbol(
// this.mangoSimpleClient.mangoGroupConfig,
// marketConfig.baseSymbol
// ).decimals;
const baseDecimals = 6;
const quoteDecimals = getTokenBySymbol(
this.mangoSimpleClient.mangoGroupConfig,
this.mangoSimpleClient.mangoGroupConfig.quoteSymbol

View File

@ -9,11 +9,12 @@
dependencies:
regenerator-runtime "^0.13.4"
"@blockworks-foundation/mango-client@^3.0.13":
version "3.0.24"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.0.24.tgz#5cd56317411326558dda1b4d1fe31ec6c8e8493b"
integrity sha512-iOlle6xlOYR0UlAfGgnrjSFSSWjvklUDoFcHbCPNoMJQPdlzf7hnKCBOnKQYXmZg6LsDYp78cObNJIUhHNXkGw==
"@blockworks-foundation/mango-client@^3.2.5":
version "3.2.5"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.2.5.tgz#a1da40078754eb1ee3ec5aa897d3a1cb548d0253"
integrity sha512-3mXYFDaDiIdDXfBf/McEZIpYMT5dpYAT4h6CRVA4GR62Vk6bY+ARzr5Ei2xc6tVyxvEU7fnutJ07cSxW4U8Qow==
dependencies:
"@project-serum/anchor" "^0.16.2"
"@project-serum/serum" "0.13.55"
"@project-serum/sol-wallet-adapter" "^0.2.0"
"@solana/spl-token" "^0.1.6"
@ -21,8 +22,10 @@
axios "^0.21.1"
big.js "^6.1.1"
bigint-buffer "^1.1.5"
bn.js "^5.1.0"
bn.js "^5.2.0"
buffer-layout "^1.2.1"
dotenv "^10.0.0"
dotenv-expand "^5.1.0"
yargs "^17.0.1"
"@cspotcode/source-map-consumer@0.8.0":
@ -57,6 +60,26 @@
snake-case "^3.0.4"
toml "^3.0.0"
"@project-serum/anchor@^0.16.2":
version "0.16.2"
resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.16.2.tgz#b8b4ec4c749d59a224108f8d82ab68217ef752ae"
integrity sha512-wOJwObd4wOZ5tRRMCKYjeMNsEmf7vuC71KQRnw6wthhErL8c/818n4gYIZCf/1ZPl/8WPruIlmtQHDSEyy2+0Q==
dependencies:
"@project-serum/borsh" "^0.2.2"
"@solana/web3.js" "^1.17.0"
base64-js "^1.5.1"
bn.js "^5.1.2"
bs58 "^4.0.1"
buffer-layout "^1.2.0"
camelcase "^5.3.1"
crypto-hash "^1.3.0"
eventemitter3 "^4.0.7"
find "^0.3.0"
js-sha256 "^0.9.0"
pako "^2.0.3"
snake-case "^3.0.4"
toml "^3.0.0"
"@project-serum/borsh@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.2.tgz#63e558f2d6eb6ab79086bf499dea94da3182498f"
@ -451,7 +474,7 @@ bn.js@^4.11.9:
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88"
integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==
bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.2:
bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.2, bn.js@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002"
integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==
@ -753,7 +776,12 @@ dot-case@^3.0.4:
no-case "^3.0.4"
tslib "^2.0.3"
dotenv@10.0.0:
dotenv-expand@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
dotenv@10.0.0, dotenv@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==