From bd8e0d04b8bd362f7c97cd81d526645b3ce09b9c Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Fri, 9 Sep 2022 19:28:30 +0300 Subject: [PATCH] adds example of a pool + removes entry fun (#4544) --- .../examples/defi/sources/pool.move | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/sui_programmability/examples/defi/sources/pool.move b/sui_programmability/examples/defi/sources/pool.move index a75757e015683..6597581f3f33b 100644 --- a/sui_programmability/examples/defi/sources/pool.move +++ b/sui_programmability/examples/defi/sources/pool.move @@ -9,6 +9,24 @@ /// - Fees are customizable per Pool. /// - Max stored value for both tokens is: U64_MAX / 10_000 /// +/// To publish a new pool, a type is required. Eg: +/// ``` +/// module me::my_pool { +/// use defi::pool; +/// +/// struct POOL_TEAM has drop {} +/// +/// entry fun create_pool( +/// token: Coin, +/// sui: Coin, +/// fee_percent: u64, +/// ctx: &mut TxContext +/// ) { +/// pool::create_pool(POOL_TEAM {}, token, sui, fee_percent, ctx) +/// } +/// } +/// ``` +/// /// This solution is rather simple and is based on the example from the Move repo: /// https://github.com/move-language/move/blob/main/language/documentation/examples/experimental/coin-swap/sources/CoinSwap.move module defi::pool { @@ -68,21 +86,6 @@ module defi::pool { /// to create a type which will mark LSPs. fun init(_: &mut TxContext) {} - /// Entrypoint for the `create_pool` method. - entry fun create_pool_( - witness: P, - token: Coin, - sui: Coin, - // share: u64, - fee_percent: u64, - ctx: &mut TxContext - ) { - transfer::transfer( - create_pool(witness, token, sui, /* share, */ fee_percent, ctx), - tx_context::sender(ctx) - ) - } - /// Create new `Pool` for token `T`. Each Pool holds a `Coin` /// and a `Coin`. Swaps are available in both directions. ///