@@ -204,11 +204,15 @@ async def imf_page(clearing_house: DriftClient):
204
204
205
205
# Calculate effective weight
206
206
base_weight = init_weight
207
- if imf != 0 :
208
- base_weight = base_weight * 0.8 # Discount when IMF active
209
-
210
- ddsize = np .sqrt (np .abs (base ))
211
- effective_weight = max (init_weight , base_weight + imf * ddsize )
207
+ if weight_type == "Liability (Borrow)" :
208
+ if imf != 0 :
209
+ base_weight = base_weight * 0.8 # Discount when IMF active
210
+
211
+ ddsize = np .sqrt (np .abs (base ))
212
+ effective_weight = max (init_weight , base_weight + imf * ddsize )
213
+ else :
214
+ ddsize = np .sqrt (np .abs (base ))
215
+ effective_weight = min (init_weight , (1.1 ) - imf * ddsize )
212
216
213
217
if weight_type == "Asset (Collateral)" :
214
218
st .write (f"Base Asset Weight: { init_weight :.3f} " )
@@ -233,11 +237,17 @@ async def imf_page(clearing_house: DriftClient):
233
237
234
238
def calc_effective_weight (weight , imf , size , is_liability = True ):
235
239
base_weight = weight
236
- if imf != 0 :
237
- base_weight = weight * 0.8
238
- dd = np .sqrt (np .abs (size ))
239
- effective = max (weight , base_weight + imf * dd )
240
- return 1 / effective if is_liability else effective
240
+
241
+ if is_liability :
242
+ if imf != 0 :
243
+ base_weight = weight * 0.8
244
+ dd = np .sqrt (np .abs (size ))
245
+ effective = max (weight , base_weight + imf * dd )
246
+ return 1 / effective if is_liability else effective
247
+ else :
248
+ dd = np .sqrt (np .abs (size ))
249
+ effective = min (weight , (1.1 ) - imf * dd )
250
+ return effective
241
251
242
252
is_liability = weight_type == "Liability (Borrow)"
243
253
df = pd .Series ([calc_effective_weight (init_weight , imf , x , is_liability ) for x in index ])
0 commit comments