aboutsummaryrefslogblamecommitdiffstats
path: root/packages/instant/src/util/balance.ts
blob: 5336568585edfd863d05c621d18e0cb0a37bb484 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                               
                            
 
                            
                                                                                                                

                                          
         
                                                                                
                                                                        

      
import { BuyQuote } from '@0x/asset-buyer';
import { Web3Wrapper } from '@0x/web3-wrapper';
import * as _ from 'lodash';

export const balanceUtil = {
    hasSufficentEth: async (takerAddress: string | undefined, buyQuote: BuyQuote, web3Wrapper: Web3Wrapper) => {
        if (_.isUndefined(takerAddress)) {
            return false;
        }
        const balanceWei = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
        return balanceWei >= buyQuote.worstCaseQuoteInfo.totalEthAmount;
    },
};