From b3d901120f98d57b6bb881c5671d02292e9cc97f Mon Sep 17 00:00:00 2001 From: Bucur David Date: Tue, 30 Jul 2024 15:35:20 +0300 Subject: [PATCH] feat: top up admin & merged views --- src/abis/core-mx-life-bonding-sc.abi.json | 2723 ++++++++++---------- src/abis/core-mx-liveliness-stake.abi.json | 892 +++---- src/bond.ts | 94 + 3 files changed, 1934 insertions(+), 1775 deletions(-) diff --git a/src/abis/core-mx-life-bonding-sc.abi.json b/src/abis/core-mx-life-bonding-sc.abi.json index 47b70c4..3a18290 100644 --- a/src/abis/core-mx-life-bonding-sc.abi.json +++ b/src/abis/core-mx-life-bonding-sc.abi.json @@ -1,1335 +1,1396 @@ { - "buildInfo": { - "rustc": { - "version": "1.78.0", - "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", - "commitDate": "2024-04-29", - "channel": "Stable", - "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" - }, - "contractCrate": { - "name": "core-mx-life-bonding-sc", - "version": "3.0.0" - }, - "framework": { - "name": "multiversx-sc", - "version": "0.51.1" - } - }, - "name": "LifeBondingContract", - "constructor": { - "inputs": [], - "outputs": [] - }, - "upgradeConstructor": { - "inputs": [], - "outputs": [] - }, - "endpoints": [ - { - "name": "bond", - "mutability": "mutable", - "payableInTokens": [ - "*" - ], - "inputs": [ - { - "name": "original_caller", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "lock_period_seconds", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "withdraw", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "renew", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "proof", - "mutability": "mutable", - "payableInTokens": [ - "*" - ], - "inputs": [], - "outputs": [] - }, - { - "name": "claimRefund", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setVaultNonce", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "topUpVault", - "mutability": "mutable", - "payableInTokens": [ - "*" - ], - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "stakeRewards", - "mutability": "mutable", - "inputs": [ - { - "name": "original_caller", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "amount", - "type": "BigUint" - } - ], - "outputs": [] - }, - { - "name": "getCompensationBlacklist", - "mutability": "readonly", - "inputs": [ - { - "name": "compensation_id", - "type": "u64" - } - ], - "outputs": [ - { - "type": "variadic
", - "multi_result": true - } - ] - }, - { - "name": "getTotalBondAmount", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] - }, - { - "name": "getAddressVaultNone", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - } - ], - "outputs": [ - { - "type": "u64" - } - ] - }, - { - "name": "getLivelinessStakeAddress", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "Address" - } - ] - }, - { - "name": "getBond", - "mutability": "readonly", - "inputs": [ - { - "name": "bond_id", - "type": "u64" - } - ], - "outputs": [ - { - "type": "Bond" - } - ] - }, - { - "name": "getCompensation", - "mutability": "readonly", - "inputs": [ - { - "name": "compensation_id", - "type": "u64" - } - ], - "outputs": [ - { - "type": "Compensation" - } - ] - }, - { - "name": "getCompensations", - "mutability": "readonly", - "inputs": [ - { - "name": "input", - "type": "variadic>", - "multi_arg": true - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getPagedCompensations", - "mutability": "readonly", - "inputs": [ - { - "name": "start_index", - "type": "u64" - }, - { - "name": "end_index", - "type": "u64" - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getAddressRefundForCompensation", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [ - { - "type": "Option" - } - ] - }, - { - "name": "getAddressRefundForCompensations", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - }, - { - "name": "compensation_ids", - "type": "variadic", - "multi_arg": true - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getBondsByTokenIdentifierNonce", - "mutability": "readonly", - "inputs": [ - { - "name": "input", - "type": "variadic>", - "multi_arg": true - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getBonds", - "mutability": "readonly", - "inputs": [ - { - "name": "bond_ids", - "type": "variadic", - "multi_arg": true - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getAddressBonds", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getAddressBondsAvgScore", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - } - ], - "outputs": [ - { - "type": "BigUint" - } - ] - }, - { - "name": "getAddressBondsTotalValue", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - } - ], - "outputs": [ - { - "type": "BigUint" - } - ] - }, - { - "name": "getAllBonds", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getPagedBonds", - "mutability": "readonly", - "inputs": [ - { - "name": "start_index", - "type": "u64" - }, - { - "name": "end_index", - "type": "u64" - } - ], - "outputs": [ - { - "type": "List" - } - ] - }, - { - "name": "getBondsLen", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u32" - } - ] - }, - { - "name": "getCompensationsLen", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u32" - } - ] - }, - { - "name": "getLockPeriodsBonds", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "tuple,List>" - } - ] - }, - { - "name": "getContractConfiguration", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "ContractConfiguration" - } - ] - }, - { - "name": "initiateBond", - "mutability": "mutable", - "inputs": [ - { - "name": "address", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setBlacklist", - "mutability": "mutable", - "inputs": [ - { - "name": "compensation_id", - "type": "u64" - }, - { - "name": "addresses", - "type": "variadic
", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "removeBlacklist", - "mutability": "mutable", - "inputs": [ - { - "name": "compensation_id", - "type": "u64" - }, - { - "name": "addresses", - "type": "variadic
", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "initiateRefund", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "timestamp", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "sanction", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "penalty", - "type": "PenaltyType" - }, - { - "name": "custom_penalty", - "type": "optional", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "modifyBond", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setContractStateActive", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, - { - "name": "setContractStateInactive", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, - { - "name": "setAcceptedCallers", - "mutability": "mutable", - "inputs": [ - { - "name": "callers", - "type": "variadic
", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "removeAcceptedCallers", - "mutability": "mutable", - "inputs": [ - { - "name": "callers", - "type": "variadic
", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "setBondToken", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - } - ], - "outputs": [] - }, - { - "name": "addPeriodsBonds", - "mutability": "mutable", - "inputs": [ - { - "name": "args", - "type": "variadic>", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "removePeriodsBonds", - "mutability": "mutable", - "inputs": [ - { - "name": "lock_periods", - "type": "variadic", - "multi_arg": true - } - ], - "outputs": [] - }, - { - "name": "setMinimumPenalty", - "mutability": "mutable", - "inputs": [ - { - "name": "penalty", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setMaximumPenalty", - "mutability": "mutable", - "inputs": [ - { - "name": "penalty", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setWithdrawPenalty", - "mutability": "mutable", - "inputs": [ - { - "name": "penalty", - "type": "u64" - } - ], - "outputs": [] - }, - { - "name": "setLivelinessStakeAddress", - "mutability": "mutable", - "inputs": [ - { - "name": "address", - "type": "Address" - } - ], - "outputs": [] - }, - { - "name": "setAdministrator", - "onlyOwner": true, - "mutability": "mutable", - "inputs": [ - { - "name": "administrator", - "type": "Address" - } - ], - "outputs": [] - }, - { - "name": "getContractState", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "State" - } - ] - }, - { - "name": "getAdministrator", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "Address" - } - ] - }, - { - "name": "getAcceptedCallers", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "variadic
", - "multi_result": true - } - ] - }, - { - "name": "getBondPaymentToken", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "TokenIdentifier" - } - ] - }, - { - "name": "getLockPeriods", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "variadic", - "multi_result": true - } - ] - }, - { - "name": "getLockPeriodBondAmount", - "mutability": "readonly", - "inputs": [ - { - "name": "lock_period", - "type": "u64" - } - ], - "outputs": [ - { - "type": "BigUint" - } - ] - }, - { - "name": "getMinimumPenalty", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u64" - } - ] - }, - { - "name": "getMaximumPenalty", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u64" - } - ] - }, - { - "name": "getWithdrawPenalty", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u64" - } - ] - } - ], - "events": [ - { - "identifier": "minimum_penalty_event", - "inputs": [ - { - "name": "value", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "maximum_penalty_event", - "inputs": [ - { - "name": "value", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "withdraw_penalty_event", - "inputs": [ - { - "name": "value", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "contract_state_event", - "inputs": [ - { - "name": "state", - "type": "State", - "indexed": true - } - ] - }, - { - "identifier": "bond_event", - "inputs": [ - { - "name": "bond", - "type": "Bond", - "indexed": true - } - ] - }, - { - "identifier": "compensation_event", - "inputs": [ - { - "name": "compensation", - "type": "Compensation", - "indexed": true - } - ] - }, - { - "identifier": "withdraw_event", - "inputs": [ - { - "name": "bond_id", - "type": "u64", - "indexed": true - }, - { - "name": "caller", - "type": "Address", - "indexed": true - }, - { - "name": "withdraw_amount", - "type": "BigUint", - "indexed": true - }, - { - "name": "penalty_amount", - "type": "BigUint", - "indexed": true - } - ] - }, - { - "identifier": "renew_event", - "inputs": [ - { - "name": "bond_id", - "type": "u64", - "indexed": true - }, - { - "name": "caller", - "type": "Address", - "indexed": true - }, - { - "name": "unbond_timestmap", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "proof_event", - "inputs": [ - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - }, - { - "name": "nonce", - "type": "u64", - "indexed": true - }, - { - "name": "proof_amount", - "type": "BigUint" - } - ] - }, - { - "identifier": "claim_refund_event", - "inputs": [ - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "caller", - "type": "Address", - "indexed": true - }, - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - }, - { - "name": "nonce", - "type": "u64", - "indexed": true - }, - { - "name": "amount", - "type": "BigUint", - "indexed": true - }, - { - "name": "refund_token_identifier", - "type": "TokenIdentifier", - "indexed": true - }, - { - "name": "refund_token_nonce", - "type": "u64", - "indexed": true - }, - { - "name": "refund_amount", - "type": "BigUint", - "indexed": true - } - ] - }, - { - "identifier": "add_to_blacklist_event", - "inputs": [ - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "addresses", - "type": "variadic
", - "indexed": true - } - ] - }, - { - "identifier": "remove_from_blacklist_event", - "inputs": [ - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "addresses", - "type": "variadic
", - "indexed": true - } - ] - }, - { - "identifier": "initiate_refund_event", - "inputs": [ - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - }, - { - "name": "nonce", - "type": "u64", - "indexed": true - }, - { - "name": "timestamp", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "sanction_event", - "inputs": [ - { - "name": "bond_id", - "type": "u64", - "indexed": true - }, - { - "name": "compensation_id", - "type": "u64", - "indexed": true - }, - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - }, - { - "name": "nonce", - "type": "u64", - "indexed": true - }, - { - "name": "penalty_amount", - "type": "BigUint", - "indexed": true - } - ] - }, - { - "identifier": "modify_bond_event", - "inputs": [ - { - "name": "bond_id", - "type": "u64", - "indexed": true - }, - { - "name": "unbond_timestamp", - "type": "u64", - "indexed": true - } - ] - }, - { - "identifier": "set_accepted_callers_event", - "inputs": [ - { - "name": "callers", - "type": "variadic
", - "indexed": true - } - ] - }, - { - "identifier": "remove_accepted_callers_event", - "inputs": [ - { - "name": "callers", - "type": "variadic
", - "indexed": true - } - ] - }, - { - "identifier": "set_bond_token_event", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - } - ] - }, - { - "identifier": "set_period_and_bond_event", - "inputs": [ - { - "name": "period", - "type": "u64", - "indexed": true - }, - { - "name": "bond", - "type": "BigUint", - "indexed": true - } - ] - }, - { - "identifier": "remove_period_and_bond_event", - "inputs": [ - { - "name": "period", - "type": "u64", - "indexed": true - }, - { - "name": "bond", - "type": "BigUint", - "indexed": true - } - ] - }, - { - "identifier": "set_administrator_event", - "inputs": [ - { - "name": "administrator", - "type": "Address", - "indexed": true - } - ] - }, - { - "identifier": "set_liveliness_stake_address", - "inputs": [ - { - "name": "address", - "type": "Address", - "indexed": true - } - ] - } - ], - "esdtAttributes": [], - "hasCallback": false, - "types": { - "Bond": { - "type": "struct", - "fields": [ - { - "name": "bond_id", - "type": "u64" - }, - { - "name": "address", - "type": "Address" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "lock_period", - "type": "u64" - }, - { - "name": "bond_timestamp", - "type": "u64" - }, - { - "name": "unbond_timestamp", - "type": "u64" - }, - { - "name": "bond_amount", - "type": "BigUint" - }, - { - "name": "remaining_amount", - "type": "BigUint" - } - ] - }, - "Compensation": { - "type": "struct", - "fields": [ - { - "name": "compensation_id", - "type": "u64" - }, - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "accumulated_amount", - "type": "BigUint" - }, - { - "name": "proof_amount", - "type": "BigUint" - }, - { - "name": "end_date", - "type": "u64" - } - ] - }, - "ContractConfiguration": { - "type": "struct", - "fields": [ - { - "name": "contract_state", - "type": "State" - }, - { - "name": "bond_payment_token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "lock_periods", - "type": "List" - }, - { - "name": "bond_amounts", - "type": "List" - }, - { - "name": "minimum_penalty", - "type": "u64" - }, - { - "name": "maximum_penalty", - "type": "u64" - }, - { - "name": "withdraw_penalty", - "type": "u64" - }, - { - "name": "accepted_callers", - "type": "List
" - } - ] - }, - "EsdtTokenPayment": { - "type": "struct", - "fields": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "token_nonce", - "type": "u64" - }, - { - "name": "amount", - "type": "BigUint" - } - ] - }, - "PenaltyType": { - "type": "enum", - "variants": [ - { - "name": "Minimum", - "discriminant": 0 - }, - { - "name": "Custom", - "discriminant": 1 - }, - { - "name": "Maximum", - "discriminant": 2 - } - ] - }, - "Refund": { - "type": "struct", - "fields": [ - { - "name": "address", - "type": "Address" - }, - { - "name": "proof_of_refund", - "type": "EsdtTokenPayment" - }, - { - "name": "compensation_id", - "type": "u64" - } - ] - }, - "State": { - "type": "enum", - "variants": [ - { - "name": "Inactive", - "discriminant": 0 - }, - { - "name": "Active", - "discriminant": 1 - } - ] + "buildInfo": { + "rustc": { + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", + "channel": "Stable", + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" + }, + "contractCrate": { + "name": "core-mx-life-bonding-sc", + "version": "3.1.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.51.1" + } + }, + "name": "LifeBondingContract", + "constructor": { + "inputs": [], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "bond", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [ + { + "name": "original_caller", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "lock_period_seconds", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "withdraw", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "renew", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "proof", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [], + "outputs": [] + }, + { + "name": "claimRefund", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setVaultNonce", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "topUpVault", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "topUpAddressVault", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "stakeRewards", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [ + { + "name": "original_caller", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "getCompensationBlacklist", + "mutability": "readonly", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getTotalBondAmount", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getAddressVaultNone", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getLivelinessStakeAddress", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getBond", + "mutability": "readonly", + "inputs": [ + { + "name": "bond_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "Bond" + } + ] + }, + { + "name": "getCompensation", + "mutability": "readonly", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + } + ], + "outputs": [ + { + "type": "Compensation" + } + ] + }, + { + "name": "getCompensations", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getPagedCompensations", + "mutability": "readonly", + "inputs": [ + { + "name": "start_index", + "type": "u64" + }, + { + "name": "end_index", + "type": "u64" + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getAddressRefundForCompensation", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [ + { + "type": "Option" + } + ] + }, + { + "name": "getAddressRefundForCompensations", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "compensation_ids", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getBondsByTokenIdentifierNonce", + "mutability": "readonly", + "inputs": [ + { + "name": "input", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getBonds", + "mutability": "readonly", + "inputs": [ + { + "name": "bond_ids", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getAddressBonds", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getAddressBondsAvgScore", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getAddressBondsTotalValue", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getAddressBondsInfo", + "mutability": "readonly", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [ + { + "type": "tuple" + } + ] + }, + { + "name": "getAllBonds", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getPagedBonds", + "mutability": "readonly", + "inputs": [ + { + "name": "start_index", + "type": "u64" + }, + { + "name": "end_index", + "type": "u64" + } + ], + "outputs": [ + { + "type": "List" + } + ] + }, + { + "name": "getBondsLen", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "getCompensationsLen", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u32" + } + ] + }, + { + "name": "getLockPeriodsBonds", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "tuple,List>" + } + ] + }, + { + "name": "getContractConfiguration", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "ContractConfiguration" + } + ] + }, + { + "name": "initiateBond", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setBlacklist", + "mutability": "mutable", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + }, + { + "name": "addresses", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeBlacklist", + "mutability": "mutable", + "inputs": [ + { + "name": "compensation_id", + "type": "u64" + }, + { + "name": "addresses", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "initiateRefund", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "timestamp", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "sanction", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "penalty", + "type": "PenaltyType" + }, + { + "name": "custom_penalty", + "type": "optional", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "modifyBond", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setContractStateActive", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setContractStateInactive", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setAcceptedCallers", + "mutability": "mutable", + "inputs": [ + { + "name": "callers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removeAcceptedCallers", + "mutability": "mutable", + "inputs": [ + { + "name": "callers", + "type": "variadic
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "setBondToken", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "addPeriodsBonds", + "mutability": "mutable", + "inputs": [ + { + "name": "args", + "type": "variadic>", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "removePeriodsBonds", + "mutability": "mutable", + "inputs": [ + { + "name": "lock_periods", + "type": "variadic", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "setMinimumPenalty", + "mutability": "mutable", + "inputs": [ + { + "name": "penalty", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setMaximumPenalty", + "mutability": "mutable", + "inputs": [ + { + "name": "penalty", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setWithdrawPenalty", + "mutability": "mutable", + "inputs": [ + { + "name": "penalty", + "type": "u64" + } + ], + "outputs": [] + }, + { + "name": "setLivelinessStakeAddress", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setTopUpAdministrator", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setAdministrator", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "administrator", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "getContractState", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "State" + } + ] + }, + { + "name": "getAdministrator", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getTopUpAdministrator", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "Address" + } + ] + }, + { + "name": "getAcceptedCallers", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic
", + "multi_result": true + } + ] + }, + { + "name": "getBondPaymentToken", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "TokenIdentifier" + } + ] + }, + { + "name": "getLockPeriods", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "variadic", + "multi_result": true + } + ] + }, + { + "name": "getLockPeriodBondAmount", + "mutability": "readonly", + "inputs": [ + { + "name": "lock_period", + "type": "u64" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "getMinimumPenalty", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getMaximumPenalty", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + }, + { + "name": "getWithdrawPenalty", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "u64" + } + ] + } + ], + "events": [ + { + "identifier": "minimum_penalty_event", + "inputs": [ + { + "name": "value", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "maximum_penalty_event", + "inputs": [ + { + "name": "value", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "withdraw_penalty_event", + "inputs": [ + { + "name": "value", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "contract_state_event", + "inputs": [ + { + "name": "state", + "type": "State", + "indexed": true + } + ] + }, + { + "identifier": "bond_event", + "inputs": [ + { + "name": "bond", + "type": "Bond", + "indexed": true + } + ] + }, + { + "identifier": "compensation_event", + "inputs": [ + { + "name": "compensation", + "type": "Compensation", + "indexed": true + } + ] + }, + { + "identifier": "withdraw_event", + "inputs": [ + { + "name": "bond_id", + "type": "u64", + "indexed": true + }, + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "withdraw_amount", + "type": "BigUint", + "indexed": true + }, + { + "name": "penalty_amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "renew_event", + "inputs": [ + { + "name": "bond_id", + "type": "u64", + "indexed": true + }, + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "unbond_timestmap", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "proof_event", + "inputs": [ + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + }, + { + "name": "nonce", + "type": "u64", + "indexed": true + }, + { + "name": "proof_amount", + "type": "BigUint" + } + ] + }, + { + "identifier": "claim_refund_event", + "inputs": [ + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "caller", + "type": "Address", + "indexed": true + }, + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + }, + { + "name": "nonce", + "type": "u64", + "indexed": true + }, + { + "name": "amount", + "type": "BigUint", + "indexed": true + }, + { + "name": "refund_token_identifier", + "type": "TokenIdentifier", + "indexed": true + }, + { + "name": "refund_token_nonce", + "type": "u64", + "indexed": true + }, + { + "name": "refund_amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "add_to_blacklist_event", + "inputs": [ + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "addresses", + "type": "variadic
", + "indexed": true + } + ] + }, + { + "identifier": "remove_from_blacklist_event", + "inputs": [ + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "addresses", + "type": "variadic
", + "indexed": true + } + ] + }, + { + "identifier": "initiate_refund_event", + "inputs": [ + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + }, + { + "name": "nonce", + "type": "u64", + "indexed": true + }, + { + "name": "timestamp", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "sanction_event", + "inputs": [ + { + "name": "bond_id", + "type": "u64", + "indexed": true + }, + { + "name": "compensation_id", + "type": "u64", + "indexed": true + }, + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + }, + { + "name": "nonce", + "type": "u64", + "indexed": true + }, + { + "name": "penalty_amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "modify_bond_event", + "inputs": [ + { + "name": "bond_id", + "type": "u64", + "indexed": true + }, + { + "name": "unbond_timestamp", + "type": "u64", + "indexed": true + } + ] + }, + { + "identifier": "set_accepted_callers_event", + "inputs": [ + { + "name": "callers", + "type": "variadic
", + "indexed": true + } + ] + }, + { + "identifier": "remove_accepted_callers_event", + "inputs": [ + { + "name": "callers", + "type": "variadic
", + "indexed": true + } + ] + }, + { + "identifier": "set_bond_token_event", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + } + ] + }, + { + "identifier": "set_period_and_bond_event", + "inputs": [ + { + "name": "period", + "type": "u64", + "indexed": true + }, + { + "name": "bond", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "remove_period_and_bond_event", + "inputs": [ + { + "name": "period", + "type": "u64", + "indexed": true + }, + { + "name": "bond", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "set_administrator_event", + "inputs": [ + { + "name": "administrator", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "set_liveliness_stake_address", + "inputs": [ + { + "name": "address", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "set_top_up_administrator_event", + "inputs": [ + { + "name": "top_up_administrator", + "type": "Address", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "Bond": { + "type": "struct", + "fields": [ + { + "name": "bond_id", + "type": "u64" + }, + { + "name": "address", + "type": "Address" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "lock_period", + "type": "u64" + }, + { + "name": "bond_timestamp", + "type": "u64" + }, + { + "name": "unbond_timestamp", + "type": "u64" + }, + { + "name": "bond_amount", + "type": "BigUint" + }, + { + "name": "remaining_amount", + "type": "BigUint" + } + ] + }, + "Compensation": { + "type": "struct", + "fields": [ + { + "name": "compensation_id", + "type": "u64" + }, + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "accumulated_amount", + "type": "BigUint" + }, + { + "name": "proof_amount", + "type": "BigUint" + }, + { + "name": "end_date", + "type": "u64" + } + ] + }, + "ContractConfiguration": { + "type": "struct", + "fields": [ + { + "name": "contract_state", + "type": "State" + }, + { + "name": "bond_payment_token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "lock_periods", + "type": "List" + }, + { + "name": "bond_amounts", + "type": "List" + }, + { + "name": "minimum_penalty", + "type": "u64" + }, + { + "name": "maximum_penalty", + "type": "u64" + }, + { + "name": "withdraw_penalty", + "type": "u64" + }, + { + "name": "accepted_callers", + "type": "List
" + } + ] + }, + "EsdtTokenPayment": { + "type": "struct", + "fields": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" + }, + { + "name": "token_nonce", + "type": "u64" + }, + { + "name": "amount", + "type": "BigUint" + } + ] + }, + "PenaltyType": { + "type": "enum", + "variants": [ + { + "name": "Minimum", + "discriminant": 0 + }, + { + "name": "Custom", + "discriminant": 1 + }, + { + "name": "Maximum", + "discriminant": 2 + } + ] + }, + "Refund": { + "type": "struct", + "fields": [ + { + "name": "address", + "type": "Address" + }, + { + "name": "proof_of_refund", + "type": "EsdtTokenPayment" + }, + { + "name": "compensation_id", + "type": "u64" + } + ] + }, + "State": { + "type": "enum", + "variants": [ + { + "name": "Inactive", + "discriminant": 0 + }, + { + "name": "Active", + "discriminant": 1 } + ] } + } } diff --git a/src/abis/core-mx-liveliness-stake.abi.json b/src/abis/core-mx-liveliness-stake.abi.json index c147c0b..01c53a8 100644 --- a/src/abis/core-mx-liveliness-stake.abi.json +++ b/src/abis/core-mx-liveliness-stake.abi.json @@ -1,507 +1,511 @@ { - "buildInfo": { - "rustc": { - "version": "1.78.0", - "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", - "commitDate": "2024-04-29", - "channel": "Stable", - "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" - }, - "contractCrate": { - "name": "core-mx-liveliness-stake", - "version": "0.0.0" - }, - "framework": { - "name": "multiversx-sc", - "version": "0.51.0" + "buildInfo": { + "rustc": { + "version": "1.78.0", + "commitHash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", + "commitDate": "2024-04-29", + "channel": "Stable", + "short": "rustc 1.78.0 (9b00956e5 2024-04-29)" + }, + "contractCrate": { + "name": "core-mx-liveliness-stake", + "version": "0.0.0" + }, + "framework": { + "name": "multiversx-sc", + "version": "0.51.1" + } + }, + "name": "CoreMxLivelinessStake", + "constructor": { + "inputs": [], + "outputs": [] + }, + "upgradeConstructor": { + "inputs": [], + "outputs": [] + }, + "endpoints": [ + { + "name": "claimRewards", + "mutability": "mutable", + "inputs": [ + { + "name": "address", + "type": "optional
", + "multi_arg": true + } + ], + "outputs": [] + }, + { + "name": "stakeRewards", + "mutability": "mutable", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier" } + ], + "outputs": [] }, - "name": "CoreMxLivelinessStake", - "constructor": { - "inputs": [], - "outputs": [] + { + "name": "setContractStateActive", + "mutability": "mutable", + "inputs": [], + "outputs": [] }, - "upgradeConstructor": { - "inputs": [], - "outputs": [] + { + "name": "setContractStateInactive", + "mutability": "mutable", + "inputs": [], + "outputs": [] }, - "endpoints": [ + { + "name": "setMaxApr", + "mutability": "mutable", + "inputs": [ { - "name": "claimRewards", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "name": "max_apr", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "setRewardsTokenIdentifier", + "mutability": "mutable", + "inputs": [ { - "name": "stakeRewards", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - } - ], - "outputs": [] - }, + "name": "token_identifier", + "type": "TokenIdentifier" + } + ], + "outputs": [] + }, + { + "name": "setPerBlockRewardAmount", + "mutability": "mutable", + "inputs": [ { - "name": "setContractStateActive", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "name": "per_block_amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "topUpRewards", + "mutability": "mutable", + "payableInTokens": ["*"], + "inputs": [], + "outputs": [] + }, + { + "name": "withdrawRewards", + "mutability": "mutable", + "inputs": [ { - "name": "setContractStateInactive", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "name": "amount", + "type": "BigUint" + } + ], + "outputs": [] + }, + { + "name": "startProduceRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "endProduceRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "setBondContractAddress", + "mutability": "mutable", + "inputs": [ { - "name": "setMaxApr", - "mutability": "mutable", - "inputs": [ - { - "name": "max_apr", - "type": "BigUint" - } - ], - "outputs": [] - }, + "name": "bond_contract_address", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "setAdministrator", + "onlyOwner": true, + "mutability": "mutable", + "inputs": [ + { + "name": "administrator", + "type": "Address" + } + ], + "outputs": [] + }, + { + "name": "getContractState", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "setRewardsTokenIdentifier", - "mutability": "mutable", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier" - } - ], - "outputs": [] - }, + "type": "State" + } + ] + }, + { + "name": "rewardsState", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "setPerBlockRewardAmount", - "mutability": "mutable", - "inputs": [ - { - "name": "per_block_amount", - "type": "BigUint" - } - ], - "outputs": [] - }, + "type": "State" + } + ] + }, + { + "name": "getAdministrator", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "topUpRewards", - "mutability": "mutable", - "payableInTokens": [ - "*" - ], - "inputs": [], - "outputs": [] - }, + "type": "Address" + } + ] + }, + { + "name": "bondContractAddress", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "withdrawRewards", - "mutability": "mutable", - "inputs": [ - { - "name": "amount", - "type": "BigUint" - } - ], - "outputs": [] - }, + "type": "Address" + } + ] + }, + { + "name": "generateAggregatedRewards", + "mutability": "mutable", + "inputs": [], + "outputs": [] + }, + { + "name": "rewardsReserve", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "startProduceRewards", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "type": "BigUint" + } + ] + }, + { + "name": "accumulatedRewards", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "endProduceRewards", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "type": "BigUint" + } + ] + }, + { + "name": "rewardsTokenIdentifier", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "setBondContractAddress", - "mutability": "mutable", - "inputs": [ - { - "name": "bond_contract_address", - "type": "Address" - } - ], - "outputs": [] - }, + "type": "TokenIdentifier" + } + ] + }, + { + "name": "rewardsPerBlock", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "setAdministrator", - "onlyOwner": true, - "mutability": "mutable", - "inputs": [ - { - "name": "administrator", - "type": "Address" - } - ], - "outputs": [] - }, + "type": "BigUint" + } + ] + }, + { + "name": "lastRewardBlockNonce", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "getContractState", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "State" - } - ] - }, + "type": "u64" + } + ] + }, + { + "name": "rewardsPerShare", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "rewardsState", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "State" - } - ] - }, + "type": "BigUint" + } + ] + }, + { + "name": "addressLastRewardPerShare", + "mutability": "readonly", + "inputs": [ { - "name": "getAdministrator", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "Address" - } - ] - }, + "name": "address", + "type": "Address" + } + ], + "outputs": [ { - "name": "bondContractAddress", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "Address" - } - ] - }, + "type": "BigUint" + } + ] + }, + { + "name": "maxApr", + "mutability": "readonly", + "inputs": [], + "outputs": [ { - "name": "generateAggregatedRewards", - "mutability": "mutable", - "inputs": [], - "outputs": [] - }, + "type": "BigUint" + } + ] + }, + { + "name": "claimableRewards", + "mutability": "readonly", + "inputs": [ { - "name": "rewardsReserve", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "caller", + "type": "Address" }, { - "name": "accumulatedRewards", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] - }, + "name": "opt_bypass_liveliness", + "type": "Option" + } + ], + "outputs": [ + { + "type": "BigUint" + } + ] + }, + { + "name": "contractDetails", + "mutability": "readonly", + "inputs": [], + "outputs": [ + { + "type": "ContractDetails" + } + ] + } + ], + "events": [ + { + "identifier": "set_administrator_event", + "inputs": [ + { + "name": "administrator", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "contract_state_event", + "inputs": [ + { + "name": "state", + "type": "State", + "indexed": true + } + ] + }, + { + "identifier": "max_apr", + "inputs": [ + { + "name": "max_apr", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "rewards_token_identifier", + "inputs": [ + { + "name": "token_identifier", + "type": "TokenIdentifier", + "indexed": true + } + ] + }, + { + "identifier": "per_block_reward_amount", + "inputs": [ + { + "name": "per_block_amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "top_up_rewards_event", + "inputs": [ + { + "name": "amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "withdraw_rewards_event", + "inputs": [ + { + "name": "amount", + "type": "BigUint", + "indexed": true + } + ] + }, + { + "identifier": "rewards_state_event", + "inputs": [ { - "name": "rewardsTokenIdentifier", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "TokenIdentifier" - } - ] + "name": "state", + "type": "State", + "indexed": true + } + ] + }, + { + "identifier": "bond_contract_address", + "inputs": [ + { + "name": "bond_contract_address", + "type": "Address", + "indexed": true + } + ] + }, + { + "identifier": "claim_rewards", + "inputs": [ + { + "name": "caller", + "type": "Address", + "indexed": true }, { - "name": "rewardsPerBlock", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "rewards_amount", + "type": "BigUint", + "indexed": true }, { - "name": "lastRewardBlockNonce", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "u64" - } - ] + "name": "timestamp", + "type": "u64", + "indexed": true }, { - "name": "rewardsPerShare", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "block_nonce", + "type": "u64", + "indexed": true }, { - "name": "addressLastRewardPerShare", - "mutability": "readonly", - "inputs": [ - { - "name": "address", - "type": "Address" - } - ], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "rewards_reserve", + "type": "BigUint", + "indexed": true }, { - "name": "maxApr", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "accumulated_rewards", + "type": "BigUint", + "indexed": true }, { - "name": "claimableRewards", - "mutability": "readonly", - "inputs": [ - { - "name": "caller", - "type": "Address" - }, - { - "name": "opt_bypass_liveliness", - "type": "Option" - } - ], - "outputs": [ - { - "type": "BigUint" - } - ] + "name": "current_rewards_per_share", + "type": "BigUint", + "indexed": true }, { - "name": "contractDetails", - "mutability": "readonly", - "inputs": [], - "outputs": [ - { - "type": "ContractDetails" - } - ] - } - ], - "events": [ - { - "identifier": "set_administrator_event", - "inputs": [ - { - "name": "administrator", - "type": "Address", - "indexed": true - } - ] + "name": "user_last_rewards_per_share", + "type": "BigUint", + "indexed": true }, { - "identifier": "contract_state_event", - "inputs": [ - { - "name": "state", - "type": "State", - "indexed": true - } - ] + "name": "rewards_per_block", + "type": "BigUint", + "indexed": true + } + ] + } + ], + "esdtAttributes": [], + "hasCallback": false, + "types": { + "ContractDetails": { + "type": "struct", + "fields": [ + { + "name": "rewards_reserve", + "type": "BigUint" }, { - "identifier": "max_apr", - "inputs": [ - { - "name": "max_apr", - "type": "BigUint", - "indexed": true - } - ] + "name": "accumulated_rewards", + "type": "BigUint" }, { - "identifier": "rewards_token_identifier", - "inputs": [ - { - "name": "token_identifier", - "type": "TokenIdentifier", - "indexed": true - } - ] + "name": "rewards_token_identifier", + "type": "TokenIdentifier" }, { - "identifier": "per_block_reward_amount", - "inputs": [ - { - "name": "per_block_amount", - "type": "BigUint", - "indexed": true - } - ] + "name": "rewards_per_block", + "type": "BigUint" }, { - "identifier": "top_up_rewards_event", - "inputs": [ - { - "name": "amount", - "type": "BigUint", - "indexed": true - } - ] + "name": "rewards_per_share", + "type": "BigUint" }, { - "identifier": "withdraw_rewards_event", - "inputs": [ - { - "name": "amount", - "type": "BigUint", - "indexed": true - } - ] + "name": "administrator", + "type": "Address" }, { - "identifier": "rewards_state_event", - "inputs": [ - { - "name": "state", - "type": "State", - "indexed": true - } - ] + "name": "bond_contract_address", + "type": "Address" }, { - "identifier": "bond_contract_address", - "inputs": [ - { - "name": "bond_contract_address", - "type": "Address", - "indexed": true - } - ] + "name": "last_reward_block_nonce", + "type": "u64" }, { - "identifier": "claim_rewards", - "inputs": [ - { - "name": "caller", - "type": "Address", - "indexed": true - }, - { - "name": "rewards_amount", - "type": "BigUint", - "indexed": true - }, - { - "name": "timestamp", - "type": "u64", - "indexed": true - }, - { - "name": "block_nonce", - "type": "u64", - "indexed": true - }, - { - "name": "rewards_reserve", - "type": "BigUint", - "indexed": true - }, - { - "name": "accumulated_rewards", - "type": "BigUint", - "indexed": true - }, - { - "name": "current_rewards_per_share", - "type": "BigUint", - "indexed": true - }, - { - "name": "user_last_rewards_per_share", - "type": "BigUint", - "indexed": true - }, - { - "name": "rewards_per_block", - "type": "BigUint", - "indexed": true - } - ] - } - ], - "esdtAttributes": [], - "hasCallback": false, - "types": { - "ContractDetails": { - "type": "struct", - "fields": [ - { - "name": "rewards_reserve", - "type": "BigUint" - }, - { - "name": "accumulated_rewards", - "type": "BigUint" - }, - { - "name": "rewards_token_identifier", - "type": "TokenIdentifier" - }, - { - "name": "rewards_per_block", - "type": "BigUint" - }, - { - "name": "rewards_per_share", - "type": "BigUint" - }, - { - "name": "administrator", - "type": "Address" - }, - { - "name": "bond_contract_address", - "type": "Address" - }, - { - "name": "last_reward_block_nonce", - "type": "u64" - }, - { - "name": "max_apr", - "type": "BigUint" - } - ] + "name": "max_apr", + "type": "BigUint" + } + ] + }, + "State": { + "type": "enum", + "variants": [ + { + "name": "Inactive", + "discriminant": 0 }, - "State": { - "type": "enum", - "variants": [ - { - "name": "Inactive", - "discriminant": 0 - }, - { - "name": "Active", - "discriminant": 1 - } - ] + { + "name": "Active", + "discriminant": 1 } + ] } + } } diff --git a/src/bond.ts b/src/bond.ts index 4e6cbe6..4ff49ef 100644 --- a/src/bond.ts +++ b/src/bond.ts @@ -128,6 +128,41 @@ export class BondContract extends Contract { } } + /** + * Returns the address bonds info + * @param address address to query + * + */ + + async viewAddressBondsInfo(address: IAddress): Promise<{ + totalStakedAmount: BigNumber.Value; + userStakedAmount: BigNumber.Value; + livelinessScore: number; + }> { + const interaction = this.contract.methodsExplicit.getAddressBondsInfo([ + new AddressValue(address) + ]); + const query = interaction.buildQuery(); + const queryResponse = await this.networkProvider.queryContract(query); + const endpointDefinition = interaction.getEndpoint(); + const { firstValue, returnCode } = new ResultsParser().parseQueryResponse( + queryResponse, + endpointDefinition + ); + if (returnCode.isSuccess()) { + const returnValue = firstValue?.valueOf(); + return { + totalStakedAmount: returnValue.field0.valueOf(), + userStakedAmount: returnValue.field1.valueOf(), + livelinessScore: new BigNumber(returnValue.field2.valueOf()) + .div(100) + .toNumber() + }; + } else { + throw new ErrContractQuery('viewAddressBondsInfo', returnCode.toString()); + } + } + /** * Returns the total bond amount for a specific address * @param address address to query @@ -724,6 +759,29 @@ export class BondContract extends Contract { return setAdministratorTx; } + /** + * Builds a 'setTopUpAdministrator' transaction + * @param senderAddress address of the sender (must be the owner of the contract) + * @param address new top up administrator address + */ + setTopUpAdministrator( + senderAddress: IAddress, + address: IAddress + ): Transaction { + const setTopUpAdministratorTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction('setTopUpAdministrator') + .addArg(new AddressValue(address)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 10_000_000, + chainID: this.chainID + }); + return setTopUpAdministratorTx; + } + /** * Builds a `sanction` transaction * @param senderAddress address of the sender (must be the owner of the contract or the administrator) @@ -1193,6 +1251,42 @@ export class BondContract extends Contract { }); return topUpVaultTx; } + /** + * Builds a `topUpAddressVault` transaction + * @param senderAddress the address of the sender (must be the top up administrator) + * @param address the address to top up the vault for + * @param payment the payment for the top up (tokenIdentifier, nonce and amount) + * @param nonce the nonce of the Data Nft + * @param tokenIdentifier the token identifier of the Data Nft [default is the Data Nft token identifier based on {@link EnvironmentsEnum}] + */ + topUpAddressVault( + senderAddress: IAddress, + address: IAddress, + payment: { + tokenIdentifier: string; + amount: BigNumber.Value; + }, + nonce: number, + tokenIdentifier = dataNftTokenIdentifier[this.env as EnvironmentsEnum] + ): Transaction { + const topUpVaultTx = new Transaction({ + value: 0, + data: new ContractCallPayloadBuilder() + .setFunction(new ContractFunction('ESDTTransfer')) + .addArg(new TokenIdentifierValue(payment.tokenIdentifier)) + .addArg(new BigUIntValue(payment.amount)) + .addArg(new StringValue('topUpVault')) + .addArg(new AddressValue(address)) + .addArg(new TokenIdentifierValue(tokenIdentifier)) + .addArg(new U64Value(nonce)) + .build(), + receiver: this.contract.getAddress(), + sender: senderAddress, + gasLimit: 80_000_000, + chainID: this.chainID + }); + return topUpVaultTx; + } /** * Builds a `bond` transaction with NFT/SFT transfer