Augmint.cc basic model
Model was written in NetLogo 6.0.2
•
Viewed 253 times
•
Downloaded 59 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ ethUsd reserveEth reserveAcd totalLockedAcd interestPool earnedInterest totalSupply ethUsdRates floatingAcd ; not locked or in reserve, in circulation ] breed [loans loan] breed [deposits deposit] deposits-own [depositAmount start term maturity interestPt interestAmount] loans-own [loanAmount disbursedAmount interestAmount interestPt collateral start term maturity ] to startup setup end to setup clear-all read-ethUsdRates if startRatesIndex - 1 >= length ethUsdRates [ user-message (word "startRatesIndex " startRatesIndex " must be lower than size of historic ethUsdRates of " length ethUsdRates) ] if endRatesIndex > length ethUsdRates [ user-message (word "startRatesIndex " startRatesIndex " is higher than size of historic ethUsdRates of " length ethUsdRates) ] if startRatesIndex >= endRatesindex [ user-message (word "startRatesIndex " startRatesIndex " must be lower than endRatesIndex " endRatesIndex) ] set ethUsd item startRatesIndex ethUsdRates set earnedInterest initEarnedInterest set reserveAcd initReserveAcd set reserveEth initReserveEth set totalSupply initEarnedInterest + initReserveAcd set-default-shape loans "sheep" set-default-shape deposits "star" reset-ticks end to go if ticks + 1 > endRatesIndex - startRatesIndex [ stop ] set ethUsd item (ticks + startRatesIndex) ethUsdRates place-deposits output-print (word "Total supply: " totalSupply " ReserveAcd: " reserveAcd " totalLockedAcd: " totalLockedAcd " reserveEth: " reserveEth " interestPool: " interestPool " earnedInterest: " earnedInterest) buy-or-sell-acd output-print (word "Total supply: " totalSupply " ReserveAcd: " reserveAcd " totalLockedAcd: " totalLockedAcd " reserveEth: " reserveEth " interestPool: " interestPool " earnedInterest: " earnedInterest) release-deposits output-print (word "Total supply: " totalSupply " ReserveAcd: " reserveAcd " totalLockedAcd: " totalLockedAcd " reserveEth: " reserveEth " interestPool: " interestPool " earnedInterest: " earnedInterest) get-loans output-print (word "Total supply: " totalSupply " ReserveAcd: " reserveAcd " totalLockedAcd: " totalLockedAcd " reserveEth: " reserveEth " interestPool: " interestPool " earnedInterest: " earnedInterest) payback-loans output-print (word "Total supply: " totalSupply " ReserveAcd: " reserveAcd " totalLockedAcd: " totalLockedAcd " reserveEth: " reserveEth " interestPool: " interestPool " earnedInterest: " earnedInterest) tick end to place-deposits ifelse acdDepositInterestPt > usdDepositMktInterestPt [ ; anything between 1 ACD and the amount availabel in earnedInterest (but max maxDepositAmount and what is available in reserve) let _depositNet round((random earnedInterest ) / ( acdDepositInterestPt / 100)) + 1 if _depositNet > maxDepositAmount [ set _depositNet maxDepositAmount ] if _depositNet > reserveAcd [set _depositNet reserveAcd] let _depositAmount round( _depositNet * (1 + acdDepositInterestPt / 100)) ifelse _depositAmount > 0 [ let _interestAmount _depositAmount - _depositNet create-deposits 1 [ set heading 180 setxy (floor( (who ) / (max-pycor + 1 ) ) ) (who mod (max-pycor + 1 ) ) set color green set depositAmount _depositAmount set interestPt acdDepositInterestPt set interestAmount _interestAmount set term depositTerm set start ticks set maturity start + term output-print (word "Tick #" ticks " - New deposit #" who " depositAmount: " depositAmount "ACD _depositNet: " _depositNet "ACD." " acdDepositInterestPt: " acdDepositInterestPt " interestAmount: " _interestAmount " term: " term " maturity: " maturity) ] buy-acd-from-reserve _depositNet ; buys acd from reserve to deposit set earnedInterest earnedInterest - _interestAmount set totalLockedAcd totalLockedAcd + _depositAmount ] [ output-print (word "Tick #" ticks " - not enough earnedInterest or reserveAcd to deposit " _depositAmount "ACD _depositNet: " _depositNet "ACD. reserveAcd: " reserveAcd " earnedInterest: " earnedInterest) ] ] [ output-print (word "Tick #" ticks " - usd interest is higher or equal to ACD interest, noone deposits ACD") ] end to buy-or-sell-acd let acdSellAmount random(1) * chanceToSellAcd / 100 * floatingAcd let acdBuyAmount random(1) * chanceToBuyAcd / 100 * reserveAcd ; we assume that the max demand is what we have in reserve, if it's more then ppl will get a loan (or go to secondary mkt) let amount 0 ifelse acdSellAmount > acdBuyAmount [ set amount acdSellAmount - acdBuyAmount buy-eth-from-reserve amount set floatingAcd floatingAcd - amount ] [ set amount acdBuyAmount - acdSellAmount buy-acd-from-reserve amount set floatingAcd floatingAcd + amount ] output-print (word "Tick #" ticks " - buy-or-sell-acd floatingAcd: " floatingAcd " amount: " amount "ACD acdSellAmount: " acdSellAmount "ACD acdBuyAmount: "acdBuyAmount " ethUsd: " ethUsd " chanceToSellAcd:" chanceToSellAcd "% chanceToBuyAcd: " "% reserveAcd: " reserveAcd "ACD floatingAcd: " floatingAcd "ACD") end to release-deposits ask deposits with [ maturity = ticks ] [ output-print (word "Tick #" ticks " - deposit #" who " release " depositAmount "ACD") let ethValue (depositAmount / ethUsd) if ethValue > reserveEth [ user-message (word "Not enough ETH in reserve to convert the released " depositAmount "ACD to ETH after loan disbursement. reserveEth: " reserveEth "ETH") ] set reserveEth reserveEth - ethValue ; immediatety buys ETH with ACD released set reserveAcd reserveAcd + depositAmount set totalLockedAcd totalLockedAcd - depositAmount set color white ] end to get-loans let _disbursedAmount round((random (reserveEth * ethUsd) )) if _disbursedAmount > maxLoanAmount [ set _disbursedAmount maxLoanAmount ] ifelse _disbursedAmount > 0 [ let _collateral round(_disbursedAmount / ( loanCollateralRatio / 100) / ethUsd ) let _loanAmount round(_disbursedAmount * (1 + acdLoanInterestPt / 100)) let _interestAmount (_loanAmount - _disbursedAmount) create-loans 1 [ set heading 180 setxy (floor( (who ) / (max-pycor + 1 ) ) ) (who mod (max-pycor + 1 ) ) set color green set loanAmount _loanAmount set disbursedAmount _disbursedAmount set interestAmount _interestAmount set interestPt acdLoanInterestPt set collateral _collateral set term loanTerm set start ticks set maturity start + term output-print (word "Tick #" ticks " - New loan #" who " loanAmount: " loanAmount " disbursedAmount: " disbursedAmount " interestPt: " interestPt " interestAmount: " interestAmount " term: " term " maturity: " maturity " loanCollateralRatio: " loanCollateralRatio " collateral: " _collateral " ethUsd: " ethUsd) ] let ethValue (_disbursedAmount / ethUsd) if ethValue > reserveEth [ user-message (word "Not enough eth in reserve to convert disbursedAmount " _disbursedAmount "ACD to ETH after loan disbursement. reserveEth: " reserveEth "ETH") ] set totalSupply totalSupply + _loanAmount set reserveEth reserveEth - ethValue ; immediatly sell disbursed ACD for ETH through reserve set reserveAcd reserveAcd + _disbursedAmount set interestPool interestPool + _interestAmount ] [ output-print (word "Tick #" ticks " - reserveEth is 0, no new loan") ] end to payback-loans ask loans with [ maturity = ticks ] [ ifelse random(100) >= forgottenLoanRate [ ifelse collateral > (loanAmount / ethUsd) [ output-print (word "Tick #" ticks " - Repay loan #" who " loanAmount: " loanAmount " disbursedAmount: " disbursedAmount " interestPt: " interestPt " interestAmount: " interestAmount " term: " term " maturity: " maturity " loanCollateralRatio: " loanCollateralRatio " collateral: " collateral " ethUsd: " ethUsd) if (reserveAcd < loanAmount) [ user-message (word "Not enough ACD to buy for loan repayment. reserveACD: " reserveAcd " loanAmount: " loanAmount) ] set reserveEth reserveEth + (loanAmount / ethUsd) ; buying Acd with ETH from reserve to repay set reserveAcd reserveAcd - loanAmount set interestPool interestPool - interestAmount set earnedInterest earnedInterest + interestAmount set totalSupply totalSupply - loanAmount set collateral 0 set color white ] [ collect-loan red; didn't worth to repay ] ] [ collect-loan red + 3 ; forgot to repay ] ] end to collect-loan [ markColor ] ; turtle context let toCollect loanAmount * (1 + defaultingLoanFeePt / 100) / ethUsd if toCollect > collateral [ set toCollect collateral] output-print (word "Tick #" ticks " - loans #" who " default collecting " toCollect "ETH from " collateral "ETH collateralAcdValue: " (collateral * ethUsd) " loanAmount: " loanAmount) set reserveEth reserveEth + toCollect set interestPool interestPool - interestAmount set reserveAcd reserveAcd + interestAmount set collateral 0 set color markColor end to buy-acd-from-reserve [amount] if reserveAcd - amount < 0 [ user-message (word "not enough Acd in reserve to buy acd. reserveAcd: " reserveAcd " amount:" amount "ACD")] set reserveEth reserveEth + (amount / ethUsd) set reserveAcd reserveAcd - amount end to buy-eth-from-reserve [amount] let ethValue amount / ethUsd if reserveEth - ethValue < 0 [ user-message (word "not enough Eth in reserve to sell acd. reserveEth: " reserveEth " amount:" amount "Acd ethValue:" ethValue "ETH")] set reserveEth reserveEth - (amount / ethUsd) set reserveAcd reserveAcd + amount end to intervene-buyAcd ; buy back from acd reserve with eth reserve let ethValue reserveConvertAmount / ethUsd if ethValue > reserveEth [ user-message (word "not enough Eth in reserve. reserveEth: " reserveEth) stop ] set reserveEth reserveEth - ethValue set reserveAcd reserveAcd + reserveConvertAmount output-print (word "Tick #" ticks " - MANUAL INTERVENTION buyBackEth ethValue(sold): " ethValue "ETH reserveConvertAmount (bought): " reserveConvertAmount "ACD " ) stop end to intervene-buyEth ; if reserveConvertAmount > reserveAcd [ user-message (word "not enough ACD in reserve. reserveAcd: " reserveAcd) stop ] let ethValue reserveConvertAmount / ethUsd set reserveEth reserveEth + ethValue set reserveAcd reserveAcd - reserveConvertAmount output-print (word "Tick #" ticks " - MANUAL INTERVENTION buyBackEth ethValue(bought): " ethValue "ETH reserveConvertAmount(sold): " reserveConvertAmount "ACD " ) stop end to read-ethUsdRates set ethUsdRates [ 0.753325 0.701897 0.708448 1.07 1.22 1.83 1.83 1.69 1.57 1.2 1.09 1.26 1.46 1.4 1.38 1.35 1.23 1.14 1.16 1.15 1.19 1.18 1.32 1.36 1.35 1.29 1.26 1.27 1.34 1.3 1.25 1.24 1.21 1.17 0.982978 1.04 0.936003 0.875622 0.94441 0.907175 0.874231 0.853685 0.882391 0.938445 0.919047 0.901796 0.893406 0.81361 0.736223 0.785964 0.720839 0.582886 0.661146 0.738644 0.690215 0.678574 0.687171 0.668379 0.628643 0.650645 0.609388 0.621716 0.650628 0.627857 0.634963 0.62603 0.607655 0.522968 0.561878 0.536495 0.547178 0.517734 0.489014 0.434829 0.447329 0.567702 0.539657 0.56359 0.616039 0.731317 0.869641 1 1.21 1.04 0.916627 1.06 0.989789 1.01 0.89905 0.895637 0.926032 0.927974 1.03 0.999278 0.934348 0.791829 0.895711 0.904096 0.888812 0.906368 0.928962 1.01 0.993319 0.955532 0.92492 0.97614 0.968018 0.946969 0.900191 0.863537 0.884183 0.867951 0.915703 0.878614 0.873119 0.8748 0.82121 0.812143 0.840041 0.862438 0.8355 0.811264 0.822118 0.792167 0.840396 0.929762 0.976973 0.952884 0.993022 1.01 0.991182 0.940701 0.920127 0.908072 0.903885 0.900771 0.864202 0.858077 0.863262 0.870363 0.854603 0.856365 0.845005 0.873054 0.911958 0.933542 0.948024 0.937124 0.971905 0.95448 0.950176 0.95086 0.942005 0.986789 0.986833 0.999231 1.06 1.14 1.13 1.19 1.21 1.22 1.33 1.43 1.37 1.53 1.55 1.5 1.97 2.14 2.5 2.28 2.39 2.53 2.49 2.45 2.31 2.21 2.44 2.53 2.58 2.54 2.53 2.96 3.18 4.04 4.44 6.01 5.55 5.39 5.24 5.29 4.32 3.76 4.4 4.74 4.34 4.65 5.62 5.59 6.24 6.1 5.92 6.43 6.47 6.34 7.65 8.47 9.29 10.41 11 11.38 9.55 9.85 11.9 11.3 11.08 13.53 14.47 12.45 13.01 12.52 11.08 11 10.53 10.32 11.86 11.27 12.42 11.23 10.74 10.97 10.42 11.67 11.66 11.95 11.4 11.66 11.6 11.62 11.16 10.44 10.69 10.07 9.72 9.15 8.94 8.64 7.44 8.04 8.39 8.24 8.61 9.31 9.04 8.71 8.47 8.1 7.82 8.29 8 7.55 7.4 7.76 7.17 7.46 8.81 8.85 10.16 9.31 9.41 9.83 9.35 9.37 9.48 9.3 9.36 10 10.06 10.51 10.24 9.96 11.17 12.2 13.56 14.77 13.64 14.02 14.29 13.46 12.73 12.53 12.43 11.3 11.89 12.35 12.73 14.08 14 13.74 13.85 13.74 13.97 13.93 14.51 14.42 14.4 13.91 14.19 15.74 17.6 18.89 18.35 20.59 15.38 11.33 12.23 11.84 13.31 13.1 13.68 14.33 14.28 13.85 13.88 12.18 12.61 12.46 12.2 12.13 11.72 11.47 10.61 10.53 10.11 11.39 10.97 10.95 10.46 10.52 10.5 11.51 11.95 11.65 11.16 11.03 11.62 12.45 12.65 14.66 14.3 12.75 13.84 11.99 12.97 12.84 12.79 12.46 11.88 10.94 8.79 10.29 11.04 10.93 10.88 10.91 11.25 12.24 12.14 11.69 11.78 11.57 11.19 11.22 11.14 10.75 10.76 10.75 11.25 11.18 11.12 11.03 11.04 11.36 11.3 11.15 10.93 10.98 11.23 11.67 11.99 12.11 11.76 11.68 11.72 11.69 11.55 11.35 11.65 12.17 11.64 11.89 11.92 11.92 11.94 12.56 12.7 12.43 13.19 14.43 13.77 13.25 13.33 12.88 13.1 12.82 13.1 13.27 13.07 13.22 13.17 13.2 13.45 13.28 13.04 12.85 12.67 12.22 12.05 11.76 11.79 11.93 11.96 11.94 11.98 11.95 12.01 12.59 12.02 12.1 12.18 12.07 12.04 11.97 11.41 11.53 11.5 11.09 10.44 11.18 11 10.77 10.75 10.8 11.09 11 10.87 10.81 10.83 10.66 10.52 10.29 9.88 10.1 9.97 10.22 10.06 9.99 9.48 9.66 9.58 9.62 9.91 9.84 9.23 9.4 9.33 9 8.72 8.17 8.59 8.45 7.76 7.92 7.44 6.82 7.87 8.38 8.23 8.45 8.13 8.19 8.52 8.42 8.27 7.83 7.86 7.88 7.87 7.64 7.66 7.91 7.58 7.17 7.27 7.18 7.27 7.17 7.52 8.28 8.16 7.97 8.17 8.38 9.73 11.25 10.25 10.25 9.87 10.29 10.33 10.55 9.72 9.86 9.77 9.65 9.9 9.64 10.3 10.23 10.4 10.6 10.91 10.7 10.82 10.63 10.57 10.59 10.54 10.56 10.48 10.57 10.73 10.73 10.82 11.11 11.43 11.35 11.39 11.52 11.43 11.03 11.28 11.35 11.4 11.27 13.03 12.92 12.9 12.68 12.81 12.76 12.43 12.67 12.6 13.12 13.07 13.55 14.52 15.4 15.82 17.35 19.03 19.46 18.62 19.3 19.61 18.89 16.65 17.75 19.33 21.47 23.44 28.59 28.65 35.06 46.35 46.83 34.16 44.74 43.39 43.15 42.34 43.68 53.11 51.25 50.52 49.67 50.77 53.13 52.21 50.04 50.7 48.75 44.36 44.64 45.3 43.24 42.16 44.31 43.27 43.44 43.41 46.29 50.22 47.57 49.1 48.72 48.3 50.71 48.31 49.67 48.22 48.55 48.49 50.03 49.89 52.72 62.17 70.16 68.38 79.02 76.3 77.26 79.72 96.98 94.4 97.81 94.01 91.42 91.16 89.52 89.88 88.66 90.84 90.79 92.41 89.44 89.86 96.91 129.53 126.52 157.94 174.26 181.95 190.05 174.45 160.4 157.76 170.51 194.91 231.91 230.67 222.24 223.78 224.38 245.33 248.46 264.47 258.07 261.67 281.74 337.67 340.61 401.49 397.54 359.05 361.93 370.23 379.41 371.46 370.06 359 336.87 336.37 341.74 323.7 303.25 272.69 293.09 327.93 302.88 294.92 274.6 287.99 282.9 273.3 268.77 270.55 245.99 251.7 242.14 215.36 197.4 230.77 209.73 199.66 170.66 157.36 193.42 234.39 199.7 227.26 218.31 229.48 225.95 224.71 206.71 203.95 204.32 193.12 205.79 197.98 203.87 226.77 219.95 225.34 223.07 256.51 261.57 269.18 296.77 296.03 295.89 308.86 310.6 298.06 300.1 289.82 302.27 301.46 295.59 297.47 301.43 321.59 314.79 317.52 325.61 331.92 333.88 347.89 347.75 370.67 378.49 383.04 387.74 348.98 347.48 295.17 312.99 334.34 329.43 296.5 294.4 288.75 294.53 291.46 277.11 213.91 250.46 246.52 251.75 293.5 282.8 283.74 258.58 264.31 286.17 282.48 292.33 287.44 306.47 299.15 291.47 301.46 302.34 297.48 292.46 292.66 295.86 308.59 311.12 308.61 297.39 299.87 303.46 304.14 338.76 339.63 336.6 333.38 317.08 314.32 308.09 304.01 300.19 295.45 286.95 298.33 297.93 296.53 297.42 296.3 305.09 307.75 305.88 291.69 287.43 305.71 300.47 296.26 298.89 294.66 309.07 320.88 299.25 314.68 307.91 316.72 337.63 333.36 330.92 332.39 347.61 354.39 366.73 360.4 380.65 410.17 474.91 466.28 471.33 480.36 ] end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Augmint.cc basic model.png | preview | Preview for 'Augmint.cc basic model' | about 7 years ago, by Peter Petrovics | Download |
This model does not have any ancestors.
This model does not have any descendants.