Skip to content

Commit 5ea7535

Browse files
committed
Add draft of tutorial 1
1 parent 1ed64a4 commit 5ea7535

File tree

5 files changed

+219
-101
lines changed

5 files changed

+219
-101
lines changed

cadence/scripts/tidal-yield/get_complete_user_position_info.cdc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ fun main(address: Address): CompleteUserSummary {
241241
// Since we can't directly map tide IDs to position IDs, we'll try sequential IDs
242242
// This assumes positions are created in order (0, 1, 2, ...)
243243
let positionIndex = UInt64(positions.length) // Use the current position index
244-
actualHealth = pool.positionHealth(pid: positionIndex)
244+
let healthUInt128 = pool.positionHealth(pid: positionIndex)
245+
// Scale factor: 10^18 = 1e18, but split to avoid UFix64 overflow
246+
actualHealth = UFix64(healthUInt128 / 1000000000000000000)
245247
}
246248

247249
let estimatedHealth = actualHealth

cadence/transactions/tidal-yield/setup.cdc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import "FungibleToken"
22
import "FungibleTokenMetadataViews"
33
import "ViewResolver"
44

5+
import "TidalYieldClosedBeta"
56
import "TidalYield"
67

78
/// Configures a TidalYield.TideManager at the canonical path. If one is already configured, the transaction no-ops
89
///
910
transaction {
10-
prepare(signer: auth(BorrowValue, SaveValue, StorageCapabilities, PublishCapability) &Account) {
11+
prepare(signer: auth(BorrowValue, SaveValue, StorageCapabilities, PublishCapability, CopyValue) &Account) {
1112
let betaCap = signer.storage.copy<Capability<auth(TidalYieldClosedBeta.Beta) &TidalYieldClosedBeta.BetaBadge>>(from: TidalYieldClosedBeta.UserBetaCapStoragePath)
1213
?? panic("Signer does not have a BetaBadge stored at path \(TidalYieldClosedBeta.UserBetaCapStoragePath) - configure and retry")
1314

0 commit comments

Comments
 (0)