Skip to content

Commit

Permalink
fix vault emission
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Mar 25, 2024
1 parent 1029fd9 commit 6033864
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 3 deletions.
7 changes: 5 additions & 2 deletions contracts/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ contract Vault is IVault, Initializable {
if (msg.sender != governor) revert NotGovernor();
if (_governor == address(0)) revert ZeroAddress();
governor = _governor;
emit GovernorChanged(_governor);
}

/// @inheritdoc IVault
function updatePeriod() external returns (uint256 _period) {
_period = activePeriod;
if (block.timestamp >= _period + WEEK) {
epochCount++;
_period = (block.timestamp / WEEK) * WEEK;
uint256 _currentPeriod = (block.timestamp / WEEK) * WEEK;
uint256 elapsed = (_currentPeriod - _period) / WEEK;
_period = _currentPeriod;
activePeriod = _period;
uint256 _emission = weekly;
uint256 _emission = weekly * elapsed;

uint256 _balanceOf = address(this).balance;
if (_balanceOf < _emission) {
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface IVault {
event Emission(address indexed sender, uint256 weekly);
event WeeklyChanged(uint256 weekly);
event VeRateChanged(uint256 rate);
event GovernorChanged(address indexed governor);
event Donation(address indexed donor, address indexed token, uint256 amount);
event Withdraw(address indexed operator, address indexed token, address indexed recipcient, uint256 amount);

Expand Down
31 changes: 31 additions & 0 deletions src/types/contracts/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface VaultInterface extends Interface {
nameOrSignatureOrTopic:
| "Donation"
| "Emission"
| "GovernorChanged"
| "Initialized"
| "VeRateChanged"
| "WeeklyChanged"
Expand Down Expand Up @@ -174,6 +175,18 @@ export namespace EmissionEvent {
export type LogDescription = TypedLogDescription<Event>;
}

export namespace GovernorChangedEvent {
export type InputTuple = [governor: AddressLike];
export type OutputTuple = [governor: string];
export interface OutputObject {
governor: string;
}
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
export type Filter = TypedDeferredTopicFilter<Event>;
export type Log = TypedEventLog<Event>;
export type LogDescription = TypedLogDescription<Event>;
}

export namespace InitializedEvent {
export type InputTuple = [version: BigNumberish];
export type OutputTuple = [version: bigint];
Expand Down Expand Up @@ -416,6 +429,13 @@ export interface Vault extends BaseContract {
EmissionEvent.OutputTuple,
EmissionEvent.OutputObject
>;
getEvent(
key: "GovernorChanged"
): TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;
getEvent(
key: "Initialized"
): TypedContractEvent<
Expand Down Expand Up @@ -468,6 +488,17 @@ export interface Vault extends BaseContract {
EmissionEvent.OutputObject
>;

"GovernorChanged(address)": TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;
GovernorChanged: TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;

"Initialized(uint8)": TypedContractEvent<
InitializedEvent.InputTuple,
InitializedEvent.OutputTuple,
Expand Down
31 changes: 31 additions & 0 deletions src/types/contracts/interfaces/IVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface IVaultInterface extends Interface {
nameOrSignatureOrTopic:
| "Donation"
| "Emission"
| "GovernorChanged"
| "VeRateChanged"
| "WeeklyChanged"
| "Withdraw"
Expand Down Expand Up @@ -167,6 +168,18 @@ export namespace EmissionEvent {
export type LogDescription = TypedLogDescription<Event>;
}

export namespace GovernorChangedEvent {
export type InputTuple = [governor: AddressLike];
export type OutputTuple = [governor: string];
export interface OutputObject {
governor: string;
}
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
export type Filter = TypedDeferredTopicFilter<Event>;
export type Log = TypedEventLog<Event>;
export type LogDescription = TypedLogDescription<Event>;
}

export namespace VeRateChangedEvent {
export type InputTuple = [rate: BigNumberish];
export type OutputTuple = [rate: bigint];
Expand Down Expand Up @@ -384,6 +397,13 @@ export interface IVault extends BaseContract {
EmissionEvent.OutputTuple,
EmissionEvent.OutputObject
>;
getEvent(
key: "GovernorChanged"
): TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;
getEvent(
key: "VeRateChanged"
): TypedContractEvent<
Expand Down Expand Up @@ -429,6 +449,17 @@ export interface IVault extends BaseContract {
EmissionEvent.OutputObject
>;

"GovernorChanged(address)": TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;
GovernorChanged: TypedContractEvent<
GovernorChangedEvent.InputTuple,
GovernorChangedEvent.OutputTuple,
GovernorChangedEvent.OutputObject
>;

"VeRateChanged(uint256)": TypedContractEvent<
VeRateChangedEvent.InputTuple,
VeRateChangedEvent.OutputTuple,
Expand Down
15 changes: 14 additions & 1 deletion src/types/factories/contracts/Vault__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ const _abi = [
name: "Emission",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "governor",
type: "address",
},
],
name: "GovernorChanged",
type: "event",
},
{
anonymous: false,
inputs: [
Expand Down Expand Up @@ -398,7 +411,7 @@ const _abi = [
] as const;

const _bytecode =
"0x6080806040523461001657610be7908161001c8239f35b600080fdfe60806040908082526004908136101561003d575b5050361561002057600080fd5b60009051348152600080516020610bbb83398151915260203392a3005b600091823560e01c9182630a441f7b14610912575081630c340a24146108e95781631f850716146108c057816326cfc17b146108a15781633f2a55401461087857816346c96aac1461084c5781636a110383146107f0578163829965cc146107d1578163a83627de146105f7578163ada6565e146105d8578163c0c53b8b146103fa578163c42cf5351461038f578163d9caed1214610290578163e69d849d146101ec578163ed88c68e146101ac578163f01aea0314610129575063f4359ce5146101085780610013565b90346101255781600319360112610125576020905162093a808152f35b5080fd5b905082346101a85760203660031901126101a857600154823592906001600160a01b0316330361019a57611388831161018c5791602091817f1b3e838a14abc73095667e9ce064209c4643de8849f0efbf7f4ea8f8a7103f39945551908152a180f35b9051636a43f8d160e01b8152fd5b9051633b8d9d7560e21b8152fd5b8280fd5b839150826003193601126101a85734156101de5750819051348152600080516020610bbb83398151915260203392a380f35b9051636370392160e11b8152fd5b905082346101a857806003193601126101a85761020761092e565b906024359160018060a01b0316928151906323b872dd60e01b60208301523360248301523060448301528360648301526064825260a082019082821067ffffffffffffffff83111761027b57508252610260908461096e565b51908152600080516020610bbb83398151915260203392a380f35b604190634e487b7160e01b6000525260246000fd5b839150346101a85760603660031901126101a8576102ac61092e565b6024356001600160a01b03818116949185900361038b57604435928160015416330361037b571692836103315750848285828215610328575b839283928392f11561031f575b519081527f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f760203392a480f35b513d85823e3d90fd5b506108fc6102e5565b81519063a9059cbb60e01b602083015285602483015283604483015260448252608082019082821067ffffffffffffffff83111761027b57508252610376908461096e565b6102f2565b8251633b8d9d7560e21b81528590fd5b8580fd5b839150346101a85760203660031901126101a8576103ab61092e565b60015491906001600160a01b039081841633036103ea57169283156103dd5750506001600160a01b0319161760015580f35b5163d92e233d60e01b8152fd5b8451633b8d9d7560e21b81528390fd5b905082346101a85760603660031901126101a85761041661092e565b6001600160a01b0360243581811694929392908590036105d3576044359182168092036105d35785549160ff8360081c1615928380946105c6575b80156105af575b156105555760ff198116600117885583610544575b5086549462010000600160b01b039060101b16958662010000600160b01b0319871617885560018060a01b0319908160025416176002553381600154161760015560035416176003556103e8815569152d02c7e14af680000060055562093a809081420482810292818404149015171561053157506006556104ed578380f35b610100600160b01b0319909116909117825551600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a18180808380f35b634e487b7160e01b875260119052602486fd5b61ffff19166101011787558761046d565b845162461bcd60e51b8152602081850152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b1580156104585750600160ff821614610458565b50600160ff821610610451565b600080fd5b839150346101a857826003193601126101a85760209250549051908152f35b905082346101a857826003193601126101a8576006549162093a809081840180851161078a5742101561062f575b6020848451908152f35b90925060075460001981146107be576001016007558242048381029381850414901517156107ab57826006556005549081471061079d57805480830290838204148315171561078a57612710900460018060a01b0386808080858560035416828215610781575bf11561077757868160035416803b1561012557819085885180948193635f72ee1960e11b83525af1801561076d5761075a575b50865460101c169083039183831161053157908691813b156101a857855180948193630314777960e21b83525af1801561075057610738575b506020935081519081527ff54dbf4cddb908bac0d67a3e6d3e4de95d0e7bc059afe2d34b37a6ebbc3879ca843392a28380610625565b6107428591610944565b61074c5783610702565b8380fd5b83513d87823e3d90fd5b61076690979197610944565b95876106c9565b86513d8a823e3d90fd5b84513d88823e3d90fd5b506108fc610696565b634e487b7160e01b865260118252602486fd5b8251636a259e3160e11b8152fd5b634e487b7160e01b845260119052602483fd5b634e487b7160e01b855260118252602485fd5b8284346101255781600319360112610125576020906007549051908152f35b905082346101a85760203660031901126101a857600154823592906001600160a01b0316330361019a5750816020917f6b7d0eeb50ab9007d612c3d47bc900447594cde214923c1b9d0f2b1fc960ca719360055551908152a180f35b8284346101255781600319360112610125579054905160109190911c6001600160a01b03168152602090f35b82843461012557816003193601126101255760035490516001600160a01b039091168152602090f35b8284346101255781600319360112610125576020906005549051908152f35b82843461012557816003193601126101255760025490516001600160a01b039091168152602090f35b82843461012557816003193601126101255760015490516001600160a01b039091168152602090f35b8390346101255781600319360112610125576020906006548152f35b600435906001600160a01b03821682036105d357565b67ffffffffffffffff811161095857604052565b634e487b7160e01b600052604160045260246000fd5b6040805167ffffffffffffffff94936001600160a01b039093169290808301868111828210176109585783526020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808487829651910182855af13d15610ad9573d91888311610ac557855192601f19603f81601f8401160116840199848b10908b1117610ab15786979899610a1896975283528286893d92013e610ae6565b805191821591858315610a8a575b505050905015610a34575050565b60849250519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b91938180945001031261012557830151908115158203610aae575080388085610a26565b80fd5b634e487b7160e01b86526041600452602486fd5b634e487b7160e01b85526041600452602485fd5b610a189394959697506060915b91929015610b485750815115610afa575090565b3b15610b035790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015610b5b5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610ba1575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350610b7e56fe597440e65d8cdea1298e19df50e115bda25508180452d87a7f4f99195fb843a4a164736f6c6343000813000a";
"0x6080806040523461001657610c2c908161001c8239f35b600080fdfe60806040908082526004908136101561003d575b5050361561002057600080fd5b60009051348152600080516020610c0083398151915260203392a3005b600091823560e01c9182630a441f7b14610921575081630c340a24146108f85781631f850716146108cf57816326cfc17b146108b05781633f2a55401461088757816346c96aac1461085b5781636a110383146107ff578163829965cc146107e0578163a83627de1461061c578163ada6565e146105fd578163c0c53b8b1461041f578163c42cf5351461038f578163d9caed1214610290578163e69d849d146101ec578163ed88c68e146101ac578163f01aea0314610129575063f4359ce5146101085780610013565b90346101255781600319360112610125576020905162093a808152f35b5080fd5b905082346101a85760203660031901126101a857600154823592906001600160a01b0316330361019a57611388831161018c5791602091817f1b3e838a14abc73095667e9ce064209c4643de8849f0efbf7f4ea8f8a7103f39945551908152a180f35b9051636a43f8d160e01b8152fd5b9051633b8d9d7560e21b8152fd5b8280fd5b839150826003193601126101a85734156101de5750819051348152600080516020610c0083398151915260203392a380f35b9051636370392160e11b8152fd5b905082346101a857806003193601126101a85761020761093d565b906024359160018060a01b0316928151906323b872dd60e01b60208301523360248301523060448301528360648301526064825260a082019082821067ffffffffffffffff83111761027b5750825261026090846109b3565b51908152600080516020610c0083398151915260203392a380f35b604190634e487b7160e01b6000525260246000fd5b839150346101a85760603660031901126101a8576102ac61093d565b6024356001600160a01b03818116949185900361038b57604435928160015416330361037b571692836103315750848285828215610328575b839283928392f11561031f575b519081527f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f760203392a480f35b513d85823e3d90fd5b506108fc6102e5565b81519063a9059cbb60e01b602083015285602483015283604483015260448252608082019082821067ffffffffffffffff83111761027b5750825261037690846109b3565b6102f2565b8251633b8d9d7560e21b81528590fd5b8580fd5b839150346101a85760203660031901126101a8576103ab61093d565b60015491906001600160a01b0390818416330361040f57169283156104025750506001600160a01b03191681176001557f5ffbefd23f1844198adf645535c8dce8d9f3f2f9f5e917bf4e3aa8fc90299a908280a280f35b5163d92e233d60e01b8152fd5b8451633b8d9d7560e21b81528390fd5b905082346101a85760603660031901126101a85761043b61093d565b6001600160a01b0360243581811694929392908590036105f8576044359182168092036105f85785549160ff8360081c1615928380946105eb575b80156105d4575b1561057a5760ff198116600117885583610569575b5086549462010000600160b01b039060101b16958662010000600160b01b0319871617885560018060a01b0319908160025416176002553381600154161760015560035416176003556103e8815569152d02c7e14af680000060055562093a80908142048281029281840414901517156105565750600655610512578380f35b610100600160b01b0319909116909117825551600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a18180808380f35b634e487b7160e01b875260119052602486fd5b61ffff191661010117875587610492565b845162461bcd60e51b8152602081850152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b15801561047d5750600160ff82161461047d565b50600160ff821610610476565b600080fd5b839150346101a857826003193601126101a85760209250549051908152f35b905082346101a857826003193601126101a8576006549162093a808084018085116107cd57421015610653575b6020848451908152f35b60075460001981146107cd5760010160075580420493818502948086048314901517156107cd5790610688610695928661097c565b0484600655600554610953565b908147106107bf576127106106ab825484610953565b0460018060a01b03868080808585600354168282156107b6575bf1156107ac57868160035416803b1561012557819085885180948193635f72ee1960e11b83525af180156107a257610789575b509061070c8792835460101c16918561097c565b92813b156101a857855180948193630314777960e21b83525af1801561077f57610767575b506020935081519081527ff54dbf4cddb908bac0d67a3e6d3e4de95d0e7bc059afe2d34b37a6ebbc3879ca843392a28380610649565b6107718591610989565b61077b5783610731565b8380fd5b83513d87823e3d90fd5b9661079961070c98939293610989565b969190916106f8565b86513d8a823e3d90fd5b84513d88823e3d90fd5b506108fc6106c5565b8251636a259e3160e11b8152fd5b634e487b7160e01b865260118352602486fd5b8284346101255781600319360112610125576020906007549051908152f35b905082346101a85760203660031901126101a857600154823592906001600160a01b0316330361019a5750816020917f6b7d0eeb50ab9007d612c3d47bc900447594cde214923c1b9d0f2b1fc960ca719360055551908152a180f35b8284346101255781600319360112610125579054905160109190911c6001600160a01b03168152602090f35b82843461012557816003193601126101255760035490516001600160a01b039091168152602090f35b8284346101255781600319360112610125576020906005549051908152f35b82843461012557816003193601126101255760025490516001600160a01b039091168152602090f35b82843461012557816003193601126101255760015490516001600160a01b039091168152602090f35b8390346101255781600319360112610125576020906006548152f35b600435906001600160a01b03821682036105f857565b8181029291811591840414171561096657565b634e487b7160e01b600052601160045260246000fd5b9190820391821161096657565b67ffffffffffffffff811161099d57604052565b634e487b7160e01b600052604160045260246000fd5b6040805167ffffffffffffffff94936001600160a01b0390931692908083018681118282101761099d5783526020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808487829651910182855af13d15610b1e573d91888311610b0a57855192601f19603f81601f8401160116840199848b10908b1117610af65786979899610a5d96975283528286893d92013e610b2b565b805191821591858315610acf575b505050905015610a79575050565b60849250519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b91938180945001031261012557830151908115158203610af3575080388085610a6b565b80fd5b634e487b7160e01b86526041600452602486fd5b634e487b7160e01b85526041600452602485fd5b610a5d9394959697506060915b91929015610b8d5750815115610b3f575090565b3b15610b485790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015610ba05750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610be6575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350610bc356fe597440e65d8cdea1298e19df50e115bda25508180452d87a7f4f99195fb843a4a164736f6c6343000813000a";

type VaultConstructorParams =
| [signer?: Signer]
Expand Down
13 changes: 13 additions & 0 deletions src/types/factories/contracts/interfaces/IVault__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ const _abi = [
name: "Emission",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "governor",
type: "address",
},
],
name: "GovernorChanged",
type: "event",
},
{
anonymous: false,
inputs: [
Expand Down

0 comments on commit 6033864

Please sign in to comment.