Sha256: 26e38f0173114b3cdc6000aa36a822ea5067456cdf70e396319f1155b8fadb79

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

import { BigNumber } from '@waves/bignumber';
import { fetchAssetsBalance } from '../../api-node/assets';
import { filter, map, pipe, prop } from '../utils';
export default function (base, address, wavesFee) {
    return fetchAssetsBalance(base, address).then(pipe(prop('balances'), filter(canBeSponsor(wavesFee)), map(currentFee(wavesFee))));
}
function canBeSponsor(wavesFee) {
    return balance => (balance.minSponsoredAssetFee
        && BigNumber.toBigNumber(balance.sponsorBalance || 0)
            .gte(wavesFee)
        && BigNumber.toBigNumber(wavesFee)
            .div(0.001 * Math.pow(10, 8))
            .mul(balance.minSponsoredAssetFee)
            .lte(balance.balance)) || false;
}
function currentFee(wavesFee) {
    const count = BigNumber.toBigNumber(wavesFee)
        .div(0.001 * Math.pow(10, 8));
    return balance => ({
        assetId: balance.assetId,
        wavesFee,
        assetFee: BigNumber.toBigNumber(balance.minSponsoredAssetFee)
            .mul(count)
            .toFixed()
    });
}
//# sourceMappingURL=availableSponsoredBalances.js.map

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/@waves/node-api-js/es/tools/adresses/availableSponsoredBalances.js