Install dependencies: yarn (?)
Build: anchor build
Test: anchor test
Goal: provide a Solana (Anchor) smart contract that allows you to:
- Deposit an NFT (domain NFT) on the platform (done and tested).
- Withdraw it (done and tested).
- List it for sale (done and tested), accept offers, and make offers to any NFT.
- Sell on credit.
- Take a loan using an NFT as collateral.
-
If you own an NFT, you can create a sell offer with the currency of your choice (todo: whitelist 2–3 of them).
-
You can make an offer on any NFT (and your funds will be locked so the offer can be accepted).
- The owner of the NFT creates a sale offer on credit. For this sale, the buyer must pay x€/month for y months, then z€ (the details are still todo). During this credit period, the NFT remains on the platform, but the buyer is the owner and can change what the domain resolves to.
- Ability to make a loan offer, at a fixed rate, for one year, with the possibility of early repayment. Possibly: allow starting an auction (on the rate) for one week for a one-year loan. Also allow selling the NFT even if there’s an ongoing loan — in that case, the loan is automatically repaid using the sale proceeds.
- Creates the
EscrowStateaccount (PDA) and initializes avaultassociated token account to store the NFT. Transfers 1 token (NFT) from themakerto thevault.
- Transfers the NFT from the
vaulttomaker_ata_domain, signing with the PDAescrow.
#[account]
pub struct EscrowState {
pub seed: u64,
pub maker: Pubkey, // The person who created the escrow
pub owner: Pubkey, // "Owner" of the domain: can modify what it resolves to
pub mint_domain: Pubkey, // The mint of our NFT
pub mint_currency: Pubkey,// The mint of the currency used for dealing with this domain (eg USDC)
// Feature 1: Make a loan offer
pub wanted_loan_amount: u64,
pub wanted_apy: u64,
// Feature 2: Make a location with buy option
// todo
// Feature 3: Make a sell offer
pub wanted_sell_amount: u64,
// Rest
pub bump: u8,
}lib.rs: Anchor entrypoint, defines instructions.contexts/*.rs: instruction handlers (deposit, withdraw, sell, offer...).state/*.rs: persistent structures (EscrowState, OfferState, LoanState).tests/: tests.