
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@energi/energiswap-contracts
Advanced tools
Energiswap is a decentralized protocol for automated token exchange.
Make sure you are running Ganache CLI with the following command:
ganache-cli -a 12 -e 1000000 -l 10000000 -p 7545 -m "tackle crazy sibling hobby hurry cat donate abstract sword city
enough crime"
git clone git@git.energi.software:energi/defi/uniswap/energiswap-contracts.git
yarn install
to install the necessary dependencies for the project.truffle compile
to compile the contracts inside the contracts folder.truffle migrate
to deploy the contracts to the local ganache blockchain.Test contracts are defined under the test directory. To run the tests run:
truffle test
See the architecture diagram in ./energiswap-contracts-architecture-diagram.png
The following Energiswap contracts are fully upgradeable using Energi governance:
EnergiswapRouter.sol
EnergiswapFactory.sol
EnergiswapPairsManager.sol
In order to upgrade EnergiswapPairsERC20.sol
, one should deploy a new implementation for this contract, then deploy a
new implementation for EnergiswapPairsManager.sol
pointing to the new EnergiswapPairsERC20.sol
implementation, and
finally upgrade EnergiswapPairsManager.sol
to the new implementation using Energi governance.
EnergiswapPairsManager.sol
and EnergiswapPairsERC20.sol
hold the logic for Energiswap pairs. Upgrading those
contracts upgrades the logic for all Energiswap pairs.
WNRG.sol
contract is a dependency to Energiswap smart contracts, it must be deployed for Energiswap to work.
Multicall.sol
contract is a dependency to EnergiswapFactory and energiswap interface, it must be deployed for
Energiswap to work.
Energi governance contracts must be deployed prior to deploying Energiswap Contracts.
factory = await EnergiswapFactory.new(feeToSetter, sporkProxy, '0x0000000000000000000000000000000000000000');
feeToSetter
is the address of account which has permission to set the feeTo
account which will receive trading fees.
sporkProxy
is the address of the SporkProxy.sol
smart contract which is part of Energi governance infrastructure.
Setting the last parameter to 0x0000000000000000000000000000000000000000
will result in EnergiswapFactoryGovernedProxy
contract being deployed automatically. Alternatively, the address of an already deployed proxy contract can be passed.
The address of the deployed EnergiswapFactoryGovernedProxy
will be used later in the deployment process. It is available
via the proxy()
function of EnergiswapFactory
.
pairsERC20 = await EnergiswapPairsERC20.new();
pairsManager = await EnergiswapPairsManager.new(factoryProxyAddress, pairsERC20.address, sporkProxy, '0x0000000000000000000000000000000000000000');
factoryProxyAddress
is the address of the deployed EnergiswapFactoryGovernedProxy
contract.
pairsERC20.address
is the address of the deployed EnergiswapPairsERC20
contract.
sporkProxy
is the address of the SporkProxy.sol
smart contract which is part of Energi governance infrastructure.
Setting the last parameter to 0x0000000000000000000000000000000000000000
will result in EnergiswapPairsManagerGovernedProxy
contract being deployed automatically. Alternatively, the address of an already deployed proxy contract can be passed.
The address of the deployed EnergiswapPairsManagerGovernedProxy
will be used later in the deployment process. It is available
via the proxy()
function of EnergiswapPairsManager
.
await pairsERC20.initialize(pairsManager.address);
pairsManager.address
is the address of the deployed EnergiswapPairsManager
contract.
router = await EnergiswapRouter.new(factoryProxyAddress, wnrg.address, sporkProxy, '0x0000000000000000000000000000000000000000');
factoryProxyAddress
is the address of the deployed EnergiswapFactoryGovernedProxy
contract.
wnrg.address
is the address of the deployed WNRG
contract.
sporkProxy
is the address of the SporkProxy.sol
smart contract which is part of Energi governance infrastructure.
Setting the last parameter to 0x0000000000000000000000000000000000000000
will result in EnergiswapRouterGovernedProxy
contract being deployed automatically. Alternatively, the address of an already deployed proxy contract can be passed.
The address of the deployed EnergiswapRouterGovernedProxy
will be used later in the deployment process. It is available
via the proxy()
function of EnergiswapRouter
.
await factory.initialize(multicall.address, routerProxyAddress, pairsManagerProxyAddress, pairsERC20.address);
multicall.address
is the address of the deployed Multicall
contract.
routerProxyAddress
is the address of the deployed EnergiswapRouterGovernedProxy
contract.
pairsManagerProxyAddress
is the address of the deployed EnergiswapPairsManagerGovernedProxy
contract.
pairsERC20.address
is the address of the deployed EnergiswapPairsERC20
contract.
Start with deploying the desired upgrade implementation:
factoryUpgrade = await EnergiswapFactoryUpgrade.new(factoryStorageAddress, factoryProxyAddress);
factoryStorageAddress
is the address of the existing EnergiswapFactoryStorage
contract
factoryProxyAddress
is the address of the existing EnergiswapFactoryGovernedProxy
contract
pairsManagerUpgrade = await EnergiswapPairsManagerUpgrade.new(
pairsManagerProxyAddress,
pairsManagerStorageAddress,
pairsERC20Upgrade.address
);
pairsManagerProxyAddress
is the address of the existing EnergiswapPairsManagerGovernedProxy
contract
pairsManagerStorageAddress
is the address of the existing energiswapPairsManagerStorage
contract
pairsERC20Upgrade.address
is the address of the deployed EnergiswapPairsERC20
contract. This could be either the
former EnergiswapPairsERC20
contract, or a new EnergiswapPairsERC20Upgrade
contract.
pairsERC20Upgrade.initialize(pairsManagerUpgrade.address);
routerUpgrade = await EnergiswapRouterUpgrade.new(routerStorageAddress, routerProxyAddress);
routerStorageAddress
is the address of the existing EnergiswapRouterStorage
contract
routerProxyAddress
is the address of the existing EnergiswapRouterGovernedProxy
contract
Once this is done, call the proposeUpgrade()
function on the GovernedProxy
contract of the contract being upgraded,
with the address of the deployed upgrade implementation.
Masternode owners can now vote to accept or reject the proposed upgrade. If quorum majority is reached, the upgrade
proposal is accepted and anyone can now call the upgrade()
function on the GovernedProxy
contract of the contract
being upgraded, with the address of the deployed upgrade proposal.
FAQs
Smart contracts for Energiswap
The npm package @energi/energiswap-contracts receives a total of 5 weekly downloads. As such, @energi/energiswap-contracts popularity was classified as not popular.
We found that @energi/energiswap-contracts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.