1) starport build the chain locally
2) import cosmwasm module
3) create nft of PO
4) collateralize the NFT
5) place covered put option on the NFT
6) borrow UST liquidity from osmosis against the NFT
creator: info.sender.clone(),
owner: info.sender.clone(),
collateral is NFT;
counter_offer: UST;
expires: 30, 60, 90, 120 days; // in block numbers
#[derive()]
let state = State {
creator: info.sender.clone(),
owner: info.sender.clone(),
collateral: info.funds,
counter_offer: msg.counter_offer,
expires: msg.expires,
};
options module
transfer { recipient: String },
execute {},
burn {},
----
offer: Vec<Coin>,
counter_offer: Vec<Coin>,
execute(
deps,
env,
info)
if info.funds != state.counter_offer {
err {
offer: info.funds,
counter_offer: state.counter_offer
}
}
sends the counter offer to the creator and the collateral to the sender
BankMsg:Send{
to_address: state.creator.to_string(),
amount: state.counter_offer,
})
BankMsg:Send{
to_address: state.owner.to_string(),
amount: state.collateral,
})
list on open marketplace
put option marketplace place for asset based nfts
tokenize the cart / the proposed order
collateralize it
the end user buys put options on an nft
starport scaffold chain github.com/tendermint/mars
code mars
starport scaffold list post title body
handler handles messages
proto files describes the structure of the blockchain
don't delete the placeholders
local testnet challenge
config.yml
dev env and blockchain parameters
accounts listed to the genesis file on init
single validator
parameters: name staked
have a multinode testnet of validators
an array of validators
multiple node tesnet
starport chain build
inititialize and start the node
docs.starport.com
create a new data directory
faucet for you
cmd
marsd
main.go
stargate - v0.44.0
go releaser
task file
3rd pary developer plugins
collateralized nft plugin section
starport scaffold module loan --dep bank
json files signed with private keys
messages are processed
get routed to modules
can alter the state of the key value blockchain
loan type
starport chain serve -r
compiles to binary
converts proto into go files
need to provide collateral to the lender
incentive to repay the loan
if not paid untime then the lender can liquidate the loan and take the
collateral and fee
need a date when the lender is entitled to the collateral.
keep info about the borrower and lender about the loan.
address is in the loan object.
starport scaffold list loan amount fee collateral deadline state borrower lender
--no-message
wants a certain amount and is willing to pay fees and collateral.
starport scaffold message request-loan amount fee collateral deadline
mesg.server request loan
handler.go
dispatched the keeper method
create the loan object in the keeper
send tokens from the borrower to the escrow account of the module
collateral and fee to the escrow account.
Kept by the module.
safely secured by the module account
((((***** THIS. **********)))))
SendCoinsFromAccountToModule
in expected_keepers.go
sending tokens from the borrowers account to the module
Send the NFT from Account to Module
borrower, _ := sdk.AccAddressFromBech32(msg.Creator)
collateral, _ := sdk.ParseCoins(msg.Collateral)
amount, _ := sdk.ParseCoins(msg.Amount)
k.AppendLoan(ctx
starport chain serve
tx_request_loan
december 8th, launch december 28th
which loand
loand tx loan request-loan 100token 5token 120token
use a different token (NFT) for the collateral 600 blocks --from alice
loand q loan list-loan
1potoken
now belong to the module account
no longer has custody over the collateral
starport scaffold message approve-loan id:uint
loan, found := k.GetLoan(ctx, msg.Id)
request loan
approve loan
if loan.State !- 'requested' {
sdkerrors.WrapF(types.ErrWrongLoanState)
k.bankKeeper.SendCoins(crx, lender, borrower, amount)
k.bankKeeper.SendCoints(ctx, corrowe, lender, fee)
k.bankKeeper.SendCoinsFromModuleToAccount()
loan.Lender = msg.Creator
loan.State = "approved"
think about Types
what of all of the fields, parameters, all of the metadata
what kind of actions that user might want to do
scaffold code for messages and message handling
loan.State = "repayed"
k.SetLoan(crx, loan)
starport scaffold message liquidate-loan
if ctx.BlockHeight() < deadline {
sdkerrors liquidate before the deadline
}
SendCoinsFromModuleToAccount(ctx, types.ModuleName, lender,
loan.State = "liquidated"
k.SetLoan(ctx, loan)
scaffold --ibc
messages are meant to change the state of stateset