Dev/fresh start - #2
Conversation
| Promise::new(vault.collateral_asset.clone()).function_call( | ||
| "ft_transfer_call".to_string(), | ||
| serde_json::to_vec(&serde_json::json!({ | ||
| "receiver_id": env::current_account_id(), | ||
| "amount": collateral_amount, | ||
| "msg": format!("collateral:{}", vault_id) | ||
| })).unwrap(), | ||
| NearToken::from_yoctonear(1), | ||
| Gas::from_tgas(10), | ||
| ).then( |
There was a problem hiding this comment.
Same as above, this won't work. The token sender himself needs to send the collateral by calling ft_transfer_call on the collateral contract.
There was a problem hiding this comment.
in progress figuring out XCC work with borrow (and associated tests) too
peer2f00l
left a comment
There was a problem hiding this comment.
A few more comments and changes from me... Is there a place where the individual workflows are sketched out quite specifically?
Like:
- these are the steps to create a vault
- these are the steps to add collateral to (or create) a loan
- these are the steps to withdraw stablecoins
- these are the steps to repay stablecoins
- these are the steps to liquidation
| #[payable] | ||
| pub fn deposit_stablecoin(&mut self, vault_id: String, amount: U128) { | ||
| let nft_collection = self.get_nft_collection_for_vault(&vault_id); | ||
| require!( | ||
| self.owns_nft(&env::predecessor_account_id(), &nft_collection.to_string()), | ||
| "Not authorized", | ||
| ); | ||
|
|
||
| // Instead of calling ft_transfer_call, we just log the intent | ||
| // The actual transfer should be initiated by the user | ||
| env::log_str(&format!( | ||
| "Deposit intent: {} tokens to vault {}", | ||
| amount.0, vault_id | ||
| )); | ||
| } |
There was a problem hiding this comment.
Does this method need to exist?
There was a problem hiding this comment.
Yes. There needs to be some sort of method to call for lenders to deposit stablecoins. I updated it in the 371f3c2 commit. Think the loan test is failing because the ft_transfer_call initiates an XCC and I'm having trouble testing with that.
There was a problem hiding this comment.
Normal Rust tests cannot be used to test xccs, since there's no runner to execute the created promise. We have to use near-workspaces for that.
There was a problem hiding this comment.
| ext_ft_core::ext(vault.collateral_asset.clone()) | ||
| .with_attached_deposit(NearToken::from_yoctonear(1)) | ||
| .with_static_gas(Gas::from_tgas(10)) | ||
| .ft_transfer_call( | ||
| env::current_account_id(), | ||
| collateral_amount, | ||
| None, | ||
| format!("collateral:{vault_id}"), | ||
| ) | ||
| .then( | ||
| ext_ft_core::ext(vault.stablecoin.clone()) | ||
| .with_attached_deposit(NearToken::from_yoctonear(1)) | ||
| .with_static_gas(Gas::from_tgas(10)) | ||
| .ft_transfer(env::predecessor_account_id(), borrow_amount, None), | ||
| ) |
There was a problem hiding this comment.
This probably only needs to transfer stablecoins to the caller.
The litepaper contains most of this currently. I'll create an architecture doc specifically for what happens at the contract level tomorrow. |
Plan completeness was measured in totals, which a coherent subset satisfies: - `proposals >= 2` passed a plan with both borrow-feed steps deleted, since the collateral create/execute pair alone reaches two (#1). Each feed now needs its own create *and* execute, matched by the price id the operation names. - Storage registrations were counted, not matched, so two registrations against the collateral token satisfied a two-NEP-141 market and left the borrow asset unreceivable (#2). They are matched against the token contracts the encoded configuration names. `summary_digest` did not cover `step_digests` (#23), so deleting a step *and* its digest entry reported "unmodified since generation" on the line `review` prints above the confirmation prompt. Plan schema bumped to 3. The journal never flushed (#20). `fs::write` returns at the page cache and `rename` is atomic only against a process crash; the machine loss this module exists for could still leave a truncated journal, which reads as a step that never ran and re-sends a deploy whose deposit is already spent. A direct plan derived `proxy-oracle-<name>` and `proxy-gov-<name>` it never creates (#27), so a valid market name whose prefixed forms exceed NEAR's account-id limit failed to plan. `Derived.governance_id` is optional now. Also: a CoinGecko coin with no USD quote failed the whole response and skipped every other id in the request (#14); a spec from a newer build reported the first unknown field rather than its schema version (#19); one funding assertion message stated the opposite of what `available` does (#11); markdown fences carry languages (#4); the freeness test asserts the exact remaining set rather than a smaller count (#24). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Used
cargo near newto create this project that comes with boilerplate dir structure, readme, and github workflowsWill add more functionality in Future PR.