code-423n4 / 2023-05-ajna-findings

2 stars 0 forks source link

QA Report #467

Open code423n4 opened 1 year ago

code423n4 commented 1 year ago

See the markdown file with the details of this report here.

DadeKuma commented 1 year ago

Whops, I copied the wrong code for L-03, this is the correct one:

https://github.com/code-423n4/2023-05-ajna/blob/a51de1f0119a8175a5656a2ff9d48bbbcb4436e7/ajna-core/src/PositionManager.sol#L170-L216

File: ajna-core/src/PositionManager.sol

170:     function memorializePositions(
171:         MemorializePositionsParams calldata params_
172:     ) external override {
173:         EnumerableSet.UintSet storage positionIndex = positionIndexes[params_.tokenId];
174: 
175:         IPool   pool  = IPool(poolKey[params_.tokenId]);
176:         address owner = ownerOf(params_.tokenId);
177: 
178:         uint256 indexesLength = params_.indexes.length;
179:         uint256 index;
180: 
181:         for (uint256 i = 0; i < indexesLength; ) {
182:             index = params_.indexes[i];
183: 
184:             // record bucket index at which a position has added liquidity
185:             // slither-disable-next-line unused-return
186:             positionIndex.add(index);
187: 
188:             (uint256 lpBalance, uint256 depositTime) = pool.lenderInfo(index, owner);
189: 
190:             Position memory position = positions[params_.tokenId][index];
191: 
192:             // check for previous deposits
193:             if (position.depositTime != 0) {
194:                 // check that bucket didn't go bankrupt after prior memorialization
195:                 if (_bucketBankruptAfterDeposit(pool, index, position.depositTime)) {
196:                     // if bucket did go bankrupt, zero out the LP tracked by position manager
197:                     position.lps = 0;
198:                 }
199:             }
200: 
201:             // update token position LP
202:             position.lps += lpBalance;
203:             // set token's position deposit time to the original lender's deposit time
204:             position.depositTime = depositTime;
205: 
206:             // save position in storage
207:             positions[params_.tokenId][index] = position;
208: 
209:             unchecked { ++i; }
210:         }
211: 
212:         // update pool LP accounting and transfer ownership of LP to PositionManager contract
213:         pool.transferLP(owner, address(this), params_.indexes);
214: 
215:         emit MemorializePosition(owner, params_.tokenId, params_.indexes);
216:     }
c4-judge commented 1 year ago

Picodes marked the issue as grade-b