SpartanDev: 06SEP21 - 12SEP21

Dev Update

SpartanDev: 06SEP21 - 12SEP21

SpartanProtocol V2 private testnet is in full swing with the DApp progressing swiftly alongside it. CMC token details updated.

SpartanDev: 06SEP21 - 12SEP21

This week saw SpartanProtocol V2 private testnet in full swing & the DApp progressing swiftly alongside it. The end of the week had progress pegged roughly halfway through the testing items slated for this phase. Very excited for public testnet! Hopefully, we can get out a bit of a guide for users to get set up and prepared to contribute to Testnet soon.

Shout out to CoinMarketCap who got our $SPARTA token information updated on their platform, which is also linked to Binance CEX; so we are now seeing much more accurate total supply & circulating supply figures throughout all of the token tracking websites. As always though; use our DApp as the source of truth for tokenomics information

Wednesday feeBurn Update

Spartan Socials - Twitter

Top Tweet:

Top Community Tweet:

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 βœ… β€” Work with token-tracking informational websites to ensure new token info is up-to-date (BSCscan, CoinGecko, CoinMarketCap)

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

COMPLETED βœ… β€” Rebuild automated testing & start private testnet

Deploy V2 to public testnet

Deploy completed V2 contracts to BSC mainnet

DAppV2

COMPLETED βœ… β€” Prepare DAppV2 for testnet deploy

IN PROGRESS β€” Continue updating during private Testnet

Continue updating during public Testnet

REVISIT AFTER MAINNET β€” Set up a reliable index of history scoped to contracts (use this for positions page etc)

REVISIT AFTER MAINNET β€” 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 β€” Spartan Contracts v2

Branch: PostC5

contracts/BondVault.sol

  1. Added TransferHelper library
  2. Set bonding period in the constructor
  3. getMemberLPWeight() - store and iterate listedBondPools from memory instead of storage
  4. getBondedAssets() - Added helper to retrieve listedBondPools easier in UI

contracts/Dao.sol

  1. Added TransferHelper library
  2. claimAll() changed to claim() - instead of handing in an array (for bond claim) hand in a single asset address

contracts/DaoVault.sol

  1. Added TransferHelper library

contracts/Pool.sol

  1. Changed some variables access for UI / compile
  2. Added a separate safeTransfer function
  3. Apply 1% reduction on mintSynth
  4. Apply 5% reduction on burnSynth
  5. Refactor stirCauldron logic
  6. Moved the TVL-cap checks to _incrementPoolBalances()

contracts/Reserve.sol

  1. Added TransferHelper library

contracts/Router.sol

  1. Added TransferHelper library
  2. Made some variables private to save compile
  3. Moved synthMinting logic here
  4. removeLiquidity() - removed function; not required in UI
  5. removeLiquidityAsym() - removed function; not required in UI
  6. updatePoolStatus() - set unfreeze to true in init

contracts/TransferHelper.sol

  1. Added TransferHelper library

contracts/Utils.sol

  1. Added some variables to the getPoolData() helper for the UI

contracts/poolFactory.sol

  1. Change some variables to private to save compile
  2. createPoolADD() - adjusted require to ensure the added TOKEN amount is greater than 100,000 WEI
  3. Removed some unused helpers to save compile
  4. Added/changed helpers to get whole array of poolAssets & tokenAssets with one call for the UI

contracts/synthVault.sol

  1. Added TransferHelper library

test/1_pool.js

  1. Updated changed function names in Pool automated tests

test/2_swap.js

  1. Updated changed function names in Swap automated tests
  2. Added in synths tests

test/3_dao.js

  1. Added in synths tests

test/4_SynthFarm.js

  1. Updated SynthVault tests

test/5_farm.js

  1. Updated Bond / DaoVault tests

GitHub Activity β€” Spartan DApp v2

Branch: main
  1. Created, imported and updated the favicon / meta
Branch: V2TN

README.md

  1. Quick rewrite of the DApp repo readme to help contributors and the curious non-devs get involved. Steps including screenshots for those with no GitHub/tooling experience

package.json

  1. Removed old bsc-use-wallet web3 wallet connector/handler
  2. Finally added in the @web3-react library to rebuild the wallet handling logic (including WalletConnect)

public/sitemap.xml

  1. Added a simple static sitemap; must be updated manually

src/ABI/TN/*.json

  1. Updated all the Testnet ABIs to match the new contracts

Global

  1. Replaced all useWallet refs to useWeb3React from @web3-react/core

src/Providers.js

  1. Replaced UseWalletProvider of @binance-chain/bsc-use-wallet with: Web3ReactProvider of @web3-react/core
  2. Pulled in the customized library from ./utils/web3React.js

src/assets/scss/spartan/custom/utilities/_animations.scss

  1. Added a simple spin animation class

src/components/Approval/Approval.js

Added state/txn status check to Approvals
  1. Added wait-check to allow for a 'pending' state when approving
  2. If pending = true; a loading style icon will show on the Approve button

src/components/Common/AddressConn.js

  1. Added listeners to reload dapp on accountsChanged and chainChanged
  2. Simplified the wallet status indicators

src/components/DataManager/DataManager.js

  1. Refactored/updated calls
  2. Removed the 'listen all contracts' logic in favour of only loading in the user's relevant transactions to txnHistory
  3. We can revisit this later and show a scoped 'recent global txns' section on the relevant pages instead

src/components/Icons/icons.js

  1. Added Turkey flag, arrow-left, arrow-right, cycle & WalletConnect icons

src/components/RecentTxns/RecentTxns.js

  1. Repurposed to user/wallet/chainId scoped recentTxns instead of global protocol txns
  2. User performs txn; has is grabbed and sent thru Redux; listener grabs the txn hash and adds it to localStorage scoped by wallet address
  3. RecentTxns grabs the data from localStorage and presents it; still need to extend this at some stage but for now it provides a link to the txn on BSCscan which is the most important thing especially for testing

src/components/WalletSelect/WalletSelect.js

Added WalletConnect functionality back in with new connector library
  1. Refactored all wallet selection logic; ripped out some reliance on localStorage
  2. Uncommented the WalletConnect logic and connected it all up to the new library
  3. Cleaned up the UX flow for connecting/disconnecting & auto-connecting a wallet based on the user's last wallet action. If the user's last logged action was disconnecting a wallet; the DApp will not try to auto-connect the 'previous wallet' on next reload.
  4. If the user's last logged wallet action was not a 'disconnect' then the DApp will only try to autoconnect once. Priority of wallet it tries to connect to as follows: #1 lastWallet type (localStorage), #2 injected (MetaMask on desktop; or the relevant wallet browser's native wallet on mobile)
  5. WalletConnect auto-connect will be skipped if the DApp's selected network is Testnet as WalletConnect only supports mainnet
  6. Refactored out all the weight-calculation logic to relevant files in utils/math/ for rank calculation (and so they can be re-used elsewhere throughout the DApp)
  7. View BSCScan & Disconnect buttons only show if a wallet is connected now
Only show wallet management buttons when a wallet is connected

src/components/WalletSelect/walletTypes.js

  1. Added in WalletConnect
  2. Changed inject to connector

src/routes.js

  1. Changed /pools/liquidity to just /liquidity
  2. Changed /pools/swap to just /swap

src/store/bond/actions.js

  1. bondGlobalDetails() - removed weight (calculated dynamically now)
  2. bondVaultWeight() - adjusted order of assignment, inits, type-handling and filtering of the array to account for edge cases
  3. allListedAssets() - uses getBondedAssets() now instead; to get array of bond assets
  4. bondDeposit() - returns a transaction now instead (for recentTxns component)
  5. claimBond() - returns a transaction now instead (for recentTxns component)

src/store/dao/actions.js

  1. daoGlobalDetails() - removed memberCount - added cancelPeriod
  2. daoProposalDetails() - changed to call memberVoted() so the DApp can know whether the user has voted or not - removed votes and memberVotes (this is now equal to the user's weight if memberVoted() = true)
  3. daoMemberDetails() - added function to get user's last harvest time
  4. daoDepositTimes() - added function to get user's last DAOVault deposit time (per asset)
  5. proposalWeight() - get the dynamic weight in support of a proposal (global)
  6. daoVaultWeight() - get the daoVault's dynamic total weight (global; exc bondVault)
  7. daoDeposit() - returns a transaction now instead (for recentTxns component)
  8. daoWithdraw() - returns a transaction now instead (for recentTxns component)
  9. daoHarvest() - returns a transaction now instead (for recentTxns component)
  10. newActionProposal() - returns a transaction now instead (for recentTxns component)
  11. newParamProposal() - returns a transaction now instead (for recentTxns component)
  12. newAddressProposal() - returns a transaction now instead (for recentTxns component)
  13. newGrantProposal() - returns a transaction now instead (for recentTxns component)
  14. voteProposal() - returns a transaction now instead (for recentTxns component)
  15. removeVote() - returns a transaction now instead (for recentTxns component)
  16. pollVotes() - returns a transaction now instead (for recentTxns component)
  17. cancelProposal() - returns a transaction now instead (for recentTxns component)
  18. finaliseProposal() - returns a transaction now instead (for recentTxns component)

src/store/pool/actions.js

  1. getListedTokens() - calls a simple getTokenAssets() now instead of calling for the count and then looping a bunch of calls to each by index
  2. getListedPools() - added baseCap & synthCap
  3. getListedPools() - removed all the 0 assignments; listedPools object isn't used for that so we don't need to account for it existing in the object
  4. getPoolDetails() - added in freeze
  5. getPoolDetails() - curated changed to use the offChain curated array instead of calling poolFactory per pool

src/store/reserve/actions.js

  1. getReserveGlobalDetails() - added globalFreeze

src/store/router/actions.js

  1. Adjusted all transaction functions to return a txn instead (for recentTxns component)
  2. addLiquiditySingle() - changed to point to the new function name
  3. removeLiquiditySingle() - changed to point to the new function name
  4. swap() - added minAmount arg (enforces a revert if the output amount is not within range of the estimate)
  5. updatePoolStatus() - added function to link to the front end for the users to be able to check the safety status of all pools and flick globalFreeze off if no pools are flagged

src/store/sparta/actions.js

  1. communityWalletHoldings() - uncomment the SPARTA logic to allow user's to donate SPARTA

src/store/synth/actions.js

  1. getSynthGlobalDetails() - removed: totalWeight & blockDelay & stakedSynthLength
  2. getSynthArray() - removed 0 assignments; not required anywhere
  3. getSynthDetails() - loops the offChain synthArray for its details including: balance, staked, lastHarvest, lpBalance & totalSupply
  4. synthVaultWeight() - use offChain poolDetails, synthDetails & vaultArray to loop and return the dynamic total synthVault weight (global)
  5. Adjusted all transaction functions to return a txn instead (for recentTxns component)

src/utils/math/dao.js

  1. bondLiq() - added revert check-returns for slipAdjustment > 98% & baseCap
  2. hasQuorum() - added function to calc (off-chain) whether the proposal has quorum consensus
  3. hasMajority() - added function to calc (off-chain) whether the proposal has majority consensus

src/utils/math/nonContract.js

  1. getLPWeights() - uses the offChain poolDetails object to iterate and get the member's total LP token value in SPARTA
  2. getSynthWeight() - uses an offChain synth & pool object to get the value of synths in SPARTA
  3. getSynthWeights() - uses the synthDetails & poolDetails objects to get the user's total value of synths in SPARTA

src/utils/math/router.js

  1. addLiq() - added return 0.00 for invalid iterations to avoid NaN and broken interfaced calls
  2. addLiq() - added checks for if the txn would revert due to exceeding the slipAdjustment or baseCap
  3. addLiqAsym() - added return 0.00 for invalid iterations to avoid NaN and broken interfaced calls
  4. addLiqAsym() - added in logic to handle the changed pools balances between the swap and addLiq portions of the txn. Also added in checks for reverts (see similar above)
  5. removeLiq() - added a return of the amount of SPARTA leaving the pool for interfaced txns that need to know the pool's new balance (rather than just the amount the user receives after feeBurn)
  6. removeLiqAsym() - hand in the updated pool balances for the swap portion of this txn
  7. zapLiq() - hand in the updated pool balances for each pool on either side of this txn
  8. zapLiq() - add in revert checks for slipAdjustment & baseCap
  9. mintSynth() - ripped out the virtualisation logic (incomplete; update with next phase)
  10. burnSynth() - ripped out the virtualisation logic (incomplete; update with next phase)

src/utils/math/utils.js

  1. getToken() - added helper function to get the token from tokenDetails based on a tokenAddr
  2. calcSynthSpotValueInBase() - removed this unused function
  3. calcLiquidityUnits() - added in a slipAdjustment check return to ensure its > 98%

src/utils/web3.js

  1. Updated TN addresses
  2. getWalletProvider() - small simplification
  3. addTxn() - add a transaction to the localStorage object for recentTxns component
  4. clearTxn() - clear the user's transaction history from the localStorage item based on their currently selected wallet & chain

src/utils/web3Contracts.js

  1. Changed over to the new library from web3React

src/utils/web3React.js

  1. Setup connector objects for BSC, inject, Ledger & WalletConnector
  2. connectorsByName() - helper to retrieve a connector
  3. getLibrary() - helper to retrieve the library

src/views/pages/Bond/Bond.js

  1. Removed the claimArray logic (bond is claimed individually now instead of in batch)

src/views/pages/Dao/NewProposal.js

  1. Added REALISE proposalType

src/views/pages/Dao/Overview.js

  1. Added proposalWeight(), daoVaultWeight() & bondVaultWeight() calls to the data loop (retrieve for the Redux store)

src/views/pages/Dao/components/AssetSelect.js

  1. Added some logic to handle asset selection if REALISE proposal type is selected

src/views/pages/Donate/Overview.js

Donation page info updated; SPARTA added as donation asset
  1. Added in SPARTA handling as a donation asset
  2. Updated tiles and text to match the purpose of this as a general donation page now
  3. Added in information on the two upcoming AMA crowdfunding campaigns
Binance AMA info added along with SPARTA donation tracking

src/views/pages/Home/NewPool.js

  1. Added stages/state to the new pool creation process (approval spinner, buttons changing based on status of txn etc)

src/views/pages/Home/Overview.js

  1. Simplified to two tabs (pools and new pools) will use a badge to differentiate curated instead of a tab

src/views/pages/Home/SummaryItem.js

  1. Setup structure for someone to contribute to the wording here to explain the types of pools (curated, standard & new pools)

src/views/pages/PU/EmptyPools.js

  1. This component theoretically is redundant now; will probably remove, but has been updated according to the new contracts

src/views/pages/PU/FrozenPools.js

  1. Created a FrozenPools management component. As you can see below it will show a list of pools with ratios outside the safety level signalling either a recent move in the price of the assets or an arbitrage opportunity
List of pools outside their expected safe ratio/range

2. If the pools are all inside their safe ranges & there is a globalFreeze in place, the user can trigger Β updatePoolStatus() to restore the protocol's globalFreeze status to false

If there is a globalFreeze but pools are safe; anyone can unfreeze

src/views/pages/Pools/LiqAdd.js

  1. Changed some of the assetSelect on load logic/filtering
  2. getAddLiq() - handle revert checks to prevent doing a txn if it is likely to revert
  3. getAddLiqAsym() - handle revert checks to prevent doing a txn if it is likely to revert
  4. checkValid() - refactored all the validity checks to a single function to handle the bool & label for button/error message
  5. This component will now display a message inside the addLiq interface when the pool is still in its initialization phase to warn users they won't be able to remove their liquidity until X time (7 days from the pool's creation). There is also a confirm switch for this to enable the button to proceed with txn
Pool initialising warning for pools that are less than 7 days old

src/views/pages/Pools/LiqBond.js

  1. Refactored out the minusFeeBurn logic (handled in maths files now)
  2. Refactored out getBondLiq logic to maths files too
  3. getBondLiq() - handle revert checking to prevent a bond that is likely to revert
  4. checkValid() - refactored all the validity checks to a single function to handle the bool & label for button/error message
Validity checks to prevent & tell the user why their txn cant proceed

src/views/pages/Pools/LiqRemove.js

  1. checkValid() - refactored all the validity checks to a single function to handle the bool & label for button/error message
  2. Changed to allow newPool assets to be calculated for removal but disable the button to actually proceed with an explanation of why (and when it will unlock)
Validity check for new pools and explain to user why/when liquidity can be removed

src/views/pages/Swap/Swap.js

  1. Changed some of the assetSelect on load logic/filtering
  2. getZap() - handle revert checks to prevent doing a txn if it is likely to revert
  3. checkValid() - refactored all the validity checks to a single function to handle the bool & label for button/error message
  4. minAmount handling - at the moment the UI will enforce a revert if the output of the txn is not within 5% of the estimate shown in the DApp. We can make this customizable for the user in their wallet/dashboard or similar

src/views/pages/Synths/NewSynth.js

  1. Minor wording change for creating a synth

src/views/pages/Synths/Overview.js

  1. Conditionally show component only if there are valid synths in existence

src/views/pages/Upgrade/Upgrade.js

  1. Updated to support WalletConnect and mainnet balances from tokenDetails

src/views/pages/Vault/DaoVault.js

  1. Uncommented the data grabbers for: daoVaultWeight(), bondVaultWeight() & daoDepositTimes()
  2. Removed memberCount from front-end

src/views/pages/Vault/SynthVault.js

  1. Adapted to get the dynamic weight of the member via the math function instead of calling the old weight getter

GitHub Activity β€” Spartan Blog

Branch: main

README.md

  1. Updated readme file for the repo to make it a bit more clear what the repo is for (theming/frontend) along with more information on the steps to run/modify it locally and make contributions

src/utils/siteConfig.js

  1. Updated the blog's meta description slightly. Launching the blog has already seen a large increase in traffic from Google search; this is worth allocation some time to weekly to ensure the official blog is showing up to relevant search queries

External Changes

  1. Whilst not relevant to the open-source code/repo/GitHub; a lot of changes were implemented this week in regard to the Spartan Protocol blog to try to automate the distribution after an article is published and also around ensuring a good sitemap is generated and indexed by Google

Project Information

  • Website: https://spartanprotocol.org/
  • DApp: https://dapp.spartanprotocol.org/
  • GitBook (Docs): https://docs.spartanprotocol.org/
  • GitHub: https://github.com/spartan-protocol

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.

Binance Smart Chain TestNet Faucet

Contributors TestNet Wallet

Got some spare BSC TestNet assets? Please throw some to the contributors getting ready for testing! Or build up your testnet balances via the faucet to help contribute to balancing the pools in the upcoming testnet.

  • 0x3d2aCFafd10600896C90a325c31700B3E1E2D791

Engage with the community and contributors

Where to find out about all the latest updates or suggest improvements β€” get involved.