### Common Testing Suite Setup Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Provides utilities for setting up a common testing environment, likely for integration tests of the DEX contracts. This includes mock stargate clients and contract instantiation helpers. ```rust pub fn create_default_test_case(mut app: App) -> (App, Addr, Addr, Addr, Addr, Addr, Addr) { let (mut app, epoch_manager_addr, farm_manager_addr, pool_manager_addr, fee_collector_addr, router_addr, amm_pair_addr) = create_all_contracts(app); let epoch_manager_addr = make_contract_addr(app.storage_mut(), epoch_manager_addr.to_string()); let farm_manager_addr = make_contract_addr(app.storage_mut(), farm_manager_addr.to_string()); let pool_manager_addr = make_contract_addr(app.storage_mut(), pool_manager_addr.to_string()); let fee_collector_addr = make_contract_addr(app.storage_mut(), fee_collector_addr.to_string()); let router_addr = make_contract_addr(app.storage_mut(), router_addr.to_string()); let amm_pair_addr = make_contract_addr(app.storage_mut(), amm_pair_addr.to_string()); (app, epoch_manager_addr, farm_manager_addr, pool_manager_addr, fee_collector_addr, router_addr, amm_pair_addr) } ``` -------------------------------- ### Running Tests and Optimization Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Commands to clone the repository, build the project, run tests, and optimize the code using Cargo and Just. Includes instructions for installing Just and checking test coverage with Cargo Tarpaulin. ```bash git clone --recurse https://github.com/code-423n4/2024-11-mantra-dex.git cd 2024-11-mantra-dex cargo build cargo test # If you don“t have `just`: `cargo install just` before proceeding just optimize ``` ```bash # For test coverage cargo tarpaulin -v ``` -------------------------------- ### MANTRA DEX Audit Process Overview Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Provides an overview of the MANTRA DEX audit lifecycle, from opening to closing, and the subsequent review process by the sponsor team and judges. It also mentions the potential start of PJQA (Pre-Judged Quality Assurance). ```APIDOC Audit Lifecycle: - Opening: Audit begins, wardens participate. - Closing: Audit period ends, submissions are finalized. - Review Phase: Sponsor team and judges review submitted findings. - PJQA: Pre-Judged Quality Assurance may commence during or after the review phase. - Results: Final audit results are communicated to participants. Key Timelines: - Judging ongoing: Review process is in progress. - PJQA start: Expected by the end of the week or the following week. - Results availability: Expected today or early next week. ``` -------------------------------- ### MANTRA DEX Audit Details Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Provides essential information about the MANTRA DEX audit, including the start and end dates, duration, and a link to the official audit page. It also mentions key MANTRA team members available for questions. ```en Audit opens Friday, 29 November 2024 (20:00 UTC) and runs through Monday, 13 January 2025 (20:00 UTC) (45 days). Audit Page: [https://code4rena.com/audits/2024-11-mantra-dex](https://code4rena.com/audits/2024-11-mantra-dex) Key MANTRA team members: @Delroy, @jvr0x, and @mantra_man ``` -------------------------------- ### MANTRA DEX Build and Deployment Scripts Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Provides an overview of the shell scripts used for building and deploying the MANTRA DEX smart contracts. Includes scripts for release builds, schema generation, and artifact size validation. ```sh build_release.sh build_schemas.sh check_artifacts_size.sh check_artifacts_size.sh 400 ``` -------------------------------- ### Epoch Manager - Contract Owner Altering Epoch Configuration Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Addresses the capability of the contract owner in the Epoch Manager to alter epoch configurations, which could impact farm reward calculations. It's noted that this is not intended after the contract instantiation and genesis epoch start. ```en - **[Epoch Manager]** - The contract owner can alter the epoch configuration, which could change the epoch values derived by the contract when querying the current epoch value, which is used when calculating farm rewards. Although this is possible, it is not intended to happen once the contract is instantiated and the genesis epoch starts. ``` -------------------------------- ### Token Factory Create Denom Command Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Handles the command for creating a new token denomination using the Token Factory module, specifying the name and symbol for the new token. ```rust pub fn execute_tokenfactory_create_denom( deps: DepsMut, env: Env, name: String, symbol: String, ) -> Result { let msg = TokenFactoryMsg::CreateDenom { create_denom: CreateDenom { name: name.to_string(), symbol: symbol.to_string(), }, }; Ok(Response::new().add_message(msg)) } ``` -------------------------------- ### Pool Manager Contract Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Defines the executable commands for the Pool Manager smart contract, covering pool creation, configuration updates, liquidity management, and swap operations. ```rust pub fn execute_pool_manager_commands( deps: DepsMut, env: Env, msg: PoolManagerExecuteMsg, ) -> Result { match msg { PoolManagerExecuteMsg::CreatePool { pool_config } => { create_pool(deps, env, pool_config) } PoolManagerExecuteMsg::UpdatePoolConfig { pool_id, config } => { update_pool_config(deps, pool_id, config) } PoolManagerExecuteMsg::AddLiquidity { pool_id, amounts, recipient, } => { add_liquidity(deps, env, pool_id, amounts, recipient) } PoolManagerExecuteMsg::RemoveLiquidity { pool_id, amounts, recipient, } => { remove_liquidity(deps, env, pool_id, amounts, recipient) } PoolManagerExecuteMsg::Swap { swap_request } => { perform_swap(deps, env, swap_request) } PoolManagerExecuteMsg::UpdateConfig { config } => { update_config(deps, config) } } } ``` -------------------------------- ### MANTRA DEX Just Recipes Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Lists the available 'just' recipes for building, optimizing, formatting, and generating schemas for the MANTRA DEX project. These recipes streamline common development tasks. ```sh just build just optimize just fmt just schemas ``` -------------------------------- ### MANTRA DEX Architecture Overview Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Provides an overview of the MANTRA DEX architecture, stating it is based on White Whale V2 and utilizes singleton contracts for easier management and integration. It also references a diagram illustrating contract dependencies. ```en MANTRA DEX is based on White Whale V2. The protocol is built around singleton contracts, which makes it easier to manage and integrate with other protocols. The following is the architecture of MANTRA DEX, and a general description of each contract: ![Mantra Mermaid](https://github.com/code-423n4/2024-11-mantra-dex/blob/main/mantramermaid.png?raw=true) The direction of the arrows represents the dependencies between the contracts. ``` -------------------------------- ### Epoch Manager API Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/epoch-manager/README.md API documentation for the Epoch Manager contract, detailing its configuration, hook management, and epoch creation functionalities. ```APIDOC EpochManager: __init__(epoch_config: EpochConfig) epoch_config: Configuration for epochs, including duration and genesis epoch time. create_epoch(): Description: Creates a new epoch. Can be called by anyone after the genesis epoch. Requires: Epoch duration has passed since the last epoch. Effects: Increments epoch ID, updates start time, triggers hooks. add_hook(contract_address: Addr): Description: Adds a contract to the list of hooks to be notified on epoch changes. Only callable by the owner. Parameters: contract_address: The address of the contract to add as a hook. Requires: Caller is the owner of the Epoch Manager. Effects: Adds the contract address to the HOOKS list. remove_hook(contract_address: Addr): Description: Removes a contract from the list of hooks. Only callable by the owner. Parameters: contract_address: The address of the contract to remove from hooks. Requires: Caller is the owner of the Epoch Manager. Effects: Removes the contract address from the HOOKS list. EpochChangedHookMsg(epoch: Epoch): epoch: Information about the newly created epoch. id: The ID of the new epoch. start_time: The start time of the new epoch. ``` -------------------------------- ### Token Factory Mint Command Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Handles the command for minting new tokens using the Token Factory module, specifying the amount and the recipient of the minted tokens. ```rust pub fn execute_tokenfactory_mint( deps: DepsMut, env: Env, amount: Uint128, denom: String, recipient: String, ) -> Result { let msg = TokenFactoryMsg::MintTokens { mint: MintTokens { amount: amount.u128(), denom: denom.to_string(), recipient: recipient.to_string() } }; Ok(Response::new().add_message(msg)) } ``` -------------------------------- ### Farm Manager Contract Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Defines the executable commands for the Farm Manager smart contract, covering operations like creating farms, updating farm configurations, managing rewards, and claiming rewards. ```rust pub fn execute_farm_manager_commands( deps: DepsMut, env: Env, msg: FarmManagerExecuteMsg, ) -> Result { match msg { FarmManagerExecuteMsg::CreateFarm { farm_config } => { create_farm(deps, env, farm_config) } FarmManagerExecuteMsg::UpdateFarm { farm_id, farm_config } => { update_farm(deps, farm_id, farm_config) } FarmManagerExecuteMsg::RemoveFarm { farm_id } => { remove_farm(deps, farm_id) } FarmManagerExecuteMsg::AddRewardToFarm { farm_id, reward_config, } => { add_reward_to_farm(deps, farm_id, reward_config) } FarmManagerExecuteMsg::UpdateRewardToFarm { farm_id, reward_config, } => { update_reward_to_farm(deps, farm_id, reward_config) } FarmManagerExecuteMsg::RemoveRewardFromFarm { farm_id, reward_denom, } => { remove_reward_from_farm(deps, farm_id, reward_denom) } FarmManagerExecuteMsg::Deposit { farm_id, amount, denom, } => { deposit(deps, env, farm_id, amount, denom) } FarmManagerExecuteMsg::Withdraw { farm_id, amount, denom, } => { withdraw(deps, env, farm_id, amount, denom) } FarmManagerExecuteMsg::ClaimRewards { farm_id } => { claim_rewards(deps, env, farm_id) } FarmManagerExecuteMsg::DistributeRewards { farm_id, epoch_id, } => { distribute_rewards(deps, env, farm_id, epoch_id) } FarmManagerExecuteMsg::UpdateConfig { config } => { update_config(deps, config) } } } ``` -------------------------------- ### Pool Manager Swap Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Commands for executing token swaps within the Pool Manager contract, including the logic for performing the actual swap operation based on the provided request. ```rust pub fn execute_swap_commands( deps: DepsMut, env: Env, msg: SwapExecuteMsg, ) -> Result { match msg { SwapExecuteMsg::Swap { swap_request } => { perform_swap(deps, env, swap_request) } } } ``` -------------------------------- ### Pool Manager API Reference Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/pool-manager/README.md Defines the core messages and functionalities for interacting with the Pool Manager contract, including pool creation, liquidity provision, withdrawals, and swaps. ```APIDOC CreatePool: message: CreatePool description: Creates a new AMM pool with specified parameters. parameters: asset_denoms: Array of strings representing the denominations of assets in the pool. fees: Object containing fee parameters for the pool. pool_type: String indicating the type of pool ('ConstantProduct' or 'StableSwap'). pool_creation_fee: Coin representing the fee for creating the pool. returns: Pool ID: Unique identifier for the newly created pool. ProvideLiquidity: message: ProvideLiquidity description: Allows users to deposit assets into a pool and receive LP tokens. parameters: pool_id: Identifier of the pool to deposit into. assets_to_deposit: Array of Coins representing the assets and amounts to deposit. min_lp_tokens: Minimum number of LP tokens expected by the user. returns: lp_tokens_minted: Coin representing the LP tokens minted to the user. WithdrawLiquidity: message: WithdrawLiquidity description: Allows users to redeem assets from a pool by burning LP tokens. parameters: pool_id: Identifier of the pool to withdraw from. lp_tokens_to_burn: Coin representing the LP tokens to burn. min_assets_received: Minimum number of assets expected by the user. returns: assets_received: Array of Coins representing the assets withdrawn by the user. Swap: message: Swap description: Executes a single-hop swap of assets within a pool. parameters: pool_id: Identifier of the pool for the swap. offer_asset: Coin representing the asset being offered for the swap. demand_asset: String representing the denomination of the asset being demanded. min_demand_amount: Minimum amount of the demand asset expected. returns: demand_amount_swapped: Coin representing the amount of the demand asset received. ExecuteSwapOperations: message: ExecuteSwapOperations description: Executes a multi-hop swap operation across multiple pools. parameters: operations: Array of SwapOperation objects defining the swap route. min_amount_out: Minimum amount of the final asset expected. returns: amount_out: Coin representing the final amount of the asset received. Pool Types: ConstantProduct: Suitable for assets with varying values. StableSwap: Suitable for assets with equivalent or near-equivalent values (e.g., stablecoins). ``` -------------------------------- ### Pool Manager Liquidity Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Specific commands for managing liquidity within pools, including adding and removing liquidity, and handling the associated token amounts and recipients. ```rust pub fn execute_liquidity_commands( deps: DepsMut, env: Env, msg: LiquidityExecuteMsg, ) -> Result { match msg { LiquidityExecuteMsg::AddLiquidity { pool_id, amounts, recipient, } => { add_liquidity(deps, env, pool_id, amounts, recipient) } LiquidityExecuteMsg::RemoveLiquidity { pool_id, amounts, recipient, } => { remove_liquidity(deps, env, pool_id, amounts, recipient) } } } ``` -------------------------------- ### Epoch Manager Contract Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Provides commands for interacting with the Epoch Manager smart contract, likely related to managing epochs, rewards, and other time-based functionalities within the DEX. ```rust pub fn execute_epoch_manager_commands( deps: DepsMut, env: Env, msg: EpochManagerExecuteMsg, ) -> Result { match msg { EpochManagerExecuteMsg::UpdateConfig { config } => { update_config(deps, config) } EpochManagerExecuteMsg::AddEpoch { epoch } => { add_epoch(deps, env, epoch) } EpochManagerExecuteMsg::RemoveEpoch { epoch_id } => { remove_epoch(deps, epoch_id) } EpochManagerExecuteMsg::UpdateEpoch { epoch } => { update_epoch(deps, epoch) } EpochManagerExecuteMsg::ClaimRewards { farm_id, epoch_id } => { claim_rewards(deps, env, farm_id, epoch_id) } EpochManagerExecuteMsg::DistributeRewards { farm_id, epoch_id } => { distribute_rewards(deps, env, farm_id, epoch_id) } } } ``` -------------------------------- ### Chat Log Interactive Functions Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Contains JavaScript functions to enhance the chat log experience. `highlightBlock` from highlight.js is used to syntax-highlight code blocks. `loadAnimation` from lottie-web is used to animate stickers. `scrollToMessage` provides smooth scrolling to a specific message with a highlight effect. `showSpoiler` reveals hidden spoiler content. ```javascript document.addEventListener('DOMContentLoaded',()=>{document.querySelectorAll('.chatlog__markdown-pre--multiline').forEach(e=>hljs.highlightBlock(e));});document.addEventListener('DOMContentLoaded',()=>{document.querySelectorAll('.chatlog__sticker--media[data-source]').forEach(e=>{const anim=lottie.loadAnimation({container:e,renderer:'svg',loop:true,autoplay:true,path:e.getAttribute('data-source')});anim.addEventListener('data_failed',()=>e.innerHTML='[Sticker cannot be rendered]');});});function scrollToMessage(event,id){const element=document.getElementById('chatlog__message-container-'+id);if(!element) return;event.preventDefault();element.classList.add('chatlog__message-container--highlighted');window.scrollTo({top:element.getBoundingClientRect().top-document.body.getBoundingClientRect().top-(window.innerHeight/2),behavior:'smooth'});window.setTimeout(()=>element.classList.remove('chatlog__message-container--highlighted'),2000);} function showSpoiler(event,element){if(!element) return;if(element.classList.contains('chatlog__attachment--hidden')){event.preventDefault();element.classList.remove('chatlog__attachment--hidden');} if(element.classList.contains('chatlog__markdown-spoiler--hidden')){event.preventDefault();element.classList.remove('chatlog__markdown-spoiler--hidden');}} ``` -------------------------------- ### Token Factory Burn Command Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Handles the command for burning tokens using the Token Factory module, specifying the amount and the denom of the tokens to be burned. ```rust pub fn execute_tokenfactory_burn( deps: DepsMut, env: Env, amount: Uint128, denom: String, ) -> Result { let msg = TokenFactoryMsg::BurnTokens { burn: BurnTokens { amount: amount.u128(), denom: denom.to_string(), }, }; Ok(Response::new().add_message(msg)) } ``` -------------------------------- ### Documentation Bot Assistance Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Explains how to interact with the documentation bot ('@Docs Wolf') for general questions about the codebase. It details that the bot will attempt to answer based on the codebase and documentation and provide relevant links. The bot is available during the audit period. ```en For general questions about the codebase, give our documentation bot a try, by tagging `@Docs Wolf` in any thread (private or public) and asking your question. The bot will make its best attempt to answer based on the codebase and documentation, and link you to relevant resources. _Docs Wolf will be available when the audit is live._ ``` -------------------------------- ### Pool Manager Operations Overview Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/pool-manager/README.md Visualizes the core operations of the Pool Manager contract, including pool creation, deposits/withdrawals, and swaps, along with their associated processes and outcomes. ```Mermaid graph LR A[Pool Manager] --> B(Pool Creation) A --> C(Deposits and Withdrawals) A --> D(Swaps) subgraph Pool Creation B --> E["CreatePool (User)"] E --> X[Fees Collected by Fee Collector] E --> F[Pools Map] end subgraph Deposits and Withdrawals C --> G["ProvideLiquidity (User)"] C --> H["WithdrawLiquidity (User)"] G --> I[LP Tokens Minted] H --> J[LP Tokens Burned] J --> Z[User gets assets equivalent to the LP shares burned] end subgraph Swaps D --> K["Swap (Single-hop)"] D --> L["ExecuteSwapOperations (Multi-hop)"] K --> M{Pool Balances Updated} L --> M M --> N[Fees Collected by Fee Collector] M --> O[Swap Fees Remain in Pool for LPs] end ``` -------------------------------- ### Farm Management Actions Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/farm-manager/README.md Defines the actions that can be performed on a farm within the Farm Manager contract. These include filling (creating or topping up) and closing farms. ```APIDOC FarmAction: Fill - Creates a new farm or tops up an existing one. - Requires a farm identifier (optional, contract generates if not provided). - Topping up requires the same token and an amount that is a multiple of the original farm's amount. Close - Closes an existing farm. - Requires the farm identifier. - Remaining tokens are sent to the farm owner. ``` -------------------------------- ### Farm Manager Overview Diagram Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/farm-manager/README.md A Mermaid diagram illustrating the overview of the Farm Manager, including farms, positions, and the reward claiming process. ```mermaid graph TD A[Farm Manager] --> B(Farms) A --> C(Positions) subgraph Farms B --> D["Create Farm (User)"] B --> E["Top up Farm (User)"] B --> F["Close Farm (Owner or Contract Owner)"] end subgraph Positions C --> G["Create Position (User)"] C --> H["Expand Position (User)"] C --> I["Close Position (User)"] C --> J["Withdraw Position (User)"] end L{On Epoch Changed} --> Q[Store LP weight for contract] N["Claim Farm Rewards (User)"] -->|Rewards go to user| O[Save user's last claimed epoch] N --> P[Save LP Weight History] ``` -------------------------------- ### Epoch Manager Hook Mechanism Diagram Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/epoch-manager/README.md A Mermaid diagram illustrating the Epoch Manager's hook mechanism. It shows how the Epoch Manager triggers epoch creation and notifies registered contracts when a new epoch is created. ```mermaid --- title: Epoch Manager Hook Mechanism --- flowchart E[Epoch Manager] -->|on_epoch_created| C1[Contract 1] E -.->|CreateEpoch| E E -->|on_epoch_created| C2[Contract 2] E -->|on_epoch_created| N[...] E -->|on_epoch_created| CN[Contract N] ``` -------------------------------- ### Position Management Actions Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/farm-manager/README.md Details the actions available for managing user positions in the Farm Manager contract, including creation, topping up, withdrawal, and emergency withdrawal. ```APIDOC PositionAction: Fill - Adds more LP tokens to an existing position. - Requires the position identifier. - Unlocking duration cannot be changed; the original duration is used. Close - Marks a position as closed. - Requires the position identifier. - Sets `Position.open` to false and `expiring_at` to the unlock block height. Withdraw - Retrieves LP tokens from a position after the unlocking duration is complete. - Requires the position identifier. EmergencyWithdraw - Immediately unlocks and withdraws LP tokens from a position. - Requires the position identifier and `emergency_unlock` parameter set to true. - Incurs a penalty fee sent to the Fee Collector. ``` -------------------------------- ### Farm Manager Contract Configuration Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/farm-manager/README.md Describes configuration parameters for the Farm Manager contract, specifically the maximum number of concurrent farms allowed for a given LP token denomination. ```APIDOC Config: max_concurrent_farms: uint - The maximum number of farms that can exist concurrently for a specific LP token denom. - Set during contract instantiation. ``` -------------------------------- ### MANTRA DEX Audit Timeline and Status Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].txt Provides a timeline of the MANTRA DEX audit, from its opening date to its closure and the subsequent review process. It also includes updates on the judging and PJQA phases. ```APIDOC Audit Timeline: - Opens: Friday, 29 November 2024 (20:00 UTC) - Closes: Monday, 13 January 2025 (20:00 UTC) - Duration: 45 days Post-Audit Process: - Review Period: Several weeks for sponsor team and judge review. - Judging Status: Ongoing. - PJQA Start: Expected by end of week or next week (relative to Jan 28, 2025). - Finalization: Everything done, including PJQA. Results expected today or early next week (relative to Feb 7, 2025). ``` -------------------------------- ### MANTRA DEX Audit Scope and Live Code Policy Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].txt Details the scope of the MANTRA DEX audit (version 1.0.0) and clarifies Code4rena's policy on 'live criticals' for deployed code. It specifies which parts of the codebase are currently deployed and how sensitive disclosures should be handled. ```APIDOC MANTRA DEX Audit Scope: - Version: 1.0.0 - In Scope Repositories: mantra-dex - Release History: https://github.com/MANTRA-Chain/mantra-dex/releases Live Criticals Policy: - Policy Link: https://docs.code4rena.com/awarding/incentive-model-and-awards#the-live-criticals-exception - Sensitive Disclosures: Only findings affecting deployed/live code should be submitted as sensitive disclosures. - Currently Deployed Code: - Pool Manager - Fee Collector - Expected to Deploy: - Farm Manager - Epoch Manager - Deployment Documentation: https://docs.mantrachain.io/mantra-smart-contracts/mantra_dex/deployments ``` -------------------------------- ### Mantra DEX Audit Award Distribution Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].txt Lists the awardees for the Mantra DEX audit, their USDC prize amounts, and summarizes the audit findings. It also includes a link to the Code4rena awarding process documentation and notes on tax reporting deadlines. ```APIDOC Project: Mantra DEX Audit Awards: - carrotsmuggler: $15,876.19 USDC - oakcobalt: $5,729.36 USDC - 0xAlix2 (@a_kalout, @ali_shehab): $4,436.61 USDC - Abdessamed: $4,383.96 USDC - Roman: $3,818.92 USDC - DadeKuma: $2,923.31 USDC - 0x1982us: $2,276.67 USDC - Bauchibred: $2,190.40 USDC - Tigerfrake: $1,348.43 USDC - LonnyFlash: $975.84 USDC - Rajkumar: $943.26 USDC - Egis_Security (@nmirchev8, @deth): $898.20 USDC - evokid: $821.08 USDC - DOWSERS (@desaperh, @Pepito, @n0kto): $618.84 USDC - Rhaydden: $484.27 USDC - peachtea3471: $396.53 USDC - Daniel526: $305.03 USDC - audinarey: $305.03 USDC - p0wd3r: $305.03 USDC - Lookman: $237.63 USDC - jasonxiale: $220.66 USDC - gegul: $183.96 USDC - 0x0: $96.48 USDC - Usagi: $12.22 USDC - Sparrow: $12.22 USDC Findings Summary: - High risk findings: 12 - Medium risk findings: 20 - Participating wardens: 45 Top Performers: - Top Hunter: carrotsmuggler - Top Gatherer: carrotsmuggler - Top QA report: Bauchibred Award Distribution: - Awards will be distributed on Polygon within the next week. Tax Reporting: - Awardees must complete tax reporting info within 30 days (by Thursday, 13 March 2025) to receive awards. - Link for tax reporting: https://docs.code4rena.com/awarding/incentive-model-and-awards/awarding-process#tax-information-for-code4rena-contributors-wardens-judges-etc - Website may take a week to reflect submitted tax information. Related Documentation: - Awarding process overview: https://docs.code4rena.com/awarding/incentive-model-and-awards/awarding-process ``` -------------------------------- ### NSLOC Confirmation Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html A brief exchange confirming the total number of non-comment source lines of code (NSLOC) for the project. ```en rudhra Did total nsloc 22268 ? Agontuk [11/30/2024 10:21](#chatlog__message-container-1312362878392733767) yes ``` -------------------------------- ### Farm Manager Position Commands Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Handles commands related to user positions within the Farm Manager contract, including depositing and withdrawing assets, and claiming accrued rewards. ```rust pub fn execute_position_commands( deps: DepsMut, env: Env, msg: PositionExecuteMsg, ) -> Result { match msg { PositionExecuteMsg::Deposit { farm_id, amount, denom, } => { deposit(deps, env, farm_id, amount, denom) } PositionExecuteMsg::Withdraw { farm_id, amount, denom, } => { withdraw(deps, env, farm_id, amount, denom) } PositionExecuteMsg::ClaimRewards { farm_id } => { claim_rewards(deps, env, farm_id) } PositionExecuteMsg::UpdateConfig { config } => { update_config(deps, config) } } } ``` -------------------------------- ### Ownership Utilities Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/scope.txt Contains utilities for managing ownership of contracts or modules, likely enforcing that only the owner can perform certain administrative actions. ```rust pub fn assert_owner(deps: &Deps, sender: &Addr) -> Result<(), ContractError> { let owner = get_owner(deps)?; if sender != &owner { Err(ContractError::Unauthorized { }) } else { Ok(()) } } ``` -------------------------------- ### Farm Manager - Minimal Farm Assets Amount Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Highlights an issue in the Farm Manager where the MIN_FARM_AMOUNT constant does not account for different currencies, potentially leading to issues with dust rewards. Mitigation is discussed through high farm creation fees, with a note that a dynamic solution involving oracles would be needed for full dynamic adjustment. ```en - **[Farm Manager]** - Minimal farm assets amount does not respect different currencies. The MIN_FARM_AMOUNT constant does not take into account different coins with varying monetary value, despite farms can use different denominations for rewards. The constant was essentially chosen to prevent creating farms with dust rewards. However, considering the farm creation fee is relatively high, that issue is mitigated. To make the MIN_FARM_AMOUNT value dynamic a solution involving oracles must be adopted, which is not in place at the moment. ``` -------------------------------- ### Chat Log Styling Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Provides comprehensive CSS rules for styling various elements within a chat log interface. This includes styling for generic embeds (videos, GIFs), Spotify embeds, YouTube embeds, stickers, reactions, markdown rendering (headers, lists, quotes, code blocks, mentions, spoilers), and timestamps. It also includes specific styling for highlighted messages and sticker animations. ```css .chatlog__embed-generic-video{object-fit:contain;object-position:left;max-width:45vw;max-height:500px;vertical-align:top;border-radius:3px}.chatlog__embed-generic-gifv{object-fit:contain;object-position:left;max-width:45vw;max-height:500px;vertical-align:top;border-radius:3px}.chatlog__embed-spotify{border:0}.chatlog__embed-youtube-container{margin-top:0.6rem}.chatlog__embed-youtube{border:0;border-radius:3px}.chatlog__sticker{width:180px;height:180px}.chatlog__sticker--media{max-width:100%;max-height:100%}.chatlog__reactions{display:flex}.chatlog__reaction{display:flex;margin:0.35rem 0.1rem 0.1rem 0;padding:0.125rem 0.375rem;border:1px solid transparent;border-radius:8px;background-color:#2f3136;align-items:center}.chatlog__reaction:hover{border:1px solid hsla(0,0%,100%,.2);background-color:transparent}.chatlog__reaction-count{min-width:9px;margin-left:0.35rem;color:#b9bbbe;font-size:0.875rem}.chatlog__reaction:hover .chatlog__reaction-count{color:#dcddde}.chatlog__markdown{max-width:100%;line-height:1.3;overflow-wrap:break-word}.chatlog__markdown h1{margin:1rem 0 0.5rem;color:#f2f3f5;font-size:1.5rem;line-height:1}.chatlog__markdown h2{margin:1rem 0 0.5rem;color:#f2f3f5;font-size:1.25rem;line-height:1}.chatlog__markdown h3{margin:1rem 0 0.5rem;color:#f2f3f5;font-size:1rem;line-height:1}.chatlog__markdown h1:first-child,h2:first-child,h3:first-child{margin-top:0.5rem}.chatlog__markdown ul,ol{margin:0 0 0 1rem;padding:0}.chatlog__markdown-preserve{white-space:pre-wrap}.chatlog__markdown-spoiler{background-color:rgba(255,255,255,0.1);padding:0 2px;border-radius:3px}.chatlog__markdown-spoiler--hidden{cursor:pointer;background-color:#202225;color:rgba(0,0,0,0)}.chatlog__markdown-spoiler--hidden:hover{background-color:rgba(32,34,37,0.8)}.chatlog__markdown-spoiler--hidden::selection{color:rgba(0,0,0,0)}.chatlog__markdown-quote{display:flex;margin:0.05rem 0}.chatlog__markdown-quote-border{margin-right:0.5rem;border:2px solid #4f545c;border-radius:3px}.chatlog__markdown-pre{background-color:#2f3136;font-family:"Consolas","Courier New",Courier,monospace;font-size:0.85rem;text-decoration:inherit}.chatlog__markdown-pre--multiline{display:block;margin-top:0.25rem;padding:0.5rem;border:2px solid #282b30;border-radius:5px;color:#b9bbbe}.chatlog__markdown-pre--multiline.hljs{background-color:#2f3136;color:#b9bbbe}.chatlog__markdown-pre--inline{display:inline-block;padding:2px;border-radius:3px}.chatlog__markdown-mention{border-radius:3px;padding:0 2px;background-color:rgba(88,101,242,.3);color:#dee0fc;font-weight:500}.chatlog__markdown-mention:hover{background-color:#5865f2;color:#ffffff}.chatlog__markdown-timestamp{background-color:rgba(255,255,255,0.1);padding:0 2px;border-radius:3px}.chatlog__emoji{width:1.325rem;height:1.325rem;margin:0 0.06rem;vertical-align:-0.4rem}.chatlog__emoji--small{width:1rem;height:1rem}.chatlog__emoji--large{width:2.8rem;height:2.8rem}.postamble{padding:1.25rem}.postamble__entry{color:#ffffff} ``` -------------------------------- ### Bug Acceptability in Customized Chains Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Discusses the scenario where a bug exists in a smart contract but is rendered invalid due to the specific on-chain execution logic of a customized chain like MANTRA. It highlights the potential challenge for auditors unfamiliar with the underlying implementation (e.g., Go implementation of Cosmos SDK). ```en OxElliot [12/13/2024 13:47](#chatlog__message-container-1317125855616696470) Hey @CloudEllie @Delroy @jvr0x I have a question about the acceptability of the bugs, For example if a Bug Explicitly Exists in the smart contract but due to the customized and application-specific logic of mantra chain that bug becomes invalid in on-chain execution, what would happen in that case? since some or most of the researchers auditing CosmWasm based Smart Contracts may not be familiar with the GO implementation of Cosmos SDK in customized chains ``` -------------------------------- ### EpochChangedHook Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/contracts/farm-manager/README.md Callback function triggered by the Epoch Manager when a new epoch begins. The Farm Manager uses this to snapshot LP token weights for reward calculation. ```APIDOC EpochChangedHook(new_epoch_id: uint) - Called by the Epoch Manager when a new epoch starts. - Farm Manager takes snapshots of LP token weights and stores them in `LP_WEIGHT_HISTORY` for the current epoch. - This data is used later for calculating user rewards. ``` -------------------------------- ### Preamble and Guild Icon Styling Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Styles the preamble section, which appears to contain guild information. It uses CSS Grid for layout, defining columns for an icon container and content. Specific styles are applied to the guild icon and entry text for size and appearance. ```css .preamble{display:grid;grid-template-columns:auto 1fr;max-width:100%;padding:1rem}.preamble__guild-icon-container{grid-column:1}.preamble__guild-icon{max-width:88px;max-height:88px}.preamble__entries-container{grid-column:2;margin-left:1rem}.preamble__entry{margin-bottom:0.15rem;color:#ffffff;font-size:1.4rem}.preamble__entry--small{font-size:1rem} ``` -------------------------------- ### Font Face Definitions Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/discord-export/Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html Defines multiple @font-face rules to load different variations of the 'gg sans' font. Each rule specifies the source URL for the font file (woff2 format) and the corresponding font-family, font-weight, and font-style. ```css @font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-normal-400-1456D.woff2");font-family:gg sans;font-weight:400;font-style:normal}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-normal-500-89CE5.woff2");font-family:gg sans;font-weight:500;font-style:normal}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-normal-600-C1EA8.woff2");font-family:gg sans;font-weight:600;font-style:normal}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-normal-700-1949A.woff2");font-family:gg sans;font-weight:700;font-style:normal}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-normal-800-58487.woff2");font-family:gg sans;font-weight:800;font-style:normal}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-italic-400-E988B.woff2");font-family:gg sans;font-weight:400;font-style:italic}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-italic-500-0777F.woff2");font-family:gg sans;font-weight:500;font-style:italic}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-italic-600-CB411.woff2");font-family:gg sans;font-weight:600;font-style:italic}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-italic-700-891AC.woff2");font-family:gg sans;font-weight:700;font-style:italic}@font-face{src:url("Code4rena - ARCHIVE-PUBLIC - mantra-dex-nov [1311080144613412996].html_Files/ggsans-italic-800-D36B0.woff2");font-family:gg sans;font-weight:800;font-style:italic} ``` -------------------------------- ### Farm Manager - Farm Creation Blocking Source: https://github.com/code-423n4/2024-11-mantra-dex/blob/main/README.md Discusses a scenario where an attacker could block legitimate farm creation in the Farm Manager by creating the maximum allowed number of farms for a given LP denom. Mitigation is discussed through high farm creation fees and the contract owner's ability to close spam farms. ```en - **[Farm Manager]** - Since the number of farms that can be created for a given LP denom is limited, the farm creation can be blocked if an attacker creates the maximum allowed number, preventing legitimate farm creators from creating meaningful farms. This is not a concern since the farm creation fee is set relatively high, making it unfeasible for someone to perform such an attack. Additionally, the contract owner has the ability to close spam farms if necessary. ```