Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force stop contracts #449

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
emission.ride
bra1nsurfer committed Apr 19, 2024
commit 4af9d7ad4db3b382ff522e08d0db16798fc6af26
22 changes: 22 additions & 0 deletions ride/emission.ride
Original file line number Diff line number Diff line change
@@ -98,8 +98,24 @@ func mustManager(i: Invocation) = {
}
}

### Force Stop check function
func isForceStopped() = {
let keyForceStopContract = ["%s", "forceStopContract"].makeString(SEP)
let forceStopAddressString = this.getString(keyForceStopContract).valueOrElse("")
let forceStopAddress = forceStopAddressString.addressFromString().valueOrElse(this)

let keyDisabledStatus = ["%s%s", "disabled", this.toString()].makeString(SEP)
let disabledStatus = forceStopAddress.getBoolean(keyDisabledStatus).valueOrElse(false)

if (disabledStatus == true)
then "Force stopped".throw()
else false
}
### End Force Stop function

@Callable(i)
func constructor(factoryAddress: String, ratePerBlockMax: Int, ratePerBlock: Int, emissionStartBlock: Int, emissionDuration: Int, emissionStartTimestamp: Int, wxAssetIdStr: String) = {
strict checkForceStop = isForceStopped()
strict checkCaller = i.mustManager()

[IntegerEntry(keyRatePerBlockMaxStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlockMax),
@@ -117,6 +133,7 @@ func constructor(factoryAddress: String, ratePerBlockMax: Int, ratePerBlock: Int

@Callable(i)
func constructorV2(votingVerifiedContractPrm: String) = {
strict checkForceStop = isForceStopped()
strict checkCaller = i.mustManager()

(
@@ -129,6 +146,7 @@ func constructorV2(votingVerifiedContractPrm: String) = {

@Callable(i)
func emit(amount: Int) = {
strict checkForceStop = isForceStopped()
if (amount <= 0) then ([], []) else
let factoryContract = readFactoryAddressOrFail()
let factoryCfg = factoryContract.readFactoryCfgOrFail()
@@ -145,6 +163,7 @@ func emit(amount: Int) = {

@Callable(i)
func burn() = {
strict checkForceStop = isForceStopped()
let factoryContract = readFactoryAddressOrFail()
let factoryCfg = factoryContract.readFactoryCfgOrFail()
let boostingContract = factoryCfg.getBoostingAddressOrFail()
@@ -168,6 +187,7 @@ func burn() = {

@Callable(i)
func gwxHoldersRewardUpdate() = {
strict checkForceStop = isForceStopped()
let factoryContract = readFactoryAddressOrFail()
let factoryCfg = factoryContract.readFactoryCfgOrFail()
let gwxRewardsContract = factoryCfg.getGwxRewardAddressOrFail()
@@ -187,11 +207,13 @@ func gwxHoldersRewardUpdate() = {

@Callable(i)
func getBoostCoeffREADONLY() = {
strict checkForceStop = isForceStopped()
([], boostCoeff)
}

@Callable(i)
func changeRatePerBlock(newRatePerBlock: Int) = {
strict checkForceStop = isForceStopped()
strict check = i.caller == votingEmissionRateContract || i.mustManager() || throwErr("should be invoked by votingEmissionRateContract")

let factoryContract = readFactoryAddressOrFail()