@firefly-exchange/firefly-client
Version:
The Firefly Client Library allows traders to sign, create, retrieve and listen to orders on Firefly Exchange.
41 lines • 2.29 kB
JavaScript
/**
* Adding Markets code example
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-console */
const index_1 = require("../index");
function main() {
return __awaiter(this, void 0, void 0, function* () {
const dummyAccountKey = "a182091b4d5a090b65d604e36f68629a692e3bf2aa864bd3f037854034cdd676";
// using TESTNET network
const client = new index_1.FireflyClient(true, index_1.Networks.TESTNET_ARBITRUM, dummyAccountKey); //passing isTermAccepted = true for compliance and authorizarion
yield client.init();
// will add dot market to client and will be using the orders contract
// from contractAddresses initialized with init() method above
console.log("Market Added: ", client.addMarket(index_1.MARKET_SYMBOLS.DOT));
const client2 = new index_1.FireflyClient(true, index_1.Networks.TESTNET_ARBITRUM, dummyAccountKey);
yield client2.init();
console.log("Market Added: ", client2.addMarket(index_1.MARKET_SYMBOLS.DOT, "0x36AAc8c385E5FA42F6A7F62Ee91b5C2D813C451C"));
// this will throw because ETH market is not yet available on TESTNET.
// the function looks up the contractAddresses (initialized above) to determine if a particular
// market is available or not
try {
client.addMarket(index_1.MARKET_SYMBOLS.ETH);
}
catch (e) {
// do something about the error: like not providing invalid MARKET NAMES
}
});
}
main().then().catch(console.warn);
//# sourceMappingURL=2.add-markets.js.map
;