Coder Social home page Coder Social logo

crytotech / apeswap-swap-periphery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apeswapfinance/apeswap-swap-periphery

0.0 0.0 0.0 1.37 MB

Ape Swap periphery and router contracts to make swapping easier.

License: GNU General Public License v3.0

Shell 0.16% JavaScript 9.38% TypeScript 16.39% Solidity 74.07%

apeswap-swap-periphery's Introduction

ApeSwap Periphery

The ApeSwap periphery contracts, commonly known as the "Router", handles important checks regarding interacting with the core DEX contracts. This is related to the main functionality of the DEX which includes adding/removing liquidity and swapping tokens.

The periphery contracts are unique in that they don't hold any value, it just manages transferring the proper amount of tokens to the proper contracts for the core DEX contracts to properly do their work.

Because the periphery contracts hold no value, they can be easily upgraded and improved without requiring a DEX migration.

Configuration

Environment

To deploy/verify contracts copy .env.example and rename it .env. Fill in the variables in this file to deploy to different networks and verify the contracts after.

Truffle

The truffle-config.js is used to configure deployable networks

Setting up a new DEX

Deploying a periphery contract to work with a new set of DEX core contracts requires an update to the contract code for ApeLibrary.sol in the pairFor function.

This function pre-computes a pair address before creation and requires that the hex value match the INIT_CODE_PAIR_HASH of the core pair contract. On the deployed factory that the periphery contract is intended to be linked to, there is a public variable INIT_CODE_PAIR_HASH that should be used to replace the hex value in ApeLibrary.sol. (Remember to remove the 0x before the hash)

Commands

The following assumes the use of node@>=12.

Install Dependencies

yarn

Compile Contracts

npx truffle compile

Run Tests

yarn test

Migrate Contracts

Once the migration seed phrases are setup in .env and the truffle-config.js is configured for the network of your choice, contracts can be deployed to a specific network using: npx truffle migrate --network <network-name>

Local Development

  • Start a local blockchain npx ganache-cli
  • Deploy to local blockchain npx truffle migrate --network development

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.