Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalized payment release strategy #367

Open
olanod opened this issue Apr 19, 2024 · 1 comment
Open

Generalized payment release strategy #367

olanod opened this issue Apr 19, 2024 · 1 comment
Labels
payments payments pallet

Comments

@olanod
Copy link
Member

olanod commented Apr 19, 2024

I propose generalizing the way how payments are released to the beneficiary.

The core feature of payments pallet is being able to hold funds until the sender is satisfied with an event happening off-chain(e.g. when receiving goods). To support more use cases, like when there is more trust between paying parties that conduct businesses regularly, an automated way to release funds progressively becomes very useful.

We can add a parameter to pay that accepts the "release strategy" represented as an enum.

enum Release<T> {
    // Beneficiary must call `release` manually this many times
    // `Release::Manual(1)` matches current behavior
    Manual(NonZeroU8),
    // Whenever beneficiary calls (new)`claim` it can unlock up to the amount that the schedule allows
    // E.g:
    // `Release::Auto{ duration: "30day".into(), start: "-10day".into(), initial: 5 }`
    // A payment of `100 abc` the 10th of the month would on day 0 have 5% of the total amount unlocked
    // the remaining 95% is split evenly along the duration, calling `claim` right after the creation
    // would unlock 10 days worth of pay(on top of the 5%) 
    Auto {
        duration: BlockNumberOf<T>,
        start: i32, // relative to the time of creation to allow tx to be resubmitted without changes
        initial: Percent,
    }
}
@olanod olanod changed the title Payment release strategy Generalized payment release strategy Apr 19, 2024
@olanod olanod added the payments payments pallet label Apr 19, 2024
@olanod
Copy link
Member Author

olanod commented Apr 19, 2024

NOTE: We use request_refund to cancel from the sender perspective and cancel for beneficiaries to return funds immediately, with the updated release strategy the semantics of "request refund" change, for simplicity I think we can deprecate request_refund and have only cancel for both sender and beneficiary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
payments payments pallet
Projects
None yet
Development

No branches or pull requests

1 participant