@melonproject/protocol
Version:
Technology Regulated and Operated Investment Funds
74 lines (73 loc) • 4.72 kB
JavaScript
;
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 token_math_1 = require("@melonproject/token-math");
// TODO: JSDoc comments here
// instances is object containing contract instances of mln and weth
// accounts is an array of addresses
// fund is a fund address TODO: (maybe can make this part of accounts array)
// TODO: consider making this more general,
// rather than assuming certain account numbers are manager, investor, etc.
function getAllBalances(instances, accounts, fund, env) {
return __awaiter(this, void 0, void 0, function* () {
const [deployer, manager, investor, worker, exchangeOwner, custodian,] = accounts;
return {
custodian: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(custodian).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(custodian)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(custodian).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(custodian).call()),
},
deployer: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(deployer).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(deployer)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(deployer).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(deployer).call()),
},
exchangeOwner: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(exchangeOwner).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(exchangeOwner)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(exchangeOwner).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(exchangeOwner).call()),
},
fund: {
dgx: new token_math_1.BigInteger(yield fund.accounting.methods
.assetHoldings(instances.dgx.options.address)
.call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(fund.vault.options.address)),
mln: new token_math_1.BigInteger(yield fund.accounting.methods
.assetHoldings(instances.mln.options.address)
.call()),
weth: new token_math_1.BigInteger(yield fund.accounting.methods
.assetHoldings(instances.weth.options.address)
.call()),
},
investor: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(investor).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(investor)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(investor).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(investor).call()),
},
manager: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(manager).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(manager)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(manager).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(manager).call()),
},
worker: {
dgx: new token_math_1.BigInteger(yield instances.dgx.methods.balanceOf(worker).call()),
ether: new token_math_1.BigInteger(yield env.eth.getBalance(worker)),
mln: new token_math_1.BigInteger(yield instances.mln.methods.balanceOf(worker).call()),
weth: new token_math_1.BigInteger(yield instances.weth.methods.balanceOf(worker).call()),
},
};
});
}
exports.getAllBalances = getAllBalances;