Skip to content

Commit 7f973ed

Browse files
jribbinkzhangchiqingRZhang05
committed
BTC 2025 Simulation (#242)
Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com> Co-authored-by: Raymond Zhang <zhangraymond05@gmail.com>
1 parent a193471 commit 7f973ed

17 files changed

Lines changed: 7474 additions & 32 deletions

cadence/contracts/mocks/FlowTransactionScheduler.cdc

Lines changed: 1454 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "FlowYieldVaultsAutoBalancers"
2+
3+
/// Returns both currentValue and valueOfDeposits for the AutoBalancer in a single script call.
4+
/// This reduces script call overhead when both values are needed.
5+
///
6+
/// Returns: [currentValue, valueOfDeposits] or nil if AutoBalancer doesn't exist
7+
///
8+
access(all)
9+
fun main(id: UInt64): [UFix64]? {
10+
if let autoBalancer = FlowYieldVaultsAutoBalancers.borrowAutoBalancer(id: id) {
11+
let currentValue = autoBalancer.currentValue() ?? 0.0
12+
let valueOfDeposits = autoBalancer.valueOfDeposits()
13+
return [currentValue, valueOfDeposits]
14+
}
15+
return nil
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import "FlowYieldVaultsAutoBalancers"
2+
3+
/// Returns the value of deposits tracked by the AutoBalancer related to the provided YieldVault ID or `nil` if none exists
4+
/// This is the historical cumulative value used to compute the rebalance ratio: currentValue / valueOfDeposits
5+
///
6+
access(all)
7+
fun main(id: UInt64): UFix64? {
8+
return FlowYieldVaultsAutoBalancers.borrowAutoBalancer(id: id)?.valueOfDeposits() ?? nil
9+
}

0 commit comments

Comments
 (0)