Ejemplo n.º 1
0
        // ********************************************************************************************
        // *** ECOSYSTEM
        // ********************************************************************************************

        public object Get(GetEcosystemStatus request)
        {
            // Using the request's contract address provided, retrieve all the ecosystem's addresses to get the pool address
            EcosystemContractAddresses adr = AppServices.GetEcosystemAdr(request.ContractAdr);

            // Create the return instance
            EcosystemStatus status = new EcosystemStatus();

            // Load the trust contract to retrieve the external access interface duration for pre-authorisation
            var contract = AppServices.web3.Eth.GetContract(AppModelConfig.POOL.abi, adr.PoolContractAdr);

            status.currentPoolDay          = contract.GetFunction("currentPoolDay").CallAsync <ulong>().Result;
            status.isWinterTime            = contract.GetFunction("isWinterTime").CallAsync <bool>().Result;
            status.daylightSavingScheduled = contract.GetFunction("daylightSavingScheduled").CallAsync <bool>().Result;

            // Bank account balances
            status.WC_Bal_FA_Cu = contract.GetFunction("WC_Bal_FA_Cu").CallAsync <ulong>().Result;
            status.WC_Bal_BA_Cu = contract.GetFunction("WC_Bal_BA_Cu").CallAsync <ulong>().Result;
            status.WC_Bal_PA_Cu = contract.GetFunction("WC_Bal_PA_Cu").CallAsync <ulong>().Result;

            // Variables used by the Insurance Pool during overnight processing only
            status.overwriteWcExpenses = contract.GetFunction("overwriteWcExpenses").CallAsync <bool>().Result;
            status.WC_Exp_Cu           = contract.GetFunction("WC_Exp_Cu").CallAsync <ulong>().Result;

            // Pool variables as defined in the model
            status.WC_Locked_Cu   = contract.GetFunction("WC_Locked_Cu").CallAsync <ulong>().Result;
            status.WC_Bond_Cu     = contract.GetFunction("WC_Bond_Cu").CallAsync <ulong>().Result;
            status.WC_Transit_Cu  = contract.GetFunction("WC_Transit_Cu").CallAsync <ulong>().Result;
            status.B_Yield_Ppb    = contract.GetFunction("B_Yield_Ppb").CallAsync <ulong>().Result;
            status.B_Gradient_Ppq = contract.GetFunction("B_Gradient_Ppq").CallAsync <ulong>().Result;

            // Flag to indicate if the bond yield accelleration is operational (and scheduled by the timer)
            status.bondYieldAccellerationScheduled = contract.GetFunction("bondYieldAccellerationScheduled").CallAsync <bool>().Result;
            status.bondYieldAccelerationThreshold  = contract.GetFunction("bondYieldAccelerationThreshold").CallAsync <ulong>().Result;

            // Load the bond contract
            contract            = AppServices.web3.Eth.GetContract(AppModelConfig.BOND.abi, adr.BondContractAdr);
            status.BondListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result;

            // Load the policy contract
            contract = AppServices.web3.Eth.GetContract(AppModelConfig.POLICY.abi, adr.PolicyContractAdr);
            status.totalIssuedPolicyRiskPoints = contract.GetFunction("totalIssuedPolicyRiskPoints").CallAsync <ulong>().Result;
            status.PolicyListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result;

            // Load the adjustor contract
            contract = AppServices.web3.Eth.GetContract(AppModelConfig.ADJUSTOR.abi, adr.AdjustorContractAdr);
            status.AdjustorListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result;

            // Load the settlement contract
            contract = AppServices.web3.Eth.GetContract(AppModelConfig.SETTLEMENT.abi, adr.SettlementContractAdr);
            status.SettlementListInfo = contract.GetFunction("hashMap").CallDeserializingToObjectAsync <ListInfo>().Result;

            // Load the bank contract
            contract = AppServices.web3.Eth.GetContract(AppModelConfig.BANK.abi, adr.BankContractAdr);
            status.fundingAccountPaymentsTracking_Cu = contract.GetFunction("fundingAccountPaymentsTracking_Cu").CallAsync <ulong>().Result;

            // Load the timer contract
            contract = AppServices.web3.Eth.GetContract(AppModelConfig.TIMER.abi, adr.TimerContractAdr);
            status.lastPingExececution = contract.GetFunction("lastPingExec_10_S").CallAsync <ulong>().Result * 10;

            return(status);
        }
Ejemplo n.º 2
0
        public object Get(GetEcosystemConfiguration request)
        {
            // Using the request's contract address provided, retrieve all the ecosystem's addresses to get the pool address
            EcosystemContractAddresses adr = AppServices.GetEcosystemAdr(request.ContractAdr);

            // Create the return instance
            EcosystemConfiguration setup = new EcosystemConfiguration();

            // Load the trust contract to retrieve the external access interface duration for pre-authorisation
            var contract = AppServices.web3.Eth.GetContract(AppModelConfig.EXTACCESSI.abi, adr.TrustContractAdr);

            // Pre-authorisation duration for external authentication
            setup.EXT_ACCESS_PRE_AUTH_DURATION_SEC = contract.GetFunction("EXT_ACCESS_PRE_AUTH_DURATION_SEC").CallAsync <ulong>().Result;

            // Get the contract for the Pool by specifying the pool address
            contract        = AppServices.web3.Eth.GetContract(AppModelConfig.SETUPI.abi, adr.PoolContractAdr);
            setup.POOL_NAME = contract.GetFunction("POOL_NAME").CallAsync <string>().Result;

            // Constants used by the Insurance Pool
            setup.WC_POOL_TARGET_TIME_SEC           = contract.GetFunction("WC_POOL_TARGET_TIME_SEC").CallAsync <ulong>().Result;
            setup.DURATION_TO_BOND_MATURITY_SEC     = contract.GetFunction("DURATION_TO_BOND_MATURITY_SEC").CallAsync <ulong>().Result;
            setup.DURATION_BOND_LOCK_NEXT_STATE_SEC = contract.GetFunction("DURATION_BOND_LOCK_NEXT_STATE_SEC").CallAsync <ulong>().Result;
            setup.DURATION_WC_EXPENSE_HISTORY_DAYS  = contract.GetFunction("DURATION_WC_EXPENSE_HISTORY_DAYS").CallAsync <ulong>().Result;

            // Yield constants
            setup.YAC_PER_INTERVAL_PPB      = contract.GetFunction("YAC_PER_INTERVAL_PPB").CallAsync <ulong>().Result;
            setup.YAC_INTERVAL_DURATION_SEC = contract.GetFunction("YAC_INTERVAL_DURATION_SEC").CallAsync <ulong>().Result;
            setup.YAC_EXPENSE_THRESHOLD_PPT = contract.GetFunction("YAC_EXPENSE_THRESHOLD_PPT").CallAsync <ulong>().Result;
            setup.MIN_YIELD_PPB             = contract.GetFunction("MIN_YIELD_PPB").CallAsync <ulong>().Result;
            setup.MAX_YIELD_PPB             = contract.GetFunction("MAX_YIELD_PPB").CallAsync <ulong>().Result;

            // Bond constants
            setup.MIN_BOND_PRINCIPAL_CU = contract.GetFunction("MIN_BOND_PRINCIPAL_CU").CallAsync <ulong>().Result;
            setup.MAX_BOND_PRINCIPAL_CU = contract.GetFunction("MAX_BOND_PRINCIPAL_CU").CallAsync <ulong>().Result;
            setup.BOND_REQUIRED_SECURITY_REFERENCE_PPT = contract.GetFunction("BOND_REQUIRED_SECURITY_REFERENCE_PPT").CallAsync <ulong>().Result;

            // Policy constants
            setup.MIN_POLICY_CREDIT_CU = contract.GetFunction("MIN_POLICY_CREDIT_CU").CallAsync <ulong>().Result;
            setup.MAX_POLICY_CREDIT_CU = contract.GetFunction("MAX_POLICY_CREDIT_CU").CallAsync <ulong>().Result;
            setup.MAX_DURATION_POLICY_RECONCILIATION_DAYS = contract.GetFunction("MAX_DURATION_POLICY_RECONCILIATION_DAYS").CallAsync <ulong>().Result;
            setup.POLICY_RECONCILIATION_SAFETY_MARGIN     = contract.GetFunction("POLICY_RECONCILIATION_SAFETY_MARGIN").CallAsync <ulong>().Result;
            setup.MIN_DURATION_POLICY_PAUSED_DAY          = contract.GetFunction("MIN_DURATION_POLICY_PAUSED_DAY").CallAsync <ulong>().Result;
            setup.MAX_DURATION_POLICY_PAUSED_DAY          = contract.GetFunction("MAX_DURATION_POLICY_PAUSED_DAY").CallAsync <ulong>().Result;
            setup.DURATION_POLICY_POST_LAPSED_DAY         = contract.GetFunction("DURATION_POLICY_POST_LAPSED_DAY").CallAsync <ulong>().Result;
            setup.MAX_DURATION_POLICY_LAPSED_DAY          = contract.GetFunction("MAX_DURATION_POLICY_LAPSED_DAY").CallAsync <ulong>().Result;

            // Pool processing costants
            setup.POOL_DAILY_PROCESSING_OFFSET_SEC    = contract.GetFunction("POOL_DAILY_PROCESSING_OFFSET_SEC").CallAsync <ulong>().Result;
            setup.POOL_DAYLIGHT_SAVING_ADJUSTMENT_SEC = contract.GetFunction("POOL_DAYLIGHT_SAVING_ADJUSTMENT_SEC").CallAsync <ulong>().Result;
            setup.POOL_TIME_ZONE_OFFSET = contract.GetFunction("POOL_TIME_ZONE_OFFSET").CallAsync <long>().Result;

            // Operator and Trust fees
            setup.POOL_OPERATOR_FEE_PPT = contract.GetFunction("POOL_OPERATOR_FEE_PPT").CallAsync <ulong>().Result;
            setup.TRUST_FEE_PPT         = contract.GetFunction("TRUST_FEE_PPT").CallAsync <ulong>().Result;

            // Hashes of the bank account owner and bank account number (sha3(accountOwner, accountNumber))
            setup.PREMIUM_ACCOUNT_PAYMENT_HASH    = AppModelConfig.convertToHex(contract.GetFunction("PREMIUM_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.BOND_ACCOUNT_PAYMENT_HASH       = AppModelConfig.convertToHex(contract.GetFunction("BOND_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.FUNDING_ACCOUNT_PAYMENT_HASH    = AppModelConfig.convertToHex(contract.GetFunction("FUNDING_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.TRUST_ACCOUNT_PAYMENT_HASH      = AppModelConfig.convertToHex(contract.GetFunction("TRUST_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.OPERATOR_ACCOUNT_PAYMENT_HASH   = AppModelConfig.convertToHex(contract.GetFunction("OPERATOR_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.SETTLEMENT_ACCOUNT_PAYMENT_HASH = AppModelConfig.convertToHex(contract.GetFunction("SETTLEMENT_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);
            setup.ADJUSTOR_ACCOUNT_PAYMENT_HASH   = AppModelConfig.convertToHex(contract.GetFunction("ADJUSTOR_ACCOUNT_PAYMENT_HASH").CallAsync <string>().Result);

            return(setup);
        }