1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! # Liquidity Interface Add-On
//!
//! `abstract_os::etf` is an app which allows users to deposit into or withdraw from a [`crate::proxy`] contract.
//!
//! ## Description
//! This contract uses the proxy's value calculation configuration to get the value of the assets held in the proxy and the relative value of the deposit asset.
//! It then mints LP tokens that are claimable for an equal portion of the proxy assets at a later date.
//!
//! ---
//! **WARNING:** This mint/burn mechanism can be mis-used by flash-loan attacks if the assets contained are of low-liquidity compared to the etf's size.
//!
//! ## Creation
//! The etf contract can be added on an OS by calling [`ExecuteMsg::InstallModule`](crate::manager::ExecuteMsg::InstallModule) on the manager of the os.
//! ```ignore
//! let etf_init_msg = InstantiateMsg{
//! deposit_asset: "juno".to_string(),
//! base: BaseInstantiateMsg{ans_host_address: "juno1...".to_string()},
//! fee: Decimal::percent(10),
//! provider_addr: "juno1...".to_string(),
//! token_code_id: 3,
//! etf_lp_token_name: Some("demo_etf".to_string()),
//! etf_lp_token_symbol: Some("DEMO".to_string()),
//! };
//! let create_module_msg = ExecuteMsg::InstallModule {
//! module: Module {
//! info: ModuleInfo {
//! name: ETF.into(),
//! version: None,
//! },
//! kind: crate::core::modules::ModuleKind::External,
//! },
//! init_msg: Some(to_binary(&etf_init_msg).unwrap()),
//! };
//! // Call create_module_msg on manager
//! ```
//!
//! ## Migration
//! Migrating this contract is done by calling `ExecuteMsg::Upgrade` on [`crate::manager`] with `crate::ETF` as module.
use Decimal;
use AssetUnchecked;
/// Init msg