-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
velords: create lords burner contract
- Loading branch information
1 parent
c6b899c
commit 6f51aea
Showing
7 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[31m ____ _ [39m | ||
[31m | \ ___ ___| |___ _ _ [39m | ||
[31m | | | -_| . | | . | | |[39m | ||
[31m |____/|___| _|_|___|_ |[39m | ||
[31m |_| |___|[39m | ||
[34m | ||
|
||
|
||
Contract is lordship_burner.contract_class.json... | ||
|
||
[39m | ||
[35m | ||
Declaring Lordship Lords Burner... | ||
|
||
[39m | ||
[35m- Class Hash: [39m 0x1fee7f8d94aab37b94bcf07b35a556d3039cbe72ba36109216b52d6cc07251b | ||
[35m- Tx Hash: [39m Already declared | ||
[32m | ||
Deploying Lordship Lords Burner ... | ||
|
||
[39m | ||
[32mTx hash: [39m https://voyager.online/tx/0x302d79c2523f13d9796d14ae9e6ddc59da8ddd323a243af6770325bb1512dd5) | ||
[32mContract Address: [39m 0x45c587318c9ebcf2fbe21febf288ee2e3597a21cd48676005a5770a50d433c5 | ||
|
||
|
||
"addresses/prod/Lordship Lords Burner.json" has been saved or overwritten |
9 changes: 9 additions & 0 deletions
9
veLords/scripts/deployment/addresses/prod/Lordship Lords Burner.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"address": "0x45c587318c9ebcf2fbe21febf288ee2e3597a21cd48676005a5770a50d433c5", | ||
"calldata": [ | ||
"0x992acf50dba66f87d8cafffbbc3cdbbec5f8f514b5014f6d4d75e6b8789153", | ||
"0x91b13b83e5c34112aa066a844d4cbe6af99b3d134293829ca1730ea4869a71" | ||
], | ||
"deployed_at": 1726197087423, | ||
"deployed_at_readable": "Fri, 13 Sep 2024 03:11:27 GMT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// A simple contract that receives lords and allows anyone | ||
// to call the burn function to send it to the reward pool | ||
|
||
// the contract is upgradeable so new functions can be added in the future | ||
|
||
#[starknet::contract] | ||
mod burner { | ||
use lordship::interfaces::IBurner::IBurner; | ||
use lordship::interfaces::IERC20::{IERC20Dispatcher, IERC20DispatcherTrait}; | ||
use lordship::interfaces::IRewardPool::{IRewardPoolDispatcher, IRewardPoolDispatcherTrait}; | ||
use openzeppelin::access::ownable::OwnableComponent; | ||
use openzeppelin::upgrades::UpgradeableComponent; | ||
use openzeppelin::upgrades::interface::IUpgradeable; | ||
use starknet::{ClassHash, ContractAddress, get_contract_address, contract_address_const}; | ||
|
||
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); | ||
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent); | ||
|
||
#[abi(embed_v0)] | ||
impl OwnableTwoStepImpl = OwnableComponent::OwnableTwoStepImpl<ContractState>; | ||
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>; | ||
impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl<ContractState>; | ||
|
||
#[storage] | ||
struct Storage { | ||
// component storage | ||
#[substorage(v0)] | ||
ownable: OwnableComponent::Storage, | ||
#[substorage(v0)] | ||
upgradeable: UpgradeableComponent::Storage, | ||
reward_pool: IRewardPoolDispatcher | ||
} | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
pub enum Event { | ||
#[flat] | ||
OwnableEvent: OwnableComponent::Event, | ||
#[flat] | ||
UpgradeableEvent: UpgradeableComponent::Event | ||
} | ||
|
||
fn LORDS_TOKEN() -> IERC20Dispatcher { | ||
IERC20Dispatcher { | ||
contract_address: contract_address_const::< | ||
0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49 | ||
>() | ||
} | ||
} | ||
|
||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState, owner: ContractAddress, reward_pool: ContractAddress,) { | ||
self.ownable.initializer(owner); | ||
self.reward_pool.write(IRewardPoolDispatcher { contract_address: reward_pool }); | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl UpgradeableImpl of IUpgradeable<ContractState> { | ||
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { | ||
self.ownable.assert_only_owner(); | ||
self.upgradeable._upgrade(new_class_hash); | ||
} | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl IBurnerImpl of IBurner<ContractState> { | ||
fn burn_lords(ref self: ContractState) { | ||
let this: ContractAddress = get_contract_address(); | ||
let lords_token = LORDS_TOKEN(); | ||
let lords_balance = lords_token.balance_of(this); | ||
assert!(lords_balance > 0, "LORDS balance is zero"); | ||
|
||
let reward_pool = self.reward_pool.read(); | ||
lords_token.approve(reward_pool.contract_address, lords_balance); | ||
reward_pool.burn(lords_balance); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use starknet::ContractAddress; | ||
|
||
#[starknet::interface] | ||
pub trait IBurner<TContractState> { | ||
fn burn_lords(ref self: TContractState); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters