The Buidl Continues

SpartanProtocol
10 min readMay 10, 2021

You will notice this week’s Dev update bundles in a 2 week period due to the attacks that happened just before last week’s update. This week has been about figuring out what happened in detail and refining a path forward.

Please take the time to read the Medium articles below to make sure you are up to speed with what happened during the exploit and the path forward.

What Happened?

The Road Ahead?

Spartan Socials

The past week has seen Spartan Protocol get a fair amount of air time, driving a lot of people to join our social media channels to see what is happening and how the protocol responds to the exploit.

Considering that crypto socials, in general, have a reputation for being a bit toxic, it was refreshing and heartwarming to see the positive interactions between community members supporting each other taking the time to help everyone understand what has happened and the plan forward.

The numbers below highlight the growth in the community that are now actively engaged with our social platforms, please help continue this positive environment and support any newcomers to the shield wall.

We have an opportunity to show the community what makes Spartan Protocol different.

Twitter

Top Impressions:

Top Engagement:

Top Community Mention:

A big thank you goes out to the team at PeckShield for their help through this tough period. They also provided a full and detailed analysis of the transaction which you can read about below.

SpartanSocials — Medium

SpartanSocials — Telegram

GitHub Activity

Whilst the contract contributors prepare the new base token contract and adapt the existing V2 contracts in preparation for the CodeArena bounty, the front enders have continued to work on the DAppV2 & the snapshot of LP holders from just before the attack.

SpartanContractsV2 (‘master’ Branch)

  • Separate out harvestAll() & harvest() ready for testing in UI
  • Refactor DAO & DaoVault + update automated testing
  • Expand the functionality of synths mint/burn to include all base BEP20 assets instead of just SPARTA for minting/burning
  • Update router to include functionality for minting from and burning to all listed BEP20 assets
  • Adjust automated tests accordingly and add in new tests
  • Fix memberSynth weight mapping
  • Add BNB/WBNB handling for synths
  • Implement initial fix for calcLiqShare bug & move the sync() function here
  • Change bond period to 6 months (was 12 months)
  • Remove Utils pricing functions
  • Update synthVault automated tests
  • Update repo readme in preparation for CodeArena bounty

SpartanContractsV2 (‘RebuildSparta’ Branch)

New base (SPARTA token) contract with the initial new functions/features:

  • iBEP677 approveAndCall() | to replace the previous transferTo function
  • burn() | ability to internally burn SPARTA tokens
  • upgrade() | ability for users to upgrade/bridge their old SPARTA tokens for the new SPARTA tokens

New ‘claim’ contract for the SPARTANs affected by the attacks:

  • claim() | ability for users to claim their allocated SPARTA based on the snapshot of their SPARTA weight of LP tokens held or locked in DAO/bond
  • expire() | users will have a 6 month window to make their claim of the SPARTA, after which the remainder will transfer to the DAO

Refactor contracts:

  • BondVault
  • Dao
  • DaoVault
  • Add in a one-time function to allocate the SPARTA for affected users to the ‘claim’ contract
  • Refactor Utils contract
  • Add automated tests for base (SPARTA token) contract

Refactor DAO proposals:

  • ‘Start Emissions’ & ‘Stop Emissions’ -> ‘Flip Emissions’ now that the base contract has been simplified accordingly
  • Incentive address no longer relevant with Reserve contract etc; so has been removed

Other Changes:

  • Name changed from “SPARTAN PROTOCOL TOKEN” to “Spartan Protocol Token”
  • approveAndCall() added to test Token1 contract (for automated testing)
  • TestVault created for initial testing of the approveAndCall() implementation
  • Base contract automated testing expanded

GitHub Activity — SpartanDAppV2

  • Refactor dataManager and most array grabs
  • Consolidate redux stores
  • Use things like getToken() getSynth() getPool() throughout instead of running one big array with all the details (store can now call for each as required theoretically allowing us to reduce the rcp calls)
  • Change long-winded things like ‘finalLpArray’ to ‘poolDetails’
  • Add useTranslate() injections to the nav menu
  • Replace a lot of this kind of thing: ‘poolFactory.finalLpArray.synthAddress’ with this kind of thing ‘synth.synthDetails.address’
  • Refactored swapPair to only require 1 arg instead of 3
  • Swap SPARTA to synth functionality added and tested
  • Added focus() to the input1 after some actions to the liquidity component (better UX)
  • AddLiq component improved (UI / UX)
  • RemoveLiq component improved with NaN handling(UI / UX)
  • BondLiq component improved (UI / UX)
  • Fixed font issues for mac users
  • Updated styling throughout
  • Updated default number formatting throughout (0.00)
  • Tested ‘tile’ style layout to ~480px width to help with responsiveness on other screen sizes
  • Extend translations
  • Notifications / alert component added
  • Change terminology Lock+Earn, farm etc to ‘Vault’
  • Added SynthVault
  • Created parent ‘vault’ page to link to the ‘synthVault’ and ‘daoVault’
  • Setup basic vault staking functionality
  • Create 480px style classNames to move forward with a more responsive MVP
  • Refactor bond store
  • Refactor dao store
  • Merge daoVault + dao stores
  • Refactor/prep synth store
  • Get daoVault component to next stage
  • Get synthVault to next stage
  • Update contract addresses to newly deployed contracts
  • Translate share component to spanish
  • Fix share component & remove the arg (use localStorage instead)
  • Translate assetSelect component
  • Add reserve store
  • Extend sparta store
  • Add claimable to synthVaut
  • Refactor synthVault -> itemized
  • Change ‘poolFactory’ to ‘pool’ & change codebase throughout accordingly
  • Update synthVaultItem to include ‘harvestable’ & ‘lastHarvest’
  • Updated daoVault store to include one main ‘globalDetails’ call
  • Added getClaimable to daoVault
  • Updated store ‘type’s to make sure they are unique to prevent wrong items being linked to wrong actions
  • BondLiq update to figma; move to final UI stages
  • RemoveLiq update to figma; move to final UI stages
  • Add in a ‘synths’ component/page for people who better-understanding minting/burning a synth rather than ‘swapping’ to/from a synth
  • Fix synth fee estimation issue
  • Fix synth ‘pre-filled token can be non-curated’ issue
  • Swap page update to Figma; move to final UI stages
  • Replace -SPS & -SPP with ‘s’ and ‘p’ throughout UI
  • DaoVault/SynthVault fix incorrect -SPP & -SPS usage
  • DaoVault & SynthVault replace big numbers with % (weights)
  • Added functionality to swap any BEP20 token to a synth and vice versa
  • Synth page; add swapPair & approval component
  • Change simpleSwap synth handling of filters for assetSelect to essentially make the new feature functional enough for testing
  • BondLiq; change default behaviour to not allow a non-curated pool as the input
  • AddLiq; fix backspace issue in input1 when on the ‘add both’ tab
  • Fix bondLiq assetSelect bug
  • Filters sorted for assetSelect now that synth handles all BEP20s
  • Updated synths page to handle all BEP20s
  • Add async to approval component to wait for approval state
  • Update synth page and simpleSwap to handle all synth combinations
  • Fix the estimates and outputs especially for when synth + base asset are the same
  • Disabled a bunch of tests due to unresponsive public RPCs causing tests to fail due to slow/delays
  • Refactor approval component
  • Move approval requirement conditionals out of template
  • Added ‘hide-if-siblings’ class to hide txn button if approval is required (without having to check outside of the approval component)
  • Add ‘close on click outside popover’ feature
  • Rip out the pools overview page and init a new general overview page
  • Build new overview page
  • Fix DOM error from the popOver fix
  • Limit inputs to decimals (better UX)
  • Then tested, confirmed and replicated throughout dapp
  • Fix naughty sidebar behaviour (tutt tutt)
  • Convert all views to ‘tiles’ style for an easier and cleaner MVP on all device sizes
  • Make the nav toggle better UX
  • Vaults; balance tile heights & add details
  • Finalise the better-UX navBar toggle handling

Supply DropDown:

  • Extend translations
  • Refactor contractLinks into a .map() instead of repeating code
  • Extend translations

Contributor’s Focus

Contributor focus moving forward is going to be broken into phases. This is done to highlight that the original goal has not changed but acknowledges and embraces the opportunities that there is some rebuilding required in order to get there.

  • Phase One — deals with the snapshot process, along with the new $SPARTA token and bridge
  • Phase Two — happening in line with phase 1; is adapting the V2 contracts to the new changes/features and getting them prepared for the CodeArena bounty. This phase also includes the code review process
  • Phase Three— is continuing with the goal of delivering incentivised deep liquidity pools for leveraged synthetic token generation

Phase 1 — The New $SPARTA Bridge

Affected Users Snapshot

Confirm SpartanProtocol holders & members snapshot from just prior to the attack.

Firstly a complete list of all possible wallets needed to be built to ensure no Spartans would be missed:

  • A complete list (for each pool) of every wallet address that held the LP token at any point *COMPLETE*
  • A complete list (for each bond contract) of every wallet that ever added liquidity via bond *COMPLETE*
  • A complete list of every wallet that ever deposited into the DAO (Lock+Earn) *COMPLETE*
  • Recreate the state of the chain from just prior to the attack to do the below calls *COMPLETE*

Loop the above lists using the relevant contract functions:

  • List of all wallet holdings (LP tokens) *COMPLETE*
  • List of pool’s depth in SPARTA & total supply of LP units *COMPLETE*
  • List of each DAO member’s locked units (LP Tokens) *COMPLETE*
  • List of each Bond member’s locked units (LP Tokens) *COMPLETE*
  • Use the above to get every wallet’s claim to base (SPARTA) to be allocated for the ‘claim’ contract for affected users *IN PROGRESS*

Issue A New $SPARTA token (Must await snapshot completion)

  • Confirm new token ticker — suggestions welcome but leaning towards keeping the old ticker ($SPARTA)
  • Build & deploy new base contract
  • 1-way bridge — 1 old SPARTA = 1 new SPARTA
  • The above-weighted claims (from the snapshot) are plugged in for affected users to claim via the bridge dapp
  • Implement deflationary mechanisms (burn SPARTA on each transfer etc)

Tokenomics

  • The 300 million market cap remains unchanged
  • The 100 million previously-planned initial distribution is unchanged however the remaining allocation for Bond will be reduced to account for the above snapshot/claim process

Phase 2 — The Original Plan

SpartanContracts

  • Continue updating V2 contracts to suit the changes to the base contract and get it finalised ready for the CodeArena bounty
  • Put the contracts through a code review process on CodeArena
  • Continue the code review process within the community

DAppV2

  • Update the DAppV2 to suit any changed contracts

Community Forum

A community forum for longer-form & categorised discussion has been created in GitHub: join the discussion here.

This was a plan for some time now but fits in well with the current plans to further integrate the community with the code. We all know the only way to do this is to ensure community members are always only 1 click away from the code changes (GitHub)

  • Setup categories & get the community contributing good questions about DAO proposals & mechanics of AMMs so that they can be padded out into longer-form go-to guides to post in the channels

Phase 3 — Deploy & Iterate

  • Deploy V2 to mainnet (with Synths)
  • Enable Bond allocations to get some TVL into the V2 pools
  • Deploy Lending to testnet
  • Continue ahead with the previous plans!

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.

GitHub list of bounties available

Reach out on telegram to get involved: https://t.me/SpartanProtocolBounties

--

--

SpartanProtocol

Incentivized liquidity and synthetic asset generation for Binance Smart Chain. https://SpartanProtocol.org