MCPcopy Create free account
hub / github.com/ccxt/ccxt / eip_message_for_order

Method eip_message_for_order

python/ccxt/grvt.py:2073–2121  ·  view source on GitHub ↗
(self, order, structureType)

Source from the content-addressed store, hash-verified

2071 return int(x)
2072
2073 def eip_message_for_order(self, order, structureType):
2074 priceMultiplier = '1000000000'
2075 orderLegs = self.safe_list(order, 'legs', [])
2076 legs = []
2077 for i in range(0, len(orderLegs)):
2078 leg = orderLegs[i]
2079 market = self.market(leg['instrument'])
2080 bigInt10 = self.convert_to_big_int_custom('10')
2081 precisionValue = self.precision_from_string(self.safe_string(market['precision'], 'base'))
2082 precisionValueStr = str(precisionValue)
2083 sizeMultiplier = math.pow(bigInt10, self.convert_to_big_int_custom(precisionValueStr))
2084 size = leg['size']
2085 sizeParts = size.split('.')
2086 sizeDec = self.safe_string(sizeParts, 1, '')
2087 sizeDecLength = len(sizeDec) + 0 # php tr
2088 sizeDecLengthStr = str(sizeDecLength)
2089 sizeInteger = self.convert_to_big_int_custom(size.replace('.', '')) * sizeMultiplier / (math.pow(bigInt10, self.convert_to_big_int_custom(sizeDecLengthStr)))
2090 legOrder = {
2091 'assetID': market['info']['instrument_hash'],
2092 'contractSize': self.parse_to_int(sizeInteger),
2093 'isBuyingContract': leg['is_buying_asset'],
2094 }
2095 limitPrice = self.safe_string(leg, 'limit_price')
2096 if self.omit_zero(limitPrice) is not None:
2097 price = leg['limit_price']
2098 limitParts = price.split('.')
2099 limitDec = self.safe_string(limitParts, 1, '')
2100 limitDecLength = len(limitDec) + 0 # php tr
2101 limitDecLengthStr = str(limitDecLength)
2102 powerNum = limitDecLengthStr == 0 if '0' else self.convert_to_big_int_custom(limitDecLengthStr)
2103 priceInteger = (self.convert_to_big_int_custom(price.replace('.', '')) * self.convert_to_big_int_custom(priceMultiplier) / (math.pow(bigInt10, powerNum)))
2104 legOrder['limitPrice'] = self.parse_to_int(priceInteger)
2105 else:
2106 legOrder['limitPrice'] = 0 # should be zero to validate type-check
2107 legs.append(legOrder)
2108 returnValue = {
2109 'subAccountID': order['sub_account_id'],
2110 'isMarket': order['is_market'],
2111 'timeInForce': self.time_in_force_to_int(order['time_in_force']),
2112 'postOnly': order['post_only'],
2113 'reduceOnly': order['reduce_only'],
2114 'legs': legs,
2115 'nonce': order['signature']['nonce'],
2116 'expiration': order['signature']['expiration'],
2117 }
2118 if structureType == 'EIP712_ORDER_WITH_BUILDER_TYPE' and self.safe_bool(self.options, 'builderFee', True):
2119 returnValue['builder'] = order['builder']
2120 returnValue['builderFee'] = self.parse_to_int(self.convert_to_big_int_custom(self.fee_amount_multiplier()) * float(order['builder_fee'])) # the order is matter for Multiply in go, b must be float64 otherwise the value would be 0
2121 return returnValue
2122
2123 def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2124 """

Callers 1

create_signed_requestMethod · 0.95

Calls 15

time_in_force_to_intMethod · 0.95
fee_amount_multiplierMethod · 0.95
safe_listMethod · 0.80
precision_from_stringMethod · 0.80
safe_stringMethod · 0.80
splitMethod · 0.80
replaceMethod · 0.80
parse_to_intMethod · 0.80
omit_zeroMethod · 0.80
safe_boolMethod · 0.80
rangeFunction · 0.50

Tested by

no test coverage detected