aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/balance.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/util/balance.ts')
-rw-r--r--packages/instant/src/util/balance.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/instant/src/util/balance.ts b/packages/instant/src/util/balance.ts
new file mode 100644
index 000000000..533656858
--- /dev/null
+++ b/packages/instant/src/util/balance.ts
@@ -0,0 +1,13 @@
+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;
+ },
+};