本文整理汇总了TypeScript中bignumber.js.default.plus方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.plus方法的具体用法?TypeScript js.default.plus怎么用?TypeScript js.default.plus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bignumber.js.default
的用法示例。
在下文中一共展示了js.default.plus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
explanation.outputs = _.map(operations, operation => {
// Get memo to attach to address, if type is 'id'
const memoId = (_.get(explanation, 'memo.type') === 'id' && ! _.get(explanation, 'memo.value') ? `?memoId=${explanation.memo.value}` : '');
const output = {
amount: this.bigUnitsToBaseUnits(operation.startingBalance || operation.amount),
address: operation.destination + memoId
};
spendAmount = spendAmount.plus(output.amount);
return output;
});
示例2: at
/**
* Calculates rewards at round position.
* Fees and feesRemaining based on slots
*/
public at(index: number): { balance: number, fees: number, feesRemaining: number, rewards: number } {
const rewards = this.roundRewards[index] ? new Bignum(this.roundRewards[index].toPrecision(15))
.integerValue(BigNumber.ROUND_FLOOR) : 0;
return {
balance : Number(this.fees.plus(rewards).toFixed()),
fees : Number(this.fees.toFixed()),
feesRemaining: Number(this.feesRemaining.toFixed()),
rewards : Number(rewards.toFixed()),
};
}
示例3: incrementMarketVolume
async function incrementMarketVolume(db: Knex, marketId: Address, amount: BigNumber, tradesRow: TradesRow<BigNumber>, isIncrease: boolean): Promise<void> {
const marketsRow: { minPrice: BigNumber, maxPrice: BigNumber, volume: BigNumber; shareVolume: BigNumber } | undefined = await db("markets").first("minPrice", "maxPrice", "volume", "shareVolume").where({ marketId });
if (marketsRow === undefined) throw new Error(`No marketId for incrementMarketVolume: ${marketId}`);
const newShareVolume = amount.plus(marketsRow.shareVolume);
let vft = volumeForTrade({
marketMinPrice: marketsRow.minPrice,
marketMaxPrice: marketsRow.maxPrice,
...tradesRow,
});
if (!isIncrease) vft = vft.negated();
const newVolume = marketsRow.volume.plus(vft);
await db("markets").update({ volume: newVolume.toString(), shareVolume: newShareVolume.toString() }).where({ marketId });
}
示例4: BigNumber
export function sumProfitLossResults<T extends ProfitLossResult>(left: T, right: T): T {
const leftPosition = new BigNumber(left.netPosition, 10);
const rightPosition = new BigNumber(right.netPosition, 10);
const netPosition = leftPosition.plus(rightPosition);
const averagePrice = left.averagePrice.plus(right.averagePrice).dividedBy(2);
const realized = left.realized.plus(right.realized);
const unrealized = left.unrealized.plus(right.unrealized);
const unrealizedCost = left.unrealizedCost.plus(right.unrealizedCost);
const unrealizedRevenue = left.unrealizedRevenue.plus(right.unrealizedRevenue);
const realizedCost = left.realizedCost.plus(right.realizedCost);
const totalCost = left.totalCost.plus(right.totalCost);
const total = realized.plus(unrealized);
const { unrealizedProfitPercent } = getUnrealizedProfitPercent({
unrealizedCost: new Tokens(unrealizedCost),
unrealizedProfit: new Tokens(unrealized),
});
const { realizedProfitPercent } = getRealizedProfitPercent({
realizedCost: new Tokens(realizedCost),
realizedProfit: new Tokens(realized),
});
const { totalProfitPercent } = getTotalProfitPercent({
totalCost: new Tokens(totalCost),
totalProfit: new Tokens(total),
});
return Object.assign(_.clone(left), {
netPosition,
averagePrice,
realized,
unrealized,
total,
unrealizedCost,
realizedCost,
totalCost,
unrealizedPercent: unrealizedProfitPercent.magnitude,
realizedPercent: realizedProfitPercent.magnitude,
totalPercent: totalProfitPercent.magnitude,
unrealizedRevenue,
});
}
示例5: BigNumber
x.modulo(0.9) // '0.1'
const y = new BigNumber(33)
y.mod('a', 33) // '3'
}
{
const x = new BigNumber(1.8)
x.negated() // '-1.8'
const y = new BigNumber(-1.3)
y.neg() // '1.3'
}
{
0.1 + 0.2 // 0.30000000000000004
const x = new BigNumber(0.1)
const y = x.plus(0.2) // '0.3'
new BigNumber(0.7).plus(x).plus(y) // '1'
x.plus('0.1', 8) // '0.225'
}
{
const x = new BigNumber(1.234)
x.precision() // 4
const y = new BigNumber(987000)
y.sd() // 3
y.sd(true) // 6
}
{
const x = 1234.56
Math.round(x) // 1235