@@ -23,7 +23,7 @@ contract LayerCredit is EVCUtil {
2323
2424 GenericFactory immutable private eVaultFactory;
2525 IEulerRouterFactory immutable private routerFactory;
26- StubOracle immutable private stubOracle;
26+ StubOracle immutable private stubOracle; // FIXME: do we want to support pull oracles?
2727
2828 uint256 private constant MAX_COLLATERALS = 3 ;
2929
@@ -300,6 +300,10 @@ contract LayerCredit is EVCUtil {
300300 return getSlice (activeBonds, start, end);
301301 }
302302
303+ function getSettlingBonds (uint256 start , uint256 end ) external view returns (address [] memory ) {
304+ return getSlice (settlingBonds, start, end);
305+ }
306+
303307
304308 error SliceOutOfBounds ();
305309
@@ -339,8 +343,8 @@ contract LayerCredit is EVCUtil {
339343
340344
341345
342- uint64 historyLength;
343- uint40 nextHistEntityId = 1 ;
346+ uint64 public historyLength;
347+ uint40 private nextHistEntityId = 1 ;
344348 uint256 [18446744073709551615 ] private history;
345349
346350 struct HistEntity {
@@ -408,10 +412,41 @@ contract LayerCredit is EVCUtil {
408412 _addToHistory (action, bond, who, metadata, address (0 ));
409413 }
410414
415+ function getHistEntityLength (address entity ) external view returns (uint256 ) {
416+ return histEntities[histEntityLookup[entity]].nextIndexEntry;
417+ }
418+
419+ function getHistoryGlobal (uint256 start , uint256 end ) external view returns (uint256 [] memory ) {
420+ if (end == type (uint256 ).max) end = historyLength;
421+ if (end < start || end > historyLength) revert SliceOutOfBounds ();
422+
423+ uint256 [] memory slice = new uint256 [](end - start);
424+ for (uint256 i; i < end - start; ++ i) {
425+ slice[i] = history[start + i];
426+ }
427+
428+ return slice;
429+ }
430+
431+ function getHistoryForEntity (address entity , uint256 start , uint256 end ) external view returns (uint256 [] memory ) {
432+ HistEntity storage ent = histEntities[histEntityLookup[entity]];
433+
434+ if (end == type (uint256 ).max) end = ent.nextIndexEntry;
435+ if (end < start || end > ent.nextIndexEntry) revert SliceOutOfBounds ();
436+
437+ uint256 [] memory slice = new uint256 [](end - start);
438+ for (uint256 i; i < end - start; ++ i) {
439+ slice[i] = history[ent.index[start + i]];
440+ }
441+
442+ return slice;
443+ }
444+
445+
411446
412447
413448
414- function sameAccount (address a , address b ) internal pure returns (bool ) {
449+ function isSameAccount (address a , address b ) internal pure returns (bool ) {
415450 return (uint160 (a) >> 8 ) == (uint160 (b) >> 8 );
416451 }
417452
@@ -420,12 +455,12 @@ contract LayerCredit is EVCUtil {
420455
421456 function _enforceRestrictedLender (address bond , address msgSender ) internal view {
422457 address restrictedLender = bondsByVault[bond].restrictedLender;
423- require (restrictedLender == address (0 ) || sameAccount (msgSender, restrictedLender), RestrictedLender ());
458+ require (restrictedLender == address (0 ) || isSameAccount (msgSender, restrictedLender), RestrictedLender ());
424459 }
425460
426461 function _enforceRestrictedBorrower (address bond , address msgSender ) internal view {
427462 address restrictedBorrower = bondsByVault[bond].restrictedBorrower;
428- require (restrictedBorrower == address (0 ) || sameAccount (msgSender, restrictedBorrower), RestrictedBorrower ());
463+ require (restrictedBorrower == address (0 ) || isSameAccount (msgSender, restrictedBorrower), RestrictedBorrower ());
429464 }
430465
431466
0 commit comments