Skip to content

Commit

Permalink
remove fieldsToUpdate undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pingustar committed Dec 18, 2023
1 parent 894498d commit daa2d2b
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/components/strategies/useUpdateStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StrategyUpdate } from '@bancor/carbon-sdk';
import { MarginalPriceOptions } from '@bancor/carbon-sdk/strategy-management';
import { useNotifications } from 'hooks/useNotifications';
import {
Expand Down Expand Up @@ -173,14 +174,21 @@ export const useUpdateStrategy = () => {
throw new Error('error in withdraw strategy budget: missing data ');
}

const fieldsToUpdate: StrategyUpdate = Object.assign({});

if (buyMarginalPrice) {
fieldsToUpdate.buyBudget = order0.balance;
}

if (sellMarginalPrice) {
fieldsToUpdate.sellBudget = order1.balance;
}

updateMutation.mutate(
{
id,
encoded,
fieldsToUpdate: {
buyBudget: order0.balance,
sellBudget: order1.balance,
},
fieldsToUpdate,
buyMarginalPrice,
sellMarginalPrice,
},
Expand Down Expand Up @@ -219,14 +227,21 @@ export const useUpdateStrategy = () => {
throw new Error('error in deposit strategy budget: missing data');
}

const fieldsToUpdate: StrategyUpdate = Object.assign({});

if (buyMarginalPrice) {
fieldsToUpdate.buyBudget = order0.balance;
}

if (sellMarginalPrice) {
fieldsToUpdate.sellBudget = order1.balance;
}

updateMutation.mutate(
{
id,
encoded,
fieldsToUpdate: {
buyBudget: order0.balance,
sellBudget: order1.balance,
},
fieldsToUpdate,
buyMarginalPrice,
sellMarginalPrice,
},
Expand Down

0 comments on commit daa2d2b

Please sign in to comment.