Skip to content

Commit

Permalink
Complete funding pool logic
Browse files Browse the repository at this point in the history
Renamed fees_recipient to funding_pool_forwarding for better naming
Made funding_pool_forwarding optional
Allow updating the funding_pool_forwarding by owner
Allow withdrawing from the funding pool by owner
  • Loading branch information
ismellike committed Apr 9, 2024
1 parent 11eaf88 commit b1e64f7
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 84 deletions.
12 changes: 6 additions & 6 deletions contracts/external/cw-abc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Each bonding curve has a pricing function, also known as the price curve (or `cu
With bonding curves, we will always know what the price of an asset will be based on supply! More on benefits later.

This contract implements two methods:
- `Buy {}` is called with sending along some reserve curency (such as $USDC, or whatever the bonding curve is backed by). The reserve currency is stored by the bonding curve contract, and new tokens are minted and sent to the user.
- `Sell {}` is called along with sending some supply currency (the token minted by the bonding curve). The supply tokens are burned, and reserve curency is returned.
- `Buy {}` is called with sending along some reserve currency (such as $USDC, or whatever the bonding curve is backed by). The reserve currency is stored by the bonding curve contract, and new tokens are minted and sent to the user.
- `Sell {}` is called along with sending some supply currency (the token minted by the bonding curve). The supply tokens are burned, and reserve currency is returned.

It is possible to use this contact as a basic bonding curve, without any of the augmented features.

Expand Down Expand Up @@ -64,7 +64,7 @@ Augmented Bonding Curves are nothing new, some articles that inspired this imple
- https://medium.com/commonsstack/deep-dive-augmented-bonding-curves-b5ca4fad4436
- https://tokeneconomy.co/token-bonding-curves-in-practice-3eb904720cb8

At a high level, augmented bonding curves extend bonding curves with new funcationality:
At a high level, augmented bonding curves extend bonding curves with new functionality:
- Entry and exit fees
- Different phases representing the life cycles of projects

Expand All @@ -74,7 +74,7 @@ Example Instantiation message:

``` json
{
"fees_recipient": "address that recieves fees",
"fees_recipient": "address that receives fees",
"token_issuer_code_id": 0,
"supply": {
"subdenom": "utokenname",
Expand Down Expand Up @@ -120,9 +120,9 @@ Example Instantiation message:
}
```

- `fees_recipient`: the address that will recieve fees (usually a DAO).
- `fees_recipient`: the address that will receive fees (usually a DAO).
- `token_issuer_code_id`: the CosmWasm code ID for a `cw-tokenfactory_issuer` contract.
- `supply`: infor about the token that will be minted by the curve. This is the token that is created by the bonding curve.
- `supply`: info about the token that will be minted by the curve. This is the token that is created by the bonding curve.
- `reserve`: this is the token that is used to mint the supply token.
- `curve_type`: information about the pricing curve.
- `phase_config`: configuration for the different phase of the augmented bonding curve.
Expand Down
90 changes: 77 additions & 13 deletions contracts/external/cw-abc/schema/cw-abc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"type": "object",
"required": [
"curve_type",
"fees_recipient",
"phase_config",
"reserve",
"supply"
Expand All @@ -22,9 +21,12 @@
}
]
},
"fees_recipient": {
"description": "The recipient for any fees collected from bonding curve operation",
"type": "string"
"funding_pool_forwarding": {
"description": "An optional address for automatically forwarding funding pool gains",
"type": [
"string",
"null"
]
},
"hatcher_allowlist": {
"description": "TODO different ways of doing this, for example DAO members? Using a whitelist contract? Merkle tree? Hatcher allowlist",
Expand Down Expand Up @@ -563,7 +565,7 @@
"additionalProperties": false
},
{
"description": "Donate will add reserve tokens to the funding pool",
"description": "Donate will donate tokens to the funding pool. You must send only reserve tokens.",
"type": "object",
"required": [
"donate"
Expand All @@ -576,6 +578,33 @@
},
"additionalProperties": false
},
{
"description": "Withdraw will withdraw tokens from the funding pool.",
"type": "object",
"required": [
"withdraw"
],
"properties": {
"withdraw": {
"type": "object",
"properties": {
"amount": {
"description": "The amount to withdraw (defaults to full amount).",
"anyOf": [
{
"$ref": "#/definitions/Uint128"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Sets (or unsets if set to None) the maximum supply",
"type": "object",
Expand Down Expand Up @@ -626,7 +655,7 @@
"additionalProperties": false
},
{
"description": "Update the hatch phase allowlist. This can only be called by the owner.",
"description": "Update the hatch phase allowlist. Only callable by owner.",
"type": "object",
"required": [
"update_hatch_allowlist"
Expand Down Expand Up @@ -659,6 +688,29 @@
},
"additionalProperties": false
},
{
"description": "Update the funding pool forwarding. Only callable by owner.",
"type": "object",
"required": [
"update_funding_pool_forwarding"
],
"properties": {
"update_funding_pool_forwarding": {
"type": "object",
"properties": {
"address": {
"description": "The address to receive the funding pool forwarding. Set to None to stop forwarding.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Update the configuration of a certain phase. This can only be called by the owner.",
"type": "object",
Expand Down Expand Up @@ -1114,13 +1166,13 @@
"additionalProperties": false
},
{
"description": "Returns the Fee Recipient for the contract. This is the address that receives any fees collected from bonding curve operation",
"description": "Returns the funding pool forwarding config for the contract. This is the address that receives any fees collected from bonding curve operation and donations",
"type": "object",
"required": [
"fees_recipient"
"funding_pool_forwarding"
],
"properties": {
"fees_recipient": {
"funding_pool_forwarding": {
"type": "object",
"additionalProperties": false
}
Expand Down Expand Up @@ -1471,11 +1523,23 @@
}
}
},
"fees_recipient": {
"funding_pool_forwarding": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Addr",
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
"title": "Nullable_Addr",
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
],
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.",
"type": "string"
}
}
},
"hatcher_allowlist": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Loading

0 comments on commit b1e64f7

Please sign in to comment.