mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-11-29 00:15:11 +00:00
test: require M3e liquidation cascades and VAR impulses
This commit is contained in:
@@ -2,6 +2,8 @@ program test_tokenomics
|
|||||||
use tokenomics_engine
|
use tokenomics_engine
|
||||||
implicit none
|
implicit none
|
||||||
real(8) :: shock(3), exposure(3,3), propagated(3), w(3), apy(3), vol(3)
|
real(8) :: shock(3), exposure(3,3), propagated(3), w(3), apy(3), vol(3)
|
||||||
|
real(8) :: collateral(4), borrowed(4), ltv(4), cascade_exposure(4,4), losses(4)
|
||||||
|
real(8) :: var_a(3,3), impulse(3,4)
|
||||||
type(token_state) :: state0, state1
|
type(token_state) :: state0, state1
|
||||||
real(8) :: e_before, e_half, e_quarter
|
real(8) :: e_before, e_half, e_quarter
|
||||||
if (abs(lending_rate(0.80d0,0.02d0,0.04d0,0.60d0,0.80d0)-0.052d0) > 1d-9) error stop 'below kink'
|
if (abs(lending_rate(0.80d0,0.02d0,0.04d0,0.60d0,0.80d0)-0.052d0) > 1d-9) error stop 'below kink'
|
||||||
@@ -29,5 +31,28 @@ program test_tokenomics
|
|||||||
if (abs(e_before-20d0)>1d-12) error stop 'pre-halving emission'
|
if (abs(e_before-20d0)>1d-12) error stop 'pre-halving emission'
|
||||||
if (abs(e_half-10d0)>1d-12) error stop 'first halving'
|
if (abs(e_half-10d0)>1d-12) error stop 'first halving'
|
||||||
if (abs(e_quarter-5d0)>1d-12) error stop 'second halving'
|
if (abs(e_quarter-5d0)>1d-12) error stop 'second halving'
|
||||||
|
|
||||||
|
|
||||||
|
collateral = [100d0,100d0,100d0,100d0]
|
||||||
|
borrowed = [90d0,50d0,20d0,20d0]
|
||||||
|
ltv = [0.80d0,0.80d0,0.80d0,0.80d0]
|
||||||
|
cascade_exposure = 0d0
|
||||||
|
cascade_exposure(2,1) = 0.50d0
|
||||||
|
cascade_exposure(3,2) = 0.50d0
|
||||||
|
call liquidation_cascade(collateral,borrowed,ltv,cascade_exposure,3,losses)
|
||||||
|
if (abs(losses(1)-10d0)>1d-9) error stop 'initial liquidation'
|
||||||
|
if (losses(2) <= 0d0) error stop 'first contagion hop'
|
||||||
|
if (losses(3) <= 0d0) error stop 'second contagion hop'
|
||||||
|
if (abs(losses(4)) > 1d-12) error stop 'isolated protocol'
|
||||||
|
|
||||||
|
var_a = 0d0
|
||||||
|
var_a(2,1) = 0.40d0
|
||||||
|
var_a(3,2) = 0.50d0
|
||||||
|
call var_impulse_response(var_a,[1d0,0d0,0d0],3,impulse)
|
||||||
|
if (abs(impulse(1,1)-1d0)>1d-12) error stop 'impulse origin'
|
||||||
|
if (abs(impulse(2,2)-0.40d0)>1d-12) error stop 'var first hop'
|
||||||
|
if (abs(impulse(3,3)-0.20d0)>1d-12) error stop 'var second hop'
|
||||||
|
if (abs(impulse(1,4))+abs(impulse(2,4))+abs(impulse(3,4)) > 1d-12) &
|
||||||
|
error stop 'impulse decay'
|
||||||
print *, 'TOKENOMICS TESTS PASSED'
|
print *, 'TOKENOMICS TESTS PASSED'
|
||||||
end program
|
end program
|
||||||
|
|||||||
Reference in New Issue
Block a user