Skip to content

codeislight1/optimized-apecoin-staking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ape Staking Gas Improvement Proposal

This repository contains the efficient implemented version of Ape Staking Contract, there were improvements in terms of variables packing (while respecting possible values according to the requirements), assigning variables before a loop (since it would assign a new memory slot on each iteration), using access modifiers as needed, calling Apecoin transfer and transferFrom once, using storage instead of memory to read from storage when suitable, using revert errors instead of require, usage of unchecked when overflow is impossible.

Dependencies

Install Node.js v16.2.0.

Run npm install to install dependencies.

Demonstration

a set of test cases have been conducted on all functions in question, showcasing gas costs optimization difference between original staking contract and optimized version.

optimization test case:

where numbersOfIterations is 10.

alt text

where numbersOfIterations is 1000, to more accurately average out the gas costs consumptions.

alt text

Setup

using local development is sufficient

to run unit tests:

navigate to test\test.ts

you may edit the testing variables, or leave them in the default state

then run npm run test

it would display at the end gas profiling table

About

Optimized Apecoin Staking Contract 🔨👷

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published