Skip to content
Open
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
613 changes: 613 additions & 0 deletions cadence/contracts/FlowYieldVaultsStrategiesV1_1.cdc

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions cadence/tests/test_helpers.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ access(all) fun deployContracts() {
)
Test.expect(err, Test.beNil())

err = Test.deployContract(
name: "FlowYieldVaultsStrategiesV1_1",
path: "../contracts/FlowYieldVaultsStrategiesV1_1.cdc",
arguments: [
"0x986Cb42b0557159431d48fE0A40073296414d410",
"0x92657b195e22b69E4779BBD09Fa3CD46F0CF8e39",
"0x8dd92c8d0C3b304255fF9D98ae59c3385F88360C"
]
)
// FLOW looping strategy
err = Test.deployContract(
name: "PMStrategiesV1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import "FungibleToken"
import "EVM"
import "FlowYieldVaultsStrategiesV1_1"

/// Admin tx to (re)configure Uniswap paths for the mUSDFStrategy
///
/// NOTE:
/// - Must be signed by the account that deployed FlowYieldVaultsStrategies
/// - You can omit some collaterals by passing empty arrays and guarding in prepare{}
transaction(
tokenTypeIdentifier: String,
yieldTokenEVMAddress: String,

// collateral path/fees: [YIELD, ..., <COLLATERAL>]
swapPath: [String],
fees: [UInt32]
) {

prepare(acct: auth(Storage, Capabilities, BorrowValue) &Account) {
let tokenType = CompositeType(tokenTypeIdentifier)
?? panic("Invalid tokenTypeIdentifier \(tokenTypeIdentifier)")
// This tx must run on the same account that stores the issuer
// otherwise this borrow will fail.
let issuer = acct.storage.borrow<
auth(FlowYieldVaultsStrategiesV1_1.Configure) &FlowYieldVaultsStrategiesV1_1.StrategyComposerIssuer
>(from: FlowYieldVaultsStrategiesV1_1.IssuerStoragePath)
?? panic("Missing StrategyComposerIssuer at IssuerStoragePath")

let yieldEVM = EVM.addressFromString(yieldTokenEVMAddress)

// helper to map [String] -> [EVM.EVMAddress]
fun toEVM(_ hexes: [String]): [EVM.EVMAddress] {
let out: [EVM.EVMAddress] = []
for h in hexes {
out.append(EVM.addressFromString(h))
}
return out
}

let composerType = Type<@FlowYieldVaultsStrategiesV1_1.mUSDFStrategyComposer>()
let strategyType = Type<@FlowYieldVaultsStrategiesV1_1.mUSDFStrategy>()

//issuer.purgeConfig()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not, if not needed, let's removed, if leaving, mentioned why with additional comments


// === FLOW collateral ===
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? only flow?

if swapPath.length > 0 {
issuer.addOrUpdateCollateralConfig(
composer: composerType,
strategyType: strategyType,
collateralVaultType: tokenType,
yieldTokenEVMAddress: yieldEVM,
yieldToCollateralAddressPath: toEVM(swapPath),
yieldToCollateralFeePath: fees
)
}
}
}
70 changes: 69 additions & 1 deletion flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@
"testnet": "d2580caf2ef07c2f"
}
},
"FlowYieldVaultsStrategiesV1_1": {
"source": "cadence/contracts/FlowYieldVaultsStrategiesV1_1.cdc",
"aliases": {
"emulator": "045a1763c93006ca",
"mainnet": "b1d63873c3cc9f79",
"testing": "0000000000000009",
"testnet": "d2580caf2ef07c2f"
}
},
"FungibleTokenConnectors": {
"source": "./lib/FlowCreditMarket/FlowActions/cadence/contracts/connectors/FungibleTokenConnectors.cdc",
"aliases": {
Expand Down Expand Up @@ -728,6 +737,14 @@
"resourceID": "projects/dl-flow-devex-production/locations/us-central1/keyRings/tidal-keyring/cryptoKeys/tidal_admin_pk/cryptoKeyVersions/1"
}
},
"mainnet-band-oracle-connectors": {
"address": "e36ef556b8b5d955",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/flow-foundation-admin/locations/global/keyRings/defi-actions/cryptoKeys/mainnet-defi-actions/cryptoKeyVersions/1"
}
},
"mainnet-flow-credit-market-deployer": {
"address": "6b00ff876c299c61",
"key": {
Expand Down Expand Up @@ -856,6 +873,23 @@
]
},
{
"name": "FlowYieldVaultsStrategiesV1_1",
"args": [
{
"value": "0x986Cb42b0557159431d48fE0A40073296414d410",
"type": "String"
},
{
"value": "0x92657b195e22b69E4779BBD09Fa3CD46F0CF8e39",
"type": "String"
},
{
"value": "0x8dd92c8d0C3b304255fF9D98ae59c3385F88360C",
"type": "String"
}
]
},
{
"name": "PMStrategiesV1",
"args": [
{
Expand Down Expand Up @@ -967,6 +1001,23 @@
]
},
{
"name": "FlowYieldVaultsStrategiesV1_1",
"args": [
{
"value": "0xca6d7Bb03334bBf135902e1d919a5feccb461632",
"type": "String"
},
{
"value": "0xeEDC6Ff75e1b10B903D9013c358e446a73d35341",
"type": "String"
},
{
"value": "0x370A8DF17742867a44e56223EC20D82092242C85",
"type": "String"
}
]
},
{
"name": "PMStrategiesV1",
"args": [
{
Expand Down Expand Up @@ -1053,8 +1104,25 @@
"type": "Array"
}
]
},
{
"name": "FlowYieldVaultsStrategiesV1_1",
"args": [
{
"value": "0x92657b195e22b69E4779BBD09Fa3CD46F0CF8e39",
"type": "String"
},
{
"value": "0x2Db6468229F6fB1a77d248Dbb1c386760C257804",
"type": "String"
},
{
"value": "0xA1e0E4CCACA34a738f03cFB1EAbAb16331FA3E2c",
"type": "String"
}
]
}
]
}
}
}
}
4 changes: 2 additions & 2 deletions local/punchswap/punchswap.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ TOKENS_OWNER=0xC31A5268a1d311d992D637E8cE925bfdcCEB4310
USDC_MINT=2000000000000
WBTC_MINT=100000000000000

USDC_ADDR=0x102A7ed67858cF757CBBeA3390eaB72fcc60237E
WBTC_ADDR=0x6Ce75363856e46B42bf0c933E01A4Eec17eE963B
USDC_ADDR=0xaf2Bb3E0017d2eD9B69004c9b38318a166fA9f63
WBTC_ADDR=0x34A99426966D2023f1f66929c1b0989fA5C6B9FC

# how much to fund the helper (base units)
# USDC_FUND=600000000 # 600k * 1e6
Expand Down
12 changes: 12 additions & 0 deletions local/setup_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ flow transactions send ./cadence/transactions/flow-yield-vaults/admin/add_strate
/storage/FlowYieldVaultsStrategyComposerIssuer_0x045a1763c93006ca \
--signer emulator-flow-yield-vaults

# flow transactions send ../cadence/transactions/flow-yield-vaults/admin/upsert_musdf_config.cdc \
# "A.0ae53cb6e3f42a79.FlowToken.Vault" \
# <yield token>



flow transactions send ./cadence/transactions/flow-yield-vaults/admin/add_strategy_composer.cdc \
'A.045a1763c93006ca.FlowYieldVaultsStrategiesV1_1.USDFStrategy' \
'A.045a1763c93006ca.FlowYieldVaultsStrategiesV1_1.USDFStrategyComposer' \
/storage/FlowYieldVaultsStrategyV1_1ComposerIssuer_0x045a1763c93006ca \
--signer emulator-flow-yield-vaults

# grant PoolBeta cap
echo "Grant Protocol Beta access to FlowYieldVaults"
flow transactions send ./lib/FlowCreditMarket/cadence/tests/transactions/flow-credit-market/pool-management/03_grant_beta.cdc \
Expand Down
63 changes: 60 additions & 3 deletions local/setup_mainnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ flow transactions send ./lib/FlowCreditMarket/cadence/transactions/flow-credit-m
--network mainnet \
--signer mainnet-flow-credit-market-deployer

# add WBTC to band oracle
cd ./lib/FlowCreditMarket/FlowActions && flow transactions send ./cadence/transactions/band-oracle-connector/add_symbol.cdc "BTC" "A.dfc20aee650fcbdf.EVMVMBridgedToken_717dae2baf7656be9a9b01dee31d571a9d4c9579.Vault" --network testnet --signer mainnet-band-oracle-connectors && cd ../../..

# add WETH to band oracle
cd ./lib/FlowCreditMarket/FlowActions && flow transactions send ./cadence/transactions/band-oracle-connector/add_symbol.cdc "ETH" "A.dfc20aee650fcbdf.EVMVMBridgedToken_2f6f07cdcf3588944bf4c42ac74ff24bf56e7590.Vault" --network testnet --signer mainnet-band-oracle-connectors && cd ../../..

# add WBTC as supported token
flow transactions send ./lib/FlowCreditMarket/cadence/transactions/flow-credit-market/pool-governance/add_supported_token_simple_interest_curve.cdc \
'A.dfc20aee650fcbdf.EVMVMBridgedToken_717dae2baf7656be9a9b01dee31d571a9d4c9579.Vault' \
0.8 \
1.0 \
1_000_000.0 \
1_000_000.0 \
--network mainnet \
--signer mainnet-flow-credit-market-deployer

# add WETH as supported token
flow transactions send ./lib/FlowCreditMarket/cadence/transactions/flow-credit-market/pool-governance/add_supported_token_simple_interest_curve.cdc \
'A.dfc20aee650fcbdf.EVMVMBridgedToken_2f6f07cdcf3588944bf4c42ac74ff24bf56e7590.Vault' \
0.8 \
1.0 \
1_000_000.0 \
1_000_000.0 \
--network mainnet \
--signer mainnet-flow-credit-market-deployer

# TODO
# swap
# echo "swap Flow to MOET"
Expand All @@ -57,11 +83,42 @@ flow transactions send ./cadence/transactions/mocks/swapper/set_liquidity_connec
flow transactions send ./lib/FlowCreditMarket/FlowActions/cadence/transactions/fungible-tokens/setup_generic_vault.cdc 'A.1e4aa0b87d10b141.EVMVMBridgedToken_c52e820d2d6207d18667a97e2c6ac22eb26e803c.Vault' --network mainnet --signer mainnet-admin
# flow transactions send ./cadence/transactions/mocks/swapper/set_liquidity_connector.cdc /storage/EVMVMBridgedToken_4154d5b0e2931a0a1e5b733f19161aa7d2fc4b95Vault --network mainnet --signer mainnet-admin
#


# Setup UniV3 path tauUSDFv -> USDF -> WFLOW
flow transactions send ./cadence/transactions/flow-yield-vaults/admin/upsert_musdf_config.cdc \
'A.1654653399040a61.FlowToken.Vault' \
"0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c" \
'["0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c","0x2aaBea2058b5aC2D339b163C6Ab6f2b6d53aabED","0xd3bF53DAC106A0290B0483EcBC89d40FcC961f3e"]' \
'[100,3000]' \
--network mainnet \
--signer mainnet-admin


# Setup UniV3 path tauUSDFv -> USDF -> WBTC
flow transactions send ./cadence/transactions/flow-yield-vaults/admin/upsert_musdf_config.cdc \
'A.0x1e4aa0b87d10b141.EVMVMBridgedToken_717dae2baf7656be9a9b01dee31d571a9d4c9579.Vault' \
"0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c" \
'["0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c","0x2aaBea2058b5aC2D339b163C6Ab6f2b6d53aabED","0x717DAE2BaF7656BE9a9B01deE31d571a9d4c9579"]' \
'[100,3000]' \
--network mainnet \
--signer mainnet-admin

# Setup UniV3 path tauUSDFv -> USDF -> WETH
flow transactions send ./cadence/transactions/flow-yield-vaults/admin/upsert_musdf_config.cdc \
'A.0x1e4aa0b87d10b141.EVMVMBridgedToken_2f6f07cdcf3588944bf4c42ac74ff24bf56e7590.Vault' \
"0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c" \
'["0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c","0x2aaBea2058b5aC2D339b163C6Ab6f2b6d53aabED","0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590"]' \
'[100,3000]' \
--network mainnet \
--signer mainnet-admin

#
# add TracerStrategy as supported Strategy with the ability to initialize when new YieldVaults are created
flow transactions send ./cadence/transactions/flow-yield-vaults/admin/add_strategy_composer.cdc \
'A.b1d63873c3cc9f79.FlowYieldVaultsStrategies.mUSDCStrategy' \
'A.b1d63873c3cc9f79.FlowYieldVaultsStrategies.mUSDCStrategyComposer' \
/storage/FlowYieldVaultsStrategyComposerIssuer_0xb1d63873c3cc9f79 \
'A.b1d63873c3cc9f79.FlowYieldVaultsStrategiesV1_1.mUSDFStrategy' \
'A.b1d63873c3cc9f79.FlowYieldVaultsStrategiesV1_1.mUSDFStrategyComposer' \
/storage/FlowYieldVaultsStrategyV1_1ComposerIssuer_0xb1d63873c3cc9f79 \
--network mainnet \
--signer mainnet-admin

Expand Down
Loading