SpartanDev: 06SEP21 - 12SEP21
SpartanProtocol V2 private testnet is in full swing with the DApp progressing swiftly alongside it. CMC token details updated.
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
- Added
TransferHelper
library - Set bonding period in the constructor
getMemberLPWeight()
- store and iterate listedBondPools from memory instead of storagegetBondedAssets()
- Added helper to retrieve listedBondPools easier in UI
contracts/Dao.sol
- Added
TransferHelper
library claimAll()
changed toclaim()
- instead of handing in an array (for bond claim) hand in a single asset address
contracts/DaoVault.sol
- Added
TransferHelper
library
contracts/Pool.sol
- Changed some variables access for UI / compile
- Added a separate
safeTransfer
function - Apply 1% reduction on
mintSynth
- Apply 5% reduction on
burnSynth
- Refactor
stirCauldron
logic - Moved the TVL-cap checks to
_incrementPoolBalances()
contracts/Reserve.sol
- Added
TransferHelper
library
contracts/Router.sol
- Added
TransferHelper
library - Made some variables private to save compile
- Moved
synthMinting
logic here removeLiquidity()
- removed function; not required in UIremoveLiquidityAsym()
- removed function; not required in UIupdatePoolStatus()
- set unfreeze to true in init
contracts/TransferHelper.sol
- Added
TransferHelper
library
contracts/Utils.sol
- Added some variables to the
getPoolData()
helper for the UI
contracts/poolFactory.sol
- Change some variables to private to save compile
createPoolADD()
- adjusted require to ensure the addedTOKEN
amount is greater than100,000 WEI
- Removed some unused helpers to save compile
- Added/changed helpers to get whole array of
poolAssets
&tokenAssets
with one call for the UI
contracts/synthVault.sol
- Added
TransferHelper
library
test/1_pool.js
- Updated changed function names in Pool automated tests
test/2_swap.js
- Updated changed function names in Swap automated tests
- Added in synths tests
test/3_dao.js
- Added in synths tests
test/4_SynthFarm.js
- Updated SynthVault tests
test/5_farm.js
- Updated Bond / DaoVault tests
GitHub Activity β Spartan DApp v2
Branch: main
- Created, imported and updated the favicon / meta
Branch: V2TN
README.md
- 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
- Removed old
bsc-use-wallet
web3 wallet connector/handler - Finally added in the
@web3-react
library to rebuild the wallet handling logic (including WalletConnect)
public/sitemap.xml
- Added a simple static sitemap; must be updated manually
src/ABI/TN/*.json
- Updated all the Testnet ABIs to match the new contracts
Global
- Replaced all
useWallet
refs touseWeb3React
from@web3-react/core
src/Providers.js
- Replaced
UseWalletProvider
of@binance-chain/bsc-use-wallet
with:Web3ReactProvider
of@web3-react/core
- Pulled in the customized library from
./utils/web3React.js
src/assets/scss/spartan/custom/utilities/_animations.scss
- Added a simple
spin
animation class
src/components/Approval/Approval.js
- Added wait-check to allow for a 'pending' state when approving
- If
pending = true
; a loading style icon will show on the Approve button
src/components/Common/AddressConn.js
- Added listeners to reload dapp on
accountsChanged
andchainChanged
- Simplified the wallet status indicators
src/components/DataManager/DataManager.js
- Refactored/updated calls
- Removed the 'listen all contracts' logic in favour of only loading in the user's relevant transactions to txnHistory
- We can revisit this later and show a scoped 'recent global txns' section on the relevant pages instead
src/components/Icons/icons.js
- Added Turkey flag, arrow-left, arrow-right, cycle & WalletConnect icons
src/components/RecentTxns/RecentTxns.js
- Repurposed to user/wallet/chainId scoped recentTxns instead of global protocol txns
- User performs txn; has is grabbed and sent thru Redux; listener grabs the txn hash and adds it to localStorage scoped by wallet address
- 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
- Refactored all wallet selection logic; ripped out some reliance on localStorage
- Uncommented the WalletConnect logic and connected it all up to the new library
- 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.
- 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)
- WalletConnect auto-connect will be skipped if the DApp's selected network is Testnet as WalletConnect only supports mainnet
- 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) View BSCScan
&Disconnect
buttons only show if a wallet is connected now
src/components/WalletSelect/walletTypes.js
- Added in WalletConnect
- Changed
inject
toconnector
src/routes.js
- Changed
/pools/liquidity
to just/liquidity
- Changed
/pools/swap
to just/swap
src/store/bond/actions.js
bondGlobalDetails()
- removedweight
(calculated dynamically now)bondVaultWeight()
- adjusted order of assignment, inits, type-handling and filtering of the array to account for edge casesallListedAssets()
- usesgetBondedAssets()
now instead; to get array of bond assetsbondDeposit()
- returns a transaction now instead (forrecentTxns
component)claimBond()
- returns a transaction now instead (forrecentTxns
component)
src/store/dao/actions.js
daoGlobalDetails()
- removedmemberCount
- addedcancelPeriod
daoProposalDetails()
- changed to callmemberVoted()
so the DApp can know whether the user has voted or not - removedvotes
andmemberVotes
(this is now equal to the user's weight ifmemberVoted() = true
)daoMemberDetails()
- added function to get user's last harvest timedaoDepositTimes()
- added function to get user's last DAOVault deposit time (per asset)proposalWeight()
- get the dynamic weight in support of a proposal (global)daoVaultWeight()
- get the daoVault's dynamic total weight (global; exc bondVault)daoDeposit()
- returns a transaction now instead (forrecentTxns
component)daoWithdraw()
- returns a transaction now instead (forrecentTxns
component)daoHarvest()
- returns a transaction now instead (forrecentTxns
component)newActionProposal()
- returns a transaction now instead (forrecentTxns
component)newParamProposal()
- returns a transaction now instead (forrecentTxns
component)newAddressProposal()
- returns a transaction now instead (forrecentTxns
component)newGrantProposal()
- returns a transaction now instead (forrecentTxns
component)voteProposal()
- returns a transaction now instead (forrecentTxns
component)removeVote()
- returns a transaction now instead (forrecentTxns
component)pollVotes()
- returns a transaction now instead (forrecentTxns
component)cancelProposal()
- returns a transaction now instead (forrecentTxns
component)finaliseProposal()
- returns a transaction now instead (forrecentTxns
component)
src/store/pool/actions.js
getListedTokens()
- calls a simplegetTokenAssets()
now instead of calling for the count and then looping a bunch of calls to each by indexgetListedPools()
- addedbaseCap
&synthCap
getListedPools()
- removed all the0
assignments; listedPools object isn't used for that so we don't need to account for it existing in the objectgetPoolDetails()
- added infreeze
getPoolDetails()
-curated
changed to use the offChain curated array instead of callingpoolFactory
per pool
src/store/reserve/actions.js
getReserveGlobalDetails()
- addedglobalFreeze
src/store/router/actions.js
- Adjusted all transaction functions to return a txn instead (for
recentTxns
component) addLiquiditySingle()
- changed to point to the new function nameremoveLiquiditySingle()
- changed to point to the new function nameswap()
- addedminAmount
arg (enforces a revert if the output amount is not within range of the estimate)updatePoolStatus()
- added function to link to the front end for the users to be able to check the safety status of all pools and flickglobalFreeze
off if no pools are flagged
src/store/sparta/actions.js
communityWalletHoldings()
- uncomment the SPARTA logic to allow user's to donate SPARTA
src/store/synth/actions.js
getSynthGlobalDetails()
- removed:totalWeight
&blockDelay
&stakedSynthLength
getSynthArray()
- removed0
assignments; not required anywheregetSynthDetails()
- loops the offChain synthArray for its details including:balance
,staked
,lastHarvest
,lpBalance
&totalSupply
synthVaultWeight()
- use offChainpoolDetails
,synthDetails
&vaultArray
to loop and return the dynamic total synthVault weight (global)- Adjusted all transaction functions to return a txn instead (for
recentTxns
component)
src/utils/math/dao.js
bondLiq()
- added revert check-returns forslipAdjustment > 98%
&baseCap
hasQuorum()
- added function to calc (off-chain) whether the proposal has quorum consensushasMajority()
- added function to calc (off-chain) whether the proposal has majority consensus
src/utils/math/nonContract.js
getLPWeights()
- uses the offChainpoolDetails
object to iterate and get the member's total LP token value in SPARTAgetSynthWeight()
- uses an offChainsynth
&pool
object to get the value of synths in SPARTAgetSynthWeights()
- uses thesynthDetails
&poolDetails
objects to get the user's total value of synths in SPARTA
src/utils/math/router.js
addLiq()
- added return0.00
for invalid iterations to avoid NaN and broken interfaced callsaddLiq()
- added checks for if the txn would revert due to exceeding theslipAdjustment
orbaseCap
addLiqAsym()
- added return0.00
for invalid iterations to avoid NaN and broken interfaced callsaddLiqAsym()
- added in logic to handle the changed pools balances between theswap
andaddLiq
portions of the txn. Also added in checks for reverts (see similar above)removeLiq()
- added a return of the amount ofSPARTA
leaving the pool for interfaced txns that need to know the pool's new balance (rather than just the amount the user receives afterfeeBurn
)removeLiqAsym()
- hand in the updated pool balances for theswap
portion of this txnzapLiq()
- hand in the updated pool balances for each pool on either side of this txnzapLiq()
- add in revert checks forslipAdjustment
&baseCap
mintSynth()
- ripped out the virtualisation logic (incomplete; update with next phase)burnSynth()
- ripped out the virtualisation logic (incomplete; update with next phase)
src/utils/math/utils.js
getToken()
- added helper function to get the token from tokenDetails based on a tokenAddrcalcSynthSpotValueInBase()
- removed this unused functioncalcLiquidityUnits()
- added in aslipAdjustment
check return to ensure its> 98%
src/utils/web3.js
- Updated TN addresses
getWalletProvider()
- small simplificationaddTxn()
- add a transaction to the localStorage object for recentTxns componentclearTxn()
- clear the user's transaction history from the localStorage item based on their currently selected wallet & chain
src/utils/web3Contracts.js
- Changed over to the new library from web3React
src/utils/web3React.js
- Setup connector objects for BSC, inject, Ledger & WalletConnector
connectorsByName()
- helper to retrieve a connectorgetLibrary()
- helper to retrieve the library
src/views/pages/Bond/Bond.js
- Removed the claimArray logic (bond is claimed individually now instead of in batch)
src/views/pages/Dao/NewProposal.js
- Added
REALISE
proposalType
src/views/pages/Dao/Overview.js
- Added
proposalWeight()
,daoVaultWeight()
&bondVaultWeight()
calls to the data loop (retrieve for the Redux store)
src/views/pages/Dao/components/AssetSelect.js
- Added some logic to handle asset selection if
REALISE
proposal type is selected
src/views/pages/Donate/Overview.js
- Added in SPARTA handling as a donation asset
- Updated tiles and text to match the purpose of this as a general donation page now
- Added in information on the two upcoming AMA crowdfunding campaigns
src/views/pages/Home/NewPool.js
- 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
- 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
- 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
- This component theoretically is redundant now; will probably remove, but has been updated according to the new contracts
src/views/pages/PU/FrozenPools.js
- 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
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
src/views/pages/Pools/LiqAdd.js
- Changed some of the assetSelect on load logic/filtering
getAddLiq()
- handle revert checks to prevent doing a txn if it is likely to revertgetAddLiqAsym()
- handle revert checks to prevent doing a txn if it is likely to revertcheckValid()
- refactored all the validity checks to a single function to handle thebool
&label
for button/error message- 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
src/views/pages/Pools/LiqBond.js
- Refactored out the
minusFeeBurn
logic (handled in maths files now) - Refactored out
getBondLiq
logic to maths files too getBondLiq()
- handle revert checking to prevent a bond that is likely to revertcheckValid()
- refactored all the validity checks to a single function to handle thebool
&label
for button/error message
src/views/pages/Pools/LiqRemove.js
checkValid()
- refactored all the validity checks to a single function to handle thebool
&label
for button/error message- 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)
src/views/pages/Swap/Swap.js
- Changed some of the assetSelect on load logic/filtering
getZap()
- handle revert checks to prevent doing a txn if it is likely to revertcheckValid()
- refactored all the validity checks to a single function to handle thebool
&label
for button/error messageminAmount
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
- Minor wording change for creating a synth
src/views/pages/Synths/Overview.js
- Conditionally show component only if there are valid synths in existence
src/views/pages/Upgrade/Upgrade.js
- Updated to support WalletConnect and mainnet balances from tokenDetails
src/views/pages/Vault/DaoVault.js
- Uncommented the data grabbers for:
daoVaultWeight()
,bondVaultWeight()
&daoDepositTimes()
- Removed memberCount from front-end
src/views/pages/Vault/SynthVault.js
- 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
- 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
- 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
- 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
Official Links
- 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.
- Medium: https://medium.com/spartanprotocol
- Twitter: https://twitter.com/spartanprotocol
- Telegram Community: https://t.me/spartanprotocolorg
- Telegram Announcements: https://t.me/spartanprotocolann
- Community-Built Discord: https://discord.gg/wQggvntnGk