本文整理汇总了TypeScript中bignumber.js.default.lt方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.lt方法的具体用法?TypeScript js.default.lt怎么用?TypeScript js.default.lt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bignumber.js.default
的用法示例。
在下文中一共展示了js.default.lt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: co
BitGo.prototype.checkFunded = co(function *checkFunded() {
// We are testing both BTC and ETH funds here, to make sure that
// we don't spend for already 'failed' test runs (e.g., spending ETH when we don't have enough BTC)
// Test we have enough ETH
yield this.authenticateTestUser(this.testUserOTP());
const testWalletId = BitGo.V2.TEST_ETH_WALLET_ID;
const {
tethWallet,
tbtcWallet,
unspentWallet,
sweep1Wallet
} = yield Promise.props({
tethWallet: this.coin('teth').wallets().get({ id: testWalletId }),
tbtcWallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET1_ID }),
unspentWallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_WALLET2_UNSPENTS_ID }),
sweep1Wallet: this.coin('tbtc').wallets().getWallet({ id: BitGo.V2.TEST_SWEEP1_ID }),
});
const spendableBalance = tethWallet.spendableBalanceString;
let balance = new BigNumber(spendableBalance);
// Check our balance is over 60000 (we spend 50000, add some cushion)
if (balance.lt(60000)) {
throw new Error(`The TETH wallet ${testWalletId} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
}
// Check we have enough in the wallet to run test suite
tbtcWallet.should.have.property('spendableBalanceString');
balance = new BigNumber(tbtcWallet.spendableBalanceString());
// Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
let minimumBalance = 0.05 * 1e8;
if (balance.lt(minimumBalance)) {
throw new Error(`The TBTC wallet ${tbtcWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
}
// Check we have enough in the wallet to run test suite
unspentWallet.should.have.property('spendableBalanceString');
balance = new BigNumber(unspentWallet.spendableBalanceString());
// Check our balance is over 0.05 tBTC (we spend 0.04, add some cushion)
minimumBalance = 0.05 * 1e8;
if (balance.lt(minimumBalance)) {
throw new Error(`The TBTC wallet ${unspentWallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
}
// Check we have enough in the wallet to run test suite
sweep1Wallet.should.have.property('spendableBalanceString');
balance = new BigNumber(sweep1Wallet.spendableBalanceString());
// Since we will lose our unspents value to fees, make sure there is a large enough balance to continue
minimumBalance = 0.05 * 1e8;
if (balance.lt(minimumBalance)) {
throw new Error(`The TBTC wallet ${sweep1Wallet.id()} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`);
}
});
示例2: denormalizePrice
export function denormalizePrice(minPrice: string|number|BigNumber, maxPrice: string|number|BigNumber, normalizedPrice: string|number|BigNumber): BigNumber {
const bnMinPrice: BigNumber = new BigNumber(minPrice, 10);
const bnMaxPrice: BigNumber = new BigNumber(maxPrice, 10);
const bnNormalizedPrice: BigNumber = new BigNumber(normalizedPrice, 10);
if (bnMinPrice.gt(bnMaxPrice)) throw new Error("Minimum value larger than maximum value");
if (bnNormalizedPrice.lt(0)) throw new Error("Normalized price is below 0");
if (bnNormalizedPrice.gt(1)) throw new Error("Normalized price is above 1");
return bnNormalizedPrice.times(bnMaxPrice.minus(bnMinPrice)).plus(bnMinPrice);
}