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

ap-dapps-links-update #534

Merged
merged 19 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions docs/examples/DAO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ sidebar_position: 8

### What is DAO

A decentralized autonomous organization, or a DAO for short, is a new type of way to run organizations or institutions that enable individuals to work together for a specific cause in transparent, fair and honest ways. DAOs can be thought of as online groups of like-minded individuals that are also collectively owned and managed by the members themselves in equitable ways.
A decentralized autonomous organization, or DAO for short, is a novel approach to managing organizations or institutions that enables individuals to collaborate for a specific cause in transparent, fair, and honest ways. DAOs can be likened to online communities of like-minded individuals, collectively owned and managed by their members in equitable ways.

Decisions are governed by proposals and votes to ensure that everyone within a decentralized autonomous organization has a voice. This is significant because it means that no central entity can manipulate anything for personal gain or based on personal beliefs.
Decisions are made through proposals and votes, ensuring that every member within a decentralized autonomous organization has a voice. This is significant because it prevents any central entity from manipulating matters for personal gain or based on personal beliefs.

DAOs offer safe alternatives to pooling together money for a particular cause. But this isn’t just money that can be ordinarily managed by members. For instance, a group could set up a DAO to govern a charity to begin accepting donations and distributing aid accordingly. However, by far the biggest use cases for DAOs at the moment have been decentralized investment funds. This is where a group of investors create a venture fund that pools capital together and votes transparently on where to allocate the capital.
DAOs provide secure alternatives for pooling funds for a particular cause. It's not limited to ordinary financial management by members. For example, a group could establish a DAO to oversee a charity, accepting donations and distributing aid in an accountable manner. However, the most prominent use cases for DAOs at the moment involve decentralized investment funds. In such scenarios, a group of investors establishes a venture fund that combines capital and transparently votes on its allocation.

### DAO application example by Gear

Anyone can easily create their own DAO application and run it on the Gear Network. To do this, Gear created an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light).
Anyone can easily create their own DAO application and run it on the Gear Network. To facilitate this, Gear has provided an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light).

This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios.
This article explains the programming interface, data structure, basic functions, and their purposes. You can use it as-is or modify it to suit your own scenarios.

<!-- In addition, Gear provides an example implementation of the DAO user interface to demonstrate its interaction with the smart contract in the Gear Network. You can watch a video on how to get the DAO application up and running and its capabilities here: **https://youtu.be/6lxr7eojADw**. The source code for the DAO application is available on [GitHub](https://github.com/gear-foundation/dapps-dao-app).
-->
Expand Down Expand Up @@ -121,7 +121,7 @@ The actions that the contract receives outside are defined in enum `DaoActions`.

### DAO functions

- Joining the DAO. In order to send the DAO contract the tokens and become the DAO members a user has to send the following message:
- Joining DAO. To join the DAO and become a DAO member, a user needs to send the following message to the DAO contract:"

```rust
/// Deposits tokens to DAO
Expand Down Expand Up @@ -157,7 +157,7 @@ SubmitFundingProposal {
},
```

- The member or the delegate address of the member submits his vote (YES or NO) on the proposal.
- The member or the delegate address of the member submits their vote (YES or NO) on the proposal.

```rust
/// The member submits a vote (YES or NO) on the proposal.
Expand All @@ -176,7 +176,7 @@ SubmitVote {
},
```

- The right for members to withdraw their capital during the grace period. It can be used when the members don’t agree with the result of the proposal and the acceptance of that proposal can affect their shares. The member can ragequit only if he has voted NO on that proposal.
- Members have the option to withdraw their capital during a grace period. This feature is useful when members disagree with the outcome of a proposal, especially if the acceptance of that proposal could impact their shares. A member can initiate a 'ragequit' only if they have voted 'NO' on the proposal.

```rust
/// Withdraws the capital of the member
Expand All @@ -193,7 +193,7 @@ RageQuit {
},
```

- The proposal processing after the proposal competes during the grace period. If the proposal is accepted, the tribute tokens are deposited into the contract and new shares are minted and issued to the applicant. If the proposal is rejected, the tribute tokens are returned to the applicant.
- The proposal processing occurs after the proposal completes its grace period. If the proposal is accepted, the tribute tokens are deposited into the contract, and new shares are minted and issued to the applicant. In the event of rejection, the tribute tokens are returned to the applicant.

```rust
/// The proposal processing after the proposal completes during the grace period.
Expand All @@ -210,7 +210,7 @@ ProcessProposal {
proposal_id: u128,
},
```
- The ability to continue the transaction. Шf the transaction has not been completed due to network failure, the user can send a message `Continue` indicating the transaction id that needs to be completed:
- The option to resume the transaction is available. If a transaction hasn't been completed due to a network failure, the user can send a `Continue` message specifying the transaction ID that needs to be finalized:

```rust
/// Continues the transaction if it fails due to lack of gas
Expand All @@ -228,6 +228,8 @@ Continue(
## Consistency of contract states
The `DAO` contract interacts with the `fungible` token contract. Each transaction that changes the states of DAO and the fungible token is stored in the state until it is completed. User can complete a pending transaction by sending a message `Continue` indicating the transaction id. The idempotency of the fungible token contract allows to restart a transaction without duplicate changes which guarantees the state consistency of these 2 contracts.

The `DAO` contract interacts with the `fungible token` contract. Every transaction that alters the states of the DAO and the fungible token is recorded in the state until it is finalized. Users can complete a pending transaction by sending a `Continue` message along with the transaction ID. The idempotency feature of the fungible token contract allows transactions to be restarted without duplicating changes, ensuring the state consistency of these two contracts.

<!--
## User interface

Expand Down Expand Up @@ -299,7 +301,7 @@ extern "C" fn state() {
.expect("Failed to share state");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `DaoState` state. For example - [dao-light/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `DaoState` state. For example - [gear-foundation/dapps-dao/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dao/state):
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

```rust
#[metawasm]
Expand Down Expand Up @@ -329,7 +331,7 @@ pub trait Metawasm {
```

## Source code
The source code of this example of DAO smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light).
The source code for this DAO smart contract example and its testing implementation are available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light).

The extended version of DAO that includes admin, membership proposals and delegated voting can be found at [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao).

Expand Down
10 changes: 5 additions & 5 deletions docs/examples/crowdsale.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ sidebar_position: 19

## Introduction

A public offering to invest in a brand-new cryptocurrency or other digital asset is known as a cryptocurrency Crowdsale. A crowdsale can be used by new projects to raise money for development and other purposes. It is a time-limited campaign where investors can exchange their cryptocurrencies defined in the campaign to newly proposed tokens. The new tokens are promoted as future functional units after the crowdsale's funding goal is met and the project launches.
A public offering to invest in a brand-new cryptocurrency or other digital asset is known as a cryptocurrency crowdsale. A crowdsale can be used by new projects to raise money for development and other purposes. It is a time-limited campaign during which investors can exchange their cryptocurrencies, as defined in the campaign, for newly proposed tokens. These new tokens are promoted as future functional units once the crowdsale's funding goal is met, and the project launches.

An example of a crowdsale smart-contract implementation described in this article is one of many other decentralized applications that can be implemented and launched on Gear. This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own crowdsale application and run it on the Gear Network.
The example of a crowdsale smart contract implementation described in this article is just one of many decentralized applications that can be implemented and launched on Gear. This article explains the programming interface, data structure, basic functions, and their purposes. You can use it as-is or modify it to suit your own scenarios. Anyone can easily create their own crowdsale application and run it on a Gear-powered network.

Initial funds with which a token is purchased are determined by the Gear fungible tokens contract - [gFT](https://wiki.gear-tech.io/examples/gft-20). The contract's source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale).
The initial funds used to purchase a token are determined by the Gear fungible tokens contract - [gFT](gft-20). The contract's source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale).

## Interface
### Source files
1. `messages.rs` - contains function of the fungible token contract. Crowdsale contract interacts with fungible token contract through transfer_tokens function:
1. `messages.rs` - contains function of the fungible token contract. Crowdsale contract interacts with the fungible token contract through `transfer_tokens` function:
```rust
pub async fn transfer_tokens(
transaction_id: u64, // - associated transaction id
Expand Down Expand Up @@ -174,7 +174,7 @@ extern "C" fn state() {
);
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` state. For example - [crowdsale/state](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` state. For example - [gear-foundation/dapps-crowdsale/state](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale/state):
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

```rust
#[metawasm]
Expand Down
5 changes: 1 addition & 4 deletions docs/examples/dein.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ Decentralized Internet (DNS) demonstrates an on-chain server-less approach to we
Briefly the solution consists of a DNS program that is uploaded on-chain. It lists programs (smart-contracts) that are also uploaded on-chain and registered in DNS contract as DNS records. Hosted programs may have the user interface that resides on IPFS. The DNS program stores program ids and meta info of their interfaces (name, description and link).

The source code of the smart contract and frontend implementation is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/ddns).

<!--
Note that its repository contains a git submodule, so cloning should be done with the `--recurse-submodules` flag, i.e.:
```
git clone --recurse-submodules "https://github.com/gear-foundation/dapps"
git clone --recurse-submodules "https://github.com/gear-foundation/dapps/tree/master/contracts/ddns"
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved
```
-->

## Connect your dApp to the Decentralized Internet

Expand Down
25 changes: 13 additions & 12 deletions docs/examples/dex.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ sidebar_position: 21
# DEX (decentralized exchange)

## Introduction
A decentralized exchange (DEX for short) is a peer-to-peer marketplace where transactions occur directly between crypto traders. Unlike centralized exchanges like Binance, DEXs don’t allow for exchanges between fiat and crypto — instead, they exclusively trade cryptocurrency tokens for other cryptocurrency tokens.
Decentralized exchanges, on the other hand, are simply a set of smart contracts. They establish the prices of various cryptocurrencies against each algorithmically and use “liquidity pools” — in which investors lock funds in exchange for interest-like rewards — to facilitate trades.
While transactions on a centralized exchange are recorded on that exchange’s internal database, DEX transactions are settled directly on the blockchain.
DEXs are usually built on open-source code, meaning that anyone interested can see exactly how they work. That also means that developers can adapt existing code to create new competing projects — which is how Uniswap’s code has been adapted by an entire host of DEXs with “swap” in their names like Sushiswap and Pancakeswap.
A decentralized exchange (DEX, for short), is a peer-to-peer marketplace where transactions occur directly between cryptocurrency traders. Unlike centralized exchanges like Binance, DEXs don’t allow for exchanges between fiat and cryptocurrencies; instead, they exclusively trade cryptocurrency tokens for other cryptocurrency tokens.

The exchange uses [Gear fungible tokens (GFT-20)](/docs/examples/gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps/blob/master/contracts/gear-lib/src/tokens/fungible.rs) for the pair to keep track of the liquidity.
Decentralized exchanges, on the other hand, are essentially a set of smart contracts. They establish the prices of various cryptocurrencies algorithmically and use "liquidity pools," in which investors lock funds in exchange for interest-like rewards, to facilitate trades.

While transactions on a centralized exchange are recorded in that exchange's internal database, DEX transactions are settled directly on the blockchain.

DEXs are usually built on open-source code, meaning that anyone interested can see exactly how they work. This also means that developers can adapt existing code to create new competing projects, which is how Uniswap's code has been adapted by a whole host of DEXs with "swap" in their names, such as Sushiswap and Pancakeswap.

The exchange uses [Gear fungible tokens (GFT-20)](gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens/fungible) for the pair to keep track of the liquidity.
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

### Math
As it was said all the prices are algorithmically calculated. Investors provide funds to the liquidity pools and price is calculated according to the amount of tokens in the reserves using the following formula: <br/><br/>
$$reserve0 * reserve1 = K$$, where $$reserve0, reserve1$$ - are the reserves of token0 and token1 respectively provided by the investors, and $$K$$ - is the constant.
All the prices/amounts all calculated in the way that the $$K$$ **MUST** remain constant. This basically means that the more token0 we have in pool, the lower price of token1 will be when performing a swap.
All the prices/amounts all calculated in the way that the $$K$$ <strong>MUST</strong> remain constant. This basically means that the more token0 we have in pool, the lower price of token1 will be when performing a swap.
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

## Factory contract description
Taking into account that we might have a large amount of trading pairs, we should have a way to monitor them/deploy another one and etc. That's where a factory comes into play. Factory helps to create a new pair and monitor all the existing pairs.
Expand Down Expand Up @@ -127,7 +130,7 @@ extern "C" fn state() {
.expect("Failed to encode or reply with `<ContractMetadata as Metadata>::State` from `state()`");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` struct. For example - [dex/factory/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory/state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `State` struct. For example - [gear-foundation/dapps-dex/factory/state](https://github.com/gear-foundation/dapps-dex/tree/master/factory/state):
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

```rust
#[metawasm]
Expand Down Expand Up @@ -185,11 +188,9 @@ async fn create_pair(&mut self, mut token_a: ActorId, mut token_b: ActorId);
```

### Source code
The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [dex/factory](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory).
The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dex/tree/master/factory](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory).
AndrePanin marked this conversation as resolved.
Show resolved Hide resolved

<!--
See also an example of the smart contract testing implementation based on `gtest`: [dex/factory/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory/tests).
-->
See also an example of the smart contract testing implementation based on `gtest`: [tests/utils/factory.rs](https://github.com/gear-foundation/dapps/blob/master/contracts/dex/tests/utils/factory.rs).

For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article.

Expand Down Expand Up @@ -559,7 +560,7 @@ pub async fn swap_tokens_for_exact(&mut self, amount_out: u128, to: ActorId);
```

### Source code
The source code of this example of DEX pair smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps/dex](https://github.com/gear-foundation/dapps/tree/master/contracts/dex).
The source code of this example of DEX pair smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dex).

See also an example of the smart contract testing implementation based on `gtest`: [dex/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/tests).

Expand Down
Loading
Loading