Команда Swapgate
18 ноября 2024 г.
~1 мин. чтения
SDK
Оглавление
- Установка
- Лицензия
Установка
pip install swapgate-sdk
Использование
config = Config(api_url="https://swapgate.io", api_public="changeme", api_secret="changeme")
sdk = SwapgateSDK(config)
Получить инструмент
res = InstrumentReq(currencyTitle="USDT", networkTitle="TRC20")
instrument = sdk.get_instrument(res)
Получить тариф
res = RateReq(
instrumentFromCurrencyTitle="BTC",
instrumentFromNetworkTitle="BTC",
instrumentToCurrencyTitle="USDT",
instrumentToNetworkTitle="TRC20",
claimedDepositAmount="10000",
rateMode="FLOATING",
claimedDepositAmountCurrency="USDT",
markup="1.0",
)
rate = sdk.get_rate(res)
Создать заказ
res = RateReq(
instrumentFromCurrencyTitle="BTC",
instrumentFromNetworkTitle="BTC",
instrumentToCurrencyTitle="USDT",
instrumentToNetworkTitle="TRC20",
claimedDepositAmount="10000",
rateMode="FLOATING",
claimedDepositAmountCurrency="BTC",
markup="0.3",
)
rate = sdk.get_rate(res)
public_rate = ClaimedPublicRate(
claimedAmountToReceive=rate.amountToGet,
finalNetworkFeeAmount=rate.finalNetworkFeeAmount,
platformFee_Absolute=rate.platformFee_Absolute,
price=rate.price,
quotes=rate.quotes,
updatedAt=rate.updatedAt,
)
req = CreateOrderReq(
instrumentFrom=rate.instrumentFrom,
instrumentTo=rate.instrumentTo,
destinationAddress='TFe5tdqSy8CMGMDVHPJHLTK8hrAL6ddUpD',
destinationAddressMemo=None,
refundAddress=None,
refundAddressMemo=None,
claimedPublicRate=public_rate,
claimedNetworkFee=rate.finalNetworkFeeAmount,
legacyOrderId=None,
referrerId=None,
claimedDepositAmount=rate.amountToGive,
rateMode="FLOATING",
markup=rate.markup,
)
new_order = sdk.create_order(req)
Лицензия
swapgate-sdk
is distributed under the terms of the MIT license.