forked from svanas/delphereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb3.eth.yearn.finance.v2.pas
168 lines (143 loc) · 4.04 KB
/
web3.eth.yearn.finance.v2.pas
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{******************************************************************************}
{ }
{ Delphereum }
{ }
{ Copyright(c) 2020 Stefan van As <[email protected]> }
{ Github Repository <https://github.com/svanas/delphereum> }
{ }
{ Distributed under Creative Commons NonCommercial (aka CC BY-NC) license. }
{ }
{******************************************************************************}
unit web3.eth.yearn.finance.v2;
{$I web3.inc}
interface
uses
// Velthuis' BigNumbers
Velthuis.BigIntegers,
// web3
web3,
web3.eth.defi,
web3.eth.types,
web3.eth.yearn.finance;
type
TyEarnV2 = class(TyEarnCustom)
public
class function Name: string; override;
class function Supports(
chain : TChain;
reserve: TReserve): Boolean; override;
class procedure APY(
client : TWeb3;
reserve : TReserve;
period : TPeriod;
callback: TAsyncFloat); override;
class procedure Deposit(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
amount : BigInteger;
callback: TAsyncReceipt); override;
class procedure Balance(
client : TWeb3;
owner : TAddress;
reserve : TReserve;
callback: TAsyncQuantity); override;
class procedure Withdraw(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
callback: TAsyncReceiptEx); override;
class procedure WithdrawEx(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
amount : BigInteger;
callback: TAsyncReceiptEx); override;
end;
implementation
type
TyDAIv2 = class(TyToken)
public
class function DeployedAt: TAddress; override;
end;
TyUSDCv2 = class(TyToken)
public
class function DeployedAt: TAddress; override;
end;
TyUSDTv2 = class(TyToken)
public
class function DeployedAt: TAddress; override;
end;
const
yTokenClass: array[TReserve] of TyTokenClass = (
TyDAIv2, // DAI
TyUSDCv2, // USDC
TyUSDTv2 // USDT
);
{ TyEarnV2 }
class function TyEarnV2.Name: string;
begin
Result := 'yEarn v2';
end;
class function TyEarnV2.Supports(chain: TChain; reserve: TReserve): Boolean;
begin
Result := chain = Mainnet;
end;
class procedure TyEarnV2.APY(
client : TWeb3;
reserve : TReserve;
period : TPeriod;
callback: TAsyncFloat);
begin
Self._APY(client, yTokenClass[reserve], period, callback);
end;
class procedure TyEarnV2.Deposit(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
amount : BigInteger;
callback: TAsyncReceipt);
begin
Self._Deposit(client, from, yTokenClass[reserve], amount, callback);
end;
class procedure TyEarnV2.Balance(
client : TWeb3;
owner : TAddress;
reserve : TReserve;
callback: TAsyncQuantity);
begin
Self._Balance(client, owner, yTokenClass[reserve], callback);
end;
class procedure TyEarnV2.Withdraw(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
callback: TAsyncReceiptEx);
begin
Self._Withdraw(client, from, yTokenClass[reserve], callback);
end;
class procedure TyEarnV2.WithdrawEx(
client : TWeb3;
from : TPrivateKey;
reserve : TReserve;
amount : BigInteger;
callback: TAsyncReceiptEx);
begin
Self._WithdrawEx(client, from, yTokenClass[reserve], amount, callback);
end;
{ TyDAIv2 }
class function TyDAIv2.DeployedAt: TAddress;
begin
Result := TAddress('0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01');
end;
{ TyUSDCv2 }
class function TyUSDCv2.DeployedAt: TAddress;
begin
Result := TAddress('0xd6aD7a6750A7593E092a9B218d66C0A814a3436e');
end;
{ TyUSDTv2 }
class function TyUSDTv2.DeployedAt: TAddress;
begin
Result := TAddress('0x83f798e925BcD4017Eb265844FDDAbb448f1707D');
end;
end.