diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ed6c31b..643398e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ on: jobs: deploy-landing-page-staging: name: deployment - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest environment: testnet steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 5d58e12..04fc71f 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -13,7 +13,7 @@ on: jobs: deploy-landing-page-staging: name: deployment - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest environment: testnet steps: - uses: actions/checkout@v2 diff --git a/src/constants/abi/metrics.abi.json b/src/constants/abi/metrics.abi.json index c7f96ce..7b192da 100644 --- a/src/constants/abi/metrics.abi.json +++ b/src/constants/abi/metrics.abi.json @@ -1,442 +1,417 @@ [ { + "name": "MetricsImpl", + "type": "impl", + "interface_name": "common::interfaces::imetrics::IMetrics" + }, + { + "name": "core::integer::u256", + "type": "struct", "members": [ { "name": "low", - "offset": 0, - "type": "felt" + "type": "core::integer::u128" }, { "name": "high", - "offset": 1, - "type": "felt" + "type": "core::integer::u128" } - ], - "name": "Uint256", - "size": 2, - "type": "struct" + ] }, { + "name": "common::interfaces::imetrics::Market_Info", + "type": "struct", "members": [ { "name": "borrow_rate", - "offset": 0, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "supply_rate", - "offset": 2, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "staking_rate", - "offset": 4, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "total_supply", - "offset": 6, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "lent_assets", - "offset": 8, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "total_borrow", - "offset": 10, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "utilisation_per_market", - "offset": 12, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "exchange_rate_rToken_to_asset", - "offset": 14, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "exchange_rate_dToken_to_asset", - "offset": 16, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "exchange_rate_asset_to_rToken", - "offset": 18, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "exchange_rate_asset_to_dToken", - "offset": 20, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "token_address", - "offset": 22, - "type": "felt" + "type": "core::starknet::contract_address::ContractAddress" } - ], - "name": "Market_Info", - "size": 23, - "type": "struct" + ] }, { + "name": "common::interfaces::imetrics::ProtocolReserves", + "type": "struct", "members": [ { "name": "total_reserves", - "offset": 0, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "available_reserves", - "offset": 2, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "avg_asset_utilisation", - "offset": 4, - "type": "Uint256" + "type": "core::integer::u256" } - ], - "name": "ProtocolReserves", - "size": 6, - "type": "struct" + ] }, { + "name": "common::interfaces::imetrics::Deposit", + "type": "struct", "members": [ { "name": "asset_address", - "offset": 0, - "type": "felt" + "type": "core::starknet::contract_address::ContractAddress" }, { "name": "rToken_amount", - "offset": 1, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "rToken_free", - "offset": 3, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "rToken_locked", - "offset": 5, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "rToken_staked", - "offset": 7, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "supply_asset_amount", - "offset": 9, - "type": "Uint256" + "type": "core::integer::u256" } - ], - "name": "Deposit", - "size": 11, - "type": "struct" + ] }, { + "name": "common::interfaces::imetrics::UserDepositStats", + "type": "struct", "members": [ { "name": "your_supply", - "offset": 0, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "net_supply_apr", - "offset": 2, - "type": "Uint256" + "type": "core::integer::u256" } - ], - "name": "UserDepositStats", - "size": 4, - "type": "struct" + ] }, { + "name": "common::interfaces::imetrics::UserLoanStats", + "type": "struct", "members": [ { "name": "your_borrow", - "offset": 0, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "net_borrow_apr", - "offset": 2, - "type": "Uint256" + "type": "core::integer::u256" }, { "name": "net_current_amount", - "offset": 4, - "type": "Uint256" - } - ], - "name": "UserLoanStats", - "size": 6, - "type": "struct" - }, - { - "data": [ - { - "name": "from_", - "type": "felt" - }, - { - "name": "to", - "type": "felt" - }, - { - "name": "value", - "type": "Uint256" - } - ], - "keys": [], - "name": "Transfer", - "type": "event" - }, - { - "data": [ - { - "name": "owner", - "type": "felt" - }, - { - "name": "spender", - "type": "felt" - }, - { - "name": "value", - "type": "Uint256" - } - ], - "keys": [], - "name": "Approval", - "type": "event" - }, - { - "data": [ - { - "name": "previousOwner", - "type": "felt" - }, - { - "name": "newOwner", - "type": "felt" - } - ], - "keys": [], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "data": [ - { - "name": "implementation", - "type": "felt" - } - ], - "keys": [], - "name": "Upgraded", - "type": "event" - }, - { - "data": [ - { - "name": "previousAdmin", - "type": "felt" - }, - { - "name": "newAdmin", - "type": "felt" - } - ], - "keys": [], - "name": "AdminChanged", - "type": "event" - }, - { - "inputs": [ - { - "name": "diamond_address", - "type": "felt" - } - ], - "name": "initializer", - "outputs": [], - "type": "function" - }, - { - "inputs": [ - { - "name": "index", - "type": "felt" - }, - { - "name": "token_addr_len", - "type": "felt" - }, - { - "name": "token_addr", - "type": "felt*" - } - ], - "name": "set_token_addresses", - "outputs": [], - "type": "function" - }, - { - "inputs": [ - { - "name": "token_addr", - "type": "felt" - } - ], - "name": "set_token_address", - "outputs": [], - "type": "function" - }, - { - "inputs": [], - "name": "get_tokens_len", - "outputs": [ - { - "name": "len", - "type": "felt" + "type": "core::integer::u256" } - ], - "stateMutability": "view", - "type": "function" + ] }, { - "inputs": [ - { - "name": "index", - "type": "felt" - } - ], - "name": "get_token_by_index", - "outputs": [ - { - "name": "address", - "type": "felt" + "name": "common::interfaces::imetrics::IMetrics", + "type": "interface", + "items": [ + { + "name": "initializer", + "type": "function", + "inputs": [ + { + "name": "router", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "governor", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "dial", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "pricer", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "name": "upgrade_class_hash", + "type": "function", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "name": "set_token_addresses", + "type": "function", + "inputs": [ + { + "name": "index", + "type": "core::felt252" + }, + { + "name": "token_addr_len", + "type": "core::felt252" + }, + { + "name": "token_addr", + "type": "core::array::Array::" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "name": "transfer_ownership", + "type": "function", + "inputs": [ + { + "name": "new_owner", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "name": "set_token_address", + "type": "function", + "inputs": [ + { + "name": "token_addr", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "name": "get_tokens_len", + "type": "function", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "name": "get_token_by_index", + "type": "function", + "inputs": [ + { + "name": "index", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + }, + { + "name": "get_protocol_stats", + "type": "function", + "inputs": [ + { + "name": "token_add", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "common::interfaces::imetrics::Market_Info" + } + ], + "state_mutability": "view" + }, + { + "name": "get_protocol_reserves", + "type": "function", + "inputs": [], + "outputs": [ + { + "type": "common::interfaces::imetrics::ProtocolReserves" + } + ], + "state_mutability": "view" + }, + { + "name": "get_user_deposit", + "type": "function", + "inputs": [ + { + "name": "rToken", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "common::interfaces::imetrics::Deposit" + } + ], + "state_mutability": "view" + }, + { + "name": "get_user_deposit_stats_info", + "type": "function", + "inputs": [ + { + "name": "rToken", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "common::interfaces::imetrics::UserDepositStats" + } + ], + "state_mutability": "view" + }, + { + "name": "get_user_loan_stats_info", + "type": "function", + "inputs": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "index", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "common::interfaces::imetrics::UserLoanStats" + } + ], + "state_mutability": "view" + }, + { + "name": "get_user_loan_ids_length", + "type": "function", + "inputs": [ + { + "name": "user", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" } - ], - "stateMutability": "view", - "type": "function" + ] }, { + "name": "constructor", + "type": "constructor", "inputs": [ { - "name": "token_add", - "type": "felt" - } - ], - "name": "get_protocol_stats", - "outputs": [ - { - "name": "market_info", - "type": "Market_Info" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "get_protocol_reserves", - "outputs": [ - { - "name": "protocol_reserves", - "type": "ProtocolReserves" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "rToken", - "type": "felt" - }, - { - "name": "account", - "type": "felt" - } - ], - "name": "get_user_deposit", - "outputs": [ - { - "name": "deposit", - "type": "Deposit" + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" } - ], - "stateMutability": "view", - "type": "function" + ] }, { - "inputs": [ - { - "name": "rToken", - "type": "felt" - }, - { - "name": "account", - "type": "felt" - } - ], - "name": "get_user_deposit_stats_info", - "outputs": [ + "kind": "struct", + "name": "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded", + "type": "event", + "members": [ { - "name": "user_deposit_stats", - "type": "UserDepositStats" + "kind": "data", + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" } - ], - "stateMutability": "view", - "type": "function" + ] }, { - "inputs": [ - { - "name": "user", - "type": "felt" - }, - { - "name": "index", - "type": "felt" + "kind": "enum", + "name": "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event", + "type": "event", + "variants": [ + { + "kind": "nested", + "name": "Upgraded", + "type": "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded" } - ], - "name": "get_user_loan_stats_info", - "outputs": [ - { - "name": "user_loan_stats", - "type": "UserLoanStats" - } - ], - "stateMutability": "view", - "type": "function" + ] }, { - "inputs": [ - { - "name": "user", - "type": "felt" - } - ], - "name": "get_user_loan_ids_length", - "outputs": [ - { - "name": "loan_ids_len", - "type": "felt" + "kind": "enum", + "name": "v1_core::contracts::metrics::Metrics::Event", + "type": "event", + "variants": [ + { + "kind": "flat", + "name": "UpgradeableEvent", + "type": "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event" } - ], - "stateMutability": "view", - "type": "function" + ] } ] diff --git a/src/services/data.service.ts b/src/services/data.service.ts index c7e20ba..0cd66d8 100644 --- a/src/services/data.service.ts +++ b/src/services/data.service.ts @@ -65,20 +65,18 @@ export const server = { getTvl: async () => { const metricsContract = new Contract( metricsAbi, - '0x548f38cb45720a101a1ec2edfaf608b47d2b39d137d0d3134087315f1b5f4a5', + '0x55eda1d714ffd97ebdd6a0bb6dd75de91255697a848e15004eed985b0e5ed38', rpcProvider ); - const { protocol_reserves }: any = await metricsContract.call( + const { total_reserves }: any = await metricsContract.call( 'get_protocol_reserves', [], { blockIdentifier: 'pending', } ); - if (!protocol_reserves) - throw new Error('Failed to get protocol reserves'); - const { total_reserves } = protocol_reserves; + if (!total_reserves) throw new Error('Failed to get protocol reserves'); const totalReserveParsed = uint256.uint256ToBN(total_reserves); // Using token decimals of 18 and display decimals of 2 const formattedReserves = formatBigNumber(totalReserveParsed, 8, 2);