SpartanDev: May 2021

May Summary

I think it's pretty safe to say that May was a rollercoaster month for Spartan Protocol, its Shield Wall, the BSC ecosystem and the wider crypto community in general.

  • Removing components related to the original ‘Burn For SPARTA’ TGE
  • Create a deflationary aspect to assist with inflation resulting from the FallenSpartans compensation
  • Upgrade the transfer() function to ensure best practice (removal of tx.origin)
  • Upgrading their V1 Tokens to V2 Tokens
  • Claiming the SPARTA side of the liquidity that was drained in the May 2 exploit (FallenSpartans compensation)
BSCSCAN.com Screenshot 23 MAY 21: https://bscscan.com/token/0x3910db0600ea925f63c36ddb1351ab6e2c6eb102

Looking Forwards to June

Stepping into June, the contributors look forward to releasing SpartanProtocol V2 (V2 contract suite) to CodeArena for stress testing and review, in preparation for go-live and the re-opening of the Liquidity Pools.

Spartan Protocol GitBook

Some new & old community members have put their hands up recently to help get the Spartan Protocol GitBook to reflect current progress and iterations of the protocol — head over and check it out to learn more.

Spartan Socials

They say you should always attempt to see the silver lining in all situations. The exploit resulted in a lot of attention focused on Spartan Protocol from the wider Crypto community, and on community contributors and Shield Wall members to discover what had happened. Many Shield Wall members stepped up to both support the project and offer their assistance, and more contributors continue to come out of the woodwork.

Spartan Socials — Twitter

Top Impressions:

Top Engagement:

Top Community Mention:

SpartanSocials — Medium

SpartanSocials — Telegram

Contributor’s Focus

The contributor focus moving forward has been broken into rough phases. This has been done to highlight that the original goal has not changed. This also acknowledges and embraces the fact that there is some rebuilding required in order to get there.

Phase 1 — SPARTA V2 (Token) — Completed!

Affected Users Snapshot

A snapshot of the state of all user’s liquidity holdings (Wallet Holdings, DaoVault Staked & Bond Locked) was taken from a block height just prior to the V1 LP drain transaction. This was cross-referenced with the depth of the pools to define the precise volume of $SPARTA taken from liquidity providers. See the result below:

Deploy New $SPARTA v2 BASE Token

Deploy Upgrade dApp

  • 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)

Phase 2 — Spartan Protocol V2 (Protocol) — In Progress

SPARTA V2 (Token)

  • Work with the centralised exchanges (CEX) listing SPARTA to ensure that SPARTA holders all have their tokens upgraded as simply as possible. It is expected that CEX holders will not need to perform any specific actions to have their tokens exchanged for V2 tokens (Binance, BKEX, MXC etc)
  • Work with DEXs & aggregators to ensure the new SPARTA token address is added to their lists (1inch, PancakeSwap etc)
  • Work with token-tracking information websites to ensure new token info is added and verified (BSCscan, CoinGecko, CoinMarketCap etc)

SpartanContracts

  • Continue updating and stringent testing of V2 contracts to suit the changes made against the base token contract, and ensure the V2 contract suite is in a complete and stable position ready for a CodeArena bounty period
  • Put the contracts through a code review process on CodeArena
  • Continue the code review process within the community

DAppV2

  • Update the V2 dApp to suit any required contract changes/upgrades
  • Add in simple DAO for Bond+Mint allocations
  • Test bond process from start to finish via UI (propose bond allocation, vote it in, finalise it, and then proceed to bond assets and test the weight from that in the DAOVault, and other proposals)

Community Forum

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

  • 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 Protocol V2 to Binance Smart Chain mainnet
  • Enable Bond allocations to replenish TVL into the V2 pools
  • Deploy Lending to testnet
  • March onwards with our original goals of building the decentralised, yield-generating, solo staking, leveraged synthetics and derivatives + lending protocol on Binance Smart Chain

GitHub Activity — SpartanContractsV2

contracts/BondVault.sol

New & improved BondVault; members now get their Bond weight contributing to DAO proposals & DAOVault for harvesting

  • Bond members weight now contributes to DAO proposals (greater advantage to future Bond+Mint participants)
  • Bond member’s locked LPs now contribute to their DAOVault harvest weight (greater advantage to future Bond+Mint participants)
  • Pending SPARTA that has been unlocked and allocated via DAO proposals will now be held in the DAO address
  • The Bond/BondVault refactor along with the SPARTAv2 token has resulted in the removal of a Bond contract; only BondVault (Simplified; reduce code scope)

contracts/Dao.sol

  • setGenesisAddresses() — changed to external and _BOND removed (Bond contract no longer required)
  • depositLPForMember() — msg.sender changed to member arg. Added in BondVault weight to the check for the forced harvest()
  • calcReward() — added BondVault member’s weight to the DaoVault calculation (and vice versa with the totalWeight used in the calc)
  • Added functions to handle the Bond-SPARTA allocations held in the DAO contract. ie. burn remaining allocation, or move it to a new DAO address
  • Added functions to handle Bond-enabled assets. ie. List or de-list bond assets.
  • Added functions to handle end-users performing bond actions. ie. bond, calc and claim
  • Reverted SPARTA Bond-allocation back to 2.5M per proposal
  • Removed some additional redundant functions
  • countVotes() — now uses BondVault member weight included in the calculation of weight in a proposal. Same with all the functions that check for minority and majority and quorum etc

contracts/DaoVault.sol

  • Refactor and cleanup require() returns to save contract size
  • Change public functions to external

contracts/Pool.sol

  • mintSynth() — add output arg to SYNTH.mintSynth()
  • Emit a MintSynth event
  • burnSynth() — use UTILS.calSwapOutput() instead of UTILS.calcSwapValueInBase()
  • Emit a BurnSynth even

contracts/Reserve.sol

  • Remove newDao references (no longer used)

contracts/Router.sol

  • Added back in the receive() function for handling BNB/WBNB
  • zapLiquidity() — added in the transfer ‘fromToken’ for the swap
  • addLiquiditySingleForMember() — allow asym-add directly into the pools (reduce gas for user)
  • removeLiquidityExact() — handle BNB/WBNB
  • swapSynthToAsset() — handle feeBurn

contracts/Synth.sol

  • mapAddress changed to mapSynth (shorter and more accurate/readable)
  • mintSynth() — refactor; amount handed in as arg
  • realise() — added ‘realise’ function to cut back the LP unit collateral if it is greater than the debt (funnel more revenue into the underlying pools for LPers to benefit instead of the un-owned Synth contract)

contracts/Utils.sol

  • Added getPool() & getPoolShareWeight() & calcActualSynthUnits()
  • Cleanup case and brackets in calcLiquidityUnitsAsym()

contracts/synthFactory.sol

  • Simplify require() return (smaller contract code)

contracts/synthVault.sol

  • harvestAll() — _member changed to msg.sender throughout & the new SYNTH.realise() function is now called on harvest
  • harvestSingle() — _member changed to msg.sender throughout & the new SYNTH.realise() function is now called on harvest
  • withdraw() — _member changes to msg.sender throughout

Automated Tests

  • Updated to suit changes in above contracts
  • Tests added to suite new functions added (ie. SYNTH.realise())

GitHub Activity — SpartanDAppV2

ABIs

  • Cleanup; move unused ABIs to ‘old’ folder, remove when confirmed irrelevant
  • Update all the testnet ABIs to match the newly testnet-deployed V2 contracts

src/Providers.js

  • Remove bondVault store; have simply rolled it into the ‘bond’ store even though there is no longer a bond contract; better to keep it short
  • Removed utilsMath store; it’s not something we need
  • Removed utilsPricing store; it’s not something we need

src/components/AssetSelect/AssetSelect.js

  • Update AssetSelect to handle SPARTAv2 instead of SPARTAv1 now that it’s pointing at the new contracts
  • Add getWalletType() to detect if a wallet is MetaMask or TrustWallet to handle their unique watchAsset functions (Show MetaMask or TrustWallet icons next to assets dynamically to add the custom tokens to your respective wallet, previously this always just showed MetaMask)
  • Icon has also been fixed in regards to the added watchAsset. Metamask will now use the relevant tokenIcon from the DApp
TrustWallet vs MetaMask dynamic watchAsset() handling

src/components/DataManager/DataManager.js

  • Disabled eventListeners for RecentTxns component temporarily (improved component being worked on)
  • Removed actions that are no longer relevant (ie. getCuratedPools and getBondSpartaRemaining)
  • Added action: bondGlobalDetails() to the initial global loop

src/components/Share/SharePool.js

  • Handle ‘assetType’ from params along with validation to avoid corrupt type being added to localStorage
  • Update the usage of window.location
  • Handle the asset type being shown (icon/symbol shown based on selected assetType)

src/components/Supply/Supply.js

  • Remove ‘bond’ and ‘migrate’ contracts from the types list; no longer relevant (the bond contract was refactored out of v2 and migration is obviously no longer required)
  • Burn & bond distribution numbers added as const for the tokenomics calculations (these numbers are now final and won't change, so do not need to dynamically call for updated counts)
  • Bond added as a const too for v2. However, we can convert this into a simple call to count the completed DAO proposals of type: “GET_SPARTA” and multiply it by 2.5M *OR* call all ‘Transfer’ events from BASE to DAO who’s amount is 2.5M SPARTA.
  • Hide distro-breakdown on Testnet; only really relevant on Mainnet
  • Show V1 circulating vs V2 to visually show the progress of the token upgrade

src/components/WalletSelect/WalletSelect.js

  • When a user disconnects the wallet via the dapp; place a localStorage variable disabling the auto-wallet connect feature until the user manually selects a wallet again
  • checkWallets() — refactor out repeat checks and set fallback to ‘injected’ for mobile wallets so we get better UX for mobile users (try to auto-connect first-time mobile users to the wallet that is relevant to their browser)
  • Add getWalletType() to detect if a wallet is MetaMask or TrustWallet to handle their unique watchAsset functions (Show MetaMask or TrustWallet icons next to assets dynamically to add the custom tokens to your respective wallet, previously this always just showed MetaMask)
  • Icon has also been fixed in regards to the added watchAsset. Metamask will now use the relevant tokenIcon from the DApp
  • Detect if the device is Apple/iOS; if so; show a button before connecting the wallet to enable the in-app DApp browser in TrustWallet
  • WalletConnect disabled throughout; not a priority right now but will revisit later and get the bridge setup so wallets can ‘write’ instead of only ‘read’

src/store/bond/actions.js

  • Major cleanup/refactor to match the changes to the contracts (and the removal of the bond contract)
  • Any DAO contract functions relevant to BOND will be located here even though they are in a different contract; makes sense from a common-sense perspective; but not from a search-via-contract perspective. The former seems to suit most contributors

src/store/dao/actions.js

  • Added globalDetails action to follow suit with the other stores where major calls are broken down by scope (Global scope, member scope & id-scope)

src/store/pool/actions.js

  • Fix and refactor token-icon handling
  • Remove all curatedArray refs (handled in poolDetails now without needing an extra loop)

src/store/router/actions.js

  • Cull/refactor
  • Updated functions to suit changes in the new V2 contracts

src/store/sparta/actions.js

  • feeOnTransfer converted to a string in the store for human-readable throughout the dapp
  • Culled some old functions

src/store/synth/actions.js

  • synthDeposit() — added listen to txn to wait for confirmation for txn modal in the synthVault

src/store/utils/actions.js

  • Culled old/unused functions
  • Also deleted the utilsMath & utilsPricing stores

src/utils/web3.js

  • Updated ABIs and addresses to point to new V2 testnet contracts
  • Handle SPARTAv2 throughout as the base asset

src/utils/web3Contracts.js

  • Small cleanup

src/utils/web3Utils.js

  • Adjusted calcFeeBurn to return the basisPoints instead of end-resulting feeBurn; makes more sense as basis points are required throughout the DApp. For now, we handle the end result calculation within each component using the sparta.global.maxSupply (v2 token) variable in the store. However, this can be refactored into a utils function later for cleanup

src/views/pages/Pools/LiqAdd.js

  • Handle SPARTAv2 throughout as the base asset
  • Handle feeBurn in all transaction estimates/outputs

src/views/pages/Pools/LiqBond.js

  • Handle SPARTAv2 throughout as the base asset
  • Handle feeBurn in all transaction estimates/outputs (needs further testing for 100% accuracy this week)

src/views/pages/Pools/LiqRemove.js

  • Handle SPARTAv2 throughout as the base asset
  • Handle feeBurn in all transaction estimates/outputs (needs further testing for 100% accuracy this week)
  • Added approval component for LPs now that they require approval

src/views/pages/Pools/Overview.js

  • Cleanup / refactor

src/views/pages/Swap/Swap.js

  • Handle SPARTAv2 throughout as the base asset
  • Handle feeBurn in all transaction estimates/outputs (needs further testing for 100% accuracy this week)
  • Large refactor especially with synth handling
  • Handle params for ‘assetType’
  • Made variables in some sections more human-readable
  • Added approval component for LPs and Synths now that they require approval

src/views/pages/Synths/Overview.js

  • Rename ‘mint’ to ‘forge’ and ‘burn’ to ‘melt’. The aim here is to give synths terms that aren't too unique but also aren't sharing the same name as other common functions that have ‘history’ in crypto (such as Burn).
  • Handle SPARTAv2 throughout as the base asset
  • Handle feeBurn in all transaction estimates/outputs (continued testing is taking place)
  • Added approval component for synths now that they require approval
  • Refactor calculations for outputs and each step between
  • Renamed some variables to be more human-readable

src/views/pages/Upgrade/Upgrade.js

  • Minor cleanup

src/views/pages/Vault/Components/DaoDepositModal.js

  • Take it to the next stage ready for some txnDetails after the confirmation
  • Added approval component for LPs now that they require approval

src/views/pages/Vault/Components/SynthDepositModal.js

  • Take it to the next stage ready for some txnDetails after the confirmation
  • Added approval component for synths now that they require approval

src/views/pages/Vault/DaoVault.js

  • Handle feeBurn in claimable

src/views/pages/Vault/SynthVaultItem.js

  • Handle feeBurn in claimable
  • Add in synthVault deposit modal

Deleted Throughout

  • All references to ‘Lending’ and ‘Migration’. Migration is no longer relevant and Lending will be approached once the V2 Contracts and dApp are finalised

GitHub Activity — SpartanSite

Styles

  • Reduce zoom amount
  • Adjusted margins and padding throughout

Footer

  • Add in Discord icon/link

index.html

  • Added Discord icon/link to hero section

Project Information

Official Links

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.

Engage with the community and contributors

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

Community Bounty Wallet

Whilst there is no treasury nor contributor allocations, there was a public community bounty wallet set up a while ago to help handle donations from the community and other incentive programs (BNB from the Binance BUIDl program was sent here) which can be viewed here:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SpartanProtocol

SpartanProtocol

1.3K Followers

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