@@ -31,11 +31,20 @@ contract ACash is ERC20, Initializable, Ownable {
3131 // calculates bond price
3232 IPricingStrategy public pricingStrategy;
3333
34+ // Yield applied on each tranche
35+ // tranche yields is specific to the parent bond's class identified by its config hash
36+ // a bond's class is the combination of the {collateralToken, trancheRatios}
37+ // specified as a fixed point number with YIELD_DECIMALS
38+ mapping (bytes32 => uint256 []) private _trancheYields;
39+
3440 // bondQueue is a queue of Bonds, which have an associated number of seniority-based tranches.
3541 AddressQueue.Queue public bondQueue;
3642
37- // system only keeps bonds which mature further out than the `tolarableBondMaturiy` in the queue
38- uint256 private _tolarableBondMaturiy;
43+ // the minimum maturity time in seconds for a bond below which it gets removed from the bond queue
44+ uint256 private _minQueueMaturiySec;
45+
46+ // the maximum maturity time in seconds for a bond above which it can't get added into the bond queue
47+ uint256 private _maxQueueMaturiySec;
3948
4049 //---- ERC-20 parameters
4150 uint8 private immutable _decimals;
@@ -44,6 +53,9 @@ contract ACash is ERC20, Initializable, Ownable {
4453 // They can only be rolled over and not burnt
4554 mapping (ITranche => bool ) trancheIcebox;
4655
56+ // constants
57+ uint256 public constant YIELD_DECIMALS = 6 ;
58+
4759 constructor (
4860 string memory name ,
4961 string memory symbol ,
@@ -84,11 +96,16 @@ contract ACash is ERC20, Initializable, Ownable {
8496
8597 uint256 mintAmt = 0 ;
8698 for (uint256 i = 0 ; i < trancheCount; i++ ) {
99+ uint256 trancheYield = _trancheYields[bondIssuer.configHash (mintingBond)][i];
100+ if (trancheYield == 0 ){
101+ continue ;
102+ }
103+
87104 (ITranche t , ) = mintingBond.tranches (i);
88105 t.safeTransferFrom (_msgSender (), address (this ), trancheAmts[i]);
89106
90107 // get bond price, ie amount of SPOT for trancheAmts[i] amount of t tranches
91- mintAmt += pricingStrategy.getTranchePrice (t, trancheAmts[i]);
108+ mintAmt += ( pricingStrategy.getTranchePrice (t, trancheAmts[i]) * trancheYield) / ( 10 ** YIELD_DECIMALS );
92109 }
93110
94111 int256 fee = feeStrategy.computeMintFee (mintAmt);
@@ -102,8 +119,9 @@ contract ACash is ERC20, Initializable, Ownable {
102119 // push new bond into the queue
103120 function advanceMintBond (IBondController newBond ) public {
104121 require (address (newBond) != bondQueue.head (), "New bond already in queue " );
105- require (bondIssuer.isInstance (address (newBond)), "Expect new bond to be minted by the minter " );
106- require (newBond.maturityDate () > tolarableBondMaturiyDate (), "New bond matures too soon " );
122+ require (bondIssuer.isInstance (newBond), "Expect new bond to be minted by the minter " );
123+ require (newBond.maturityDate () > minQueueMaturityDate (), "New bond matures too soon " );
124+ require (newBond.maturityDate () <= maxQueueMaturityDate (), "New bond matures too late " );
107125
108126 bondQueue.enqueue (address (newBond));
109127 }
@@ -114,7 +132,7 @@ contract ACash is ERC20, Initializable, Ownable {
114132 while (true ) {
115133 IBondController latestBond = IBondController (bondQueue.tail ());
116134
117- if (address (latestBond) == address (0 ) || latestBond.maturityDate () > tolarableBondMaturiyDate ()) {
135+ if (address (latestBond) == address (0 ) || latestBond.maturityDate () > minQueueMaturityDate ()) {
118136 break ;
119137 }
120138
@@ -168,12 +186,21 @@ contract ACash is ERC20, Initializable, Ownable {
168186 feeStrategy = feeStrategy_;
169187 }
170188
171- function setTolarableBondMaturiy (uint256 tolarableBondMaturiy ) external onlyOwner {
172- _tolarableBondMaturiy = tolarableBondMaturiy;
189+ function setTolarableBondMaturiy (uint256 minQueueMaturiySec , uint256 maxQueueMaturiySec ) external onlyOwner {
190+ _minQueueMaturiySec = minQueueMaturiySec;
191+ _maxQueueMaturiySec = maxQueueMaturiySec;
192+ }
193+
194+ function setTrancheYields (bytes32 configHash , uint256 [] memory yields ) external onlyOwner {
195+ _trancheYields[configHash] = yields;
196+ }
197+
198+ function minQueueMaturityDate () public view returns (uint256 ) {
199+ return block .timestamp + _minQueueMaturiySec;
173200 }
174201
175- function tolarableBondMaturiyDate () public view returns (uint256 ) {
176- return block .timestamp + _tolarableBondMaturiy ;
202+ function maxQueueMaturityDate () public view returns (uint256 ) {
203+ return block .timestamp + _maxQueueMaturiySec ;
177204 }
178205
179206 /*
0 commit comments