UXDProtocol / uxd-program

Implementation of a program that manages on chain accounts to mint and redeem Redeemables tokens (UXD), hedged by a delta neutral position on underlying DEXes.
https://uxd.fi/
Other
21 stars 6 forks source link

Have assoc token creation where the mint is #18

Open acamill opened 3 years ago

acamill commented 3 years ago

If mint is owned by program, the account creation might make more sense to be there instead than in a local instruction. https://github.com/project-serum/anchor/pull/790

We already mentionned it, not sure what's best

    // XXX this may make sense to be in the program 
    const ix = createAssocTokenIx(wallet, userBTCDepositoryRedeemableTokenAccount, depositoryBTC.redeemableMintPda);
    await Depository.rpc.deposit(depositAmountBTC, {
      accounts: {
        user: wallet.publicKey,
        state: depositoryBTC.statePda,
        programCoin: depositoryBTC.depositPda,
        redeemableMint: depositoryBTC.redeemableMintPda,
        userCoin: userBTCTokenAccount,
        userRedeemable: userBTCDepositoryRedeemableTokenAccount,
        systemProgram: SystemProgram.programId,
        tokenProgram: TOKEN_PROGRAM_ID,
      },
      signers: [wallet.payer],
      options: TXN_OPTS,
      instructions: [ix],
    });
acamill commented 3 years ago

Associated_token https://github.com/project-serum/anchor/pull/790

And they recently added a init_when_needed or smthg like that that can be used too

sjillen commented 3 years ago

That would definitely make it easier to handle at least on the frontend side of things

acamill commented 3 years ago

Yes but we cannot use cause that would blow the computing budget iirc? Or these ix are accounted in the whole Tx? Forgot how it works exactly