1月 262019
 


https://developers.ripple.com/offers.html
https://developers.ripple.com/offercreate.html
https://developers.ripple.com/offercancel.html

Offers
报价单

In the XRP Ledger’s decentralized exchange, orders to trade currency are called “Offers”. Offers can trade XRP with issued currencies, or issued currencies with each other, including issued currencies with the same currency code but different issuers. (Currencies with the same code but different issuers can also sometimes be exchanged through rippling.)
在XRP总账网络的去中心化汇兑中,用以交易货币的订单称为Offers报价单。报价单交易可以是在XRP和已发行货币之间,也可以是在不同已发行货币之间,包括不同发行人发行的具有相同货币代码的已发行货币。(通常不同发行人发行的具有相同货币代码的已发行货币也可以通过rippling进行交易。)

To create an Offer, send an OfferCreate transaction.

要创建报价单,需要提交一个OfferCreate交易。
Offers that aren’t fully filled immediately become Offer objects in the ledger data. Later Offers and Payments can consume the Offer object from the ledger.

报价单

Cross-currency payments consume offers to provide liquidity.

跨货币支付

TakerGets The amount and type of currency being provided by the offer creator.
报价单创建者提供的货币类型和数额

TakerPays The amount and type of currency being requested by the offer creator.
报价单创建者需要的货币类型和数额

Lifecycle of an Offer
报价单生命周期

When an OfferCreate transaction is processed, it automatically consumes matching or crossing offers to the extent possible. (If existing offers provide a better rate than requested, the offer creator could pay less than the full TakerGets amount to receive the entire TakerPays amount.) If that does not completely fulfill the TakerPays amount, then the offer becomes an Offer object in the ledger. (You can use OfferCreate Flags to modify this behavior.)
当OfferCreate交易处理后,系统自动进行消费匹配或在可接受范围内交叉报价。(如果现有报价单比已请求报价具有更优费率,报价单创建者可以支付少于TakerGets的数额,而收到TakerPays的全额。)如果不满足TakerPays数额要求,则该订单将作为Offer对象存在于总账网络中。

An offer in the ledger can be fulfilled either by additional OfferCreate transactions that match up with the existing offers, or by Payment transactions that use the offer to connect the payment path. Offers can be partially fulfilled and partially funded. A single transaction can consume up to 850 Offers from the ledger. (Any more than that, and the metadata becomes too large, resulting in tecOVERSIZE.)
总账网络中的报价单可以与其他由OfferCreate交易创建的报价单进行匹配交易,也可以在付款交易中使用报价单来连接付款路径。报价单支持部分匹配和部分兑现,单笔交易在总账网络中最多消耗850个报价单。(超过该限制,将导致metadata数据过大,相关参数为tecOVERSIZE)

You can create an offer so long as you have at least some (any positive, nonzero amount) of the currency specified by the TakerGets parameter of the offer. The offer sells as much of the currency as you have, up to the TakerGets amount, until the TakerPays amount is satisfied. An offer cannot place anyone in debt.
只要你的账户中拥有TakerGets参数所指定的货币种类和余额就可以创建报价单。报价单所指定的TakerGets数额不能超过你所具有该货币的实际数额。报价单不会使交易双方产生债务。

It is possible for an offer to become temporarily or permanently unfunded:
报价单可能产生临时或永久额度不足的情况:

If the creator no longer has any of the TakerGets currency.
    The offer becomes funded again when the creator obtains more of that currency.

当创建者不再持有TakerGets所指定的货币时。当创建者再次取得该货币时报价单及资金才变为可用状态。

If the currency required to fund the offer is held in a frozen trust line.
    The offer becomes funded again when the trust line is no longer frozen.

如果交易货币资金处在冻结状态的信任线上,只有当信任线不再冻结以后报价单及资金才变为可用状态。

If the creator does not have enough XRP for the reserve amount of a new trust line required by the offer. (See Offers and Trust.)
    The offer becomes funded again when the creator obtains more XRP, or the reserve requirements decrease.

当创建者XRP余额不能满足储备金要求以建立满足该报价单的新信任线时。报价单在创建者获取更多XRP或储备金标准降低时报价单才变为可用状态。

If the Expiration time included in the offer is before the close time of the most recently-closed ledger. (See Offer Expiration.)

如果报价单的过期时间在最近关闭的总账版本时间之前。

An unfunded offer can stay on the ledger indefinitely, but it does not have any effect. The only ways an offer can be permanently removed from the ledger are:
没有资金交付的报价单可以一直留存在总账网络中,但是没有任何效应。从总账网络中永久移除报价单的方式如下:

It becomes fully claimed by a Payment or a matching OfferCreate transaction.

完全被支付消耗或匹配其他OfferCreate交易。

An OfferCancel or OfferCreate transaction explicitly cancels the offer.

由OfferCancel或OfferCreate交易明确取消。

An OfferCreate transaction from the same account crosses the earlier offer. (In this case, the older offer is automatically canceled.)

由同一账户发起重叠的OfferCreate交易。(在这种情况下,旧报价单自动取消)

An offer is found to be unfunded during transaction processing, typically because it was at the tip of the orderbook.

报价单在处理交易时发现资金额度不可用。通常因为该报价单位于orderbook最末端。

    This includes cases where one side or the other of an offer is found to be closer to 0 than rippled's precision supports.

这包括一方或者另一个报价单挂出比rippled支持精度更接近0的报价。

Tracking Unfunded Offers
追踪无资金报价单

Tracking the funding status of all offers can be computationally taxing. In particular, addresses that are actively trading may have a large number of offers open. A single balance can affect the funding status of many offers to buy different currencies. Because of this, rippled does not proactively find and remove offers.
追踪报价单的资金状态以便进行税费计算。特别是活跃的账户地址通常保有大量进行中的报价单。单一的账户余额会影响到所有买入不同货币交易的资金状态。因此,rippled默认设计为不积极主动查找和移除报价单。

A client application can locally track the funding status of offers. To do this, first retreive an order book using the book_offers method and check the taker_gets_funded field of offers. Then, subscribe to the transactions stream and watch the transaction metadata to see which offers are modified.
客户端程序可以本地追踪报价单资金状态。首先使用book_offers方法检索order book并检查taker_gets_funded字段。然后参阅交易流及交易metadata元数据信息以确认哪些报价单发生了变化。

Offers and Trust
报价单与信任

The limit values of trust lines (See TrustSet) do not affect offers. In other words, you can use an offer to acquire more than the maximum amount you trust an issuer to redeem.
信任线的限额设置不影响报价单。也就是用户可以获取超过信任线限额或发行人偿付能力的货币。

However, holding non-XRP balances still requires a trust line to the address issuing those balances. When an offer is taken, it automatically creates any necessary trust lines, setting their limits to 0. Because trust lines increase the reserve an account must hold, any offers that would require a new trust line also require the address to have enough XRP to meet the reserve for that trust line.
但是,持有非XRP货币余额仍需与发行地址建立信任线。创建报价单时将自动创建必需的信任线,并设置限额为0。因为信任线与账户储备金相关,任何报价单创建时所需要的信任线关系都需要具有满足储备金要求的XRP。

A trust line indicates an issuer you trust enough to accept their issuances as payment, within limits. Offers are explicit instructions to acquire certain issuances, so they are allowed to go beyond those limits.
信任线限额是用户足够信任并接受能够使用发行进行付款的额度。报价单则是明确表明要获得的发行及额度,所以允许超出该限制。

Offer Preference
报价单偏好

Existing offers are grouped by exchange rate (sometimes called “offer quality”), which is measured as the ratio between TakerGets and TakerPays. Offers with a higher exchange rate are taken preferentially. (That is, the person accepting the offer receives as much as possible for the amount of currency they pay out.) Offers with the same exchange rate are taken on the basis of which offer was placed in the earliest ledger version.
现有报价单按汇率(也叫报价质量)进行分组,即TakerGets和TakerPays的比率。具有较高汇率的报价单将优先处理。(也就是说是尽量少的成本获取尽量多的回报)。具有相同汇率的报价单则根据其出现在总账版本的时间顺序优先处理。

When offers of the same exchange rate are placed in the same ledger version, the order in which they are taken is determined by the canonical order in which the transactions were applied to the ledger. This behavior is designed to be deterministic, efficient, and hard to game.
如果发生具有相同汇率的报价单出现在相同的总账版本中,订单将按照报价单交易提交至总账网络的权威顺序处理。这种行为被设计为确定的,高效的,难以捉弄的。

Offer Expiration
报价单过期

Since transactions can take time to propagate and confirm, the timestamp of a ledger is used to determine offer validity. An offer only expires when its Expiration time is before the most-recently validated ledger. In other words, an offer with an Expiration field is still considered “active” if its expiration time is later than the timestamp of the most-recently validated ledger, regardless of what your local clock says.
因为交易需要时间传递和确认,总账网络中的时间戳用以确认报价单有效性。报价单过期时间早于最近已验证总账时间则认为报价单过期。报价单过期时间晚于最新已验证总账时间,则认为是有效的报价单。

You can determine the final disposition of an offer with an Expiration as soon as you see a fully-validated ledger with a close time equal to or greater than the expiration time.
当用户看到报价单的过期时间等于或远远大于最新已验证总账的关闭时间时,即可以确认该报价单的最终意向。

Note:
Since only new transactions can modify the ledger, an expired offer can stay on the ledger after it becomes inactive. The offer is treated as unfunded and has no effect, but it can continue to appear in results (for example, from the ledger_entry command). Later on, the expired offer can get finally deleted as a result of another transaction (such as another OfferCreate) if the server finds it while processing.
只有新的交易可以修改总账,报价单可以留存在已生成和验证(过期)的总账中。不会有任何影响,但该报价单仍会出现在命令执行的结果中(如ledger_entry命令)。最终该报价单会在进行另外一笔OffercCreate交易时被删除。

要删除一项旧的报价并更换为新的报价,用户可以使用带有一个OfferSequence参数的OfferCreate 交易来代替使用OfferCancel并创建另一个OfferCreate交易。

If an OfferCreate transaction has an Expiration time that has already passed when the transaction first gets included in a ledger, the transaction does not execute the offer. The result code of such a transaction depends on whether the Checks amendment is enabled. With the Checks amendment enabled, the transaction has the tecEXPIRED result code. Otherwise, the transaction has the tesSUCCESS transaction code. In either case, the transaction has no effect except to destroy the XRP paid as a transaction cost.
如果OfferCreate交易的过期时间在提交至总账网络之前就已经过期,报价单将不会被使用。其交易返回代码将将根据是否启用Checks amendment支票修正设置而不同。该设置开启时,交易返回tecEXPIRED,未开启时返回tesSUCCESS。任何情况下,除取消该报价单时产生的XRP交易费用外,该报价单不会有任何效应。