maki-swap-lib
v2.1.0
Published
Maki Swap Library
Downloads
10
Readme
Maki Swap Lib
Solidity libraries that are shared across MakiSwap contracts. These libraries are focused on safety and gas efficiency.
Installing
Run yarn
to install dependencies.
Testing
Run yarn test
to execute the test suite.
Using
Install this in another project via yarn add maki-swap-lib
Then import the contracts via:
import "maki-swap-lib/contracts/access/Ownable.sol";
Test Results
AddressStringUtil
#toAsciiString
✓ zero address (63ms)
✓ own address
✓ random address
✓ reverts if len % 2 != 0
✓ reverts if len >= 40
✓ reverts if len == 0
✓ produces len characters (54ms)
FixedPoint
#encode
✓ shifts left by 112
✓ will not take >type(uint112).max
#encode144
✓ shifts left by 112
✓ will not take >type(uint144).max
#decode
✓ shifts right by 112
✓ will not take >type(uint224).max
#decode144
✓ shifts right by 112
✓ will not take >uint256(-1)
#div
✓ correct division
✓ throws for div by zero
#mul
✓ correct multiplication
✓ overflow
✓ max of q112x112
#fraction
✓ correct computation less than 1
✓ correct computation greater than 1
✓ fails with 0 denominator
#reciprocal
✓ works for 0.25
✓ fails for 0
✓ works for 5
#sqrt
✓ works for 25
✓ works with numbers less than 1
✓ works with 0
PairNamer
#pairName
✓ concatenation (134ms)
#pairSymbol
✓ concatenation (116ms)
SafeHRC20Namer
#tokenName
✓ works with compliant (66ms)
✓ works with noncompliant (62ms)
✓ works with empty bytes32 (63ms)
✓ works with noncompliant full bytes32 (68ms)
✓ works with optional (68ms)
✓ works with non-code address
✓ works with really long strings (91ms)
✓ falls back to address with empty strings (67ms)
#tokenSymbol
✓ works with compliant (66ms)
✓ works with noncompliant (61ms)
✓ works with empty bytes32 (59ms)
✓ works with noncompliant full bytes32 (68ms)
✓ works with optional (54ms)
✓ works with non-code address
✓ works with really long strings (93ms)
✓ falls back to address with empty strings (62ms)
SafeMathTest
#sqrt
✓ works for 0-99 (1088ms)
✓ max uint256
TransferHelper
#safeApprove
✓ succeeds with compliant with no revert and true return (103ms)
✓ fails with compliant with no revert and false return (76ms)
✓ fails with compliant with revert (63ms)
✓ succeeds with noncompliant (no return) with no revert (132ms)
✓ fails with noncompliant (no return) with revert (64ms)
#safeTransfer
✓ succeeds with compliant with no revert and true return (91ms)
✓ fails with compliant with no revert and false return (60ms)
✓ fails with compliant with revert (62ms)
✓ succeeds with noncompliant (no return) with no revert (92ms)
✓ fails with noncompliant (no return) with revert (63ms)
#safeTransferFrom
✓ succeeds with compliant with no revert and true return (87ms)
✓ fails with compliant with no revert and false return (60ms)
✓ fails with compliant with revert (65ms)
✓ succeeds with noncompliant (no return) with no revert (88ms)
✓ fails with noncompliant (no return) with revert (68ms)
#safeTransferHT
✓ succeeds call not reverted (144ms)
✓ fails if call reverts (62ms)
66 passing (5s)
✨ Done in 14.70s.