(symbol, type, side, amount, price = undefined, params = {})
| 2543 | return settlement; |
| 2544 | } |
| 2545 | async createExtendedOrderRequest(symbol, type, side, amount, price = undefined, params = {}) { |
| 2546 | await this.loadMarkets(); |
| 2547 | const market = this.market(symbol); |
| 2548 | const uppercaseType = type.toUpperCase(); |
| 2549 | const uppercaseSide = side.toUpperCase(); |
| 2550 | if (market['spot'] && uppercaseType !== 'LIMIT') { |
| 2551 | throw new BadRequest(this.id + ' createOrder() supports limit orders for spot markets only'); |
| 2552 | } |
| 2553 | if (!this.inArray(uppercaseType, ['LIMIT', 'MARKET', 'CONDITIONAL', 'TPSL'])) { |
| 2554 | throw new BadRequest(this.id + ' createOrder() supports limit, market, conditional and tpsl orders only'); |
| 2555 | } |
| 2556 | if (price === undefined) { |
| 2557 | throw new ArgumentsRequired(this.id + ' createOrder() requires a price argument'); |
| 2558 | } |
| 2559 | const amountString = this.amountToPrecision(symbol, amount); |
| 2560 | const priceString = this.priceToPrecision(symbol, price); |
| 2561 | const postOnly = this.isPostOnly(uppercaseType === 'MARKET', undefined, params); |
| 2562 | const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only', false); |
| 2563 | let timeInForce = this.safeStringUpper(params, 'timeInForce'); |
| 2564 | if (timeInForce === undefined) { |
| 2565 | timeInForce = (uppercaseType === 'MARKET') ? 'IOC' : 'GTT'; |
| 2566 | } |
| 2567 | const fee = this.safeString(params, 'fee', '0.0005'); |
| 2568 | let builderFeeRate = undefined; |
| 2569 | let builderId = undefined; |
| 2570 | if (this.isSandboxModeEnabled) { |
| 2571 | builderFeeRate = this.safeString2(params, 'builderFeeRate', 'defaultBuilderFeeRate'); |
| 2572 | builderId = this.safeString2(params, 'builderId', 'defaultBuilderId'); |
| 2573 | params = this.omit(params, ['builderFeeRate', 'defaultBuilderFeeRate', 'builderId', 'defaultBuilderId']); |
| 2574 | } |
| 2575 | else { |
| 2576 | [builderFeeRate, params] = this.handleOptionAndParams(params, 'createOrder', 'builderFeeRate', '0.0001'); |
| 2577 | [builderId, params] = this.handleOptionAndParams(params, 'createOrder', 'builderId'); |
| 2578 | } |
| 2579 | let totalFee = fee; |
| 2580 | if (builderFeeRate !== undefined) { |
| 2581 | totalFee = Precise.stringAdd(fee, builderFeeRate); |
| 2582 | } |
| 2583 | const now = this.milliseconds(); |
| 2584 | const expiryEpochMillis = this.safeInteger(params, 'expiryEpochMillis', now + 3600000); |
| 2585 | const settlementExpiration = this.safeInteger(params, 'settlementExpiration', this.parseToInt((expiryEpochMillis + 999) / 1000) + 1209600); |
| 2586 | const nonce = this.numberToString(this.nonce()); |
| 2587 | const account = await this.fetchExtendedAccount(); |
| 2588 | const starkKey = this.safeString(account, 'l2Key'); |
| 2589 | const collateralPosition = this.safeString(account, 'l2Vault'); |
| 2590 | const info = this.safeDict(market, 'info', {}); |
| 2591 | const l2Config = this.safeDict(info, 'l2Config', {}); |
| 2592 | const syntheticId = this.safeString(l2Config, 'syntheticId'); |
| 2593 | const collateralId = this.safeString(l2Config, 'collateralId'); |
| 2594 | const syntheticResolution = this.safeInteger(l2Config, 'syntheticResolution'); |
| 2595 | const collateralResolution = this.safeInteger(l2Config, 'collateralResolution'); |
| 2596 | if ((syntheticId === undefined) || (collateralId === undefined) || (syntheticResolution === undefined) || (collateralResolution === undefined)) { |
| 2597 | throw new BadRequest(this.id + ' createOrder() requires l2Config in market info'); |
| 2598 | } |
| 2599 | const settlementParams = { |
| 2600 | 'totalFee': totalFee, |
| 2601 | 'starkKey': starkKey, |
| 2602 | 'syntheticId': syntheticId, |
no test coverage detected