Contracts of DEX with Curve-like invariant implementation. This contracts allows to exchange tokens with equal price. π΅ -> π°
Core concept is to provide low slippage swap between stablecoins like uUSD, kUSD, USDtz, etc.
Contract code was audited by Runtime Verification.
β./
βββ build/ # (gitignored) builded sources of contracts (*.json files)
ββββββββ lambdas/ # (gitignored) builded sources of contract lambdas (*.json files)
βββββββββββββ test/ # (gitignored) builded lambdas for tests (*.json files)
βββ contracts/ # contracts sources directory (*.ligo files)
ββββββββ main/ # the contracts to be compiled
βββββββββββββ dex.ligo # main DEX contract
βββββββββββββ dex_test.ligo # modified DEX contract for tests
ββββββββ partials/ # the code parts imported by main contracts
βββββββββββββ admin/ # admin part of DEX contact
βββββββββββββ dex_core/ # core codebase of DEX contact
βββββββββββββ fa2/ # token of FA2 standart sources for DEX contact
βββββββββββββ fa12/ # helpers for interaction with FA12 tokens for DEX contact
βββββββββββββ common_types.ligo # common types used for interaction with contracts
βββββββββββββ constants.ligo # constants that used in DEX contract
βββββββββββββ constants_test.ligo # modified constants that used in tests of DEX contract
βββββββββββββ errors.ligo # errors thrown from DEX contract
βββββββββββββ utils.ligo # utils for contracts
βββ migrations/ # migrations folder
ββββββββ NN_xxxx.ts # migration file with deployment data (storage and initial contract setup)
βββ test/ # test cases
βββββββββ storage/ # initial storage for contract originations
βββββββββ lambdas/ # *.json files that contains indexes and names of lambdas to be compiled
βββββββββ Dex/ # DEX test codebase
βββββββββββββ API/ # DEX contract base API
βββββββββ Token/ # Token (FA12/FA2) contract API
βββββββββ Dex.test.ts # main test case file
βββ scripts/ # cli for setup environment, test and deploy contracts
βββ .gitignore
βββ .eslintrc
βββ config.ts # configuration file for compile, deploy and test
βββ jest.setup.ts # setup environment file for jest tests
βββ jest.config.ts # configuration file of jest tests
βββ README.md # current file
βββ package.json
βββ yarn.lock
βββ tsconfig.json
This repository based on Docker and Node.js.
You can download Docker Desktop for your operative system at https://www.docker.com/products/docker-desktop. When download is ready, you can proceed to install it.
Same goes for Node.js, for which we suggest you download the LTS version for your system at https://nodejs.org/.
Suggested but not necessary, you can install Yarn package manager which will enable you to write shorter commands.
To start using this contracts, make sure you have all the needed packages to run it. To do so, in your Terminal just type:
npm i
or with yarn
yarn
Project provides cli interface for compile test and deploy contracts.
With cli you can compile
, compile-lambda
, start/stop sandbox
and migrate
(deploy contracts)
Launch npm run cli -- --help
or the shorter yarn cli --help
to see the full guide.
You can compile all contracts and lambdas with one simple command:
npm run compile
or with yarn
yarn compile
Or if you want to compile modified version for tests replace compile
with compile-for-test
This commands is shotcut for running yarn cli compile
and yarn cli compile-lambda
for specified contracts.
Tests are run by Jest, with a proper setup to write unit tests with Taquito.
You can find tests in the test
folder.
Testing is thought to be simulating user interaction with smart contract. This is to ensure that the expected usage of contract produces the expexted storage/operations in the Tezos blockchain.
To easily start a local Sandboxed environment (local Tezos network)
npm run start-sandbox
or, with Yarn
yarn start-sandbox
to easily start a local Sandboxed environment (local Tezos network) which processes blockchain packages much faster than real Tezos network. This makes you able to deploy a separate contract with a determined storage for every single unit test you might want to run.
Then you just need to run
npm run test
or, with Yarn
yarn test
and you'll see your tests being performed. If you want contracts to be compilled and the local sandbox to be started and stopped automatically every test run, please use the yarn compile-n-test
command.
Setup storage objects inside migrations. Replace null
values with needed and setup other params if needed.
This repository contains command that allows deploy the contracts to chosen network (from config.ts). To bring it up, just launch this command:
npm run migrate
or, with Yarn
yarn migrate
Pass --network=testnet
or --network=mainnet
to deploy in the specific network.
Pass --from <number>
or --to <number>
to deploy only specific migrations, provided at migrations directory.
Pass --key <string>
to deploy from specific account. By default this is "Alice" (edsk3QoqBuvdamxouPhin7swCvkQNgq4jP5KZPbwWNnwdZpSpJiEbq
) standard private key.
Made with β€οΈ by Madfish.Solutions