Skip to content

theghostmac/bonding-curve-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bonding Curve Test

Review

Analyzing the original BondingCurve, I could say that It is minimal and gas-efficient. It can handle larger numbers, although at the risk of overflows for them. Exponential operations expWad can easily overflow with large numbers, and the contract didn't protect against this.

More stuff:

  • High: No bounds on exponential calculations
  • Medium: No transaction size limits
  • Medium: No supply caps
  • Low: No event emissions for important state changes
// Original - more flexible but dangerous
function getAmountOut(uint256 x0, uint256 deltaY) public view returns (uint256 deltaX)

// This version - safer but more constrained
if (remainingSupply < MIN_REMAINING_SUPPLY) {
    revert InsufficientRemainingSupply(remainingSupply, MIN_REMAINING_SUPPLY);
}

The original version could be vulnerable to:

  • integer overflow attacks
  • economic attacks through large transactions
  • potential DOS through numerical limitations

Upon trying to solve this, I figured it comes at great costs like:

  • max supply must be lowered
  • transaction sizes must also be low/restricted
  • there's now more gas costs due to the checks being done

Usage

Build

$ forge build

Test

$ forge test -vvv

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

About

first - detailed - try on implementing bonding curve.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published