-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jar-o <jar@example.com>
- Loading branch information
Showing
10 changed files
with
197 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.16; | ||
|
||
import {IScribe} from "../IScribe.sol"; | ||
|
||
import {IRateSource} from "./external_/interfaces/IRateSource.sol"; | ||
|
||
interface IScribeLST is IScribe, IRateSource {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.16; | ||
|
||
import {IScribeOptimistic} from "../IScribeOptimistic.sol"; | ||
|
||
import {IRateSource} from "./external_/interfaces/IRateSource.sol"; | ||
|
||
interface IScribeOptimisticLST is IScribeOptimistic, IRateSource {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.16; | ||
|
||
import {IScribeLST} from "./IScribeLST.sol"; | ||
import {IRateSource} from "./external_/interfaces/IRateSource.sol"; | ||
|
||
import {Scribe} from "../Scribe.sol"; | ||
|
||
/** | ||
* @title ScribeLST | ||
* | ||
* @notice Schnorr based Oracle with onchain fault resolution for Liquid | ||
* Staking Token APRs. | ||
*/ | ||
contract ScribeLST is IScribeLST, Scribe { | ||
constructor(address initialAuthed_, bytes32 wat_) | ||
Scribe(initialAuthed_, wat_) | ||
{} | ||
|
||
/// @inheritdoc IRateSource | ||
/// @dev Only callable by toll'ed address. | ||
function getAPR() external view toll returns (uint) { | ||
// Note that function does not revert if val is zero. | ||
return _pokeData.val; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Contract overwrite to deploy contract instances with specific naming. | ||
* | ||
* For more info, see docs/Deployment.md. | ||
*/ | ||
contract Chronicle_BASE_QUOTE_COUNTER is ScribeLST { | ||
// @todo ^^^^ ^^^^^ ^^^^^^^ Adjust name of Scribe instance. | ||
constructor(address initialAuthed, bytes32 wat_) | ||
ScribeLST(initialAuthed, wat_) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.16; | ||
|
||
import {IScribeOptimisticLST} from "./IScribeOptimisticLST.sol"; | ||
import {IRateSource} from "./external_/interfaces/IRateSource.sol"; | ||
|
||
import {ScribeOptimistic} from "../ScribeOptimistic.sol"; | ||
|
||
/** | ||
* @title ScribeOptimisticLST | ||
* | ||
* @notice Schnorr based optimistic Oracle with onchain fault resolution for | ||
* Liquid Staking Token APRs. | ||
*/ | ||
contract ScribeOptimisticLST is IScribeOptimisticLST, ScribeOptimistic { | ||
constructor(address initialAuthed_, bytes32 wat_) | ||
ScribeOptimistic(initialAuthed_, wat_) | ||
{} | ||
|
||
/// @inheritdoc IRateSource | ||
/// @dev Only callable by toll'ed address. | ||
function getAPR() external view toll returns (uint) { | ||
// Note that function does not revert if val is zero. | ||
return _currentPokeData().val; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Contract overwrite to deploy contract instances with specific naming. | ||
* | ||
* For more info, see docs/Deployment.md. | ||
*/ | ||
contract Chronicle_BASE_QUOTE_COUNTER is ScribeOptimisticLST { | ||
// @todo ^^^^ ^^^^^ ^^^^^^^ Adjust name of Scribe instance. | ||
constructor(address initialAuthed, bytes32 wat_) | ||
ScribeOptimisticLST(initialAuthed, wat_) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity >=0.8.0; | ||
|
||
/** | ||
* @dev Interest rate oracle interface from [Spark](https://spark.fi/). | ||
* | ||
* Copied from https://github.com/marsfoundation/sparklend-advanced/blob/277ea9d9ad7faf330b88198c9c6de979a2fad561/src/interfaces/IRateSource.sol. | ||
*/ | ||
interface IRateSource { | ||
/// @notice Returns the oracle's current APR value. | ||
/// @return The oracle's current APR value. | ||
function getAPR() external view returns (uint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.16; | ||
|
||
import {IToll} from "chronicle-std/toll/IToll.sol"; | ||
|
||
import {IScribeLST} from "src/extensions/IScribeLST.sol"; | ||
|
||
import {IScribeTest} from "../IScribeTest.sol"; | ||
|
||
abstract contract IScribeLSTTest is IScribeTest { | ||
IScribeLST private scribeLST; | ||
|
||
function setUp(address scribe_) internal override(IScribeTest) { | ||
super.setUp(scribe_); | ||
|
||
scribeLST = IScribeLST(scribe_); | ||
} | ||
|
||
function test_getAPR_DoesNotRevertIf_ValIsZero() public { | ||
uint val = scribeLST.getAPR(); | ||
assertEq(val, 0); | ||
} | ||
|
||
// -- Test: Toll Protected Functions -- | ||
|
||
function test_getAPR_isTollProtected() public { | ||
vm.prank(address(0xbeef)); | ||
vm.expectRevert( | ||
abi.encodeWithSelector(IToll.NotTolled.selector, address(0xbeef)) | ||
); | ||
scribeLST.getAPR(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.16; | ||
|
||
import {IToll} from "chronicle-std/toll/IToll.sol"; | ||
|
||
import {IScribeOptimisticLST} from "src/extensions/IScribeOptimisticLST.sol"; | ||
|
||
import {IScribeOptimisticTest} from "../IScribeOptimisticTest.sol"; | ||
|
||
abstract contract IScribeOptimisticLSTTest is IScribeOptimisticTest { | ||
IScribeOptimisticLST private opScribeLST; | ||
|
||
function setUp(address scribe_) internal override(IScribeOptimisticTest) { | ||
super.setUp(scribe_); | ||
|
||
opScribeLST = IScribeOptimisticLST(scribe_); | ||
} | ||
|
||
function test_getAPR_DoesNotRevertIf_ValIsZero() public { | ||
uint val = opScribeLST.getAPR(); | ||
assertEq(val, 0); | ||
} | ||
|
||
// -- Test: Toll Protected Functions -- | ||
|
||
function test_getAPR_isTollProtected() public { | ||
vm.prank(address(0xbeef)); | ||
vm.expectRevert( | ||
abi.encodeWithSelector(IToll.NotTolled.selector, address(0xbeef)) | ||
); | ||
opScribeLST.getAPR(); | ||
} | ||
} |