dapp/defi/ido/dao質(zhì)押LP流動(dòng)性挖礦分紅系統(tǒng)開(kāi)發(fā)(開(kāi)發(fā)規(guī)則)丨案例源碼
Liquidity mining is a process that allows cryptocurrency holders to obtain rewards by mortgaging or lending their cryptocurrency to decentralized finance(DeFi)protocols.In liquidity mining,users can earn additional cryptocurrency or tokens as rewards and contribute their digital assets to the liquidity pool to facilitate transactions on the DeFi platform.
DAPP是去中心化應(yīng)用程序/分布式的應(yīng)用程序,是底層區(qū)塊鏈平臺(tái)生態(tài)上衍生的各種分布式應(yīng)用,也是區(qū)塊鏈?zhǔn)澜缰械幕A(chǔ)服務(wù)提供方。將應(yīng)用程序分布在不同節(jié)點(diǎn)上,通過(guò)共識(shí)機(jī)制和區(qū)塊鏈平臺(tái)來(lái)完成任務(wù)的應(yīng)用程序,它本身就是去中心化,不依賴于任何中心化服務(wù)器,促使用戶交易更加安全。
廣義來(lái)講,開(kāi)發(fā)詳細(xì)唯:yy625019,區(qū)塊鏈技術(shù)是利用塊鏈?zhǔn)綌?shù)據(jù)結(jié)構(gòu)來(lái)驗(yàn)證與存儲(chǔ)數(shù)據(jù)、利用分布式節(jié)點(diǎn)共識(shí)算法來(lái)生成和更新數(shù)據(jù)、利用密碼學(xué)的方式保證數(shù)據(jù)傳輸和訪問(wèn)的安全、利用由自動(dòng)化腳本代碼組成的智能合約來(lái)編程和操作數(shù)據(jù)的一種全新的分布式基礎(chǔ)架構(gòu)與計(jì)算方式。
class DKT(Module):
def __init__(self,num_c,emb_size,dropout=0.1,emb_type='qid',emb_path="",pretrain_dim=768):
super().__init__()
self.model_name="dkt"
self.num_c=num_c
self.emb_size=emb_size
self.hidden_size=emb_size
self.emb_type=emb_type
if emb_type.startswith("qid"):
self.interaction_emb=Embedding(self.num_c*2,self.emb_size)
self.lstm_layer=LSTM(self.emb_size,self.hidden_size,batch_first=True)
self.dropout_layer=Dropout(dropout)
self.out_layer=Linear(self.hidden_size,self.num_c)
def forward(self,q,r):
#print(f"q.shape is{q.shape}")
emb_type=self.emb_type
if emb_type=="qid":
x=q+self.num_c*r
xemb=self.interaction_emb(x)
#print(f"xemb.shape is{xemb.shape}")
h,_=self.lstm_layer(xemb)
h=self.dropout_layer(h)
y=self.out_layer(h)
y=torch.sigmoid(y)
return y