Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 23 additions & 1 deletion contracts/refund-vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,20 @@ pub enum DataKey {
Refund(BytesN<32>),
IsPaused,
PendingAdmin,
/// Yield strategy contract address. Stored in **Persistent** storage so
/// it is not loaded on every non-yield invocation (issue #131).
YieldStrategy,
/// Cumulative principal deployed to the yield strategy. Persistent
/// storage; see `YieldStrategy` rationale above.
DeployedPrincipal,
/// Cumulative yield harvested from the strategy and held in the vault
/// for operator withdrawal. Persistent storage (issue #131).
HarvestedYield,
/// Minimum liquid reserve ratio in basis points. Persistent storage
/// (issue #131).
ReserveRatio,
/// Maximum deployment ratio in basis points. Persistent storage
/// (issue #131).
MaxDeployRatio,
PendingPolicy,
/// Whitelisted oracle contracts, in insertion order. The aggregator
Expand Down Expand Up @@ -719,6 +729,18 @@ impl RefundVault {
.set(&DataKey::DomainSeparator, &separator);
env.storage().instance().set(&DataKey::Nonce, &0u64);

// Issue #136: store the domain separator (this contract's address)
// and initialise the monotonic nonce to 0.
let contract_addr = env.current_contract_address();
// The domain separator is a hash of the contract address so that
// events and off-chain signatures can be bound to exactly one
// deployment.
let separator = env.crypto().sha256(&contract_addr.to_buffer());
env.storage()
.instance()
.set(&DataKey::DomainSeparator, &separator);
env.storage().instance().set(&DataKey::Nonce, &0u64);

env.storage()
.instance()
.extend_ttl(TTL_THRESHOLD, TTL_EXTEND);
Expand Down Expand Up @@ -1599,7 +1621,7 @@ impl RefundVault {
let nonce = increment_nonce(&env);

YieldDeployedEvent {
strategy: strategy.clone(),
strategy,
amount,
nonce,
}
Expand Down
Loading
Loading