From 168059eda2b22b55275053e6a0d606f37e4467bf Mon Sep 17 00:00:00 2001 From: Jeremy Liu <31809888+NotJeremyLiu@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:53:30 -0400 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=9D=20Update=20ibc=20transfer=20ad?= =?UTF-8?q?apter=20readmes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../networks/neutron/ibc-transfer/README.md | 26 +++---------------- .../networks/osmosis/ibc-transfer/README.md | 15 +++-------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/contracts/networks/neutron/ibc-transfer/README.md b/contracts/networks/neutron/ibc-transfer/README.md index 661cddfb..f3e899c5 100644 --- a/contracts/networks/neutron/ibc-transfer/README.md +++ b/contracts/networks/neutron/ibc-transfer/README.md @@ -56,14 +56,14 @@ Dispatches an ICS-20 IBC Transfer given the parameters provided in the contract ## QueryMsg -### `in_progress_ibc_transfer` +### `in_progress_recover_address` -Returns the in progress ibc transfer info associated with the given `channel_id` and `sequence_id` (which make up a unique identifier mapped to in progress ibc transfers in the sub msg reply handler). +Returns the in progress recover address associated with the given `channel_id` and `sequence_id` (which make up a unique identifier mapped to in progress ibc transfers in the sub msg reply handler). Query: ``` json { - "in_progress_ibc_transfer": { + "in_progress_recover_address": { "channel_id": "channel-1", "sequence_id": 420 } @@ -72,23 +72,5 @@ Query: Response: ``` json -{ - "recover_address": "neutron...", - "coin": { - "denom": "uatom", - "amount": "1000000" - }, - "ack_fee": [ - { - "denom": "untrn", - "amount": "100000" - } - ], - "timeout_fee": [ - { - "denom": "untrn", - "amount": "100000" - } - ] -} +"neutron..." ``` \ No newline at end of file diff --git a/contracts/networks/osmosis/ibc-transfer/README.md b/contracts/networks/osmosis/ibc-transfer/README.md index a70667cd..d7d51667 100644 --- a/contracts/networks/osmosis/ibc-transfer/README.md +++ b/contracts/networks/osmosis/ibc-transfer/README.md @@ -48,14 +48,14 @@ Note: Fees sent as parameters with the contract call are unused by the contract ## QueryMsg -### `in_progress_ibc_transfer` +### `in_progress_recover_address` -Returns the in progress ibc transfer info associated with the given `channel_id` and `sequence_id` (which make up a unique identifier mapped to in progress ibc transfers in the sub msg reply handler). +Returns the in progress recover address associated with the given `channel_id` and `sequence_id` (which make up a unique identifier mapped to in progress ibc transfers in the sub msg reply handler). Query: ``` json { - "in_progress_ibc_transfer": { + "in_progress_recover_address": { "channel_id": "channel-1", "sequence_id": 420 } @@ -64,12 +64,5 @@ Query: Response: ``` json -{ - "recover_address": "osmo...", - "coin": { - "denom": "uosmo", - "amount": "1000000" - }, - "channel_id": "channel-1" -} +"osmo..." ``` \ No newline at end of file From dc13f062d662a8e8c454a61fcd74b2df75de4746 Mon Sep 17 00:00:00 2001 From: Jeremy Liu <31809888+NotJeremyLiu@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:53:59 -0400 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9D=20update=20entry=20point=20rea?= =?UTF-8?q?dme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/entry-point/README.md | 95 +++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 23 deletions(-) diff --git a/contracts/entry-point/README.md b/contracts/entry-point/README.md index 915d0e94..f4cbf251 100644 --- a/contracts/entry-point/README.md +++ b/contracts/entry-point/README.md @@ -4,8 +4,9 @@ The entry point contract is responsible for providing a standardized interface ( 1. Performs basic validation on the call data 2. If a fee swap is provided, queries the swap adapter contract to determine how much of the coin sent with the contract call is needed to receive the required fee coin(s), and dispatches the swap. 3. Dispatches the user swap provided in the call data to the relevant swap adapter contract. -4. Verifies the amount out received from the swap(s) is greater than the minimum amount required by the caller after all fees have been subtracted (swap, ibc, affiliate) -5. Dispatches one of the following post-swap actions with the received funds from the swap: +4. Handles affiliate fee payments if provided. +5. Verifies the amount out received from the swap(s) is greater than the minimum amount required by the caller after all fees have been subtracted (swap, ibc, affiliate) +6. Dispatches one of the following post-swap actions with the received funds from the swap: - Transfer to an address on the same chain - IBC transfer to an address on a different chain (which allows for multi-hop IBC transfers or contract calls if the destination chains support it) - Call a contract on the same chain @@ -40,22 +41,24 @@ Optional fields: Notes: - Only one coin can be sent to the contract when calling `swap_and_action` otherwise the transaction will fail. - `timeout_timestamp` is Unix epoch time in nanoseconds. The transaction will fail if the `timeout_timestamp` has passed when the contract is called. -- The `coin_in` field in `user_swap` is optional. If provided, the contract will attempt to swap the provided `coin_in`. If not provided, the contract will attempt to swap the coin that was sent to the contract by the caller minus the amount of that coin used by the `fee_swap`. - `post_swap_action` can be one of three actions: `bank_send`, `ibc_transfer`, or `contract_call`. - `bank_send`: Sends the assets received from the `user_swap` to an address on the same chain the swap occured on. - `ibc_transfer`: ICS-20 transfers the assets received from the swap(s) to an address on a different chain than the swap occured on. The ICS-20 transfer supports including a memo in the outgoing transfer, allowing for multi-hop transfers via Packet Forward Middleware and/or contract calls via IBC-hooks. - `contract_call`: Calls a contract on the same chain the swap occured, using the assets received from the swap as the contract call's funds. -- `affiliates` is a list of affiliates that will take a fee (in basis points) from the coin received from the `user_swap`. If no affiliates are associated with a call then an empty list is to be provided. +- `affiliates` is a list of affiliates that will take a fee (in basis points) from the `min_coin` provided. If no affiliates are associated with a call then an empty list is to be provided. +- The vector of coins provided in `ibc_info.fee` must all be the same denom. +- A `fee_swap` is only valid if the `post_swap_action` is an `ibc_transfer` with a provided `ibc_info.fee`. The `coin_out` used for the fee swap is dervied from the provided `ibc_info.fee`. +- The `coin_in` used in the `user_swap` is derived based on the coin sent to the contract from the user's contract call, after accounting for the fee swap and if the `user_swap` is a `SwapExactCoinIn` or `SwapExactCoinOut` + +#### Examples + +SwapExactCoinIn: ``` json { "swap_and_action": { "fee_swap": { "swap_venue_name": "neutron-astroport", - "coin_out": { - "denom": "untrn", - "amount": "200000" - }, "operations": [ { "pool": "neutron...", @@ -65,24 +68,75 @@ Notes: ] }, "user_swap": { - "swap_venue_name": "neutron-astroport", - "coin_in": { - "denom": "uatom", - "amount": "1000000" + "swap_exact_coin_in": { + "swap_venue_name": "neutron-astroport", + "operations": [ + { + "pool": "neutron...", + "denom_in": "uatom", + "denom_out": "untrn" + }, + { + "pool": "neutron...", + "denom_in": "untrn", + "denom_out": "uosmo" + } + ] }, + }, + "min_coin": { + "denom": "uosmo", + "amount": "1000000" + }, + "timeout_timestamp": 1000000000000, + "post_swap_action": { + "bank_send": { + "to_address": "neutron..." + } + }, + "affiliates": [ + { + "basis_points_fee": 10, + "address": "neutron..." + } + ] + } +} +``` + +SwapExactCoinOut: + +``` json +{ + "swap_and_action": { + "fee_swap": { + "swap_venue_name": "neutron-astroport", "operations": [ { "pool": "neutron...", "denom_in": "uatom", "denom_out": "untrn" - }, - { - "pool": "neutron...", - "denom_in": "untrn", - "denom_out": "uosmo" } ] }, + "user_swap": { + "swap_exact_coin_out": { + "swap_venue_name": "neutron-astroport", + "operations": [ + { + "pool": "neutron...", + "denom_in": "uatom", + "denom_out": "untrn" + }, + { + "pool": "neutron...", + "denom_in": "untrn", + "denom_out": "uosmo" + } + ], + "refund_address": "neutron..." + }, + }, "min_coin": { "denom": "uosmo", "amount": "1000000" @@ -122,12 +176,7 @@ Note: Can only be called by the entry point contract itself, any external calls "to_address": "neutron..." } }, - "affiliates": [ - { - "basis_points_fee": 10, - "address": "neutron..." - } - ] + "exact_out": false, } } ``` From 4eb4c85a6f9beaefefa6ae83dd7144443d248468 Mon Sep 17 00:00:00 2001 From: Jeremy Liu <31809888+NotJeremyLiu@users.noreply.github.com> Date: Thu, 3 Aug 2023 14:00:57 -0400 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20Add=20user=5Fswap=20example?= =?UTF-8?q?=20in=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/entry-point/README.md | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/contracts/entry-point/README.md b/contracts/entry-point/README.md index f4cbf251..ed5eb68c 100644 --- a/contracts/entry-point/README.md +++ b/contracts/entry-point/README.md @@ -157,6 +157,46 @@ SwapExactCoinOut: } ``` +### `user_swap` + +Dispatches the user swap to the relevant swap adapter contract and affiliate fee bank send messages. If the user swap is a `SwapExactCoinOut` it also dispatches the refund bank send message to the provided `refund_address` + +Note: Can only be called by the entry point contract itself, any external calls to this function will fail. + +``` json +{ + "user_swap": { + "swap": { + "swap_exact_coin_out": { + "swap_venue_name": "neutron-astroport", + "operations": [ + { + "pool": "neutron...", + "denom_in": "uatom", + "denom_out": "untrn" + }, + { + "pool": "neutron...", + "denom_in": "untrn", + "denom_out": "uosmo" + } + ], + "refund_address": "neutron..." + }, + }, + "min_coin": { + "denom": "uosmo", + "amount": "1000000" + }, + "remaining_coin": { + "denom": "uatom", + "amount": "100000" + }, + "affiliates": [] + } +} +``` + ### `post_swap_action` Performs a post swap action.