Spaces:
Running
Running
File size: 58,919 Bytes
455a7fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Global Trade Fin. Calculator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.floating-btn {
position: fixed;
bottom: 30px;
right: 30px;
width: 60px;
height: 60px;
border-radius: 50%;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
z-index: 1000;
}
.floating-btn:hover {
transform: translateY(-5px) scale(1.05);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
.floating-btn-secondary {
position: fixed;
bottom: 100px;
right: 30px;
width: 60px;
height: 60px;
border-radius: 50%;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
z-index: 1000;
}
.floating-btn-secondary:hover {
transform: translateY(-5px) scale(1.05);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
.floating-btn-tertiary {
position: fixed;
bottom: 170px;
right: 30px;
width: 60px;
height: 60px;
border-radius: 50%;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
z-index: 1000;
}
.floating-btn-tertiary:hover {
transform: translateY(-5px) scale(1.05);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
.floating-btn-quaternary {
position: fixed;
bottom: 240px;
right: 30px;
width: 60px;
height: 60px;
border-radius: 50%;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
z-index: 1000;
}
.floating-btn-quaternary:hover {
transform: translateY(-5px) scale(1.05);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
.modal {
transition: all 0.3s ease;
opacity: 0;
visibility: hidden;
}
.modal.active {
opacity: 1;
visibility: visible;
}
.tariff-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #3B82F6;
cursor: pointer;
}
.animate-pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.market-share-gauge {
width: 100%;
height: 20px;
background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);
border-radius: 10px;
margin-top: 10px;
position: relative;
}
.gauge-pointer {
position: absolute;
top: -5px;
width: 2px;
height: 30px;
background: black;
transform: translateX(-50%);
}
.tariff-badge {
display: inline-block;
padding: 0.25rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
}
.token-progress {
height: 10px;
border-radius: 5px;
background-color: #e5e7eb;
overflow: hidden;
}
.token-progress-bar {
height: 100%;
background: linear-gradient(90deg, #8b5cf6, #6366f1);
transition: width 0.3s ease;
}
.yield-farming-card {
background: linear-gradient(135deg, #f5f7fa 0%, #e4e7eb 100%);
border-radius: 12px;
padding: 1.5rem;
position: relative;
overflow: hidden;
}
.yield-farming-card::before {
content: "";
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
transform: rotate(45deg);
animation: shine 3s infinite;
}
@keyframes shine {
0% { transform: translateX(-100%) rotate(45deg); }
100% { transform: translateX(100%) rotate(45deg); }
}
.bitcoin-address {
font-family: monospace;
letter-spacing: 1px;
}
.mining-estimate {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
border-left: 4px solid #f59e0b;
}
.country-flag {
width: 24px;
height: 16px;
display: inline-block;
margin-right: 8px;
border: 1px solid #e5e7eb;
vertical-align: middle;
}
.tariff-impact-meter {
height: 8px;
border-radius: 4px;
background-color: #e5e7eb;
margin-top: 8px;
overflow: hidden;
}
.tariff-impact-bar {
height: 100%;
background: linear-gradient(90deg, #10b981, #3B82F6);
}
.credit-rating-badge {
display: inline-flex;
align-items: center;
padding: 0.25rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
}
.economic-indicator {
display: flex;
justify-content: space-between;
padding: 0.5rem 0;
border-bottom: 1px solid #e5e7eb;
}
.economic-indicator:last-child {
border-bottom: none;
}
.credit-rating-AAA { background-color: #10b981; color: white; }
.credit-rating-AA { background-color: #34d399; color: white; }
.credit-rating-A { background-color: #60a5fa; color: white; }
.credit-rating-BBB { background-color: #f59e0b; color: white; }
.credit-rating-BB { background-color: #f97316; color: white; }
.credit-rating-B { background-color: #ef4444; color: white; }
.credit-rating-CCC { background-color: #dc2626; color: white; }
.credit-rating-CC { background-color: #991b1b; color: white; }
.credit-rating-C { background-color: #7c3aed; color: white; }
.credit-rating-D { background-color: #000000; color: white; }
.fffund-panel {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 90%;
max-width: 600px;
background: white;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
z-index: 2000;
padding: 20px;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.fffund-panel.active {
opacity: 1;
visibility: visible;
}
.fffund-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1999;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.fffund-overlay.active {
opacity: 1;
visibility: visible;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-12 max-w-4xl">
<div class="text-center mb-12">
<h1 class="text-4xl font-bold text-blue-800 mb-2">Global Trade Finance Calculator</h1>
<p class="text-lg text-gray-600">Calculate trade financing costs with real-world tariff rates</p>
</div>
<div class="bg-white rounded-xl shadow-lg p-6 mb-8">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="block text-gray-700 font-medium mb-2">Trade Amount ($)</label>
<input type="number" id="loanAmount" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="e.g. 100000" value="100000">
</div>
<div>
<label class="block text-gray-700 font-medium mb-2">Base Interest Rate (%)</label>
<input type="number" id="primeRate" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="e.g. 7.5" value="7.5" step="0.01">
</div>
</div>
<div class="mt-6">
<label class="block text-gray-700 font-medium mb-2">Importing Country</label>
<select id="importCountry" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 mb-4">
<option value="US">United States</option>
<option value="EU">European Union</option>
<option value="CN">China</option>
<option value="JP">Japan</option>
<option value="CA">Canada</option>
<option value="MX">Mexico</option>
<option value="IN">India</option>
<option value="BR">Brazil</option>
</select>
</div>
<div class="mt-2">
<label class="block text-gray-700 font-medium mb-2">Product Category</label>
<select id="industrySelect" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">Select a product category</option>
<option value="steel">Steel & Aluminum</option>
<option value="agriculture">Agricultural Products</option>
<option value="automotive">Automotive & Parts</option>
<option value="electronics">Consumer Electronics</option>
<option value="textiles">Textiles & Apparel</option>
<option value="chemicals">Chemicals</option>
<option value="machinery">Industrial Machinery</option>
<option value="pharmaceuticals">Pharmaceuticals</option>
<option value="custom">Custom Tariff</option>
</select>
</div>
<div class="mt-6 hidden" id="customTariffSection">
<label class="block text-gray-700 font-medium mb-2">Custom Tariff Percentage (0-100%)</label>
<input type="range" id="tariffSlider" min="0" max="100" value="5" class="w-full tariff-slider h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
<div class="flex justify-between mt-2">
<span class="text-sm text-gray-500">0%</span>
<span id="tariffValue" class="font-medium text-blue-600">5%</span>
<span class="text-sm text-gray-500">100%</span>
</div>
</div>
<div class="mt-6 bg-blue-50 p-4 rounded-lg">
<div class="flex justify-between items-center">
<span class="text-blue-700 font-medium">Total Tariff Impact:</span>
<span id="totalTariffDisplay" class="text-xl font-bold text-blue-800">$0 (0%)</span>
</div>
<div id="tariffBreakdown" class="mt-2 text-sm text-blue-600">
<!-- Tariff breakdown will appear here -->
</div>
<div id="tariffImpactMeter" class="tariff-impact-meter hidden">
<div id="tariffImpactBar" class="tariff-impact-bar" style="width: 0%"></div>
</div>
</div>
<div class="mt-8">
<button id="calculateBtn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300 transform hover:scale-105 animate-pulse">
Calculate Trade Financing
</button>
</div>
</div>
<div id="results" class="bg-white rounded-xl shadow-lg p-6 hidden">
<h2 class="text-2xl font-bold text-gray-800 mb-4">Trade Finance Summary</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="bg-blue-50 p-4 rounded-lg">
<p class="text-sm text-blue-600 font-medium">Total Financing Needed</p>
<p id="totalLoan" class="text-2xl font-bold text-blue-800">$105,000</p>
</div>
<div class="bg-green-50 p-4 rounded-lg">
<p class="text-sm text-green-600 font-medium">Effective Interest Rate</p>
<p id="effectiveRate" class="text-2xl font-bold text-green-800">7.88%</p>
</div>
<div class="bg-purple-50 p-4 rounded-lg">
<p class="text-sm text-purple-600 font-medium">Monthly Payment</p>
<p id="monthlyPayment" class="text-2xl font-bold text-purple-800">$2,123</p>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
<div class="bg-yellow-50 p-4 rounded-lg">
<p class="text-sm text-yellow-600 font-medium">Total Tariff Cost</p>
<p id="totalTariffCost" class="text-xl font-bold text-yellow-800">$5,000</p>
</div>
<div class="bg-red-50 p-4 rounded-lg">
<p class="text-sm text-red-600 font-medium">Total Interest Cost</p>
<p id="totalInterestCost" class="text-xl font-bold text-red-800">$12,345</p>
</div>
</div>
<h3 class="text-lg font-semibold text-gray-700 mb-3">5-Year Amortization Schedule</h3>
<div class="overflow-x-auto">
<table class="min-w-full bg-white rounded-lg overflow-hidden">
<thead class="bg-gray-100">
<tr>
<th class="py-3 px-4 text-left text-gray-600">Year</th>
<th class="py-3 px-4 text-right text-gray-600">Principal</th>
<th class="py-3 px-4 text-right text-gray-600">Interest</th>
<th class="py-3 px-4 text-right text-gray-600">Balance</th>
</tr>
</thead>
<tbody id="amortizationTable" class="divide-y divide-gray-200">
<!-- Amortization data will be inserted here -->
</tbody>
</table>
</div>
</div>
</div>
<!-- Floating Buttons -->
<button id="buyDownBtn" class="floating-btn bg-blue-600 text-white flex items-center justify-center hover:bg-blue-700">
<i class="fas fa-percentage text-2xl"></i>
</button>
<button id="marketShareBtn" class="floating-btn-secondary bg-green-600 text-white flex items-center justify-center hover:bg-green-700">
<i class="fas fa-chart-pie text-2xl"></i>
</button>
<button id="tokenMintBtn" class="floating-btn-tertiary bg-purple-600 text-white flex items-center justify-center hover:bg-purple-700">
<i class="fas fa-coins text-2xl"></i>
</button>
<button id="creditRatingBtn" class="floating-btn-quaternary bg-amber-600 text-white flex items-center justify-center hover:bg-amber-700">
<i class="fas fa-star text-2xl"></i>
</button>
<!-- Buy Down Modal -->
<div id="buyDownModal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl shadow-xl p-6 max-w-md w-full">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Interest Rate Buy Down</h3>
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">Buy Down Points (0-5)</label>
<input type="range" id="buyDownSlider" min="0" max="5" value="0" step="0.25" class="w-full tariff-slider h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
<div class="flex justify-between mt-2">
<span class="text-sm text-gray-500">0 points</span>
<span id="buyDownValue" class="font-medium text-blue-600">0 points</span>
<span class="text-sm text-gray-500">5 points</span>
</div>
<p class="text-sm text-gray-500 mt-2">Each point reduces rate by 0.25% (costs 1% of loan amount)</p>
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">Fractal Bitcoin Mining Address</label>
<input type="text" id="bitcoinAddress" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bitcoin-address" placeholder="bc1qxy2kgdygjrsqtzq2n0yrf249nw3q2k6x..." pattern="^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$">
<p class="text-xs text-gray-500 mt-1">Enter your Bitcoin address to apply mining rewards to loan</p>
</div>
<div class="mining-estimate p-4 rounded-lg mb-4">
<h4 class="font-medium text-yellow-800 mb-2">Quarterly Mining Estimate</h4>
<div class="grid grid-cols-2 gap-2">
<div>
<p class="text-xs text-yellow-700">Estimated BTC Mined:</p>
<p id="estimatedBTC" class="font-bold">0.0025 BTC</p>
</div>
<div>
<p class="text-xs text-yellow-700">Buydown Points:</p>
<p id="miningPoints" class="font-bold">0.5 points</p>
</div>
<div>
<p class="text-xs text-yellow-700">Rate Reduction:</p>
<p id="miningRateReduction" class="font-bold">0.125%</p>
</div>
<div>
<p class="text-xs text-yellow-700">Loan Impact:</p>
<p id="miningLoanImpact" class="font-bold">-$1,250</p>
</div>
</div>
<p class="text-xs text-yellow-700 mt-2">* Estimates based on current mining difficulty and BTC price</p>
</div>
<div class="bg-blue-50 p-4 rounded-lg mb-4">
<p class="text-sm text-blue-600 font-medium">New Interest Rate</p>
<p id="newRate" class="text-xl font-bold text-blue-800">7.50%</p>
<p class="text-sm text-blue-600 font-medium mt-2">Buy Down Cost</p>
<p id="buyDownCost" class="text-xl font-bold text-blue-800">$0</p>
</div>
<button id="applyBuyDown" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
Apply Buy Down
</button>
</div>
</div>
<!-- Market Share Modal -->
<div id="marketShareModal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl shadow-xl p-6 max-w-md w-full">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Market Share Impact</h3>
<button id="closeMarketShareModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<div class="flex justify-between mb-2">
<span class="font-medium text-red-600">Market Share Loss</span>
<span id="marketShareLoss" class="font-bold">5%</span>
</div>
<div class="flex justify-between mb-4">
<span class="font-medium text-green-600">Cost Savings</span>
<span id="costSavings" class="font-bold">15%</span>
</div>
<div class="market-share-gauge">
<div id="gaugePointer" class="gauge-pointer" style="left: 25%;"></div>
</div>
<div class="flex justify-between mt-2 text-xs">
<span>High Loss</span>
<span>Balanced</span>
<span>High Savings</span>
</div>
</div>
<div class="bg-gray-50 p-4 rounded-lg mb-4">
<p class="text-sm text-gray-700">
<span class="font-medium">Analysis:</span>
<span id="marketShareAnalysis">Using tariff financing results in moderate market share impact but significant cost savings.</span>
</p>
</div>
<button id="closeMarketShareBtn" class="w-full bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
Close
</button>
</div>
</div>
<!-- Token Minting Modal -->
<div id="tokenMintModal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl shadow-xl p-6 max-w-md w-full">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Mint FFFUND Tokens</h3>
<button id="closeTokenModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="yield-farming-card mb-6">
<div class="flex justify-between items-center mb-2">
<span class="font-bold text-purple-700">Fabric Flow Fund™ (FFFUND)</span>
<span class="bg-purple-100 text-purple-800 text-xs font-medium px-2.5 py-0.5 rounded">BRC-20</span>
</div>
<p class="text-sm text-gray-600 mb-3">Yield farming token to fund your business loan with competitive APY</p>
<div class="grid grid-cols-2 gap-4 mb-3">
<div>
<p class="text-xs text-gray-500">Total Supply</p>
<p class="font-medium">50,000,000,000</p>
</div>
<div>
<p class="text-xs text-gray-500">Min Mint</p>
<p class="font-medium">10,000</p>
</div>
<div>
<p class="text-xs text-gray-500">Current APY</p>
<p class="font-medium text-green-600">11.0%</p>
</div>
<div>
<p class="text-xs text-gray-500">Your Balance</p>
<p class="font-medium">0</p>
</div>
</div>
<div class="mb-3">
<p class="text-xs text-gray-500">Mint Progress</p>
<div class="token-progress">
<div class="token-progress-bar" style="width: 45%"></div>
</div>
<p class="text-xs text-right mt-1">45% of current epoch minted</p>
</div>
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">Amount to Mint</label>
<input type="number" id="mintAmount" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500" placeholder="e.g. 10000" min="10000" step="1000">
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">BTC Address for Payment</label>
<input type="text" id="paymentAddress" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 bitcoin-address" placeholder="bc1qxy2kgdygjrsqtzq2n0yrf249nw3q2k6x..." pattern="^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$">
<p class="text-xs text-gray-500 mt-1">Current rate: 1,000 FFFUND = 0.0001 BTC</p>
</div>
<div class="bg-purple-50 p-4 rounded-lg mb-4">
<div class="flex justify-between mb-2">
<span class="text-purple-700 font-medium">Total Cost</span>
<span id="mintCost" class="font-bold text-purple-800">0.001 BTC</span>
</div>
<div class="flex justify-between">
<span class="text-purple-700 font-medium">Estimated APY</span>
<span id="estimatedAPY" class="font-bold text-purple-800">11.0%</span>
</div>
</div>
<button id="mintTokensBtn" class="w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
Mint FFFUND Tokens
</button>
</div>
</div>
<!-- Credit Rating Modal -->
<div id="creditRatingModal" class="modal fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl shadow-xl p-6 max-w-md w-full">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Country Credit Rating</h3>
<button id="closeCreditRatingModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">Select Country</label>
<select id="countrySelect" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-amber-500">
<option value="US">United States</option>
<option value="EU">European Union</option>
<option value="CN">China</option>
<option value="JP">Japan</option>
<option value="CA">Canada</option>
<option value="MX">Mexico</option>
<option value="IN">India</option>
<option value="BR">Brazil</option>
</select>
</div>
<div class="mb-4">
<div class="flex justify-between items-center mb-2">
<span class="font-medium text-gray-700">Credit Rating</span>
<span id="creditRating" class="credit-rating-badge credit-rating-AAA">AAA</span>
</div>
<div class="flex justify-between items-center mb-4">
<span class="font-medium text-gray-700">Risk Premium</span>
<span id="riskPremium" class="font-bold">+0.50%</span>
</div>
<div class="bg-amber-50 p-4 rounded-lg">
<h4 class="font-medium text-amber-800 mb-2">Economic Indicators</h4>
<div class="economic-indicator">
<span>GDP Growth</span>
<span id="gdpGrowth" class="font-medium">2.3%</span>
</div>
<div class="economic-indicator">
<span>Inflation Rate</span>
<span id="inflationRate" class="font-medium">3.2%</span>
</div>
<div class="economic-indicator">
<span>Unemployment</span>
<span id="unemploymentRate" class="font-medium">4.1%</span>
</div>
<div class="economic-indicator">
<span>Debt-to-GDP</span>
<span id="debtToGDP" class="font-medium">110%</span>
</div>
</div>
</div>
<button id="closeCreditRatingBtn" class="w-full bg-amber-600 hover:bg-amber-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
Close
</button>
</div>
</div>
<!-- FFFUND Panel -->
<div id="fffundPanel" class="fffund-panel">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-purple-800">Mint FFFUND Tokens</h3>
<button id="closeFFFundPanel" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="yield-farming-card mb-6">
<div class="flex justify-between items-center mb-2">
<span class="font-bold text-purple-700">Fabric Flow Fund™ (FFFUND)</span>
<span class="bg-purple-100 text-purple-800 text-xs font-medium px-2.5 py-0.5 rounded">BRC-20</span>
</div>
<p class="text-sm text-gray-600 mb-3">Yield farming token to fund your business loan with competitive APY</p>
<div class="grid grid-cols-2 gap-4 mb-3">
<div>
<p class="text-xs text-gray-500">Total Supply</p>
<p class="font-medium">50,000,000,000</p>
</div>
<div>
<p class="text-xs text-gray-500">Min Mint</p>
<p class="font-medium">10,000</p>
</div>
<div>
<p class="text-xs text-gray-500">Current APY</p>
<p class="font-medium text-green-600">11.0%</p>
</div>
<div>
<p class="text-xs text-gray-500">Your Balance</p>
<p class="font-medium">0</p>
</div>
</div>
<div class="mb-3">
<p class="text-xs text-gray-500">Mint Progress</p>
<div class="token-progress">
<div class="token-progress-bar" style="width: 45%"></div>
</div>
<p class="text-xs text-right mt-1">45% of current epoch minted</p>
</div>
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">Amount to Mint</label>
<input type="number" id="fffundMintAmount" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500" placeholder="e.g. 10000" min="10000" step="1000">
</div>
<div class="mb-4">
<label class="block text-gray-700 font-medium mb-2">BTC Address for Payment</label>
<input type="text" id="fffundPaymentAddress" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 bitcoin-address" placeholder="bc1qxy2kgdygjrsqtzq2n0yrf249nw3q2k6x..." pattern="^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$">
<p class="text-xs text-gray-500 mt-1">Current rate: 1,000 FFFUND = 0.0001 BTC</p>
</div>
<div class="bg-purple-50 p-4 rounded-lg mb-4">
<div class="flex justify-between mb-2">
<span class="text-purple-700 font-medium">Total Cost</span>
<span id="fffundMintCost" class="font-bold text-purple-800">0.001 BTC</span>
</div>
<div class="flex justify-between">
<span class="text-purple-700 font-medium">Estimated APY</span>
<span id="fffundEstimatedAPY" class="font-bold text-purple-800">11.0%</span>
</div>
</div>
<button id="fffundMintBtn" class="w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
Mint FFFUND Tokens
</button>
</div>
<div id="fffundOverlay" class="fffund-overlay"></div>
<script>
// DOM Elements
const loanAmountInput = document.getElementById('loanAmount');
const primeRateInput = document.getElementById('primeRate');
const importCountrySelect = document.getElementById('importCountry');
const industrySelect = document.getElementById('industrySelect');
const customTariffSection = document.getElementById('customTariffSection');
const tariffSlider = document.getElementById('tariffSlider');
const tariffValue = document.getElementById('tariffValue');
const totalTariffDisplay = document.getElementById('totalTariffDisplay');
const tariffBreakdown = document.getElementById('tariffBreakdown');
const tariffImpactMeter = document.getElementById('tariffImpactMeter');
const tariffImpactBar = document.getElementById('tariffImpactBar');
const calculateBtn = document.getElementById('calculateBtn');
const resultsSection = document.getElementById('results');
const totalLoanDisplay = document.getElementById('totalLoan');
const effectiveRateDisplay = document.getElementById('effectiveRate');
const monthlyPaymentDisplay = document.getElementById('monthlyPayment');
const totalTariffCost = document.getElementById('totalTariffCost');
const totalInterestCost = document.getElementById('totalInterestCost');
const amortizationTable = document.getElementById('amortizationTable');
// Modal elements
const buyDownBtn = document.getElementById('buyDownBtn');
const marketShareBtn = document.getElementById('marketShareBtn');
const tokenMintBtn = document.getElementById('tokenMintBtn');
const creditRatingBtn = document.getElementById('creditRatingBtn');
const buyDownModal = document.getElementById('buyDownModal');
const marketShareModal = document.getElementById('marketShareModal');
const tokenMintModal = document.getElementById('tokenMintModal');
const creditRatingModal = document.getElementById('creditRatingModal');
const closeModal = document.getElementById('closeModal');
const closeMarketShareModal = document.getElementById('closeMarketShareModal');
const closeTokenModal = document.getElementById('closeTokenModal');
const closeCreditRatingModal = document.getElementById('closeCreditRatingModal');
const closeMarketShareBtn = document.getElementById('closeMarketShareBtn');
const closeCreditRatingBtn = document.getElementById('closeCreditRatingBtn');
// Buy Down Modal elements
const buyDownSlider = document.getElementById('buyDownSlider');
const buyDownValue = document.getElementById('buyDownValue');
const bitcoinAddress = document.getElementById('bitcoinAddress');
const estimatedBTC = document.getElementById('estimatedBTC');
const miningPoints = document.getElementById('miningPoints');
const miningRateReduction = document.getElementById('miningRateReduction');
const miningLoanImpact = document.getElementById('miningLoanImpact');
const newRate = document.getElementById('newRate');
const buyDownCost = document.getElementById('buyDownCost');
const applyBuyDown = document.getElementById('applyBuyDown');
// Market Share Modal elements
const marketShareLoss = document.getElementById('marketShareLoss');
const costSavings = document.getElementById('costSavings');
const gaugePointer = document.getElementById('gaugePointer');
const marketShareAnalysis = document.getElementById('marketShareAnalysis');
// Token Minting Modal elements
const mintAmount = document.getElementById('mintAmount');
const paymentAddress = document.getElementById('paymentAddress');
const mintCost = document.getElementById('mintCost');
const estimatedAPY = document.getElementById('estimatedAPY');
const mintTokensBtn = document.getElementById('mintTokensBtn');
// Credit Rating Modal elements
const countrySelect = document.getElementById('countrySelect');
const creditRating = document.getElementById('creditRating');
const riskPremium = document.getElementById('riskPremium');
const gdpGrowth = document.getElementById('gdpGrowth');
const inflationRate = document.getElementById('inflationRate');
const unemploymentRate = document.getElementById('unemploymentRate');
const debtToGDP = document.getElementById('debtToGDP');
// FFFUND Panel elements
const fffundPanel = document.getElementById('fffundPanel');
const fffundOverlay = document.getElementById('fffundOverlay');
const closeFFFundPanel = document.getElementById('closeFFFundPanel');
const fffundMintAmount = document.getElementById('fffundMintAmount');
const fffundPaymentAddress = document.getElementById('fffundPaymentAddress');
const fffundMintCost = document.getElementById('fffundMintCost');
const fffundEstimatedAPY = document.getElementById('fffundEstimatedAPY');
const fffundMintBtn = document.getElementById('fffundMintBtn');
// Tariff data
const tariffRates = {
US: {
steel: 25,
agriculture: 10,
automotive: 2.5,
electronics: 0,
textiles: 16,
chemicals: 3.5,
machinery: 2,
pharmaceuticals: 0
},
EU: {
steel: 10,
agriculture: 15,
automotive: 10,
electronics: 0,
textiles: 12,
chemicals: 5,
machinery: 1.7,
pharmaceuticals: 0
},
CN: {
steel: 15,
agriculture: 20,
automotive: 15,
electronics: 0,
textiles: 10,
chemicals: 6.5,
machinery: 8,
pharmaceuticals: 0
},
JP: {
steel: 5,
agriculture: 20,
automotive: 0,
electronics: 0,
textiles: 10,
chemicals: 3,
machinery: 0,
pharmaceuticals: 0
},
CA: {
steel: 10,
agriculture: 5,
automotive: 0,
electronics: 0,
textiles: 8,
chemicals: 2,
machinery: 0,
pharmaceuticals: 0
},
MX: {
steel: 15,
agriculture: 10,
automotive: 5,
electronics: 0,
textiles: 10,
chemicals: 3,
machinery: 5,
pharmaceuticals: 0
},
IN: {
steel: 20,
agriculture: 30,
automotive: 15,
electronics: 0,
textiles: 15,
chemicals: 7.5,
machinery: 10,
pharmaceuticals: 0
},
BR: {
steel: 12,
agriculture: 25,
automotive: 10,
electronics: 0,
textiles: 20,
chemicals: 8,
machinery: 12,
pharmaceuticals: 0
}
};
// Credit rating data
const creditRatings = {
US: { rating: 'AA', premium: 0.5, gdp: 2.3, inflation: 3.2, unemployment: 4.1, debt: 110 },
EU: { rating: 'AA', premium: 0.6, gdp: 1.8, inflation: 2.8, unemployment: 6.5, debt: 85 },
CN: { rating: 'A', premium: 0.8, gdp: 5.2, inflation: 2.1, unemployment: 5.0, debt: 60 },
JP: { rating: 'A', premium: 0.7, gdp: 1.1, inflation: 0.5, unemployment: 2.5, debt: 240 },
CA: { rating: 'AAA', premium: 0.4, gdp: 2.0, inflation: 2.5, unemployment: 5.5, debt: 90 },
MX: { rating: 'BBB', premium: 1.2, gdp: 3.0, inflation: 4.2, unemployment: 3.8, debt: 55 },
IN: { rating: 'BBB-', premium: 1.5, gdp: 6.5, inflation: 5.8, unemployment: 7.2, debt: 75 },
BR: { rating: 'BB-', premium: 2.0, gdp: 2.8, inflation: 8.5, unemployment: 9.0, debt: 85 }
};
// Market share impact data
const marketShareData = {
steel: { loss: 5, savings: 15 },
agriculture: { loss: 8, savings: 10 },
automotive: { loss: 15, savings: 20 },
electronics: { loss: 2, savings: 5 },
textiles: { loss: 10, savings: 18 },
chemicals: { loss: 7, savings: 12 },
machinery: { loss: 5, savings: 10 },
pharmaceuticals: { loss: 1, savings: 3 }
};
// Initialize the app
function init() {
// Event listeners for main calculator
industrySelect.addEventListener('change', handleIndustryChange);
tariffSlider.addEventListener('input', updateTariffValue);
calculateBtn.addEventListener('click', calculateFinancing);
// Event listeners for modal toggles
buyDownBtn.addEventListener('click', () => toggleModal(buyDownModal));
marketShareBtn.addEventListener('click', () => toggleModal(marketShareModal));
tokenMintBtn.addEventListener('click', () => toggleModal(tokenMintModal));
creditRatingBtn.addEventListener('click', () => toggleModal(creditRatingModal));
// Event listeners for modal closes
closeModal.addEventListener('click', () => toggleModal(buyDownModal));
closeMarketShareModal.addEventListener('click', () => toggleModal(marketShareModal));
closeTokenModal.addEventListener('click', () => toggleModal(tokenMintModal));
closeCreditRatingModal.addEventListener('click', () => toggleModal(creditRatingModal));
closeMarketShareBtn.addEventListener('click', () => toggleModal(marketShareModal));
closeCreditRatingBtn.addEventListener('click', () => toggleModal(creditRatingModal));
// Event listeners for buy down modal
buyDownSlider.addEventListener('input', updateBuyDownValue);
bitcoinAddress.addEventListener('input', updateMiningEstimate);
applyBuyDown.addEventListener('click', applyBuyDownPoints);
// Event listeners for market share modal
industrySelect.addEventListener('change', updateMarketShareImpact);
// Event listeners for credit rating modal
countrySelect.addEventListener('change', updateCreditRating);
// Event listeners for token minting modal
mintAmount.addEventListener('input', updateMintCost);
// Event listeners for FFFUND panel
tokenMintBtn.addEventListener('click', toggleFFFundPanel);
closeFFFundPanel.addEventListener('click', toggleFFFundPanel);
fffundMintAmount.addEventListener('input', updateFFFundMintCost);
fffundMintBtn.addEventListener('click', mintFFFundTokens);
// Initialize values
updateTariffValue();
updateBuyDownValue();
updateCreditRating();
updateMintCost();
updateFFFundMintCost();
}
// Toggle modal visibility
function toggleModal(modal) {
modal.classList.toggle('active');
}
// Toggle FFFUND panel visibility
function toggleFFFundPanel() {
fffundPanel.classList.toggle('active');
fffundOverlay.classList.toggle('active');
}
// Handle industry selection change
function handleIndustryChange() {
const selectedIndustry = industrySelect.value;
if (selectedIndustry === 'custom') {
customTariffSection.classList.remove('hidden');
updateTariffValue();
} else {
customTariffSection.classList.add('hidden');
if (selectedIndustry) {
const country = importCountrySelect.value;
const tariffRate = tariffRates[country][selectedIndustry];
const loanAmount = parseFloat(loanAmountInput.value) || 0;
const tariffAmount = loanAmount * (tariffRate / 100);
totalTariffDisplay.textContent = `$${tariffAmount.toLocaleString()} (${tariffRate}%)`;
// Update tariff breakdown
tariffBreakdown.innerHTML = `
<div class="flex justify-between">
<span>${selectedIndustry.replace(/^\w/, c => c.toUpperCase())} tariff (${country}):</span>
<span>${tariffRate}%</span>
</div>
`;
// Show tariff impact meter
tariffImpactMeter.classList.remove('hidden');
tariffImpactBar.style.width = `${Math.min(tariffRate, 100)}%`;
// Update market share impact if modal is open
if (marketShareModal.classList.contains('active')) {
updateMarketShareImpact();
}
} else {
totalTariffDisplay.textContent = '$0 (0%)';
tariffBreakdown.innerHTML = '';
tariffImpactMeter.classList.add('hidden');
}
}
}
// Update custom tariff value display
function updateTariffValue() {
const tariffRate = tariffSlider.value;
tariffValue.textContent = `${tariffRate}%`;
if (industrySelect.value === 'custom') {
const loanAmount = parseFloat(loanAmountInput.value) || 0;
const tariffAmount = loanAmount * (tariffRate / 100);
totalTariffDisplay.textContent = `$${tariffAmount.toLocaleString()} (${tariffRate}%)`;
// Update tariff breakdown
tariffBreakdown.innerHTML = `
<div class="flex justify-between">
<span>Custom tariff:</span>
<span>${tariffRate}%</span>
</div>
`;
// Show tariff impact meter
tariffImpactMeter.classList.remove('hidden');
tariffImpactBar.style.width = `${Math.min(tariffRate, 100)}%`;
}
}
// Calculate financing details
function calculateFinancing() {
const loanAmount = parseFloat(loanAmountInput.value) || 0;
const primeRate = parseFloat(primeRateInput.value) || 0;
const selectedIndustry = industrySelect.value;
if (!selectedIndustry) {
alert('Please select a product category');
return;
}
// Get tariff rate
let tariffRate = 0;
if (selectedIndustry === 'custom') {
tariffRate = parseFloat(tariffSlider.value) || 0;
} else {
const country = importCountrySelect.value;
tariffRate = tariffRates[country][selectedIndustry];
}
// Calculate tariff amount
const tariffAmount = loanAmount * (tariffRate / 100);
const totalLoan = loanAmount + tariffAmount;
// Calculate effective interest rate (prime rate + risk premium)
const country = importCountrySelect.value;
const riskPremium = creditRatings[country].premium;
const effectiveRate = primeRate + riskPremium;
// Calculate monthly payment (simple amortization)
const monthlyRate = effectiveRate / 100 / 12;
const termYears = 5;
const termMonths = termYears * 12;
const monthlyPayment = totalLoan * monthlyRate * Math.pow(1 + monthlyRate, termMonths) / (Math.pow(1 + monthlyRate, termMonths) - 1);
// Calculate total interest cost
const totalInterest = monthlyPayment * termMonths - totalLoan;
// Update results display
totalLoanDisplay.textContent = `$${totalLoan.toLocaleString(undefined, {maximumFractionDigits: 2})}`;
effectiveRateDisplay.textContent = `${effectiveRate.toFixed(2)}%`;
monthlyPaymentDisplay.textContent = `$${monthlyPayment.toLocaleString(undefined, {maximumFractionDigits: 2})}`;
totalTariffCost.textContent = `$${tariffAmount.toLocaleString(undefined, {maximumFractionDigits: 2})}`;
totalInterestCost.textContent = `$${totalInterest.toLocaleString(undefined, {maximumFractionDigits: 2})}`;
// Generate amortization schedule
generateAmortizationSchedule(totalLoan, effectiveRate, termYears);
// Show results
resultsSection.classList.remove('hidden');
// Scroll to results
resultsSection.scrollIntoView({ behavior: 'smooth' });
}
// Generate amortization schedule
function generateAmortizationSchedule(principal, annualRate, years) {
const monthlyRate = annualRate / 100 / 12;
const months = years * 12;
const monthlyPayment = principal * monthlyRate * Math.pow(1 + monthlyRate, months) / (Math.pow(1 + monthlyRate, months) - 1);
let balance = principal;
let html = '';
for (let year = 1; year <= years; year++) {
let yearInterest = 0;
let yearPrincipal = 0;
for (let month = 1; month <= 12; month++) {
const interest = balance * monthlyRate;
const principalPayment = monthlyPayment - interest;
yearInterest += interest;
yearPrincipal += principalPayment;
balance -= principalPayment;
}
html += `
<tr>
<td class="py-2 px-4">${year}</td>
<td class="py-2 px-4 text-right">$${yearPrincipal.toLocaleString(undefined, {maximumFractionDigits: 2})}</td>
<td class="py-2 px-4 text-right">$${yearInterest.toLocaleString(undefined, {maximumFractionDigits: 2})}</td>
<td class="py-2 px-4 text-right">$${balance > 0 ? balance.toLocaleString(undefined, {maximumFractionDigits: 2}) : '0'}</td>
</tr>
`;
}
amortizationTable.innerHTML = html;
}
// Update buy down value display
function updateBuyDownValue() {
const points = buyDownSlider.value;
buyDownValue.textContent = `${points} points`;
// Calculate new rate
const primeRate = parseFloat(primeRateInput.value) || 0;
const country = importCountrySelect.value;
const riskPremium = creditRatings[country].premium;
const rateReduction = points * 0.25;
const newRateValue = primeRate + riskPremium - rateReduction;
// Calculate buy down cost
const loanAmount = parseFloat(loanAmountInput.value) || 0;
const cost = loanAmount * (points / 100);
// Update display
newRate.textContent = `${newRateValue.toFixed(2)}%`;
buyDownCost.textContent = `$${cost.toLocaleString(undefined, {maximumFractionDigits: 2})}`;
}
// Update mining estimate based on BTC address
function updateMiningEstimate() {
const address = bitcoinAddress.value;
if (address && address.match(/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/)) {
// Simulate mining estimate
estimatedBTC.textContent = '0.0025 BTC';
miningPoints.textContent = '0.5 points';
miningRateReduction.textContent = '0.125%';
miningLoanImpact.textContent = '-$1,250';
} else {
estimatedBTC.textContent = '0 BTC';
miningPoints.textContent = '0 points';
miningRateReduction.textContent = '0%';
miningLoanImpact.textContent = '$0';
}
}
// Apply buy down points to loan
function applyBuyDownPoints() {
const points = parseFloat(buyDownSlider.value) || 0;
if (points > 0) {
alert(`Successfully applied ${points} buy down points to your loan.`);
toggleModal(buyDownModal);
} else {
alert('Please select at least 0.25 points to apply.');
}
}
// Update market share impact based on selected industry
function updateMarketShareImpact() {
const selectedIndustry = industrySelect.value;
if (selectedIndustry && selectedIndustry !== 'custom') {
const impact = marketShareData[selectedIndustry];
marketShareLoss.textContent = `${impact.loss}%`;
costSavings.textContent = `${impact.savings}%`;
// Position gauge pointer (simple linear scale)
const position = (impact.savings - impact.loss + 30) / 60 * 100;
gaugePointer.style.left = `${Math.min(Math.max(position, 5), 95)}%`;
// Update analysis text
if (impact.loss > 10) {
marketShareAnalysis.textContent = 'This product category has significant market share risk with tariff financing.';
} else if (impact.savings > 15) {
marketShareAnalysis.textContent = 'Tariff financing offers excellent cost savings with moderate market share impact.';
} else {
marketShareAnalysis.textContent = 'Using tariff financing results in balanced market share impact and cost savings.';
}
}
}
// Update credit rating based on selected country
function updateCreditRating() {
const country = countrySelect.value;
const ratingData = creditRatings[country];
// Update rating display
creditRating.textContent = ratingData.rating;
creditRating.className = `credit-rating-badge credit-rating-${ratingData.rating.replace(/[^A-Z]/g, '')}`;
// Update other fields
riskPremium.textContent = `+${ratingData.premium}%`;
gdpGrowth.textContent = `${ratingData.gdp}%`;
inflationRate.textContent = `${ratingData.inflation}%`;
unemploymentRate.textContent = `${ratingData.unemployment}%`;
debtToGDP.textContent = `${ratingData.debt}%`;
}
// Update mint cost based on amount
function updateMintCost() {
const amount = parseFloat(mintAmount.value) || 0;
const cost = amount * 0.0000001; // 1,000 FFFUND = 0.0001 BTC
mintCost.textContent = `${cost.toFixed(6)} BTC`;
}
// Update FFFUND mint cost based on amount
function updateFFFundMintCost() {
const amount = parseFloat(fffundMintAmount.value) || 0;
const cost = amount * 0.0000001; // 1,000 FFFUND = 0.0001 BTC
fffundMintCost.textContent = `${cost.toFixed(6)} BTC`;
}
// Mint FFFUND tokens
function mintFFFundTokens() {
const amount = parseFloat(fffundMintAmount.value) || 0;
const address = fffundPaymentAddress.value;
if (amount < 10000) {
alert('Minimum mint amount is 10,000 FFFUND');
return;
}
if (!address || !address.match(/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/)) {
alert('Please enter a valid Bitcoin address');
return;
}
alert(`Successfully minted ${amount.toLocaleString()} FFFUND tokens to address ${address}`);
toggleFFFundPanel();
}
// Initialize the app
init();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=privateuserh/privfin-vbeta1-06" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |