File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 77 ApproveIfNeededResult ,
88} from './common/approveIfNeeded'
99import { UndefinedOr , whenDefined } from '@devprotocol/util-ts'
10+ import { BigNumber } from 'bignumber.js'
1011
1112type Params = {
1213 readonly provider : ContractRunner
@@ -88,11 +89,15 @@ export async function positionsCreateWithAnyTokens(
8889 ? await cont . getEstimatedDevForTokens (
8990 options . path ,
9091 typeof options . gatewayBasisPoints === 'number'
91- ? (
92- ( BigInt ( options . tokenAmount ) *
93- BigInt ( options . gatewayBasisPoints ) ) /
94- BigInt ( '10000' )
95- ) . toString ( )
92+ ? new BigNumber ( options . tokenAmount )
93+ . times (
94+ new BigNumber ( 10000 )
95+ . minus ( options . gatewayBasisPoints )
96+ . div ( 10000 ) ,
97+ )
98+ . times ( 0.8 ) // x0.8 = Hardcoded tolerance for quote and transaction differences
99+ . dp ( 0 )
100+ . toFixed ( )
96101 : options . tokenAmount ,
97102 )
98103 : 'Neither devAmountOut nor tokenAmount provided'
You can’t perform that action at this time.
0 commit comments