From 115e151748c2c5f0f1c2c4017d24bd61cf8fcd0a Mon Sep 17 00:00:00 2001 From: Antoni Mysliborski Date: Mon, 28 Nov 2022 21:03:30 +0100 Subject: [PATCH 1/2] ch: added Notion doc readme --- contracts/cw20-adapter/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contracts/cw20-adapter/README.md b/contracts/cw20-adapter/README.md index 6fdc036..085d747 100644 --- a/contracts/cw20-adapter/README.md +++ b/contracts/cw20-adapter/README.md @@ -2,6 +2,8 @@ Contract that allows exchanging CW-20 tokens for injective-chain issued native tokens (using Token Factory module) and vice-versa. +For more details refer to Notion doc: https://www.notion.so/injective/CW-20-to-TokenFactory-adapter-contract-specification-d56e37fd06af4c7e9b2d9b3447abea23 + ## Messages ### RegisterCw20Contract { addr: Addr } @@ -32,7 +34,7 @@ This method uses CW-20 `transfer` method (so it will not notify recipient in any Will redeem attached TF tokens (will fail if no registered tokens are provided) and will send CW-20 tokens to `recipient` contract. Caller may provide optional submessage -This method uses CW-20 `send` method +This method uses CW-20 `send` method, so the recipient must be a contract which adheres to cw20 Recipient specification. ### UpdateMetadata { addr : Addr} Will query cw20 address (if registered) for metadata and will call setMetadata in the bank module (using TokenFactory @@ -46,3 +48,6 @@ Return a list of registered CW-20 contracts ### NewDenomFee {} Returns a fee required to register a new token-factory denom + + + From 176fdba26e181bbcc2bcd49566c8de747064b1b7 Mon Sep 17 00:00:00 2001 From: Antoni Mysliborski Date: Tue, 29 Nov 2022 21:07:16 +0100 Subject: [PATCH 2/2] ch: docs update --- contracts/cw20-adapter/README.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/contracts/cw20-adapter/README.md b/contracts/cw20-adapter/README.md index 085d747..26a74c8 100644 --- a/contracts/cw20-adapter/README.md +++ b/contracts/cw20-adapter/README.md @@ -2,7 +2,22 @@ Contract that allows exchanging CW-20 tokens for injective-chain issued native tokens (using Token Factory module) and vice-versa. -For more details refer to Notion doc: https://www.notion.so/injective/CW-20-to-TokenFactory-adapter-contract-specification-d56e37fd06af4c7e9b2d9b3447abea23 +## Background + +CW-20 is a specification for fungible tokens in Cosmwasm, loosely based on ERC-20 specification. It allows creating and handling of arbitrary fungible tokens within Cosmwasm, specifying methods for creating, minting and burning and transferring those tokens between accounts. + +While CW-20 is relatively mature and complete standard, the tokens exists purely within cosmwasm context and are entirely managed by the issuing contract (including keeping track of account balances). That means that they cannot interact directly with any Injective/Cosmos chain functionality (for example it’s not possible to trade them on Injective exchange, or transfer without involving issuing contract) + +Considering the above, it’s necessary to provide some solution that would work as a bridge between CW20 and Injective bank module. + +### Goals + +Adapter contract allows exchanging CW-20 tokens for injective-chain issued native tokens (using Token Factory module) and vice-versa. Adapter contract should assure that only authorized source CW-20 contracts can mint tokens (to avoid faking tokens). + +Main functions of the contract are: +- register new CW-20 token +- exchange amount of X cw-20 tokens for X TF tokens (original cw-20 tokens will be held by the contract) +- exchange X TF tokens back for cw-20 tokens (cw-20 tokens are released and TF tokens are burned) ## Messages @@ -26,15 +41,17 @@ Upon receiving this message, adapter will: ### RedeemAndTransfer { recipient: Option } Will redeem attached TF tokens (will fail if no registered tokens are provided) and will transfer CW-20 tokens to `recipient`. If recipient is not provided, they will be sent -to the message caller. +to the message sender. -This method uses CW-20 `transfer` method (so it will not notify recipient in any way) +This method uses CW-20 `transfer` method. It will not notify recipient in any way, so it's not advisable +to use it to send tokens to a contract address. ### RedeemAndSend { recipient: String, submessage: Binary } Will redeem attached TF tokens (will fail if no registered tokens are provided) and will send CW-20 tokens to `recipient` contract. Caller may provide optional submessage -This method uses CW-20 `send` method, so the recipient must be a contract which adheres to cw20 Recipient specification. +This method uses CW-20 `send` method, so the recipient must be a contract which adheres to cw20 Recipient specification, +and should be able to react properly to funds sent this way. ### UpdateMetadata { addr : Addr} Will query cw20 address (if registered) for metadata and will call setMetadata in the bank module (using TokenFactory