logo
bg_imgbg_imgbg_imgbg_img
exclamation mark iconReport an issue

If you notice some outdated information please let us know!

close icon
Name
Email
Your message
arrow-left

Stargate

60%

Process Quality Review (0.8)

Stargate

Final score:60%
Date:14 Apr 2022
Audit Process:version 0.8
Author:Nick
PQR Score:60%

FAIL

Protocol Website:https://stargate.finance/

Scoring Appendix

The final review score is indicated as a percentage. The percentage is calculated as Achieved Points due to MAX Possible Points. For each element the answer can be either Yes/No or a percentage. For a detailed breakdown of the individual weights of each question, please consult this document.

The blockchain used by this protocol
Arbitrum
Avalanche
BnB Smart Chain
Ethereum
Fantom
Polygon
Optimism
#QuestionAnswer
89%
1.100%
2.100%
3.Yes
4.0%
5.100
69%
6.Yes
7.Yes
8.40%
9.60%
70%
10.100%
11.50%
12.Yes
13.0%
14.No
15.Yes
87%
16.100%
17.0%
33%
18.100%
19.0%
20.100%
21.50%
22.30%
23.0%
24.0%
25.0%
13%
26.0
27.Yes
28.No
Total:60%

Very simply, the audit looks for the following declarations from the developer's site. With these declarations, it is reasonable to trust the smart contracts.

  • Here is my smart contract on the blockchain
  • You can see it matches a software repository used to develop the code
  • Here is the documentation that explains what my smart contract does
  • Here are the tests I ran to verify my smart contract
  • Here are the audit(s) performed to review my code by third party experts

This report is for informational purposes only and does not constitute investment advice of any kind, nor does it constitute an offer to provide investment advisory or other services. Nothing in this report shall be considered a solicitation or offer to buy or sell any security, token, future, option or other financial instrument or to offer or provide any investment advice or service to any person in any jurisdiction. Nothing contained in this report constitutes investment advice or offers any opinion with respect to the suitability of any security, and the views expressed in this report should not be taken as advice to buy, sell or hold any security. The information in this report should not be relied upon for the purpose of investing. In preparing the information contained in this report, we have not taken into account the investment needs, objectives and financial circumstances of any particular investor. This information has no regard to the specific investment objectives, financial situation and particular needs of any specific recipient of this information and investments discussed may not be suitable for all investors.

Any views expressed in this report by us were prepared based upon the information available to us at the time such views were written. The views expressed within this report are limited to DeFiSafety and the author and do not reflect those of any additional or third party and are strictly based upon DeFiSafety, its authors, interpretations and evaluation of relevant data. Changed or additional information could cause such views to change. All information is subject to possible correction. Information may quickly become unreliable for various reasons, including changes in market conditions or economic circumstances.

This completed report is copyright (c) DeFiSafety 2023. Permission is given to copy in whole, retaining this copyright label.

Smart Contracts & Team

89%

This section looks at the code deployed on the relevant chain that gets reviewed and its corresponding software repository. The document explaining these questions is here.

1. Are the smart contract addresses easy to find? (%)

Answer: 100%

They can be found at https://stargateprotocol.gitbook.io/stargate/developers/contract-addresses/mainnet, as indicated in the Appendix.

Percentage Score Guidance:
100%
Clearly labelled and on website, documents or repository, quick to find
70%
Clearly labelled and on website, docs or repo but takes a bit of looking
40%
Addresses in mainnet.json, in discord or sub graph, etc
20%
Address found but labeling not clear or easy to find
0%
Executing addresses could not be found

2. How active is the primary contract? (%)

Answer: 100%

Contract Router.sol is used 200+ times a day, as indicated in the Appendix.

Percentage Score Guidance:
100%
More than 10 transactions a day
70%
More than 10 transactions a week
40%
More than 10 transactions a month
10%
Less than 10 transactions a month
0%
No activity

3. Does the protocol have a public software repository? (Y/N)

Answer: Yes

Location: https://github.com/stargate-protocol

Score Guidance:
Yes
There is a public software repository with the code at a minimum, but also normally test and scripts. Even if the repository was created just to hold the files and has just 1 transaction.
No
For teams with private repositories.

4. Is there a development history visible? (%)

Answer: 0%

At just 4 commits, this protocol does not have a good development history visible.

Percentage Score Guidance:
100%
Any one of 100+ commits, 10+branches
70%
Any one of 70+ commits, 7+branches
50%
Any one of 50+ commits, 5+branches
30%
Any one of 30+ commits, 3+branches
0%
Less than 2 branches or less than 30 commits

5. Is the team public (not anonymous)?

Answer: 100

Stargate is strapiuced by LayerZero Labs. The employees of this company are listed on LinkedIn.

Score Guidance:
100%
At least two names can be easily found in the protocol's website, documentation or medium. These are then confirmed by the personal websites of the individuals / their linkedin / twitter.
50%
At least one public name can be found to be working on the protocol.
0%
No public team members could be found.

Documentation

69%

This section looks at the software documentation. The document explaining these questions is here.

6. Is there a whitepaper? (Y/N)

Answer: Yes

Location: https://stargateprotocol.gitbook.io/stargate/

7. Is the protocol's software architecture documented? (Y/N)

Answer: Yes

This protocol's software architecture is not documented in their documentation. No diagrams / explanations as to how the contracts relate to each other were detailed. Nevertheless, nonspecific mentions of how contracts interrelate to one another are detailed in the whitepaper.

Score Guidance:
Yes
The documents identify software architecture and contract interaction through any of the following: diagrams, arrows, specific reference to software functions or a written explanation on how smart contracts interact.
No
Protocols receive a "no" if none of these are included.

8. Does the software documentation fully cover the deployed contracts' source code? (%)

Answer: 40%

There is some coverage of deployed contracts by software function documentation. Nevertheless, main contracts like Router.sol / Factory.sol are not covered.

Percentage Score Guidance:
100%
All contracts and functions documented
80%
Only the major functions documented
79 - 1%
Estimate of the level of software documentation
0%
No software documentation

9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)

Answer: 60%

There is good (but not explicit) traceability between software documentation and implemented code.

Percentage Score Guidance:
100%
Clear explicit traceability between code and documentation at a requirement level for all code
60%
Clear association between code and documents via non explicit traceability
40%
Documentation lists all the functions and describes their functions
0%
No connection between documentation and code

Testing

70%

10. Has the protocol tested their deployed code? (%)

Answer: 100%

Code examples are in the Appendix at the end of this report.. As per the SLOC, there is 181% testing to code (TtC).    This score is guided by the Test to Code ratio (TtC). Generally a good test to code ratio is over 100%. However, the reviewer's best judgement is the final deciding factor.

Percentage Score Guidance:
100%
TtC > 120% Both unit and system test visible
80%
TtC > 80% Both unit and system test visible
40%
TtC < 80% Some tests visible
0%
No tests obvious

11. How covered is the protocol's code? (%)

Answer: 50%

This protocol documents no tests for code coverage. Nevertheless, with 181% TtC we can assume there is good testing on Stargate.

Percentage Score Guidance:
100%
Documented full coverage
99 - 51%
Value of test coverage from documented results
50%
No indication of code coverage but clearly there is a complete set of tests
30%
Some tests evident but not complete
0%
No test for coverage seen

12. Does the protocol provide scripts and instructions to run their tests? (Y/N)

Answer: Yes

Scripts/Instructions location: https://github.com/stargate-protocol/stargate#testing

Score Guidance:
Yes
Scripts and/or instructions to run tests are available in the testing suite
No
Scripts and/or instructions to run tests are not available in the testing suite

13. Is there a detailed report of the protocol's test results?(%)

Answer: 0%

There is no test report documented by Stargate.

Percentage Score Guidance:
100%
Detailed test report as described below
70%
GitHub code coverage report visible
0%
No test report evident

14. Has the protocol undergone Formal Verification? (Y/N)

Answer: No

Stargate has not undergone formal verification.

Score Guidance:
Yes
Formal Verification was performed and the report is readily available
No
Formal Verification was not performed and/or the report is not readily available.

15. Were the smart contracts deployed to a testnet? (Y/N)

Answer: Yes

This protocol has been deployed to a testnet. In providing this, Stargate enables users to independently verify these using a block explorer.

Score Guidance:
Yes
Protocol has proved their tesnet usage by providing the addresses
No
Protocol has not proved their testnet usage by providing the addresses

Security

87%

This section looks at the 3rd party software audits done. It is explained in this document.

16. Is the protocol sufficiently audited? (%)

Answer: 100%

Stargate was audited twice before launch and once after.

Percentage Score Guidance:
100%
Multiple Audits performed before deployment and the audit findings are public and implemented or not required
90%
Single audit performed before deployment and audit findings are public and implemented or not required
70%
Audit(s) performed after deployment and no changes required. The Audit report is public.
65%
Code is forked from an already audited protocol and a changelog is provided explaining why forked code was used and what changes were made. This changelog must justify why the changes made do not affect the audit.
50%
Audit(s) performed after deployment and changes are needed but not implemented.
30%
Audit(s) performed are low-quality and do not indicate proper due diligence.
20%
No audit performed
0%
Audit Performed after deployment, existence is public, report is not public OR smart contract address' not found.
Deduct 25% if the audited code is not available for comparison.

17. Is the bounty value acceptably high (%)

Answer: 0%

Stargate does not offer a bug bounty at time of writing.

Percentage Score Guidance:
100%
Bounty is 10% TVL or at least $1M AND active program (see below)
90%
Bounty is 5% TVL or at least 500k AND active program
80%
Bounty is 5% TVL or at least 500k
70%
Bounty is 100k or over AND active program
60%
Bounty is 100k or over
50%
Bounty is 50k or over AND active program
40%
Bounty is 50k or over
20%
Bug bounty program bounty is less than 50k
0%
No bug bounty program offered / the bug bounty program is dead
An active program means that a third party (such as Immunefi) is actively driving hackers to the site. An inactive program would be static mentions on the docs.

Admin Controls

33%

This section covers the documentation of special access controls for a DeFi protocol. The admin access controls are the contracts that allow updating contracts or coefficients in the protocol. Since these contracts can allow the protocol admins to "change the rules", complete disclosure of capabilities is vital for user's transparency. It is explained in this document.

18. Is the protocol's admin control information easy to find?

Answer: 100%

Admin control information was documented by Stargate. It is labelled under their governance section.

Percentage Score Guidance:
100%
Admin Controls are clearly labelled and on website, docs or repo, quick to find
70%
Admin Controls are clearly labelled and on website, docs or repo but takes a bit of looking
40%
Admin Control docs are in multiple places and not well labelled
20%
Admin Control docs are in multiple places and not labelled
0%
Admin Control information could not be found

19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)

Answer: 0%

Stargate's relevant contracts are not identified as immutable / upgradeable.

Percentage Score Guidance:
100%
Both the contract documentation and the smart contract code state that the code is not upgradeable or immutable.
80%
All Contracts are clearly labelled as upgradeable (or not)
50%
Code is immutable but not mentioned anywhere in the documentation
0%
Admin control information could not be found

20. Is the type of smart contract ownership clearly indicated? (%)

Answer: 100%

Ownership is clearly indicated as being in the hands of a multisig. This may change as the governance processes develop.

Percentage Score Guidance:
100%
The type of ownership is clearly indicated in their documentation. (OnlyOwner / MultiSig / etc)
50%
The type of ownership is indicated, but only in the code. (OnlyOwner / MultiSig / etc)
0%
Admin Control information could not be found

21. Are the protocol's smart contract change capabilities described? (%)

Answer: 50%

Stargate's smart contract change capabilities are identified in non-specific contracts.

Percentage Score Guidance:
100%
The documentation covers the capabilities for change for all smart contracts
50%
The documentation covers the capabilities for change in some, but not all contracts
0%
The documentation does not cover the capabilities for change in any contract

22. Is the protocol's admin control information easy to understand? (%)

Answer: 30%

Stargate's admin control information is in software specific language, and does not relate to the safety of user investments.

Percentage Score Guidance:
100%
All the contracts are immutable
90%
Description relates to investments safety in clear non-software language
30%
Description all in software-specific language
0%
No admin control information could be found

23. Is there sufficient Pause Control documentation? (%)

Answer: 0%

Stargate's pause control is not documented.

Percentage Score Guidance:
100%
If immutable and no changes possible
100%
If admin control is fully via governance
80%
Robust transaction signing process (7 or more elements)
70%
Adequate transaction signing process (5 or more elements)
60%
Weak transaction signing process (3 or more elements)
0%
No transaction signing process evident
Evidence of audits of signers following the process add 20%

24. Is there sufficient Timelock documentation? (%)

Answer: 0%

Stargate has no timelock documentation.

Percentage Score Guidance:
100%
Documentation identifies and explains why the protocol does not need a Timelock OR Timelock documentation identifies its duration, which contracts it applies to and justifies this time period.
60%
A Timelock is identified and its duration is specified
30%
A Timelock is identified
0%
No Timelock information was documented

25. Is the Timelock of an adequate length? (Y/N)

Answer: 0%

Stargate has no timelock documentation, and we therefore cannot evaluate its lenght.

Percentage Score Guidance:
100%
Timelock is between 48 hours to 1 week OR justification as to why no Timelock is needed / is outside this length.
50%
Timelock is less than 48 hours or greater than 1 week.
0%
No Timelock information was documented OR no timelock length was identified.

Oracles

13%

This section goes over the documentation that a protocol may or may not supply about their Oracle usage. Oracles are a fundamental part of DeFi as they are responsible for relaying tons of price data information to thousands of protocols using blockchain technology. Not only are they important for price feeds, but they are also an essential component of transaction verification and security. These questions are explained in this document.

26. Is the protocol's Oracle sufficiently documented? (%)

Answer: 0

Stargate's data source is not documented. The contracts dependent are not identified. There is no relevant software function documentation.

Score Guidance:
100%
If it uses one, the Oracle is specified. The contracts dependent on the oracle are identified. Basic software functions are identified (if the protocol provides its own price feed data). Timeframe of price feeds are identified. OR The reason as to why the protocol does not use an Oracle is identified and explained.
75%
The Oracle documentation identifies both source and timeframe, but does not provide additional context regarding smart contracts.
50%
Only the Oracle source is identified.
0%
No oracle is named / no oracle information is documented.

27. Is front running mitigated by this protocol? (Y/N)

Answer: Yes

Stargate is a bridge, and is therefore is not susceptible to front-running. Stargate provides guaranteed instant finality, meaning that whatever amount of funds you bridge will be equivalently minted on the other side.

Score Guidance:
Yes
The protocol cannot be front run and there is an explanation as to why OR documented front running countermeasures are implemented.
No
The Oracle documentation identifies both source and timeframe, but does not provide additional context regarding smart contracts.

28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)

Answer: No

Stargate documents no flash loan exploit countermeasures.

Score Guidance:
Yes
The protocol's documentation includes information on how they mitigate the possibilities and extents of flash loan attacks.
No
The protocol's documentation does not include any information regarding the mitigation of flash loan attacks.

Appendices

1// SPDX-License-Identifier: BUSL-1.1
2
3pragma solidity 0.7.6;
4pragma abicoder v2;
5
6// imports
7import "@openzeppelin/contracts/access/Ownable.sol";
8import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
9import "./LPTokenERC20.sol";
10import "./interfaces/IStargateFeeLibrary.sol";
11
12// libraries
13import "@openzeppelin/contracts/math/SafeMath.sol";
14
15/// Pool contracts on other chains and managed by the Stargate protocol.
16contract Pool is LPTokenERC20, ReentrancyGuard {
17    using SafeMath for uint256;
18
19    //---------------------------------------------------------------------------
20    // CONSTANTS
21    bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)")));
22    uint256 public constant BP_DENOMINATOR = 10000;
23
24    //---------------------------------------------------------------------------
25    // STRUCTS
26    struct ChainPath {
27        bool ready; // indicate if the counter chainPath has been created.
28        uint16 dstChainId;
29        uint256 dstPoolId;
30        uint256 weight;
31        uint256 balance;
32        uint256 lkb;
33        uint256 credits;
34        uint256 idealBalance;
35    }
36
37    struct SwapObj {
38        uint256 amount;
39        uint256 eqFee;
40        uint256 eqReward;
41        uint256 lpFee;
42        uint256 protocolFee;
43        uint256 lkbRemove;
44    }
45
46    struct CreditObj {
47        uint256 credits;
48        uint256 idealBalance;
49    }
50
51    //---------------------------------------------------------------------------
52    // VARIABLES
53
54    // chainPath
55    ChainPath[] public chainPaths; // list of connected chains with shared pools
56    mapping(uint16 => mapping(uint256 => uint256)) public chainPathIndexLookup; // lookup for chainPath by chainId => poolId =>index
57
58    // metadata
59    uint256 public immutable poolId; // shared id between chains to represent same pool
60    uint256 public sharedDecimals; // the shared decimals (lowest common decimals between chains)
61    uint256 public localDecimals; // the decimals for the token
62    uint256 public immutable convertRate; // the decimals for the token
63    address public immutable token; // the token for the pool
64    address public immutable router; // the token for the pool
65
66    bool public stopSwap; // flag to stop swapping in extreme cases
67
68    // Fee and Liquidity
69    uint256 public totalLiquidity; // the total amount of tokens added on this side of the chain (fees + deposits - withdrawals)
70    uint256 public totalWeight; // total weight for pool percentages
71    uint256 public mintFeeBP; // fee basis points for the mint/deposit
72    uint256 public protocolFeeBalance; // fee balance created from dao fee
73    uint256 public mintFeeBalance; // fee balance created from mint fee
74    uint256 public eqFeePool; // pool rewards in Shared Decimal format. indicate the total budget for reverse swap incentive
75    address public feeLibrary; // address for retrieving fee params for swaps
76
77    // Delta related
78    uint256 public deltaCredit; // credits accumulated from txn
79    bool public batched; // flag to indicate if we want batch processing.
80    bool public defaultSwapMode; // flag for the default mode for swap
81    bool public defaultLPMode; // flag for the default mode for lp
82    uint256 public swapDeltaBP; // basis points of poolCredits to activate Delta in swap
83    uint256 public lpDeltaBP; // basis points of poolCredits to activate Delta in liquidity events
84
85    //---------------------------------------------------------------------------
86    // EVENTS
87    event Mint(address to, uint256 amountLP, uint256 amountSD, uint256 mintFeeAmountSD);
88    event Burn(address from, uint256 amountLP, uint256 amountSD);
89    event RedeemLocalCallback(address _to, uint256 _amountSD, uint256 _amountToMintSD);
90    event Swap(
91        uint16 chainId,
92        uint256 dstPoolId,
93        address from,
94        uint256 amountSD,
95        uint256 eqReward,
96        uint256 eqFee,
97        uint256 protocolFee,
98        uint256 lpFee
99    );
100    event SendCredits(uint16 dstChainId, uint256 dstPoolId, uint256 credits, uint256 idealBalance);
101    event RedeemRemote(uint16 chainId, uint256 dstPoolId, address from, uint256 amountLP, uint256 amountSD);
102    event RedeemLocal(address from, uint256 amountLP, uint256 amountSD, uint16 chainId, uint256 dstPoolId, bytes to);
103    event InstantRedeemLocal(address from, uint256 amountLP, uint256 amountSD, address to);
104    event CreditChainPath(uint16 chainId, uint256 srcPoolId, uint256 amountSD, uint256 idealBalance);
105    event SwapRemote(address to, uint256 amountSD, uint256 protocolFee, uint256 dstFee);
106    event WithdrawRemote(uint16 srcChainId, uint256 srcPoolId, uint256 swapAmount, uint256 mintAmount);
107    event ChainPathUpdate(uint16 dstChainId, uint256 dstPoolId, uint256 weight);
108    event FeesUpdated(uint256 mintFeeBP);
109    event FeeLibraryUpdated(address feeLibraryAddr);
110    event StopSwapUpdated(bool swapStop);
111    event WithdrawProtocolFeeBalance(address to, uint256 amountSD);
112    event WithdrawMintFeeBalance(address to, uint256 amountSD);
113    event DeltaParamUpdated(bool batched, uint256 swapDeltaBP, uint256 lpDeltaBP, bool defaultSwapMode, bool defaultLPMode);
114
115    //---------------------------------------------------------------------------
116    // MODIFIERS
117    modifier onlyRouter() {
118        require(msg.sender == router, "Stargate: only the router can call this method");
119        _;
120    }
121
122    constructor(
123        uint256 _poolId,
124        address _router,
125        address _token,
126        uint256 _sharedDecimals,
127        uint256 _localDecimals,
128        address _feeLibrary,
129        string memory _name,
130        string memory _symbol
131    ) LPTokenERC20(_name, _symbol) {
132        require(_token != address(0x0), "Stargate: _token cannot be 0x0");
133        require(_router != address(0x0), "Stargate: _router cannot be 0x0");
134        poolId = _poolId;
135        router = _router;
136        token = _token;
137        sharedDecimals = _sharedDecimals;
138        decimals = uint8(_sharedDecimals);
139        localDecimals = _localDecimals;
140        convertRate = 10**(uint256(localDecimals).sub(sharedDecimals));
141        totalWeight = 0;
142        feeLibrary = _feeLibrary;
143
144        //delta algo related
145        batched = false;
146        defaultSwapMode = true;
147        defaultLPMode = true;
148    }
149
150    function getChainPathsLength() public view returns (uint256) {
151        return chainPaths.length;
152    }
153
154    //---------------------------------------------------------------------------
155    // LOCAL CHAIN FUNCTIONS
156
157    function mint(address _to, uint256 _amountLD) external nonReentrant onlyRouter returns (uint256) {
158        return _mintLocal(_to, _amountLD, true, true);
159    }
160
161    // Local                                    Remote
162    // -------                                  ---------
163    // swap             ->                      swapRemote
164    function swap(
165        uint16 _dstChainId,
166        uint256 _dstPoolId,
167        address _from,
168        uint256 _amountLD,
169        uint256 _minAmountLD,
170        bool newLiquidity
171    ) external nonReentrant onlyRouter returns (SwapObj memory) {
172        require(!stopSwap, "Stargate: swap func stopped");
173        ChainPath storage cp = getAndCheckCP(_dstChainId, _dstPoolId);
174        require(cp.ready == true, "Stargate: counter chainPath is not ready");
175
176        uint256 amountSD = amountLDtoSD(_amountLD);
177        uint256 minAmountSD = amountLDtoSD(_minAmountLD);
178
179        // request fee params from library
180        SwapObj memory s = IStargateFeeLibrary(feeLibrary).getFees(poolId, _dstPoolId, _dstChainId, _from, amountSD);
181
182        // equilibrium fee and reward. note eqFee/eqReward are separated from swap liquidity
183        eqFeePool = eqFeePool.sub(s.eqReward);
184        // update the new amount the user gets minus the fees
185        s.amount = amountSD.sub(s.eqFee).sub(s.protocolFee).sub(s.lpFee);
186        // users will also get the eqReward
187        require(s.amount.add(s.eqReward) >= minAmountSD, "Stargate: slippage too high");
188
189        // behaviours
190        //     - protocolFee: booked, stayed and withdrawn at remote.
191        //     - eqFee: booked, stayed and withdrawn at remote.
192        //     - lpFee: booked and stayed at remote, can be withdrawn anywhere
193
194        s.lkbRemove = amountSD.sub(s.lpFee).add(s.eqReward);
195        // check for transfer solvency.
196        require(cp.balance >= s.lkbRemove, "Stargate: dst balance too low");
197        cp.balance = cp.balance.sub(s.lkbRemove);
198
199        if (newLiquidity) {
200            deltaCredit = deltaCredit.add(amountSD).add(s.eqReward);
201        } else if (s.eqReward > 0) {
202            deltaCredit = deltaCredit.add(s.eqReward);
203        }
204
205        // distribute credits on condition.
206        if (!batched || deltaCredit >= totalLiquidity.mul(swapDeltaBP).div(BP_DENOMINATOR)) {
207            _delta(defaultSwapMode);
208        }
209
210        emit Swap(_dstChainId, _dstPoolId, _from, s.amount, s.eqReward, s.eqFee, s.protocolFee, s.lpFee);
211        return s;
212    }

JavaScript Tests

Language
Files
Lines
Blanks
Comments
Testing Code
Deployed Code
Complexity
Solidity
7
1908
299
209
2667
1470
173

Tests to Code: 2667 / 1470 = 181 %