SpartanDev: 23/08/21 – 29/08/21

Dev Update

SpartanDev: 23/08/21 – 29/08/21

Happy first birthday to Spartan Protocol! Automated testing and DApp development continues towards aligning with the new contracts

SpartanDev: 23/08/21 – 29/08/21

Summary

Happy Birthday Spartans !!!

Thankyou for lending your support and determination to the shield-wall, it goes along way for a community driven project. Safe to say its been a pretty wild ride so far, we hope you have your seatbelts fastened because things are about to speed up.

Automated testing is in full swing, putting the protocol through the grinder and helping streamline processes. Whilst this has been happening the remaining contributors have been refining the DApp ready to take full use of V2 contracts. Onwards.

Read the full year in review here.

Spartan Protocol’s First Birthday
A Year In Review

Wednesday feeBurn Update

Spartan Socials — Twitter

Top Impressions:

Top Engagement:

Top Community Mention:

SpartanSocials — Medium

SpartanSocials — Telegram


Contributor’s Focus

CodeArena Contest

  • COMPLETED ✅ — triage and prioritise the feedback submitted from the CodeArena wardens during the contest to prepare for the judges
  • IN PROGRESS — work through the post-contest tasks with the C4 judges & team for the eventual allocation of awards to security wardens
  • IN PROGRESS — communicate with security wardens to clarify/expand on feedback

Once these tasks above are completed, the CodeArena report will be published, and Spartans will be able to review the final list of findings to understand how the changes that have already been implemented into Spartan Protocol (in the PostC5 repository) fit into this greater picture.

As discussed previously, we continue to build and refine code in parallel with the CodeArena post-contest actions.

SPARTA V2 (Token)

  • COMPLETED (& ONGOING) — Work with DEXs & aggregators to ensure up-to-date information on the new SPARTA token (retiring the previous contract address) (1inch, PancakeSwap etc.)
  • COMPLETED (& ONGOING) — Work with token-tracking informational websites to ensure new token info is up-to-date (BSCscan, CoinGecko, CoinMarketCap etc.)

SpartanContracts

  • COMPLETED ✅ — Sort and prioritise all CodeArena submissions into contract scopes along with tags based on ‘actionable’ or ‘discussion points’
  • COMPLETED ✅ (only minor changes as required from now on) — Implementing refinements to contracts to address C4 & contributor feedback since the C4 contest code-freeze
  • IN PROGRESS — Rebuild automated testing
  • Deploy updated V2 contracts to BSC testnet for at least 1 week of community stress testing
  • Deploy completed V2 contracts to BSC mainnet

DAppV2

  • COMPLETED (& ONGOING) — Set up a reliable index of history scoped to contracts (use this for positions page etc)
  • IN PROGRESS — Update the DApp to suit the contract changes
  • IN PROGRESS — Use the new testnet subgraph to build a more lightweight positions page for V2

After Mainnet

  • Enable Bond allocations to replenish TVL into the V2 pools
  • March onwards with our original goals of building the decentralised, yield-generating synthetics protocol on Binance Smart Chain

GitHub Activity — SpartanContractsV2 (PostC5 Branch)

contracts/BondVault.sol

  1. Updated comments

contracts/Dao.sol

  1. Updated comments
  2. Changed nested mappings to private and created getters/helpers instead
  3. Removed transfer require() from moveBASEBalance()

contracts/DaoVault.sol

  1. Updated comments
  2. Removed old mappings
  3. Added purgeDeployer()
  4. Fixed getMemberPoolDepositTime() helper (was pointing to wrong mapping)

contracts/Pool.sol

  1. Updated comments
  2. Added PoolFactory to onlyPROTOCOL() modifier
  3. Added Router to onlyDAO() modifier
  4. Changed baseCap to WEI in constructor
  5. Changes to safetyCheck()
  • Changed to run every time even if the pool’s freeze status is already true
  • Now we check the rate every time but *only* update the oldRate if an hour has passed and the pool’s status is not frozen
  • Added extra logic for if the pool is frozen to automatically handle the freeze status
  • If the pool is frozen but the ratio is back at safe levels; flick frozen status to false (for the pool; not global)
  • If the pool is frozen and 1 hour has passed; have the ratio of the pool come towards the new rate at a 25% weighted rate. ie. (currentRate + (oldRate * 3) ) / 4

contracts/Reserve.sol

  1. Added a freezeTime variable to potentially handle auto-unfreeze

contracts/Router.sol

  1. Updated comments
  2. Removed feeAllocation variable and assignment (no longer used; was apart of older more complex dividend logic)
  3. Added purgeDeployer()
  4. addLiquidityAsymForMember() — changed back to use the pool’s swap function instead of interfacing with the Router’s swap function (this also removes the dividend component)
  5. zapLiquidity() — removed dividend logic (save gas)
  6. swapSynthToAsset() — moved the swapPool requires inside the else {} statement to avoid wasted logic/gas
  7. _addDividend() — bypass dividend if emissions are off
  8. currentPoolRevenue() — removed helper (use mapping instead)
  9. pastPoolRevenue() — removed helper (use mapping instead)
  10. Removed unneeded require() for transfers between contracts:
  • removeLiquidityExactAsym()
  • zapLiquidity()
  • swapAssetToSynth()
  • _handleTransferIn()

8. Added require() for globalFreeze to be false after the safetyCheck

  • swapAssetToSynth()
  • swapSynthToAsset()

contracts/poolFactory.sol

  1. Updated comments
  2. Added require() to prevent a SPARTAv2:SPARTAv2 pool
  3. _handleTransferIn() — removed unneeded require() for transfers between contracts

contracts/synthVault.sol

  1. Changed non-nested mappings to public and removed helper

test/1_pool.js

Recreated automated tests:

  • Create pools — BNB & TOKEN
  • Add liquidity Symmetrical — BNB, TOKEN & SPARTA
  • Add liquidity Asymmetrical — BNB, TOKEN & SPARTA
  • Remove Liquidity Symmetrical — BNB, TOKEN & SPARTA
  • Remove Liquidity Asymmetrical — BNB, TOKEN & SPARTA

test/2_swap.js

Recreated automated tests:

  • Swap SPARTA to BNB
  • Swap BNB to SPARTA
  • Swap SPARTA for TOKEN
  • Swap TOKEN for SPARTA
  • Curate pools
  • ZapLiquidity
  • Create Synths
  • Swap SPARTA to TOKENs
  • Swap BNB for BNBs
  • Swap BNBs to SPARTA
  • Swap TOKEN for TOKENs
  • Swap TOKENs to TOKEN

test/math.js

  • Updated math to suit contract changes

test/utils.js

  • Updated utils to suit contract changes

GitHub Activity — SpartanDAppV2 (V2TN Branch)

package.json

  1. Updated bootstrap to v5.1.0
  2. Updated react-bootstrap to v2.0.0-beta.5

*.scss

  1. Fixed font-family mismatches; pointed most of them to the fonts stated in the variables file
  2. Reduced some card/input padding

src/components/Supply/Supply.js

  1. Updated layout
  2. Added icons and info tooltips
  3. Added external-link to tokenomics info (documentation)

src/components/Tooltip/tooltip.js

Added in tooltips for:

  • New pool / initializing period info
  • New pool ratio confirm info
  • New pool fee confirm info

src/components/WalletSelect/WalletSelect.js

  • Realigned the header section; moved copy button up next to wallet address

src/components/WalletSelect/walletTypes.js

  • Reduced size of wallet selections and icons (need to fix colours and fine-tune the icon sizes here still)

src/routes.js

  • Changed ‘CodeArena’ page to ‘Donate’ page

src/store/pool/actions.js

  • Updated redux actions to suit the changes to the Pool contracts

src/utils/web3Dao.js

  • Created new utils file specifically for simulating the Dao contract functions maths off-chain
  • Recreated just the bond calculations for now with all the returns we might need for UI

src/utils/web3Router.js

  • Created new utils file specifically for simulating the Router contract functions maths off-chain
  • Recreated all the math/calculations with lots of helpful returns as may be required throughout the dapp
  • Used this to refactor out a lot of the messy logic inside the views/components

src/utils/web3Utils.js

  • Ripped out irrelevant maths/logic
  • Rewrote the maths/calcs to handle all the Utils contract functions off-chain
  • minusFeeBurn() — added function to convert a wei input to its value minus the calculated feeBurn for that value transfer. Used to refactor throughout the codebase
  • convertTimeUnits() — added function to convert seconds to the most readable unit (days, hours, minutes, seconds) along with another string-return for the unit’s label. Used to refactor throughout
  • getTimeUntil() — added function to calculate seconds to then hand to convertTimeUnits() and get a countdown of time until a timestamp
  • getTimeSince() — added function to calculate seconds to then hand to convertTimeUnits() and get an amount of time passed since a timestamp

src/views/pages/Dao/ProposalItem.js

  • Refactored all time calculations to use the new Utils functions above

src/views/pages/Donate/Overview.js

  • Converted CodeArena donation page to general Donation page
  • Updated all the text on the page with more current placeholder text
  • This page will eventually be repurposed with a tile per ‘expense/budget/project’ which people can choose to specifically donate to/for

src/views/pages/Home/NewPool.js

  • Cleaned up the input-label alignments
  • Added confirm switch for the new-pool-fee (1% LP token fee for whoever creates the pool to reduce spam and protect pools from super-edge-case rounding/infinite ratio attacks/bugs)

src/views/pages/Home/Overview.js

  • Combined page header/breadcrumb section with an info/summary section (this will need a community contributor to pad out the info/icons here)
  • Created new tabs for ‘type’ of pool; Curated, Standard & New
  • Curated = pools that have been curated by the DAO to be enabled for dividends, vaultWeight, synths & DAO proposal weight
  • Standard = a normal AMM pool that has been live for more that 7 days.
  • New = a normal pool that was deployed less than 7 days ago. *Liquidity can not be removed from ‘New’ pools until 7 days have passed* other than that they act as normal pools (add liquidity and swap)
  • This page is ready for UI contributors to clean up/style and add text as required

src/views/pages/Pools/Components/TxnModal.js

  • Added modal to the AddLiq page to confirm txn inputs/outputs
  • Handle new pools; show a switch to confirm you understand liquidity will be locked in a ‘new’ pool until its at least 7 days old

src/views/pages/Pools/LiqAdd.js

  • Ripped out all the old maths and pointed to the new maths in web3Router (see above)
  • Combined some elements to make more compact

src/views/pages/Pools/LiqBond.js

  • Ripped out all the old maths and pointed to the new maths in web3Router / web3Bond (see above)
  • Combined some elements to make more compact

src/views/pages/Pools/LiqRemove.js

  • Ripped out all the old maths and pointed to the new maths in web3Router (see above)
  • Combined some elements to make more compact
  • Added dividend estimation logic to know what dividends to expect before performing the transaction

src/views/pages/Swap/Swap.js

  • Ripped out all the old maths and pointed to the new maths in web3Router (see above)
  • Combined some elements to make more compact
  • Added dividend estimation logic to know what dividends to expect before performing the transaction

src/views/pages/Swap/SwapPair.js

  • Combined some elements to make it more compact (See above screenshot including the new layout

src/views/pages/Synths/Overview.js

  • Ripped out all the old maths and pointed to the new maths in web3Router (see above)
  • Combined some elements to make more compact
  • Added dividend estimation logic to know what dividends to expect before performing the transaction

src/views/pages/Vault/SynthVault.js

  • Refactored all time calculations to use the new Utils functions above
  • Added function to build an array of claimable synth addresses to hand the new havestAll() function (calculate the array off-chain and hand to the adjusted contract function to save a lot of gas)

src/views/pages/Bond/Bond.js

  • Added function to build an array of claimable Bond positions to hand the new claimAll() function (calculate the array off-chain and hand to the adjusted contract function to save a lot of gas)

GitHub Activity — Resources

  • Community-contributed SpartanProtocolV2 mainnet teaser trailer

Project Information

Community Contribution

Spartan Protocol is at its core, a community-driven and led project. In this vein, the more contributors the better. There is a great opportunity for community members to contribute by making LP reward analysis tools, etc.

Recently, community members have been graciously funnelling in to contribute to explainer articles, ideas and even $SPARTA donations to support the growth of the platform.

Engage with the community and contributors

Where to find out about all the latest updates or suggest improvements — get involved.