UNPKG

@melonproject/protocol

Version:

Technology Regulated and Operated Investment Funds

59 lines (58 loc) 3.55 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const getBalance_1 = require("../../utils/evm/getBalance"); const withNewAccount_1 = require("../../utils/environment/withNewAccount"); const token_math_1 = require("@melonproject/token-math"); const sendEth_1 = require("../../utils/evm/sendEth"); const getTokenBySymbol_1 = require("../../utils/environment/getTokenBySymbol"); const getPrice_1 = require("../../contracts/prices/calls/getPrice"); const toBeTrueWith_1 = require("../utils/toBeTrueWith"); const getSystemTestEnvironment_1 = require("../utils/getSystemTestEnvironment"); const Environment_1 = require("../../utils/environment/Environment"); const getLogCurried_1 = require("../../utils/environment/getLogCurried"); const testLogger_1 = require("../utils/testLogger"); const setupFund_1 = require("../../contracts/fund/hub/transactions/setupFund"); const getExchangesInfo_1 = require("../../contracts/factory/calls/getExchangesInfo"); const getExchangeInfo_1 = require("../../contracts/fund/trading/calls/getExchangeInfo"); expect.extend({ toBeTrueWith: toBeTrueWith_1.toBeTrueWith }); const getLog = getLogCurried_1.getLogCurried('melon:protocol:systemTest:playground-multiple-investors'); describe('playground', () => { afterAll(() => __awaiter(this, void 0, void 0, function* () { yield testLogger_1.allLogsWritten(); })); test('Happy path', () => __awaiter(this, void 0, void 0, function* () { const master = yield getSystemTestEnvironment_1.getSystemTestEnvironment(Environment_1.Tracks.KYBER_PRICE); const log = getLog(master); const { melonContracts } = master.deployment; const manager = yield withNewAccount_1.withNewAccount(master); log.debug('Manager ', manager.wallet.address); const mln = getTokenBySymbol_1.getTokenBySymbol(manager, 'MLN'); try { const mlnPrice = yield getPrice_1.getPrice(master, melonContracts.priceSource.toString(), mln); log.debug('MLN Price', mlnPrice); } catch (e) { throw new Error('Cannot get MLN Price from Kyber'); } const masterBalance = yield getBalance_1.getBalance(master); expect(masterBalance).toBeTrueWith(token_math_1.greaterThan, token_math_1.createQuantity(masterBalance.token, 6)); yield sendEth_1.sendEth(master, { howMuch: token_math_1.createQuantity('ETH', 100), to: manager.wallet.address, }); const routes = yield setupFund_1.setupFund(manager); log.debug('Routes ', routes); const tradingInfo = yield getExchangesInfo_1.getExchangesInfo(manager, melonContracts.version, manager.wallet.address); log.debug('Data from Fund Factory ', tradingInfo); const exchangeInfo = yield getExchangeInfo_1.getExchangeInfo(manager, routes.tradingAddress); log.debug('Data from trading contract ', exchangeInfo); })); });