If you notice some outdated information please let us know!
FAIL
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.
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.
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.
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? (%)
Smart contract addresses can be found in their Contract Addresses page. A screenshot of the addresses can be found in the appendix.
2. How active is the primary contract? (%)
The contract v6.1 Trading is active more than 10 times a day. A screenshot of the transactions page can be found in the appendix.
3. Does the protocol have a public software repository? (Y/N)
Gains Network's GitHub can be found here.
4. Is there a development history visible? (%)
The repository gTrade-v6.1 has 2 commits, 1 branch. This gives 0% to the protocol. Other repositories would not have been able to give additional points as none of them had more than 30 commits.
5. Is the team public (not anonymous)?
The team seems to be operating under anonymity.
This section looks at the software documentation. The document explaining these questions is here.
7. Is the protocol's software architecture documented? (Y/N)
This protocol's software architecture documentation could not be found.
8. Does the software documentation fully cover the deployed contracts' source code? (%)
There is no coverage of deployed contracts by software function documentation that could be found.
9. Is it possible to trace the documented software to its implementation in the protocol's source code? (%)
There is no traceability between software documentation and implemented code that could be made.
10. Has the protocol tested their deployed code? (%)
No testing evidence could be found in the repository's GitHub.
11. How covered is the protocol's code? (%)
No testing evidence could be found in the repository's GitHub.
12. Does the protocol provide scripts and instructions to run their tests? (Y/N)
No testing evidence could be found in the repository's GitHub.
13. Is there a detailed report of the protocol's test results?(%)
No testing evidence could be found in the repository's GitHub.
14. Has the protocol undergone Formal Verification? (Y/N)
This protocol has not undergone formal verification.
15. Were the smart contracts deployed to a testnet? (Y/N)
Some evidence of testnet deployments could be found on Kovan. An evidence of deployment oculd be found here.
This section looks at the 3rd party software audits done. It is explained in this document.
16. Is the protocol sufficiently audited? (%)
Gains Network's v6 update has been audited pre-launch, with most minor issues being solved, the one major issue acknowledged being centralization. For this matter, the protocol will earn 90%. Source: https://medium.com/gains-network/gtrade-v6-update-5b13da3be00
17. Is the bounty value acceptably high (%)
Gains network offers a bounty of 100 000$ on Immunefi. This earns the protocol 70%.
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?
Admin control information could not be found in the protocol's documentation.
19. Are relevant contracts clearly labelled as upgradeable or immutable? (%)
There are mentions of contracts being upgradeable here, but this is not specified for all relevant smart contracts.
20. Is the type of smart contract ownership clearly indicated? (%)
Admin control information could not be found in the protocol's documentation.
21. Are the protocol's smart contract change capabilities described? (%)
Admin control information could not be found in the protocol's documentation.
22. Is the protocol's admin control information easy to understand? (%)
Admin control information could not be found in the protocol's documentation.
23. Is there sufficient Pause Control documentation? (%)
There is a mention of pausing opening of new trades opening when a contract is upgraded, but this does not constitute pause control documentation.
24. Is there sufficient Timelock documentation? (%)
Timelock documentation could not be found.
25. Is the Timelock of an adequate length? (Y/N)
Timelock documentation could not be found.
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? (%)
The protocol uses Chainlink oracles for their gTrade platform. As the source and the relevant contracts (gTrade) are mentioned but not the timeframe, the protocol earns 75%.
27. Is front running mitigated by this protocol? (Y/N)
Front running mitigation technique documentation could not be found.
28. Can flashloan attacks be applied to the protocol, and if so, are those flashloan attack risks mitigated? (Y/N)
Flashloan attack mitigation technique documentation could not be found.
1// SPDX-License-Identifier: MIT
2import './interfaces/StorageInterfaceV5.sol';
3pragma solidity 0.8.14;
4
5contract GNSPairInfosV6_1 {
6
7 // Addresses
8 StorageInterfaceV5 immutable storageT;
9 address public manager;
10
11 // Constant parameters
12 uint constant PRECISION = 1e10; // 10 decimals
13 uint constant LIQ_THRESHOLD_P = 90; // -90% (of collateral)
14
15 // Adjustable parameters
16 uint public maxNegativePnlOnOpenP = 40 * PRECISION; // PRECISION (%)
17
18 // Pair parameters
19 struct PairParams{
20 uint onePercentDepthAbove; // DAI
21 uint onePercentDepthBelow; // DAI
22 uint rolloverFeePerBlockP; // PRECISION (%)
23 uint fundingFeePerBlockP; // PRECISION (%)
24 }
25
26 mapping(uint => PairParams) public pairParams;
27
28 // Pair acc funding fees
29 struct PairFundingFees{
30 int accPerOiLong; // 1e18 (DAI)
31 int accPerOiShort; // 1e18 (DAI)
32 uint lastUpdateBlock;
33 }
34
35 mapping(uint => PairFundingFees) public pairFundingFees;
36
37 // Pair acc rollover fees
38 struct PairRolloverFees{
39 uint accPerCollateral; // 1e18 (DAI)
40 uint lastUpdateBlock;
41 }
42
43 mapping(uint => PairRolloverFees) public pairRolloverFees;
44
45 // Trade initial acc fees
46 struct TradeInitialAccFees{
47 uint rollover; // 1e18 (DAI)
48 int funding; // 1e18 (DAI)
49 bool openedAfterUpdate;
50 }
51
52 mapping(
53 address => mapping(
54 uint => mapping(
55 uint => TradeInitialAccFees
56 )
57 )
58 ) public tradeInitialAccFees;
59
60 // Events
61 event ManagerUpdated(address value);
62 event MaxNegativePnlOnOpenPUpdated(uint value);
63
64 event PairParamsUpdated(uint pairIndex, PairParams value);
65 event OnePercentDepthUpdated(uint pairIndex, uint valueAbove, uint valueBelow);
66 event RolloverFeePerBlockPUpdated(uint pairIndex, uint value);
67 event FundingFeePerBlockPUpdated(uint pairIndex, uint value);
68
69 event TradeInitialAccFeesStored(
70 address trader,
71 uint pairIndex,
72 uint index,
73 uint rollover,
74 int funding
75 );
76
77 event AccFundingFeesStored(uint pairIndex, int valueLong, int valueShort);
78 event AccRolloverFeesStored(uint pairIndex, uint value);
79
80 event FeesCharged(
81 uint pairIndex,
82 bool long,
83 uint collateral, // 1e18 (DAI)
84 uint leverage,
85 int percentProfit, // PRECISION (%)
86 uint rolloverFees, // 1e18 (DAI)
87 int fundingFees // 1e18 (DAI)
88 );
89
90 constructor(StorageInterfaceV5 _storageT){
91 storageT = _storageT;
92 }
93
94 // Modifiers
95 modifier onlyGov(){
96 require(msg.sender == storageT.gov(), "GOV_ONLY");
97 _;
98 }
99 modifier onlyManager(){
100 require(msg.sender == manager, "MANAGER_ONLY");
101 _;
102 }
103 modifier onlyCallbacks(){
104 require(msg.sender == storageT.callbacks(), "CALLBACKS_ONLY");
105 _;
106 }
107
108 // Set manager address
109 function setManager(address _manager) external onlyGov{
110 manager = _manager;
111
112 emit ManagerUpdated(_manager);
113 }
114
115 // Set max negative PnL % on trade opening
116 function setMaxNegativePnlOnOpenP(uint value) external onlyManager{
117 maxNegativePnlOnOpenP = value;
118
119 emit MaxNegativePnlOnOpenPUpdated(value);
120 }
121
122 // Set parameters for pair
123 function setPairParams(uint pairIndex, PairParams memory value) public onlyManager{
124 storeAccRolloverFees(pairIndex);
125 storeAccFundingFees(pairIndex);
126
127 pairParams[pairIndex] = value;
128
129 emit PairParamsUpdated(pairIndex, value);
130 }
131 function setPairParamsArray(
132 uint[] memory indices,
133 PairParams[] memory values
134 ) external onlyManager{
135 require(indices.length == values.length, "WRONG_LENGTH");
136
137 for(uint i = 0; i < indices.length; i++){
138 setPairParams(indices[i], values[i]);
139 }
140 }
141
142 // Set one percent depth for pair
143 function setOnePercentDepth(
144 uint pairIndex,
145 uint valueAbove,
146 uint valueBelow
147 ) public onlyManager{
148 PairParams storage p = pairParams[pairIndex];
149
150 p.onePercentDepthAbove = valueAbove;
151 p.onePercentDepthBelow = valueBelow;
152
153 emit OnePercentDepthUpdated(pairIndex, valueAbove, valueBelow);
154 }
155 function setOnePercentDepthArray(
156 uint[] memory indices,
157 uint[] memory valuesAbove,
158 uint[] memory valuesBelow
159 ) external onlyManager{
160 require(indices.length == valuesAbove.length
161 && indices.length == valuesBelow.length, "WRONG_LENGTH");
162
163 for(uint i = 0; i < indices.length; i++){
164 setOnePercentDepth(indices[i], valuesAbove[i], valuesBelow[i]);
165 }
166 }
167
168 // Set rollover fee for pair
169 function setRolloverFeePerBlockP(uint pairIndex, uint value) public onlyManager{
170 require(value <= 25000000, "TOO_HIGH"); // ≈ 100% per day
171
172 storeAccRolloverFees(pairIndex);
173
174 pairParams[pairIndex].rolloverFeePerBlockP = value;
175
176 emit RolloverFeePerBlockPUpdated(pairIndex, value);
177 }
178 function setRolloverFeePerBlockPArray(
179 uint[] memory indices,
180 uint[] memory values
181 ) external onlyManager{
182 require(indices.length == values.length, "WRONG_LENGTH");
183
184 for(uint i = 0; i < indices.length; i++){
185 setRolloverFeePerBlockP(indices[i], values[i]);
186 }