|
| 1 | +# Converter Contract |
| 2 | + |
| 3 | +A CosmWasm smart contract for converting between MFX and different token denominations on the Manifest Network. This contract enables secure token conversion using configurable exchange rates and authorization mechanisms. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Converter contract facilitates the conversion of MFX tokens to target tokens at a predetermined exchange rate. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Token Conversion**: Convert between any two token denominations |
| 12 | +- **Configurable Exchange Rate**: Set custom conversion rates using decimal precision |
| 13 | +- **Pause Functionality**: Emergency pause mechanism to halt conversions |
| 14 | +- **Admin Controls**: Administrative functions for configuration management |
| 15 | + |
| 16 | +## Contract Architecture |
| 17 | + |
| 18 | +### Key Components |
| 19 | + |
| 20 | +- **Rate System**: Handles exchange rate calculations and validation |
| 21 | +- **Denomination Management**: Validates and manages source/target token types |
| 22 | +- **Admin Controls**: Manages contract administration and configuration updates |
| 23 | +- **Conversion Logic**: Orchestrates the burn-and-mint token conversion process |
| 24 | + |
| 25 | +### State Management |
| 26 | + |
| 27 | +The contract maintains: |
| 28 | +- **Config**: Core configuration including rates, denominations, and pause state |
| 29 | +- **Admin**: Contract administrator with privileged access |
| 30 | + |
| 31 | +## Messages |
| 32 | + |
| 33 | +### Instantiate |
| 34 | + |
| 35 | +Initialize the contract with configuration parameters: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "admin": "manifest1...", |
| 40 | + "poa_admin": "manifest1...", |
| 41 | + "rate": "1.5", |
| 42 | + "source_denom": "utoken1", |
| 43 | + "target_denom": "utoken2", |
| 44 | + "paused": false |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +### Execute Messages |
| 49 | + |
| 50 | +#### Convert |
| 51 | +Convert source tokens to target tokens: |
| 52 | +```json |
| 53 | +{ |
| 54 | + "convert": {} |
| 55 | +} |
| 56 | +``` |
| 57 | +*Note: Send the source tokens as funds with this message* |
| 58 | + |
| 59 | +#### Update Config |
| 60 | +Update contract configuration (admin only): |
| 61 | +```json |
| 62 | +{ |
| 63 | + "update_config": { |
| 64 | + "config": { |
| 65 | + "poa_admin": "manifest1...", |
| 66 | + "rate": "2.0", |
| 67 | + "source_denom": "unewtoken", |
| 68 | + "target_denom": "uanothertoken", |
| 69 | + "paused": true |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +#### Update Admin |
| 76 | +Transfer admin privileges (admin only): |
| 77 | +```json |
| 78 | +{ |
| 79 | + "update_admin": { |
| 80 | + "admin": "manifest1..." |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### Query Messages |
| 86 | + |
| 87 | +#### Config |
| 88 | +Get current contract configuration: |
| 89 | +```json |
| 90 | +{ |
| 91 | + "config": {} |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +#### Admin |
| 96 | +Get current admin address: |
| 97 | +```json |
| 98 | +{ |
| 99 | + "admin": {} |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +## Development |
| 104 | + |
| 105 | +### Building |
| 106 | +```bash |
| 107 | +cargo wasm |
| 108 | +``` |
| 109 | + |
| 110 | +### Testing |
| 111 | +```bash |
| 112 | +cargo test |
| 113 | +``` |
| 114 | + |
| 115 | +## Migration |
| 116 | + |
| 117 | +The contract supports migration with version checking to ensure compatibility. Migration logic can be extended as needed for future versions. |
| 118 | + |
| 119 | +## License |
| 120 | + |
| 121 | +Apache-2.0 |
| 122 | + |
| 123 | +## Links |
| 124 | + |
| 125 | +- **Repository**: https://github.com/manifest-network/manifest-contracts |
| 126 | +- **Homepage**: https://manifest.network |
0 commit comments