Skip to content

About App Credit

Miao ZhiCheng edited this page Oct 4, 2023 · 10 revisions

Because of the buffer used in CFA, a super app would need liquidity for creating streams. In a large volume super app, requiring up-front liquidity can limit the number of super app developers who may not have or want to fund the super app with own liquidity. Hence a system called app credit is additionally provided in the super app framework.

Objective & 1to1 Flow Forwarding Benchmark Case

The objective of the app credit system is to allow the creation of zero balance super app in the most common use cases, the benchmark case is a 1to1 flow forwarding benchmark case.

Implementation Notes:

Due to historical naming changes, in the CFAv1 code base, it is referred to as appAllowanceBase.

App Credit Lending Rules

Rule A: Transactional Allowance Rule

  • App credit are given to the app as allowance, from the input stream sender's wallet.

  • The app can use up to that amount within the same transaction, the amount that is not used is given back to the input stream sender.

Rule CFA-1: CFA 1to1 Forwarding Rule

  • CFA allocate the same amount of buffer of the input stream to the app as the app credit.

  • It is guaranteed that forwarding the same flow rate as the input stream as a zero-balance app should always work.

Implementation Notes:

  • Due to buffer clipping, a rounding-up of the buffer amount is used instead.
    • Minimum deposit should also be taken into account.

Problem: 1:N flow forwarding issue

Due to buffer clipping rounding errors, when N > 1, app may not have enough app credit to create those flows.

Rule CFA-2: Minimum buffer amount as additional app credit

  • By default the minimum buffer is the minimum clipped buffer amount
  • Each time app create a flow, an additional minimum buffer could be borrowed form the user in addition to the rule A.
  • This way it ensures the app can always create a flow.
  • It abandons the objective that the app now could shoot itself in the foot even in a 1to1 flow forwarding case.

Possible fix 2: Change Rule CFA-1

  • App created streams use round-down clipping for calculating flow buffer.
  • Need a Math proof that, the rounded-up-clipped flow buffer can be used by N-split input flow with rounded-down-clipped flow buffers.
  • Need to solve the minimum buffer economic cost case.

References

Clone this wiki locally