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 7
7
ApproveIfNeededResult ,
8
8
} from './common/approveIfNeeded'
9
9
import { UndefinedOr , whenDefined } from '@devprotocol/util-ts'
10
+ import { BigNumber } from 'bignumber.js'
10
11
11
12
type Params = {
12
13
readonly provider : ContractRunner
@@ -88,11 +89,15 @@ export async function positionsCreateWithAnyTokens(
88
89
? await cont . getEstimatedDevForTokens (
89
90
options . path ,
90
91
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 ( )
96
101
: options . tokenAmount ,
97
102
)
98
103
: 'Neither devAmountOut nor tokenAmount provided'
You can’t perform that action at this time.
0 commit comments