-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/update-mito-indexer
- Loading branch information
Showing
167 changed files
with
4,619 additions
and
1,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,100 @@ | ||
# Table of contents | ||
|
||
* [Getting Started](README.md) | ||
* [Technical Concepts](readme/technical-concepts.md) | ||
* [Application Concepts](readme/application-concepts.md) | ||
* [Assets](readme/assets/README.md) | ||
* [Creating Tokens](readme/assets/creating-tokens.md) | ||
* [Denom Client (deprecated)](readme/assets/denom-client.md) | ||
* [Injective Lists](readme/assets/injective-list.md) | ||
* [Networks](readme/networks.md) | ||
* [CosmJs Support](readme/getting-started-cosmjs.md) | ||
* [Running examples](readme/running-examples.md) | ||
* [Wallet](wallet/README.md) | ||
* [Accounts](wallet/wallet-accounts.md) | ||
* [Wallet Connections](wallet/wallet-connections.md) | ||
* [Wallet Strategy](wallet/wallet-wallet-strategy.md) | ||
* [Offchain (Arbitrary) Data](wallet/offchain-arbitrary-data.md) | ||
* [Querying](querying/README.md) | ||
* [Indexer](querying/querying-api/README.md) | ||
* [Account](querying/querying-api/querying-indexer-account.md) | ||
* [Auction](querying/querying-api/querying-indexer-auction.md) | ||
* [Derivatives](querying/querying-api/querying-indexer-derivatives.md) | ||
* [Explorer](querying/querying-api/querying-indexer-explorer.md) | ||
* [Insurance Funds](querying/querying-api/querying-indexer-insurance-funds.md) | ||
* [Markets](querying/querying-api/querying-indexer-markets.md) | ||
* [Leaderboard](querying/querying-api/querying-indexer-leaderboard.md) | ||
* [Mito](querying/querying-api/querying-indexer-mito.md) | ||
* [Oracle](querying/querying-api/querying-indexer-oracle.md) | ||
* [Portfolio](querying/querying-api/querying-indexer-portfolio.md) | ||
* [Spot](querying/querying-api/querying-indexer-spot.md) | ||
* [Web3Gw Transactions](querying/querying-api/querying-indexer-transaction.md) | ||
* [Streaming](querying/querying-api/streaming/README.md) | ||
* [Account](querying/querying-api/streaming/streaming-indexer-account.md) | ||
* [Auction](querying/querying-api/streaming/streaming-indexer-auction.md) | ||
* [Derivatives](querying/querying-api/streaming/streaming-indexer-derivatives.md) | ||
* [Oracle](querying/querying-api/streaming/streaming-indexer-oracle.md) | ||
* [Portfolio](querying/querying-api/streaming/streaming-indexer-portfolio.md) | ||
* [Spot](querying/querying-api/streaming/streaming-indexer-spot.md) | ||
* [Explorer](querying/querying-api/streaming/streaming-indexer-explorer.md) | ||
* [Chain](querying/querying-chain/README.md) | ||
* [Auction](querying/querying-chain/querying-chain-auction-module.md) | ||
* [Auth](querying/querying-chain/querying-chain-auth-module.md) | ||
* [Bank](querying/querying-chain/querying-chain-bank-module.md) | ||
* [Distribution](querying/querying-chain/querying-chain-distribution.md) | ||
* [Exchange](querying/querying-chain/querying-chain-exchange.md) | ||
* [Governance](querying/querying-chain/querying-chain-governance.md) | ||
* [IBC](querying/querying-chain/querying-chain-ibc.md) | ||
* [Mint](querying/querying-chain/querying-chain-mint.md) | ||
* [Insurance Funds](querying/querying-chain/querying-chain-insurance-funds.md) | ||
* [Oracle](querying/querying-chain/querying-chain-oracle.md) | ||
* [Peggy](querying/querying-chain/querying-chain-peggy.md) | ||
* [Permissions](querying/querying-chain/querying-chain-permissions.md) | ||
* [Staking](querying/querying-chain/querying-chain-staking.md) | ||
* [Tendermint](querying/querying-chain/querying-chain-tendermint.md) | ||
* [Wasm](querying/querying-chain/querying-chain-wasm.md) | ||
* [WasmX](querying/querying-chain/querying-chain-wasmx.md) | ||
* [Token Factory](querying/querying-chain/token-factory.md) | ||
* [Ethereum (GraphQL)](querying/querying-ethereum.md) | ||
* [Transactions](transactions/README.md) | ||
* [Cosmos](transactions/transactions-cosmos/README.md) | ||
* [Ledger through Keplr Wallet](transactions/transactions-cosmos/ledger-through-keplr-wallet.md) | ||
* [Ethereum](transactions/ethereum.md) | ||
* [Ethereum Ledger](transactions/ethereum-ledger.md) | ||
* [MsgBroadcaster](transactions/msgbroadcaster.md) | ||
* [Private Key](transactions/private-key.md) | ||
* [Web3 Gateway](transactions/web3-gateway.md) | ||
* [Core Modules](core-modules/README.md) | ||
* [Auction](core-modules/auction.md) | ||
* [AuthZ](core-modules/authz.md) | ||
* [Bank](core-modules/bank.md) | ||
* [Distribution](core-modules/distribution.md) | ||
* [Exchange](core-modules/exchange.md) | ||
* [Feegrant](core-modules/feegrant.md) | ||
* [Governance](core-modules/governance.md) | ||
* [IBC](core-modules/ibc.md) | ||
* [Insurance](core-modules/insurance.md) | ||
* [Peggy](core-modules/peggy.md) | ||
* [Permissions](core-modules/permissions.md) | ||
* [Staking](core-modules/staking.md) | ||
* [Tokenfactory](core-modules/token-factory.md) | ||
* [Wasm](core-modules/wasm.md) | ||
* [Bridge](bridge/README.md) | ||
* [Ethereum](bridge/ethereum.md) | ||
* [IBC](bridge/ibc.md) | ||
* [Wormhole](bridge/wormhole.md) | ||
* [Contracts](contracts/README.md) | ||
* [Injective Name Service](contracts/injective-name-service.md) | ||
* [Building dApps](building-dapps/README.md) | ||
* [Configuring Nuxt](building-dapps/configuring-nuxt.md) | ||
* [Configuring React](building-dapps/configuring-react.md) | ||
* [dApps Examples](building-dapps/dapps-examples/README.md) | ||
* [Smart Contract](building-dapps/smart-contract.md) | ||
* [DEX](building-dapps/dex.md) | ||
* [Bridge](building-dapps/bridge.md) | ||
* [Simple HTML example with Webpack](building-dapps/dapps-examples/simple-html-example-with-webpack.md) | ||
* [Calculations](calculations/README.md) | ||
* [Min Price Tick Size](calculations/min-price-tick-size.md) | ||
* [Min Quantity Tick Size](calculations/min-quantity-tick-size.md) | ||
- [Getting Started](README.md) | ||
- [Technical Concepts](readme/technical-concepts.md) | ||
- [Application Concepts](readme/application-concepts.md) | ||
- [Assets](readme/assets/README.md) | ||
- [Creating Tokens](readme/assets/creating-tokens.md) | ||
- [Denom Client (deprecated)](readme/assets/denom-client.md) | ||
- [Injective Lists](readme/assets/injective-list.md) | ||
- [Networks](readme/networks.md) | ||
- [CosmJs Support](readme/getting-started-cosmjs.md) | ||
- [Running examples](readme/running-examples.md) | ||
- [Wallet](wallet/README.md) | ||
- [Accounts](wallet/wallet-accounts.md) | ||
- [Wallet Connections](wallet/wallet-connections.md) | ||
- [Wallet Strategy](wallet/wallet-wallet-strategy.md) | ||
- [Offchain (Arbitrary) Data](wallet/offchain-arbitrary-data.md) | ||
- [Querying](querying/README.md) | ||
- [Indexer](querying/querying-api/README.md) | ||
- [Account](querying/querying-api/querying-indexer-account.md) | ||
- [Auction](querying/querying-api/querying-indexer-auction.md) | ||
- [Derivatives](querying/querying-api/querying-indexer-derivatives.md) | ||
- [Explorer](querying/querying-api/querying-indexer-explorer.md) | ||
- [Insurance Funds](querying/querying-api/querying-indexer-insurance-funds.md) | ||
- [Markets](querying/querying-api/querying-indexer-markets.md) | ||
- [Leaderboard](querying/querying-api/querying-indexer-leaderboard.md) | ||
- [Mito](querying/querying-api/querying-indexer-mito.md) | ||
- [Oracle](querying/querying-api/querying-indexer-oracle.md) | ||
- [Portfolio](querying/querying-api/querying-indexer-portfolio.md) | ||
- [Spot](querying/querying-api/querying-indexer-spot.md) | ||
- [Web3Gw Transactions](querying/querying-api/querying-indexer-transaction.md) | ||
- [Streaming](querying/querying-api/streaming/README.md) | ||
- [Account](querying/querying-api/streaming/streaming-indexer-account.md) | ||
- [Auction](querying/querying-api/streaming/streaming-indexer-auction.md) | ||
- [Derivatives](querying/querying-api/streaming/streaming-indexer-derivatives.md) | ||
- [Oracle](querying/querying-api/streaming/streaming-indexer-oracle.md) | ||
- [Portfolio](querying/querying-api/streaming/streaming-indexer-portfolio.md) | ||
- [Spot](querying/querying-api/streaming/streaming-indexer-spot.md) | ||
- [Explorer](querying/querying-api/streaming/streaming-indexer-explorer.md) | ||
- [Chain](querying/querying-chain/README.md) | ||
- [Auction](querying/querying-chain/querying-chain-auction-module.md) | ||
- [Auth](querying/querying-chain/querying-chain-auth-module.md) | ||
- [Bank](querying/querying-chain/querying-chain-bank-module.md) | ||
- [Distribution](querying/querying-chain/querying-chain-distribution.md) | ||
- [Exchange](querying/querying-chain/querying-chain-exchange.md) | ||
- [Governance](querying/querying-chain/querying-chain-governance.md) | ||
- [IBC](querying/querying-chain/querying-chain-ibc.md) | ||
- [Mint](querying/querying-chain/querying-chain-mint.md) | ||
- [Insurance Funds](querying/querying-chain/querying-chain-insurance-funds.md) | ||
- [Oracle](querying/querying-chain/querying-chain-oracle.md) | ||
- [Peggy](querying/querying-chain/querying-chain-peggy.md) | ||
- [Permissions](querying/querying-chain/querying-chain-permissions.md) | ||
- [Staking](querying/querying-chain/querying-chain-staking.md) | ||
- [Tendermint](querying/querying-chain/querying-chain-tendermint.md) | ||
- [Wasm](querying/querying-chain/querying-chain-wasm.md) | ||
- [WasmX](querying/querying-chain/querying-chain-wasmx.md) | ||
- [Token Factory](querying/querying-chain/token-factory.md) | ||
- [Ethereum (GraphQL)](querying/querying-ethereum.md) | ||
- [Transactions](transactions/README.md) | ||
- [Cosmos](transactions/transactions-cosmos/README.md) | ||
- [Ledger through Keplr Wallet](transactions/transactions-cosmos/ledger-through-keplr-wallet.md) | ||
- [Ethereum](transactions/ethereum.md) | ||
- [Ethereum Ledger](transactions/ethereum-ledger.md) | ||
- [MsgBroadcaster](transactions/msgbroadcaster.md) | ||
- [Private Key](transactions/private-key.md) | ||
- [Web3 Gateway](transactions/web3-gateway.md) | ||
- [Core Modules](core-modules/README.md) | ||
- [Auction](core-modules/auction.md) | ||
- [AuthZ](core-modules/authz.md) | ||
- [Bank](core-modules/bank.md) | ||
- [Distribution](core-modules/distribution.md) | ||
- [Exchange](core-modules/exchange.md) | ||
- [Feegrant](core-modules/feegrant.md) | ||
- [Governance](core-modules/governance.md) | ||
- [IBC](core-modules/ibc.md) | ||
- [Insurance](core-modules/insurance.md) | ||
- [Peggy](core-modules/peggy.md) | ||
- [Permissions](core-modules/permissions.md) | ||
- [Staking](core-modules/staking.md) | ||
- [Tokenfactory](core-modules/token-factory.md) | ||
- [Wasm](core-modules/wasm.md) | ||
- [Bridge](bridge/README.md) | ||
- [Ethereum](bridge/ethereum.md) | ||
- [IBC](bridge/ibc.md) | ||
- [Wormhole](bridge/wormhole.md) | ||
- [Contracts](contracts/README.md) | ||
- [Injective Name Service](contracts/injective-name-service.md) | ||
- [Neptune Service](contracts/neptune-service.md) | ||
- [CW20 to Bank & Market Order in One Transaction](contracts/cw20-convert-and-market-order-example.md) | ||
- [Building dApps](building-dapps/README.md) | ||
- [Configuring Nuxt](building-dapps/configuring-nuxt.md) | ||
- [Configuring React](building-dapps/configuring-react.md) | ||
- [dApps Examples](building-dapps/dapps-examples/README.md) | ||
- [Smart Contract](building-dapps/smart-contract.md) | ||
- [DEX](building-dapps/dex.md) | ||
- [Bridge](building-dapps/bridge.md) | ||
- [Simple HTML example with Webpack](building-dapps/dapps-examples/simple-html-example-with-webpack.md) | ||
- [Calculations](calculations/README.md) | ||
- [Min Price Tick Size](calculations/min-price-tick-size.md) | ||
- [Min Quantity Tick Size](calculations/min-quantity-tick-size.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# Contracts | ||
|
||
#### [What is CosmWasm?](./#what-is-cosmwasm-)[](https://docs.injective.network/develop/guides/cosmwasm-dapps/#what-is-cosmwasm) <a href="#user-content-what-is-cosmwasm" id="user-content-what-is-cosmwasm"></a> | ||
#### What is CosmWasm? | ||
|
||
CosmWasm is a novel smart contracting platform built for the Cosmos ecosystem. You can learn more about CosmWasm [here](https://docs.cosmwasm.com/docs/), or see the [CosmWasm Book](https://book.cosmwasm.com/index.html) for a guide on creating CosmWasm smart contracts. | ||
|
||
#### Specific Cosmwasm Contracts | ||
|
||
| Topic | Description | | ||
| --------------------------------------------------- | ---------------------- | | ||
| [Injective Name Service](injective-name-service.md) | Injective Name Service | | ||
| Topic | Description | | ||
| ------------------------------------------------------------------------------------------ | ---------------------- | | ||
| [Injective Name Service](injective-name-service.md) | Injective Name Service | | ||
| [Neptune Service](neptune-service.md) | Neptune Service | | ||
| [CW20 to Bank & Market Order in One Transaction](cw20-convert-and-market-order-example.md) | Convert Cw20 Example | |
54 changes: 54 additions & 0 deletions
54
.gitbook/contracts/cw20-convert-and-market-order-example.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Convert Cw20 to Bank and Place Market Order In One Transaction Example | ||
|
||
This example helps you create messages to convert CW20 tokens to bank tokens on the Injective blockchain. This is particularly useful when you have CW20 tokens and need to convert them to their bank equivalents to perform operations like placing market orders. Note that this flow only works for cw20 tokens and their corresponding [factory tokens](../readme/application-concepts.md). | ||
|
||
This guide will walk you through: | ||
|
||
- Obtaining the user's CW20 token balance. | ||
- Creating a message to convert CW20 tokens to bank tokens using ConvertCw20ToBankService | ||
- Executing a market order using the converted bank balance and existing bank balance | ||
|
||
## Get User's CW20 Balance | ||
|
||
[Detailed here](../querying/querying-api/querying-indexer-explorer.md#fetch-cw20-balances) | ||
|
||
- Find the cw20 address and balance from the result set that you want to convert to a bank factory token | ||
|
||
## Create CW20 to Bank Conversion Message | ||
|
||
- create the `convertMsg` using the steps detailed [here](../readme/application-concepts#example-on-how-to-convert-cw20-to-a-factory-denom) in order to convert your cw20 token to a bank factory token. No need to submit the tsx yet. | ||
|
||
## Create a `MsgCreateSpotMarketOrder` message | ||
|
||
- Create the `msg` using the steps detailed in [MsgCreateSpotMarketOrder](../core-modules/exchange.md#msgcreatespotmarketorder). No need to submit the tsx yet. | ||
- Note that the buy order you create will have access to your converted cw20 balance + existing bank balance. Example: | ||
|
||
```ts | ||
const order = { | ||
price: 1, | ||
quantity: 10, | ||
} | ||
``` | ||
|
||
- If you had 5 Cw20 tokens and 5 bank tokens at a price of $1 each, then the order above will go through because we will convert the cw20 to bank before the chain executes this market order. This will be more clear in the next step. | ||
|
||
## Place a Market Order Using Converted CW20 Balance and your existing bank balance | ||
|
||
Now that you have both messages formatted, you can convert your cw20 tokens to bank factory tokens and then place a market order using the combined balance, all in one transaction | ||
|
||
```ts | ||
import { MsgBroadcasterWithPk } from '@injectivelabs/sdk-ts' | ||
import { Network } from '@injectivelabs/networks' | ||
|
||
const privateKey = '0x...' | ||
const injectiveAddress = 'inj1...' | ||
|
||
const txHash = await new MsgBroadcasterWithPk({ | ||
privateKey, | ||
network: Network.MainnetSentry, | ||
}).broadcast({ | ||
msgs: [convertMsg, msg], // the convert to bank message executes first, Then, you will have that additional balance to complete your market order in the following msg | ||
}) | ||
|
||
console.log(txHash) | ||
``` |
Oops, something went wrong.