Transactions
- class services.perpetual.api.gateway.transactions.Transaction
Transaction
Container for the different transaction types.
- Parameters
type (str) – The type of the transaction. For example, ‘“type”: “DEPOSIT”’.
- class services.perpetual.api.gateway.transactions.Deposit
Deposit
- Parameters
position_id (int) – The position ID to deposit to.
public_key (int) – The position ID owner’s public key.
amount (int) – Amount of collateral asset to be deposited; required to be >= 0.
- Example
{ "amount": "2569146471088859254", "position_id": "7758176404715800194", "public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a", "type": "DEPOSIT" }
- class services.perpetual.api.gateway.transactions.Withdrawal
Withdrawal
- Parameters
position_id (int) – The position ID to withdraw from.
public_key (int) – The position ID owner’s public key.
amount (int) – The amount to withdraw.
nonce (int) – Unique nonce issued by the caller.
expiration_timestamp (int) – The timestamp after which this request is no longer valid.
signature (
Signature
) – The position owner’s signature.
- Example
{ "amount": "2569146471088859254", "expiration_timestamp": "631194409", "nonce": "3433407905", "position_id": "7758176404715800194", "public_key": "0x35989d400b783796677a03aec2a321cd7e0f8e85d9e62f595209ca9b17beefc", "signature": { "r": "0x4b3b9e4934d635f6d1d015212cf773217abd65a32a804f0bd5c6cf3eab926f4", "s": "0x377ea02a33203f8f497ff1290e9b59c1e586134e41c3287b262f9c6e02e66c2" }, "type": "WITHDRAWAL" }
- class services.perpetual.api.gateway.transactions.WithdrawalToAddress
WithdrawalToAddress
- Parameters
position_id (int) – The position ID to withdraw from.
public_key (int) – The position ID owner’s public key.
eth_address (str) – The Ethereum address to move the funds into.
amount (int) – The amount to withdraw.
nonce (int) – Unique nonce issued by the caller.
expiration_timestamp (int) – The timestamp after which this request is no longer valid.
signature (
Signature
) – The position owner’s signature.
- Example
{ "amount": "1682637359498011204", "eth_address": "0xB6aD5EfBd6aDfa29dEfad5BC0f8cE0ad57d4c5Fb", "expiration_timestamp": "2101470722", "nonce": "4265854110", "position_id": "7758176404715800194", "public_key": "0x1b9e4c42a399f6ce069127df5ad618489aad21b1687acf4d4b09e08744084a7", "signature": { "r": "0x18326a6181a507f701968f45f56799b890374a1e329c6b9a37ec3292d92b1f8", "s": "0x66dd6745be06d033149a2bcb686e3ec896fc914ff2cb52dcc1d34bbe220b639" }, "type": "WITHDRAWAL_TO_ADDRESS" }
- class services.perpetual.api.gateway.transactions.ForcedWithdrawal
Forced Withdrawal
- Parameters
position_id (int) – The position ID to withdraw from.
public_key (int) – The position ID owner’s public key.
amount (int) – The amount to withdraw.
is_valid (bool) – A flag that specifies the validity of the forced action.
- Example
{ "amount": "5393743084917753817", "is_valid": true, "position_id": "15404588150415332147", "public_key": "0x1cfaf3dd957c66645dabbbe82b2e799fee3574d89b3f21d75c994502cb74ba9", "type": "FORCED_WITHDRAWAL" }
- class services.perpetual.api.gateway.transactions.Trade
Trade
- Parameters
party_a_order (
Order
) – Represents party a’s order.party_b_order (
Order
) – Represents party b’s order.actual_collateral (int) – The collateral amount sold in the trade.
actual_synthetic (int) – The synthetic amount sold in the trade.
actual_a_fee (int) – The amount party a paid for fees out of the maximal amount they were willing to pay.
actual_b_fee (int) – The amount party b paid for fees of the maximal amount they were willing to pay.
- Example
{ "actual_a_fee": "8791662011684601223", "actual_b_fee": "9309829342914403545", "actual_collateral": "7758176404715800194", "actual_synthetic": "15308084094301570617", "party_a_order": { "amount_collateral": "15334874138764573096", "amount_fee": "17677494534592486883", "amount_synthetic": "15460142528840632302", "asset_id_collateral": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "asset_id_synthetic": "0x2", "expiration_timestamp": "3608164305", "is_buying_synthetic": true, "nonce": "1210484339", "order_type": "LIMIT_ORDER_WITH_FEES", "position_id": "4805234989534244506", "public_key": "0x6b974202431eb8c0692c9c8111528d947bc7e70f7ffefaffbab7455dfa5d4f7", "signature": { "r": "0x54730fcf60f37072926ba182d17e55e21104fbc22886d876a7e8b191b2d456f", "s": "0x1f32f41a809b2f2b888bddc2bdbf5ef709403a00d4e5e23dbaef09e55130464" } }, "party_b_order": { "amount_collateral": "7800133567066683830", "amount_fee": "10547508580746848044", "amount_synthetic": "17015053283814123498", "asset_id_collateral": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "asset_id_synthetic": "0x2", "expiration_timestamp": "3407305306", "is_buying_synthetic": false, "nonce": "2046685052", "order_type": "LIMIT_ORDER_WITH_FEES", "position_id": "5076743434755564658", "public_key": "0x7784139b0eee3f6fd937bba714acc2b199af2877565ba7c926d3f10d0bca378", "signature": { "r": "0x929a5a30bb98b23d0fcfcc75a1ff5f0f5a437edac75002cb6ebca78173ffd3", "s": "0x2abbf077eb504ae44b2cf1ca81c1aa73489a38aead87600a7dadf82bd39efcc" } }, "type": "TRADE" }
- class services.perpetual.api.gateway.transactions.ForcedTrade
Forced Trade
- Parameters
public_key_party_a (int) – Party a’s public key.
public_key_party_b (int) – Party b’s public key.
position_id_party_a (int) – The position ID of party a.
position_id_party_b (int) – The position ID of party b.
collateral_asset_id (int) – The collateral unique asset ID (as registered on the contract).
synthetic_asset_id (int) – The unique asset ID of the synthetic asset that is traded.
amount_collateral (int) – The amount of collateral asset traded.
amount_synthetic (int) – The amount of synthetic asset traded.
is_party_a_buying_synthetic (bool) – Specifies if party A is buying the synthetic asset.
nonce (int) – Unique nonce issued by the caller.
is_valid (bool) – A flag that specifies the validity of the forced action.
- Example
{ "amount_collateral": "14797691350427913338", "amount_synthetic": "6016177607707753988", "collateral_asset_id": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "is_party_a_buying_synthetic": true, "is_valid": false, "nonce": "1118024132551217693632610875899092236504449200487573699079826449886775149099", "position_id_party_a": "14024249303067033555", "position_id_party_b": "17077091644470842180", "public_key_party_a": "0x4cf4530e87d4c996aa1325dbf9f42017402d327b82726947add90a3517be514", "public_key_party_b": "0x5ed3def0b61d2d033fed52db0531a02a4c51f7a85e9b0084024802835a6bc57", "synthetic_asset_id": "0x1", "type": "FORCED_TRADE" }
- class services.perpetual.api.gateway.transactions.Transfer
Transfer
- Parameters
amount (int) – The amount to transfer.
nonce (int) – Unique nonce issued by the caller.
sender_public_key (int) – The sender’s public key.
sender_position_id (int) – The position ID to transfer from.
receiver_public_key (int) – The receiver’s public key.
receiver_position_id (int) – The position ID to transfer to.
asset_id (int) – The unique asset ID (as registered on the contract) to transfer. Currently only the collateral asset is supported.
expiration_timestamp (int) – The timestamp after which this request is no longer valid.
signature (
Signature
) – The sender’s signature.
- Example
{ "amount": "7758176404715800194", "asset_id": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "expiration_timestamp": "2404381470", "nonce": "2195908194", "receiver_position_id": "6091063652223914538", "receiver_public_key": "0x259f432e6f4590b9a164106cf6a659eb4862b21fb97d43588561712e8e5216b", "sender_position_id": "9309829342914403545", "sender_public_key": "0x42a9616dd84637635f1bd07b8723008a0b83a0b4b0da4f5a50c55562009d253", "signature": { "r": "0x31e04b05b5090882a8e17ed91371ea267547dddecde98f8821e5ca65ab76451", "s": "0x342f351e4253945f76b9de058d92e18fc4e47e37515ad9ac750cbe046e921c2" }, "type": "TRANSFER" }
- class services.perpetual.api.gateway.transactions.ConditionalTransfer
Conditional Transfer
- Parameters
amount (int) – The amount to transfer.
nonce (int) – Unique nonce issued by the caller.
sender_public_key (int) – The sender’s public key.
sender_position_id (int) – The position ID to transfer from.
receiver_public_key (int) – The receiver’s public key.
receiver_position_id (int) – The position ID to transfer to.
asset_id (int) – The unique asset ID (as registered on the contract) to transfer. Currently only the collateral asset is supported.
expiration_timestamp (int) – The timestamp after which this request is no longer valid.
fact_registry_address (str) – The address of the fact registry smart contract. Should be checksummed according to Web3.isChecksumAddress.
fact (bytes) – The fact that should appear in the fact registry as a condition to the transfer. A 32 bytes blob.
signature (
Signature
) – The sender’s signature.
- Example
{ "amount": "7758176404715800194", "asset_id": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "expiration_timestamp": "2404381470", "fact": "6461646162616461626164616461626164616261646164616261646162616461", "fact_registry_address": "0x46479a258353d1158C3eD66dBf263cCF080225bA", "nonce": "2195908194", "receiver_position_id": "6091063652223914538", "receiver_public_key": "0x259f432e6f4590b9a164106cf6a659eb4862b21fb97d43588561712e8e5216b", "sender_position_id": "9309829342914403545", "sender_public_key": "0x5b8c4431f20b5be676a884eefcc11682acb79a848624e80f6751bb464304c8", "signature": { "r": "0x1f5fda835a938157ee7b62e6bf7a3c57de581721a23fc5868f28d21dd19094c", "s": "0x41c162952c44ff6873d5a1989db203c7cf30aee3edfe4fb54af65bcb8432a2a" }, "type": "CONDITIONAL_TRANSFER" }
- class services.perpetual.api.gateway.transactions.Liquidate
Liquidate
- Parameters
liquidator_order (
Order
) – Represents the liquidator order.liquidated_position_id (int) – The liquidated position ID.
actual_collateral (int) – The collateral amount sold in the liquidation.
actual_synthetic (int) – The synthetic amount sold in the liquidation.
actual_liquidator_fee (int) – The fee the liquidator paid out of the maximal amount they were willing to pay.
- Example
{ "actual_collateral": "7758176404715800194", "actual_liquidator_fee": "8791662011684601223", "actual_synthetic": "15308084094301570617", "liquidated_position_id": "15419682365516802845", "liquidator_order": { "amount_collateral": "8187132600743567510", "amount_fee": "11081939229867047606", "amount_synthetic": "16558026091473266411", "asset_id_collateral": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "asset_id_synthetic": "0x2", "expiration_timestamp": "1430804514", "is_buying_synthetic": false, "nonce": "3900315155", "order_type": "LIMIT_ORDER_WITH_FEES", "position_id": "11534118754833929857", "public_key": "0x5db665983e23607de57d6dc068797336bfdcb954238044688bec922ca296d3e", "signature": { "r": "0x4ac8a77f5863238a8bfb8a2e7f2dcc70cb8cad7b45692497b4b2c3ff06f6c94", "s": "0x6fd86c349a6c6266d34c11da0ff8c0cf211cafbadc39ba4a4c38124344f3bb1" } }, "type": "LIQUIDATE" }
- class services.perpetual.api.gateway.transactions.Deleverage
Deleverage
- Parameters
deleveraged_position_id (int) – The ID of the liquidated position, that is, the deleveraged position.
deleverager_position_id (int) – The ID of the counter-party position, that is, the party to which the deleveraged position is attached.
synthetic_asset_id (int) – The unique ID of the asset being deleveraged, as registered on the contract.
amount_synthetic (int) – The amount of the synthetic asset being deleveraged, with the resolution factor applied.
amount_collateral (int) – The quantized amount of the deleveraged position’s collateral.
deleverager_is_buying_synthetic (bool) – A flag that indicates if the deleverager is buying a synthetic asset.
- Example
{ "amount_collateral": "5721212930748269353", "amount_synthetic": "9309829342914403545", "deleveraged_position_id": "7758176404715800194", "deleverager_is_buying_synthetic": false, "deleverager_position_id": "15308084094301570617", "synthetic_asset_id": "0x1", "type": "DELEVERAGE" }
- class services.perpetual.api.gateway.transactions.FundingTick
Funding Tick
- Parameters
global_funding_indices (
FundingIndicesState
) – A definition of one or more global funding indices. Every asset type in the system should have a corresponding global funding index.- Example
{ "global_funding_indices": { "indices": { "0x0": "-431710025170174585", "0x1": "6084712057446794809" }, "timestamp": "1676361600" }, "type": "FUNDING_TICK" }
- class services.perpetual.api.gateway.transactions.OraclePricesTick
Oracle Prices Tick
- Parameters
oracle_prices (Mapping[int,
AssetOraclePrice
]) – Map between the asset ID to its median price and a collection of signed prices that generate this median.timestamp (int) – Transaction generation timestamp.
- Example
{ "oracle_prices": { "0x0": { "price": "4345629098988793194", "signed_prices": { "0x2ae10445c08f66270cd8d3a71cdac5630a541b1f7d13e47ec1d0373ce3e8fd3": { "external_asset_id": "0x425443555344000000000000000000004d616b6572", "price": "10117956201985462554675959028152", "timestamped_signature": { "signature": { "r": "0x13b99ddcb8e2fa4bc1b80f555f17c2fcba444aeab652407b4f14da448b6d41f", "s": "0x67b1807f682cd9ac6a26a9b808071c741d2bdd030a58d9318da482481c42a21" }, "timestamp": "3618339112" } } } }, "0x1": { "price": "14829673561266596382", "signed_prices": { "0x35007be34c2c3d47d2216cb3e13f61d65f4c3c76bb4c57bf1afbe7388bc3238": { "external_asset_id": "0x455448555344000000000000000000004d616b6572", "price": "216314955048675504460053108771", "timestamped_signature": { "signature": { "r": "0x27ef142c642e20c9a524d554bebacecc990edc4ede05ecea4a561f1f6b49e2b", "s": "0x7a75abca271b89c7dd8ab689a0729a64278da0daf2dbff383f5d0a16bb828b3" }, "timestamp": "4265854110" } }, "0x4722c15415ba4ab0a1b3a516be64b94846e9257d25e619c6014f8af08acf90c": { "external_asset_id": "0x455448555344000000000000000000004d616b6572", "price": "345280244044647467828513979784", "timestamped_signature": { "signature": { "r": "0x78b40a5e625af899b66c8ff1b95f82d67a7de48ed029ba307e61fdfffad23c9", "s": "0x4ab9a30d9a4d0ff81958a3d1a3a1fe8de8fcf8c656200264b6bd75f1ec9342a" }, "timestamp": "2685496293" } } } } }, "timestamp": "3485918757", "type": "ORACLE_PRICES_TICK" }
- class services.perpetual.api.gateway.transactions.MultiTransaction
MultiTransaction
- Parameters
txs (List[Transaction]) – The list of trasactions.
- Example
{ "txs": [ { "amount": "2569146471088859254", "position_id": "7758176404715800194", "public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a", "type": "DEPOSIT" }, { "amount": "13942126818862981423", "asset_id": "0x57d05d11b570fd197b55746070ee051c731ee109b07255eab3c9cf8b6c579d", "expiration_timestamp": "2628077981", "nonce": "3874773259", "receiver_position_id": "11534118754833929857", "receiver_public_key": "0x66194cbd71037d1b83e90ec17e0aa3c03983ca8ea7e9d498c778ea6eb2083e7", "sender_position_id": "10326739782786242647", "sender_public_key": "0x2a8212be00162b2578c201176e889cb6e3a4e7d4729e18b69228f54b75f4779", "signature": { "r": "0x3886b0da35de058e62011901b348da8abe129ba2a87294334f208a5e37f9047", "s": "0x1d7b269d0c1b813b49e02847b8e328139b1d301efaaa5f96473301e78c57236" }, "type": "TRANSFER" } ], "type": "MULTI_TRANSACTION" }
- log_additional_data(logger: Callable[[str], None]) None
Logs additional data that isn’t present in the __repr__ or __str__ functions.