Skip to content

Commit

Permalink
feat: add dex related tx (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 authored Jan 29, 2025
1 parent 22481c7 commit 320ffde
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 0 deletions.
26 changes: 26 additions & 0 deletions shared/requests/submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ components:
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
OfferCancel: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
OfferCreate: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand All @@ -95,6 +98,9 @@ components:
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
- $ref: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
- $ref: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here

description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
Expand Down Expand Up @@ -124,6 +130,9 @@ components:
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
OfferCancel: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
OfferCreate: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand All @@ -138,6 +147,9 @@ components:
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
- $ref: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
- $ref: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here
description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
required:
Expand Down Expand Up @@ -226,6 +238,9 @@ components:
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
OfferCancel: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
OfferCreate: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
Expand All @@ -241,6 +256,9 @@ components:
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
- $ref: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
- $ref: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here

SubmitSuccessResponseV2:
Expand All @@ -265,6 +283,9 @@ components:
CheckCancel: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
CheckCash: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
CheckCreate: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
OfferCancel: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
OfferCreate: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
TrustSet: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
Expand All @@ -280,6 +301,9 @@ components:
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelTransaction'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashTransaction'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateTransaction'
- $ref: '../transactions/offer_cancel.yaml#/components/schemas/OfferCancelTransaction'
- $ref: '../transactions/offer_create.yaml#/components/schemas/OfferCreateTransaction'
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetTransaction'
# TODO: Add other transaction types here

SubmitErrorResponse:
Expand All @@ -298,6 +322,8 @@ components:
- $ref: '../transactions/check_cancel.yaml#/components/schemas/CheckCancelErrorCode'
- $ref: '../transactions/check_cash.yaml#/components/schemas/CheckCashErrorCode'
- $ref: '../transactions/check_create.yaml#/components/schemas/CheckCreateErrorCode'
- $ref: '../transactions/offer_create.yaml#/components/schemas/OfferCreateErrorCode'
- $ref: '../transactions/trust_set.yaml#/components/schemas/TrustSetErrorCode'
- enum:
- amendmentBlocked
- highFee
Expand Down
19 changes: 19 additions & 0 deletions shared/transactions/offer_cancel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
components:
schemas:
OfferCancelTransaction:
$id: OfferCancelTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
An OfferCancel transaction removes an Offer object from the XRP Ledger.
required:
- OfferSequence
properties:
OfferSequence:
type: integer
format: uint32
description: |
The sequence number (or Ticket number) of a previous OfferCreate transaction. If specified,
cancel any offer object in the ledger that was created by that transaction. It is not
considered an error if the offer specified does not exist.
83 changes: 83 additions & 0 deletions shared/transactions/offer_create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
components:
schemas:
OfferCreateTransaction:
$id: OfferCreateTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
An OfferCreate transaction places an Offer in the decentralized exchange.
required:
- TakerGets
- TakerPays
properties:
Expiration:
type: integer
format: uint32
description: |
(Optional) Time after which the Offer is no longer active, in seconds since the Ripple Epoch.
OfferSequence:
type: integer
format: uint32
description: |
(Optional) An Offer to delete first, specified in the same way as OfferCancel.
TakerGets:
$ref: '../base.yaml#/components/schemas/CurrencyAmount'
description: |
The amount and type of currency being sold.
TakerPays:
$ref: '../base.yaml#/components/schemas/CurrencyAmount'
description: |
The amount and type of currency being bought.
OfferCreateFlag:
$id: OfferCreateFlag
type: string
enum:
- tfPassive: 0x00010000
- tfImmediateOrCancel: 0x00020000
- tfFillOrKill: 0x00040000
- tfSell: 0x00080000
description: Enum representing flags for OfferCreate transactions.
x-enum-descriptions:
tfPassive: If enabled, the Offer does not consume Offers that exactly match it, and instead becomes an Offer object in the ledger. It still consumes Offers that cross it.
tfImmediateOrCancel: 'Treat the Offer as an Immediate or Cancel order. The Offer never creates an Offer object in the ledger: it only trades as much as it can by consuming existing Offers at the time the transaction is processed. If no Offers match, it executes "successfully" without trading anything. In this case, the transaction still uses the result code tesSUCCESS.'
tfFillOrKill: Treat the offer as a Fill or Kill order. The Offer never creates an Offer object in the ledger, and is canceled if it cannot be fully filled at the time of execution. By default, this means that the owner must receive the full TakerPays amount; if the tfSell flag is enabled, the owner must be able to spend the entire TakerGets amount instead.
tfSell: Exchange the entire TakerGets amount, even if it means obtaining more than the TakerPays amount in exchange.
OfferCreateErrorCode:
$id: OfferCreateErrorCode
type: string
enum:
- temINVALID_FLAG
- tecEXPIRED
- tecKILLED
- temBAD_EXPIRATION
- temBAD_SEQUENCE
- temBAD_OFFER
- temREDUNDANT
- temBAD_CURRENCY
- temBAD_ISSUER
- tecNO_ISSUER
- tecFROZEN
- tecUNFUNDED_OFFER
- tecNO_LINE
- tecNO_AUTH
- tecINSUF_RESERVE_OFFER
- tecDIR_FULL
description: Enum representing possible error codes for OfferCreate transactions.
x-enum-descriptions:
temINVALID_FLAG: Occurs if the transaction specifies both tfImmediateOrCancel and tfFillOrKill.
tecEXPIRED: Occurs if the transaction specifies an Expiration time that has already passed.
tecKILLED: Occurs if the transaction specifies tfFillOrKill, and the full amount cannot be filled. If the ImmediateOfferKilled amendment is enabled, this result code also occurs when the transaction specifies tfImmediateOrCancel and executes without moving funds (previously, this would return tesSUCCESS).
temBAD_EXPIRATION: Occurs if the transaction contains an Expiration field that is not validly formatted.
temBAD_SEQUENCE: Occurs if the transaction contains an OfferSequence that is not validly formatted, or is higher than the transaction's own Sequence number.
temBAD_OFFER: Occurs if the Offer tries to trade XRP for XRP, or tries to trade an invalid or negative amount of a token.
temREDUNDANT: Occurs if the transaction specifies a token for the same token (same issuer and currency code).
temBAD_CURRENCY: Occurs if the transaction specifies a token with the currency code "XRP".
temBAD_ISSUER: Occurs if the transaction specifies a token with an invalid issuer value.
tecNO_ISSUER: Occurs if the transaction specifies a token whose issuer value is not a funded account in the ledger.
tecFROZEN: Occurs if the transaction involves a token on a frozen trust line (including local and global freezes).
tecUNFUNDED_OFFER: 'Occurs if the owner does not hold a positive amount of the TakerGets currency. (Exception: if TakerGets specifies a token that the owner issues, the transaction can succeed.)'
tecNO_LINE: Occurs if the transaction involves a token whose issuer uses Authorized Trust Lines and the necessary trust line does not exist.
tecNO_AUTH: Occurs if the transaction involves a token whose issuer uses Authorized Trust Lines and the trust line that would receive the tokens exists but has not been authorized.
tecINSUF_RESERVE_OFFER: Occurs if the owner does not have enough XRP to meet the reserve requirement of adding a new Offer object to the ledger, and the transaction did not convert any currency. (If the transaction successfully traded any amount, the transaction succeeds with the result code tesSUCCESS, but does not create an Offer object in the ledger for the rest.)
tecDIR_FULL: Occurs if the owner owns too many items in the ledger, or the order book contains too many Offers at the same exchange rate already.
52 changes: 52 additions & 0 deletions shared/transactions/trust_set.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
components:
schemas:
TrustSetTransaction:
$id: TrustSetTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
Create or modify a trust line linking two accounts.
required:
- LimitAmount
properties:
LimitAmount:
$ref: '../base.yaml#/components/schemas/CurrencyAmount'
description: |
Object defining the trust line to create or modify, in the format of a Currency Amount.
QualityIn:
type: integer
format: uint32
description: |
(Optional) Value incoming balances on this trust line at the ratio of this number per
1,000,000,000 units. A value of 0 is shorthand for treating balances at face value.
QualityOut:
type: integer
format: uint32
description: |
(Optional) Value outgoing balances on this trust line at the ratio of this number per
1,000,000,000 units. A value of 0 is shorthand for treating balances at face value.
TrustSetFlag:
$id: TrustSetFlag
type: string
enum:
- tfSetfAuth: 0x00010000
- tfSetNoRipple: 0x00020000
- tfClearNoRipple: 0x00040000
- tfSetFreeze: 0x00100000
- tfClearFreeze: 0x00200000
description: Enum representing flags for TrustSet transactions.
x-enum-descriptions:
tfSetfAuth: Authorize the other party to hold currency issued by this account. (No effect unless using the asfRequireAuth AccountSet flag.) Cannot be unset.
tfSetNoRipple: Enable the No Ripple flag, which blocks rippling between two trust lines of the same currency if this flag is enabled on both.
tfClearNoRipple: Disable the No Ripple flag, allowing rippling on this trust line.
tfSetFreeze: Freeze the trust line.
tfClearFreeze: Unfreeze the trust line.
TrustSetErrorCode:
$id: TrustSetErrorCode
type: string
enum:
- tecNO_PERMISSION
description: Enum representing possible error codes for TrustSet transactions.
x-enum-descriptions:
tecNO_PERMISSION: If the account specified in LimitAmount.issuer is blocking incoming trust lines, the transaction fails.

0 comments on commit 320ffde

Please sign in to comment.