@@ -272,33 +272,35 @@ export const getOpenAuction = (
272272 // {1} = {USD/wholeShare} / {USD/wholeShare}
273273 const progression = folio
274274 . map ( ( actualBalance , i ) => {
275- if ( ! rebalance . inRebalance [ i ] || expectedBalances [ i ] . eq ( ZERO ) ) {
276- return ONE ;
275+ if ( ! rebalance . inRebalance [ i ] ) {
276+ return ZERO ;
277277 }
278278
279279 // {wholeTok/wholeShare}
280280 const balanceInBasket = expectedBalances [ i ] . gt ( actualBalance ) ? actualBalance : expectedBalances [ i ] ;
281281
282- // {1 } = {wholeTok/wholeShare} / {wholeTok/wholeShare }
283- return balanceInBasket . div ( expectedBalances [ i ] ) ;
282+ // {USD/wholeShare } = {wholeTok/wholeShare} * {USD/wholeTok }
283+ return balanceInBasket . mul ( prices [ i ] ) ;
284284 } )
285- . reduce ( ( a , b ) => ( a . lt ( b ) ? a : b ) ) ;
285+ . reduce ( ( a , b ) => a . add ( b ) )
286+ . div ( shareValue ) ;
286287
287288 // absolute
288289 // {1} = {USD/wholeShare} / {USD/wholeShare}
289290 let initialProgression = initialFolio
290291 . map ( ( initialBalance , i ) => {
291- if ( ! rebalance . inRebalance [ i ] || expectedBalances [ i ] . eq ( ZERO ) ) {
292- return ONE ;
292+ if ( ! rebalance . inRebalance [ i ] ) {
293+ return ZERO ;
293294 }
294295
295296 // {wholeTok/wholeShare}
296297 const balanceInBasket = expectedBalances [ i ] . gt ( initialBalance ) ? initialBalance : expectedBalances [ i ] ;
297298
298- // {1 } = {wholeTok/wholeShare} / {wholeTok/wholeShare }
299- return balanceInBasket . div ( expectedBalances [ i ] ) ;
299+ // {USD/wholeShare } = {wholeTok/wholeShare} * {USD/wholeTok }
300+ return balanceInBasket . mul ( prices [ i ] ) ;
300301 } )
301- . reduce ( ( a , b ) => ( a . lt ( b ) ? a : b ) ) ;
302+ . reduce ( ( a , b ) => a . add ( b ) )
303+ . div ( shareValue ) ;
302304
303305 if ( progression < initialProgression ) {
304306 if ( debug ) {
@@ -571,6 +573,14 @@ export const getOpenAuction = (
571573 const deficitSize = deficitTokenSizes . reduce ( ( a , b ) => a + b , 0 ) ;
572574 const auctionSize = surplusSize > deficitSize ? deficitSize : surplusSize ;
573575
576+ // update targeting estimates
577+
578+ // {1} = {1} + {USD} / ({share} * {USD/share})
579+ const adjustedTarget = progression . add ( new Decimal ( auctionSize ) . div ( shareValue . mul ( supply ) ) ) ;
580+ if ( adjustedTarget . lte ( ONE ) ) {
581+ target = adjustedTarget ;
582+ }
583+
574584 const relativeTarget = target . sub ( initialProgression ) . div ( ONE . sub ( initialProgression ) ) ;
575585
576586 return [
0 commit comments